229 lines
6.7 KiB
C#
229 lines
6.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 System.Data;
|
|
|
|
using Extensiones;
|
|
|
|
public partial class CRM_CatRechazoMotivo : 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 DataTable DTProcesos
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTProcesos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTProcesos"] = value;
|
|
}
|
|
}
|
|
private int CveRechazoMotivo
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveRechazoMotivo"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveRechazoMotivo"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaTiposProcesos();
|
|
CargaDatos();
|
|
}
|
|
}
|
|
#region "CARGA DATOS"
|
|
protected void CargaDatos()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetRechazoMotivo(UsuarioActual.CveEmpresa, -1))
|
|
{
|
|
TmpDT = ObjCRM.DtResultados;
|
|
GVDatos.DataSource = TmpDT;
|
|
}
|
|
ObjCRM.Dispose();
|
|
GVDatos.DataBind();
|
|
UPDatos.Update();
|
|
}
|
|
|
|
protected void CargaTiposProcesos()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa, -1))
|
|
{
|
|
DTProcesos = ObjCRM.DtResultados;
|
|
DdlTipoProceso.DataSource = DTProcesos.FiltraParametros("CveEstatus = 1");
|
|
}
|
|
ObjCRM.Dispose();
|
|
DdlTipoProceso.DataBind();
|
|
DdlTipoProceso.Items.Insert(0,new ListItem("Seleccione","-1"));
|
|
}
|
|
|
|
protected void limpiarCamposModal(string NombreRechazo = "")
|
|
{
|
|
if (EsEditar == 1)
|
|
{
|
|
LtlModalTitulo.Text = String.Format("Actualizar Motivo de {0}", (NombreRechazo == "" ? "Rechazo" : NombreRechazo));
|
|
BtnGuardar.Text = "Actualizar";
|
|
DivEstatus.Visible = true;
|
|
DdlTipoProceso.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
LtlModalTitulo.Text = "Agregar Motivo de Rechazo";
|
|
BtnGuardar.Text = "Guardar";
|
|
DivEstatus.Visible = false;
|
|
DdlTipoProceso.Enabled = true;
|
|
}
|
|
TxtRechazoMotivo.Text = "";
|
|
TxtDescripcion.Text = "";
|
|
ChkEstatus.Checked = true;
|
|
}
|
|
#endregion
|
|
|
|
#region "ACCIONES"
|
|
protected void LnkAgregar_Click(object sender, EventArgs e)
|
|
{
|
|
EsEditar = 0;
|
|
limpiarCamposModal();
|
|
UPModal.Update();
|
|
|
|
this.RegistraScript("$('#DivModal').modal();");
|
|
}
|
|
protected void LnkEditar_Click(object sender, EventArgs e)
|
|
{
|
|
EsEditar = 1;
|
|
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
|
|
limpiarCamposModal(GvRow.DataKey("EtapaProceso").ToString());
|
|
|
|
CveRechazoMotivo = GvRow.DataKey("CveRechazoMotivo").ToEntero();
|
|
TxtRechazoMotivo.Text = GvRow.DataKey("RechazoMotivo").ToString();
|
|
TxtDescripcion.Text = GvRow.DataKey("Descripcion").ToString();
|
|
ChkEstatus.Checked = GvRow.DataKey("CveEstatus").ToString() == "True" ? true : false;
|
|
DdlTipoProceso.SelectedValueExist(GvRow.DataKey("CveTipoProceso").ToEntero());
|
|
|
|
UPModal.Update();
|
|
|
|
this.RegistraScript("$('#DivModal').modal();");
|
|
}
|
|
|
|
protected void BtnGuardar_Click(object sender, EventArgs e)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
int CveTipoProceso = DdlTipoProceso.SelectedValue.ToEntero();
|
|
String RechazoMotivo = TxtRechazoMotivo.Text;
|
|
String Descripcion = TxtDescripcion.Text;
|
|
Boolean Estatus = ChkEstatus.Checked;
|
|
|
|
int CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
|
|
if (EsEditar == 0)
|
|
{
|
|
if (ObjCRM.AddRechazoMotivo(RechazoMotivo, Descripcion, UsuarioActual.CveEmpresa, CveUsuarioIng, CveTipoProceso))
|
|
{
|
|
Alert("El Motivo de Rechazo fue creado correctamente.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ObjCRM.UpdateRechazoMotivo(RechazoMotivo, Descripcion, Estatus, CveRechazoMotivo))
|
|
{
|
|
Alert("El Motivo de Rechazo fue actualizado correctamente.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
limpiarCamposModal();
|
|
this.RegistraScript("$('#DivModal').modal('hide');");
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void GVDatos_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
|
{
|
|
CveRechazoMotivo = GVDatos.Rows[e.RowIndex].DataKey("CveRechazoMotivo").ToEntero();
|
|
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.RemoveRechazoMotivo(CveRechazoMotivo))
|
|
{
|
|
Alert("El Motivo de Rechazo 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[0].CssClass = "bg-green-haze bg-font-green-haze";
|
|
if ((index % 7) == 1) e.Row.Cells[0].CssClass = "bg-red-pink bg-font-red-pink";
|
|
if ((index % 7) == 2) e.Row.Cells[0].CssClass = "bg-blue bg-font-blue";
|
|
if ((index % 7) == 3) e.Row.Cells[0].CssClass = "bg-purple-soft bg-font-purple-soft";
|
|
if ((index % 7) == 4) e.Row.Cells[0].CssClass = "bg-yellow bg-font-yellow";
|
|
if ((index % 7) == 5) e.Row.Cells[0].CssClass = "bg-yellow-casablanca bg-font-yellow-casablanca";
|
|
if ((index % 7) == 6) e.Row.Cells[0].CssClass = "bg-grey-steel bg-font-grey-steel";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
} |