154 lines
5.7 KiB
C#
154 lines
5.7 KiB
C#
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_TareaNueva : System.Web.UI.UserControl
|
|
{
|
|
public const string iddivAgregarTarea = "iddivAgregarTarea";
|
|
public Usuario UsuarioActual { get { if (Context.Session["UsuarioSIG"] == null) { return null; } else { return (Usuario)Context.Session["UsuarioSIG"]; } } }
|
|
public int CveEventoPadre { get { return ViewState["CveEventoPadre"] != null ? ViewState["CveEventoPadre"].ToString().ToEntero() : 0; } set { ViewState["CveEventoPadre"] = value; } }
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
CveEventoPadre = -1;
|
|
}
|
|
|
|
protected void BtnopenmodalConPadre_Click(object sender, EventArgs e)
|
|
{
|
|
CveEventoPadre = txtCveEventoPadre.Text.ToEntero();
|
|
}
|
|
|
|
protected void BtnGuardarTarea_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, CveEventoPadre);
|
|
|
|
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.ToastInformacion);
|
|
|
|
TxtAsunto.Text = "";
|
|
TxtDescripcion.Text = "";
|
|
txtFechaF.Text = "";
|
|
txtFechaI.Text = "";
|
|
this.RegistraScript("if(OnAddedTareaNueva){OnAddedTareaNueva();})");
|
|
}
|
|
}
|
|
}
|
|
} |