215 lines
9.0 KiB
C#
215 lines
9.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
public partial class OI_Proyecto : ClsPaginas
|
|
{
|
|
|
|
#region Propiedades
|
|
public const string iddivAgregarProyecto = "iddivAgregarProyecto";
|
|
public int RCveEvento { get { return ViewState["RCveEvento"] != null ? ViewState["RCveEvento"].ToString().ToEntero() : 0; } set { ViewState["RCveEvento"] = value; } }
|
|
public int RCveEventoB { get { return ViewState["RCveEventoB"] != null ? ViewState["RCveEventoB"].ToString().ToEntero() : 0; } set { ViewState["RCveEventoB"] = value; } }
|
|
public int Folio { get { return ViewState["Folio"] != null ? ViewState["Folio"].ToString().ToEntero() : 0; } set { ViewState["Folio"] = value; } }
|
|
public decimal Avance { get { return ViewState["Avance"] != null ? ViewState["Avance"].ToString().ToEntero() : 0; } set { ViewState["Avance"] = value; } }
|
|
public int CveUsuarioPara { get { return ViewState["CveUsuarioPara"].ToString().ToEntero(); } set { ViewState["CveUsuarioPara"] = value; } }
|
|
public int CveUsuarioDe { get { return ViewState["CveUsuarioDe"].ToString().ToEntero(); } set { ViewState["CveUsuarioDe"] = value; } }
|
|
public List<int> LCveUsuarioCCP { get { if (ViewState["LCveUsuarioCCP"] == null) { ViewState["LCveUsuarioCCP"] = new List<int>(); } return (List<int>)ViewState["LCveUsuarioCCP"]; } set { ViewState["LCveUsuarioCCP"] = value; } }
|
|
public List<int> LcveuserVisto { get { if (ViewState["LcveuserVisto"] == null) { ViewState["LcveuserVisto"] = new List<int>(); } return (List<int>)ViewState["LcveuserVisto"]; } set { ViewState["LcveuserVisto"] = value; } }
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
if (Request["CveEvento"] != null)
|
|
{
|
|
RCveEvento = Request["CveEvento"].ToString().ToEntero();
|
|
}
|
|
if(RCveEvento > 0)
|
|
{
|
|
loadEvento();
|
|
}
|
|
|
|
DdlPara.DataSource = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa).FiltraParametros("Estatus =1 ", "Rol ASC"); ;
|
|
DdlPara.DataBind();
|
|
|
|
DdlTema.DataSource = get_GlobalDTOIRevision(UsuarioActual.CveEmpresa).FiltraParametros(string.Format("CveUsuario = {0}", UsuarioActual.CveUsuario));
|
|
DdlTema.DataBind();
|
|
DdlTema.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
}
|
|
|
|
}
|
|
public void loadEvento()
|
|
{
|
|
string separator = "";
|
|
StringBuilder str = new StringBuilder();
|
|
str.AppendLine("datosGant=[");
|
|
using (ClsOIEventos oieve = new ClsOIEventos())
|
|
{
|
|
if (oieve.GetTareaConHijos(RCveEvento,UsuarioActual.CveEmpresa))
|
|
{
|
|
foreach (System.Data.DataRow dr in oieve.DtResultados.Select("Nivel > 0"))
|
|
{
|
|
str.AppendLine(string.Format("{0}{{id: {1}, text: \"{2}\", start_date: \"{3:yyyy/MM/dd}\", end_date: \"{4:yyyy/MM/dd}\", parent: {5}, progress:{6}, open: true }}",
|
|
separator,dr["CveEvento"], dr["Asunto"].ToString().Replace("\\", "\\\\").Replace("\"", "\\\""), dr["FechaInicio"], dr["FechaFin"], (dr["Nivel"].ToString().ToEntero()<=1?0: dr["CveEventoPadre"].ToString().ToEntero()), dr["Avance"].ToString().ToDecimal()/100));
|
|
separator = ",";
|
|
|
|
}
|
|
}
|
|
}
|
|
str.AppendLine("];loadGant();");
|
|
this.RegistraScript(str.ToString());
|
|
UpContenido.Update();
|
|
//{ id: 2, text: "Direccion: evaluación de mercado", start_date: "2020/04/29 00:00", end_date: "2020/05/02 00:00",/*duration: 3,*/ parent: 1, progress: 0.25 }
|
|
}
|
|
|
|
protected void LnkNewProyecto_Click(object sender, EventArgs e)
|
|
{
|
|
this.RegistraScript(string.Format("$('#{0}').modal()", iddivAgregarProyecto));
|
|
RCveEventoB = RCveEvento;
|
|
}
|
|
|
|
protected void btnguardarProyecto_Click(object sender, EventArgs e)
|
|
{
|
|
string errorMessage = "";
|
|
|
|
int cveUsuarioDe = UsuarioActual.CveUsuario;
|
|
List<int> listaCCP = new List<int>();
|
|
int cveUsuarioPara = DdlPara.SelectedValue.ToEntero();
|
|
|
|
OITipoEventos cveTipoEvento = OITipoEventos.Proyecto;
|
|
string asunto = TxtAsunto.Text;
|
|
string descripcion = TxtDescripcion.Text;
|
|
int prioridad = DdlPrioridad.SelectedValue.ToEntero();
|
|
string fechaInicio = "";
|
|
if (txtFechaI.Text.ToDateTimeExcat().Year <= 1999)
|
|
{
|
|
if (txtFechaI.Text.ToDateTimeExcat("dd/MM/yyyy").Year <= 1999)
|
|
{
|
|
errorMessage = "No se ingresó una fecha de inicio valida";
|
|
|
|
}
|
|
else
|
|
{
|
|
fechaInicio = txtFechaI.Text.ToDateTimeExcat("dd/MM/yyyy").ToString("yyyy/MM/dd HH:mm");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
fechaInicio = txtFechaI.Text.ToDateTimeExcat().ToString("yyyy/MM/dd HH:mm");
|
|
}
|
|
string fechaFin = "";
|
|
if (txtFechaF.Text.ToDateTimeExcat().Year <= 1999)
|
|
{
|
|
if (txtFechaF.Text.ToDateTimeExcat("dd/MM/yyyy").Year <= 1999)
|
|
{
|
|
errorMessage = "No se ingresó una fecha fin valida";
|
|
|
|
}
|
|
else
|
|
{
|
|
fechaFin = string.Format("{0:yyyy/MM/dd} 23:59", txtFechaF.Text.ToDateTimeExcat("dd/MM/yyyy"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
fechaFin = txtFechaF.Text.ToDateTimeExcat().ToString("yyyy/MM/dd HH:mm");
|
|
}
|
|
int cveRevision = DdlTema.SelectedValue.ToEntero();
|
|
string archivoname = "";
|
|
string rutaarchivoOri = "";
|
|
//string ArchivoExtencion = "";
|
|
//foreach (Archivo item in TxtArchivo.getfiles().Archivos)
|
|
//{
|
|
// archivoname = item.filenameO;
|
|
// ArchivoExtencion = string.Format("{0}{1}", (item.Extencion.Length > 0 ? "." : ""), item.Extencion);
|
|
// rutaarchivoOri = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, item.patch, item.filename);
|
|
//}
|
|
|
|
|
|
int cveUsuarioIng = UsuarioActual.CveUsuario;
|
|
int cveEmpresa = UsuarioActual.CveEmpresa;
|
|
bool Continuar = false;
|
|
int Folio = -1;
|
|
int CveEvento = -1;
|
|
|
|
if (cveUsuarioDe <= 0)
|
|
{
|
|
errorMessage = "No se selecciono el miembro 'C C Para'";
|
|
}
|
|
|
|
if (cveUsuarioPara <= 0)
|
|
{
|
|
errorMessage = "No se selecciono el miembro 'Para'";
|
|
|
|
}
|
|
if (errorMessage.Length == 0)
|
|
{
|
|
|
|
List<string> chkList = new List<string>();
|
|
|
|
using (ClsOIEventos objOI = new ClsOIEventos())
|
|
{
|
|
objOI.IniciaTransacSQL();
|
|
Continuar = objOI.AddOI_Eventos2(cveTipoEvento, asunto, descripcion, prioridad, cveUsuarioDe, cveUsuarioPara, fechaInicio, fechaFin, cveRevision, archivoname, listaCCP, chkList, cveUsuarioIng, cveEmpresa, RCveEventoB);
|
|
|
|
CveEvento = objOI.CveEvento;
|
|
Folio = objOI.Folio;
|
|
if (CveEvento == 0)
|
|
{
|
|
Continuar = false;
|
|
}
|
|
if (Continuar)
|
|
{
|
|
objOI.Commit();
|
|
//ObjEventosCorreo o = objOI.objCorreo;
|
|
//string mailbody = MailgetBodyNuevatarea(o.Folio, o.Link, o.Asunto, o.Descripcion, o.Fechai, o.Fechaf, o.Prioridad, o.Tema);
|
|
//EnviarCorreo(UsuarioActual.Empresa, o.AsuntoCorreo, mailbody, o.mailPara, "");
|
|
}
|
|
else
|
|
{
|
|
objOI.RollBack();
|
|
Continuar = false;
|
|
}
|
|
}
|
|
if (Continuar && CveEvento > 0)
|
|
{
|
|
if (rutaarchivoOri.Length > 0)
|
|
{
|
|
string ruta = string.Format("{0}OIFiles\\", UsuarioActual.Empresa.Ruta);
|
|
if (!System.IO.Directory.Exists(ruta))
|
|
{
|
|
System.IO.Directory.CreateDirectory(ruta);
|
|
}
|
|
ruta = string.Format("{0}{1}\\", ruta, Folio);
|
|
if (!System.IO.Directory.Exists(ruta))
|
|
{
|
|
System.IO.Directory.CreateDirectory(ruta);
|
|
}
|
|
ruta = string.Format("{0}{1}", ruta, archivoname);//, ArchivoExtencion);
|
|
System.IO.File.Move(rutaarchivoOri, ruta);
|
|
}
|
|
//this.Alert("Se ha agregadó la nueva tarea", ModExtensiones.TipoMensaje.MsgInformacion, string.Format("location.replace(\"/OI/Proyecto.aspx?CveEvento={0}\");", CveEvento));
|
|
loadEvento();
|
|
TxtAsunto.Text = "";
|
|
TxtDescripcion.Text = "";
|
|
txtFechaF.Text = "";
|
|
txtFechaI.Text = "";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void BtnopenmodalClickGant_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
this.RegistraScript(string.Format("$('#{0}').modal()", iddivAgregarProyecto));
|
|
RCveEventoB = txtCveEvento.Text.ToEntero();
|
|
}
|
|
} |