usercontrol Tareas
This commit is contained in:
326
UserControl/TareaNueva.ascx.cs
Normal file
326
UserControl/TareaNueva.ascx.cs
Normal file
@@ -0,0 +1,326 @@
|
||||
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 UserControl_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; } }
|
||||
public OITipoEventos cveTipoEvento { get { return ViewState["cveTipoEvento"] != null ? (OITipoEventos)ViewState["cveTipoEvento"] : OITipoEventos.Tarea; } set { ViewState["cveTipoEvento"] = value; } }
|
||||
|
||||
//OITipoEventos cveTipoEvento = OITipoEventos.Tarea;
|
||||
public bool Ismodal { get { return ViewState["Ismodal"] != null ? (bool)ViewState["Ismodal"] : true; } set { ViewState["Ismodal"] = value; } }
|
||||
public string OnAddedTareaNueva { get { return ViewState["OnAddedTareaNueva"] != null ? ViewState["OnAddedTareaNueva"].ToString() : "OnAddedTareaNueva"; } set { ViewState["OnAddedTareaNueva"] = value; } }
|
||||
public const string iddivAgregarTema = "divModalAgregartema";
|
||||
|
||||
protected System.Data.DataTable get_GlobalDTUsuarios(int CveUsuario = -1, int CveEmpresa = -1)
|
||||
{
|
||||
System.Text.StringBuilder Str = new System.Text.StringBuilder();
|
||||
if (CveUsuario != -1) { Str.AppendFormat("CveUsuario = {0}", CveUsuario); }
|
||||
if (CveEmpresa != -1) { Str.AppendFormat(" {0} CveEmpresa = {1}", Str.Length > 0 ? "AND" : "", CveEmpresa); }
|
||||
System.Data.DataTable dt = null;
|
||||
if (CveUsuario != -1 || CveEmpresa != -1)
|
||||
{
|
||||
System.Data.DataView Dv = new System.Data.DataView((System.Data.DataTable)Application["GlobalDTUsuarios"], Str.ToString(), "", System.Data.DataViewRowState.CurrentRows);
|
||||
dt = Dv.ToTable();
|
||||
Dv.Dispose();
|
||||
}
|
||||
else
|
||||
{ dt = (System.Data.DataTable)Application["GlobalDTUsuarios"]; }
|
||||
return dt;
|
||||
}
|
||||
//public DataTable GlobalDTOIRevision
|
||||
protected System.Data.DataTable get_GlobalDTOIRevision(int CveEmpresa = -1)
|
||||
{
|
||||
System.Data.DataTable dt = null;
|
||||
System.Text.StringBuilder Str = new System.Text.StringBuilder();
|
||||
|
||||
if (CveEmpresa != -1)
|
||||
{
|
||||
string StrSQL = string.Format("CveEmpresa = {0}", CveEmpresa);
|
||||
System.Data.DataView Dv = new System.Data.DataView((System.Data.DataTable)Application["GlobalDTOIRevision"], StrSQL, "", System.Data.DataViewRowState.CurrentRows);
|
||||
dt = Dv.ToTable();
|
||||
Dv.Dispose();
|
||||
}
|
||||
else { dt = (System.Data.DataTable)Application["GlobalDTOIRevision"]; }
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
if (!Ismodal)
|
||||
{
|
||||
iddivAgregarTarea.CssClass = "";
|
||||
iddivAgregarTareamodaldialog.CssClass = "";
|
||||
iddivAgregarTareamodalbody.CssClass = "";
|
||||
iddivAgregarTareamodalcontent.CssClass = "";
|
||||
iddivAgregarTareamodalheader.Visible = false;
|
||||
iddivAgregarTareamodalfooter.Visible = false;
|
||||
}
|
||||
if (CveEventoPadre > 0)
|
||||
{
|
||||
txtCveEventoPadre.Text = CveEventoPadre.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
CveEventoPadre = -1;
|
||||
txtCveEventoPadre.Text = "-1";
|
||||
}
|
||||
GVUsuarios_TareaNueva.DataSource = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa).FiltraParametros("Estatus =1 ", "Rol ASC");
|
||||
|
||||
DdlPara.DataSource = GVUsuarios_TareaNueva.DataSource;
|
||||
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"));
|
||||
GVUsuarios_TareaNueva.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
protected void BtnopenmodalConPadre_Click(object sender, EventArgs e)
|
||||
{
|
||||
CveEventoPadre = txtCveEventoPadre.Text.ToEntero();
|
||||
if (Ismodal)
|
||||
{
|
||||
this.RegistraScript(string.Format("$('#{0}').modal()", iddivAgregarTarea.ClientID));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void BtnGuardarTarea_Click(object sender, EventArgs e)
|
||||
{
|
||||
string errorMessage = "";
|
||||
|
||||
TxtCveActivoFijo.Text = TxtCveActivoFijo.Text.ToEntero() > 0 ? TxtCveActivoFijo.Text : "-1";
|
||||
TxtCveIE.Text = TxtCveIE.Text.ToEntero() > 0 ? TxtCveIE.Text : "-1";
|
||||
TxtCveProspecto.Text = TxtCveProspecto.Text.ToEntero() > 0 ? TxtCveProspecto.Text : "-1";
|
||||
TxtCveCliente.Text = TxtCveCliente.Text.ToEntero() > 0 ? TxtCveCliente.Text : "-1";
|
||||
TxtCveOS.Text = TxtCveOS.Text.ToEntero() > 0 ? TxtCveOS.Text : "-1";
|
||||
TxtCveOC.Text = TxtCveOC.Text.ToEntero() > 0 ? TxtCveOC.Text : "-1";
|
||||
TxtCvePersonal.Text = TxtCvePersonal.Text.ToEntero() > 0 ? TxtCvePersonal.Text : "-1";
|
||||
TxtCveProveedor.Text = TxtCveProveedor.Text.ToEntero() > 0 ? TxtCveProveedor.Text : "-1";
|
||||
TxtCveCompra.Text = TxtCveCompra.Text.ToEntero() > 0 ? TxtCveCompra.Text : "-1";
|
||||
TxtCveVenta.Text = TxtCveVenta.Text.ToEntero() > 0 ? TxtCveVenta.Text : "-1";
|
||||
TxtCveContrato.Text = TxtCveContrato.Text.ToEntero() > 0 ? TxtCveContrato.Text : "-1";
|
||||
TxtCveSubProyecto.Text = TxtCveSubProyecto.Text.ToEntero() > 0 ? TxtCveSubProyecto.Text : "-1";
|
||||
TxtCveMovimientoAlmacen.Text = TxtCveMovimientoAlmacen.Text.ToEntero() > 0 ? TxtCveMovimientoAlmacen.Text : "-1";
|
||||
|
||||
int cveUsuarioDe = UsuarioActual.CveUsuario;
|
||||
List<int> listaCCP = new List<int>();
|
||||
int cveUsuarioPara = DdlPara.SelectedValue.ToEntero();
|
||||
|
||||
foreach (GridViewRow gvRow in GVUsuarios_TareaNueva.Rows)
|
||||
{
|
||||
if (gvRow.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
CheckBox ChkOk = gvRow.FCCheckBox("ChkOk");
|
||||
if (ChkOk.Checked)
|
||||
{
|
||||
int CveUsuario = gvRow.DataKey("CveUsuario").ToString().ToEntero();
|
||||
listaCCP.Add(CveUsuario);
|
||||
}
|
||||
}
|
||||
}
|
||||
//OITipoEventos cveTipoEvento = OITipoEventos.Tarea;
|
||||
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,
|
||||
CveActivoFijo: TxtCveActivoFijo.Text.ToEntero(),
|
||||
CveIE: TxtCveIE.Text.ToEntero(), CveProspecto: TxtCveProspecto.Text.ToEntero(), CveCliente: TxtCveCliente.Text.ToEntero(),
|
||||
CveOS: TxtCveOS.Text.ToEntero(), CveOC: TxtCveOC.Text.ToEntero(), CvePersonal: TxtCvePersonal.Text.ToEntero(),
|
||||
CveProveedor: TxtCveProveedor.Text.ToEntero(), CveCompra: TxtCveCompra.Text.ToEntero(), CveVenta: TxtCveVenta.Text.ToEntero(),
|
||||
CveContrato: TxtCveContrato.Text.ToEntero(), CveSubProyecto: TxtCveSubProyecto.Text.ToEntero(), CveMovimientoAlmacen: TxtCveMovimientoAlmacen.Text.ToEntero());
|
||||
|
||||
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 = "";
|
||||
if (Ismodal)
|
||||
{
|
||||
this.RegistraScript(string.Format("$('#{0}').modal('hide')", iddivAgregarTarea.ClientID));
|
||||
}
|
||||
this.RegistraScript(string.Format("if({0}){0}();", OnAddedTareaNueva));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Alert(errorMessage.ToString(), ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void GVUsuarios_TareaNueva_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
CheckBox ChkOk = e.Row.FCCheckBox("ChkOk");
|
||||
int CveUsuario = e.Row.DataKey("CveUsuario").ToString().ToEntero();
|
||||
if (CveUsuario == UsuarioActual.CveUsuario)
|
||||
{
|
||||
ChkOk.Checked = true;
|
||||
}
|
||||
string CveRol = e.Row.DBCampo("CveRol");
|
||||
string CveSubProyecto = e.Row.DBCampo("CveSubProyecto");
|
||||
e.Row.CssClass = "items";
|
||||
e.Row.Attributes.Add("data-rol", CveRol);
|
||||
e.Row.Attributes.Add("data-sucursal", CveRol);
|
||||
}
|
||||
}
|
||||
|
||||
protected void LnkAddTtemaB_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.RegistraScript(string.Format("$('#{0}').modal()", iddivAgregarTema));
|
||||
}
|
||||
|
||||
private void CargaTemas()
|
||||
{
|
||||
DdlTema.DataSource = get_GlobalDTOIRevision(UsuarioActual.CveEmpresa).FiltraParametros(string.Format("CveUsuario = {0}", UsuarioActual.CveUsuario));
|
||||
DdlTema.DataBind();
|
||||
DdlTema.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||||
|
||||
}
|
||||
protected void BtnAgregarTema_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
using (ClsOIEventos objoi = new ClsOIEventos())
|
||||
{
|
||||
if (objoi.AddRevisionesEventos(TxtTema.Text.Trim(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
this.Alert("Tema agregada con éxito.", ModExtensiones.TipoMensaje.MsgInformacion);
|
||||
this.RegistraScript(string.Format("$('#{0}').modal('hide')", iddivAgregarTema));
|
||||
|
||||
if (Ismodal)
|
||||
{
|
||||
this.RegistraScript(string.Format("$('#{0}').modal()", iddivAgregarTarea.ClientID));
|
||||
}
|
||||
TxtTema.Text = "";
|
||||
//set_GlobalDTOIRevision(-1, objoi.DtResultados);
|
||||
Application["GlobalDTOIRevision"] = objoi.DtResultados;
|
||||
CargaTemas();
|
||||
UpModalTareaNueva.Update();
|
||||
}
|
||||
else { this.Alert("Ocurrió un error al agregar la revisión. Por favor vuelva a intentar.", ModExtensiones.TipoMensaje.MsgError); }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user