using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Extensiones; public partial class OI_RepProyectos : ClsPaginas { #region Propiedades public const string iddivAgregarProyecto = "iddivAgregarProyecto"; #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { 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")); cargar(); } } public void cargar() { using (ClsOIEventos ObjOI_E = new ClsOIEventos()) { if (ObjOI_E.GetEventos2(-1, UsuarioActual.CveEmpresa, -1) && ObjOI_E.DtResultados.Rows.Count > 0) { System.Data.DataTable dt = ObjOI_E.DtResultados; GvProyecto.DataSource = dt.FiltraParametros(string.Format("CveTipoEvento ={0} AND (CveUsuarioDe ={1} OR CveUsuarioPara={1} ) AND (CveEventoPadre IS NULL OR CveEventoPadre <= 0)", (int)OITipoEventos.Proyecto, UsuarioActual.CveUsuario)); GvProyecto.DataBind(); } } UpContenido.Update(); } protected void LnkNewProyecto_Click(object sender, EventArgs e) { this.RegistraScript(string.Format("$('#{0}').modal()", iddivAgregarProyecto)); } protected void btnguardarProyecto_Click(object sender, EventArgs e) { string errorMessage = ""; int cveUsuarioDe = UsuarioActual.CveUsuario; List listaCCP = new List(); 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 chkList = new List(); 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); 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)); this.Alert("Se ha agregadó la nueva tarea", ModExtensiones.TipoMensaje.MsgInformacion); cargar(); TxtAsunto.Text = ""; TxtDescripcion.Text = ""; txtFechaF.Text = ""; txtFechaI.Text = ""; } } } }