226 lines
6.5 KiB
C#
226 lines
6.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Data;
|
|
|
|
using Extensiones;
|
|
|
|
public partial class CRM_CatMediosCaptacion : ClsPaginas
|
|
{
|
|
|
|
#region "PROPIEDADES"
|
|
private int EsEditar
|
|
{
|
|
get
|
|
{
|
|
return ViewState["EsEditar"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["EsEditar"] = value;
|
|
}
|
|
}
|
|
private DataTable TmpDT
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["TmpDT"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["TmpDT"] = value;
|
|
}
|
|
}
|
|
private int CveMedioCaptacion
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveMedioCaptacion"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveMedioCaptacion"] = value;
|
|
}
|
|
}
|
|
private DataTable DTProcesos
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTProcesos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTProcesos"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargarModalDatos();
|
|
CargaDatos();
|
|
}
|
|
}
|
|
|
|
#region "CARGA DATOS"
|
|
protected void CargaDatos()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa))
|
|
{
|
|
TmpDT = ObjCRM.DtResultados;
|
|
GVDatos.DataSource = TmpDT;
|
|
}
|
|
ObjCRM.Dispose();
|
|
GVDatos.DataBind();
|
|
UPDatos.Update();
|
|
}
|
|
|
|
private void CargarModalDatos()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
if (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlTipoProceso.DataSource = ObjCRM.DtResultados;
|
|
DTProcesos = ObjCRM.DtResultados;
|
|
}
|
|
ObjCRM.Dispose();
|
|
DdlTipoProceso.DataBind();
|
|
DdlTipoProceso.Items.Insert(0,new ListItem("Seleccione","-1"));
|
|
}
|
|
|
|
protected void limpiarCamposModal()
|
|
{
|
|
if (EsEditar == 1)
|
|
{
|
|
LtlModalTitulo.Text = "Actualizar Medio de Captación";
|
|
BtnGuardar.Text = "Actualizar";
|
|
DivEstatus.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
LtlModalTitulo.Text = "Agregar Medio de Captación";
|
|
BtnGuardar.Text = "Guardar";
|
|
DivEstatus.Visible = false;
|
|
}
|
|
TxtMedioCaptacion.Text = "";
|
|
TxtDescripcion.Text = "";
|
|
ChkEstatus.Checked = true;
|
|
DdlTipoProceso.SelectedValue = "-1";
|
|
}
|
|
#endregion
|
|
|
|
#region "ACCIONES"
|
|
protected void LnkAgregar_Click(object sender, EventArgs e)
|
|
{
|
|
EsEditar = 0;
|
|
limpiarCamposModal();
|
|
UPModal.Update();
|
|
|
|
this.RegistraScript("$('#DivModal').modal();");
|
|
}
|
|
|
|
protected void GVDatos_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
|
{
|
|
CveMedioCaptacion = GVDatos.Rows[e.RowIndex].DataKey("CveMedioCaptacion").ToEntero();
|
|
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.RemoveMedioCaptacion(CveMedioCaptacion))
|
|
{
|
|
Alert("El Medio de Captación ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void GVDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (Convert.ToBoolean(e.Row.DataKey("CveEstatus")))
|
|
{
|
|
e.Row.FCLabel("lblEstatus").CssClass = "label label-sm label-success";
|
|
}
|
|
else
|
|
{
|
|
e.Row.FCLabel("lblEstatus").CssClass = "label label-sm label-danger";
|
|
}
|
|
|
|
foreach (DataRow proceso in DTProcesos.Rows)
|
|
{
|
|
int index = DTProcesos.Rows.IndexOf(proceso);
|
|
|
|
if (proceso["CveTipoProceso"].ToEntero() == e.Row.DataKey("CveTipoProceso").ToEntero())
|
|
{
|
|
if ((index % 7) == 0) e.Row.Cells[2].CssClass = "bg-green-haze bg-font-green-haze";
|
|
if ((index % 7) == 1) e.Row.Cells[2].CssClass = "bg-red-pink bg-font-red-pink";
|
|
if ((index % 7) == 2) e.Row.Cells[2].CssClass = "bg-blue bg-font-blue";
|
|
if ((index % 7) == 3) e.Row.Cells[2].CssClass = "bg-purple-soft bg-font-purple-soft";
|
|
if ((index % 7) == 4) e.Row.Cells[2].CssClass = "bg-yellow bg-font-yellow";
|
|
if ((index % 7) == 5) e.Row.Cells[2].CssClass = "bg-yellow-casablanca bg-font-yellow-casablanca";
|
|
if ((index % 7) == 6) e.Row.Cells[2].CssClass = "bg-grey-steel bg-font-grey-steel";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void LnkEditar_Click(object sender, EventArgs e)
|
|
{
|
|
EsEditar = 1;
|
|
limpiarCamposModal();
|
|
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
|
|
CveMedioCaptacion = GvRow.DataKey("CveMedioCaptacion").ToEntero();
|
|
TxtMedioCaptacion.Text = GvRow.DataKey("MedioCaptacion").ToString();
|
|
TxtDescripcion.Text = GvRow.DataKey("Descripcion").ToString();
|
|
ChkEstatus.Checked = GvRow.DataKey("CveEstatus").ToString() == "True" ? true : false;
|
|
DdlTipoProceso.SelectedValue = GvRow.DataKey("CveTipoProceso").ToString();
|
|
UPModal.Update();
|
|
|
|
this.RegistraScript("$('#DivModal').modal();");
|
|
}
|
|
|
|
protected void BtnGuardar_Click(object sender, EventArgs e)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
String MedioCaptacion = TxtMedioCaptacion.Text;
|
|
String Descripcion = TxtDescripcion.Text;
|
|
Boolean Estatus = ChkEstatus.Checked;
|
|
|
|
int CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
|
|
if (EsEditar == 0)
|
|
{
|
|
if (ObjCRM.AddMedioCaptacion(MedioCaptacion, Descripcion, UsuarioActual.CveEmpresa, CveUsuarioIng,DdlTipoProceso.SelectedValue.ToEntero()))
|
|
{
|
|
Alert("El Medio de Captación fue creado correctamente.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ObjCRM.UpdateMedioCaptacion(MedioCaptacion, Descripcion, Estatus, CveMedioCaptacion,DdlTipoProceso.SelectedValue.ToEntero()))
|
|
{
|
|
Alert("El Medio de Captación fue actualizado correctamente.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
limpiarCamposModal();
|
|
this.RegistraScript("$('#DivModal').modal('hide');");
|
|
CargaDatos();
|
|
}
|
|
#endregion
|
|
} |