1669 lines
62 KiB
C#
1669 lines
62 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.IO;
|
|
using System.Data;
|
|
|
|
using Extensiones;
|
|
using System.Web.UI.HtmlControls;
|
|
|
|
public partial class CRM_Acercamiento : ClsPaginas
|
|
{
|
|
#region "PROPIEDADES"
|
|
private int CveAcercamiento
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveAcercamiento"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveAcercamiento"] = value;
|
|
}
|
|
}
|
|
private int CveEmpresaCRM
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveEmpresaCRM"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveEmpresaCRM"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveVendedorAsignado
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveVendedorAsignado"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveVendedorAsignado"] = value;
|
|
}
|
|
}
|
|
|
|
protected int NumeroEtapasProceso
|
|
{
|
|
get
|
|
{
|
|
return ViewState["NumeroEtapasProceso"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["NumeroEtapasProceso"] = value;
|
|
}
|
|
}
|
|
|
|
protected int CveEtapaActual
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveEtapaActual"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveEtapaActual"] = value;
|
|
}
|
|
}
|
|
|
|
protected int OrdenEtapaActual
|
|
{
|
|
get
|
|
{
|
|
return ViewState["OrdenEtapaActual"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["OrdenEtapaActual"] = value;
|
|
}
|
|
}
|
|
|
|
protected int CveContactoPrincipal
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveContactoPrincipal"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveContactoPrincipal"] = value;
|
|
}
|
|
}
|
|
|
|
protected int CveTipoProceso
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveTipoProceso"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveTipoProceso"] = value;
|
|
}
|
|
}
|
|
|
|
private String TipoProceso
|
|
{
|
|
get
|
|
{
|
|
return ViewState["TipoProceso"].ToString();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["TipoProceso"] = value;
|
|
}
|
|
}
|
|
|
|
private String NombreAcercamiento
|
|
{
|
|
get
|
|
{
|
|
return ViewState["NombreAcercamiento"].ToString();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["NombreAcercamiento"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable DTEventosBitacora
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTEventosBitacora"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTEventosBitacora"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable DTEtapasProceso
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTEtapasProceso"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTEtapasProceso"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveEncuestaProcesoCRM
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveEncuestaProcesoCRM"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveEncuestaProcesoCRM"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveEncuestaAplicadaProceso
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveEncuestaAplicadaProceso"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveEncuestaAplicadaProceso"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable DTRespuestasDatosTecnicos
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTRespuestasDatosTecnicos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTRespuestasDatosTecnicos"] = value;
|
|
}
|
|
}
|
|
public string UrlIMGEncriptada(string param)
|
|
{
|
|
return ModExtensiones.Encripta(param);
|
|
}
|
|
private Boolean Actualizar
|
|
{
|
|
get
|
|
{
|
|
return (Boolean)ViewState["Actualizar"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["Actualizar"] = value;
|
|
}
|
|
}
|
|
private int CveAcercamientoGasto
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveAcercamientoGasto"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveAcercamientoGasto"] = value;
|
|
}
|
|
}
|
|
private int CvePS
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CvePS"] == null ? -1 : ViewState["CvePS"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CvePS"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
InicializaDatos();
|
|
CargaDatos();
|
|
CargaCotizaciones();
|
|
CargaGastos();
|
|
CargaRechazosMotivos();
|
|
|
|
if (UsuarioActual.CveEmpresa == 72)
|
|
{
|
|
TabDatosTecnicos.Visible = false;
|
|
TabImagenes.Visible = false;
|
|
}
|
|
|
|
if (CveAcercamiento > 0)
|
|
{
|
|
CargaEtapasBitacora();
|
|
CargarTiposEventosBitacora();
|
|
ActivaOpcionCierreCancelacion();
|
|
ActivaFechaCierre(CveEtapaActual);
|
|
VerificaPermisosEdicion();
|
|
|
|
if (CveEncuestaProcesoCRM > 0)
|
|
{
|
|
CargaDatosTecnicos();
|
|
if (DTRespuestasDatosTecnicos.Rows.Count > 0)
|
|
{
|
|
DivMensajeDatosTecnicos.Visible = false;
|
|
}
|
|
}
|
|
}
|
|
CargarPS();
|
|
}
|
|
}
|
|
|
|
#region "CARGA DATOS - TAB INFO"
|
|
protected void CargaDatos()
|
|
{
|
|
if (CveAcercamiento > 0)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetAcercamiento(UsuarioActual.CveEmpresa, CveAcercamiento: CveAcercamiento) && ObjCRM.DtResultados.Rows.Count > 0)
|
|
{
|
|
LblEncabezadoAcercamiento.Text = String.Format("<span class='bold' style='color: #32c5d2;'>{0}:</span> {1}", ObjCRM.DtResultados.FiltroPrimeroValor("TipoProceso").ToUpper(), ObjCRM.DtResultados.FiltroPrimeroValor("NombreAcercamiento").ToUpper());
|
|
CveTipoProceso = ObjCRM.DtResultados.FiltroPrimeroValor("CveTipoProceso").ToEntero();
|
|
//SECCION DATOS DEL ACERCAMIENTO
|
|
TxtNombreAcercamiento.Text = ObjCRM.DtResultados.FiltroPrimeroValor("NombreAcercamiento");
|
|
TxtDescripcion.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Descripcion");
|
|
TxtFechaApertura.Text = ObjCRM.DtResultados.FiltroPrimeroValor("FechaApertura").ToDateTime().ToShortDateString();
|
|
TxtFechaCierre.Text = (ObjCRM.DtResultados.FiltroPrimeroValor("FechaCierre") == "") ? "" : ObjCRM.DtResultados.FiltroPrimeroValor("FechaCierre").ToDateTime().ToShortDateString();
|
|
TxtImporte.Text = String.Format("{0:C2}", ObjCRM.DtResultados.FiltroPrimeroValor("Importe").ToString().ToDecimal());
|
|
TxtComision.Text = String.Format("{0:C2}", ObjCRM.DtResultados.FiltroPrimeroValor("Comision").ToString().ToDecimal());
|
|
|
|
DdlProbabilidadAcercamiento.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveProbabilidadAcercamiento"));
|
|
DdlPrioridad.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("Prioridad"));
|
|
|
|
CargaDdl();
|
|
//SECCION DATOS DE LA EMPRESA
|
|
DdlEmpresaCRM.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveEmpresaCRM"));
|
|
//DdlContactoPrincipal.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveContactoPrincipal"));
|
|
//SECCION DATOS DEL PROCESO
|
|
//DdlTipoProceso.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveTipoProceso"));
|
|
DdlEtapaProceso.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveEtapaProcesoActual"));
|
|
DdlVendedor.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveVendedor"));
|
|
DdlMedioCaptacion.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveMedioCaptacion"));
|
|
|
|
//CARGA MODAL CIERRE-CANCELACION
|
|
TxtFechaCierreRechazo.Text = (ObjCRM.DtResultados.FiltroPrimeroValor("FechaCierre") == "") ? DateTime.Now.ToShortDateString() : ObjCRM.DtResultados.FiltroPrimeroValor("FechaCierre").ToDateTime().ToShortDateString();
|
|
DdlRechazoMotivo.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveRechazoMotivo"));
|
|
TxtObservacionRechazo.Text = ObjCRM.DtResultados.FiltroPrimeroValor("ObservacionRechazo");
|
|
|
|
//CARGAMOS PARAMETROS
|
|
NombreAcercamiento = ObjCRM.DtResultados.FiltroPrimeroValor("NombreAcercamiento").ToUpper();
|
|
CveEmpresaCRM = ObjCRM.DtResultados.FiltroPrimeroValor("CveEmpresaCRM").ToEntero();
|
|
CveVendedorAsignado = ObjCRM.DtResultados.FiltroPrimeroValor("CveVendedor").ToEntero();
|
|
CveContactoPrincipal = (ObjCRM.DtResultados.FiltroPrimeroValor("CveTipoProceso").ToEntero() > 0) ? ObjCRM.DtResultados.FiltroPrimeroValor("CveContactoPrincipal").ToEntero() : -1;
|
|
|
|
CveEtapaActual = ObjCRM.DtResultados.FiltroPrimeroValor("CveEtapaProcesoActual").ToEntero();
|
|
|
|
|
|
CveEncuestaProcesoCRM = (ObjCRM.DtResultados.FiltroPrimeroValor("CveEncuestaProcesoCRM").ToEntero() > 0) ? ObjCRM.DtResultados.FiltroPrimeroValor("CveEncuestaProcesoCRM").ToEntero() : -1;
|
|
CveEncuestaAplicadaProceso = (ObjCRM.DtResultados.FiltroPrimeroValor("CveEncuestaAplicadaProceso").ToEntero() > 0) ? ObjCRM.DtResultados.FiltroPrimeroValor("CveEncuestaAplicadaProceso").ToEntero() : -1;
|
|
//CveEtapaBitacoraSeleccionada = CveEtapaActual;
|
|
|
|
CvePS = ObjCRM.DtResultados.FiltroPrimeroValor("CvePS").ToEntero();
|
|
|
|
HdfEtapaSeleccionada.Value = CveEtapaActual.ToString();
|
|
//INHABILITAMOS CAMPOS QUE NO SE PUEDEN EDITAR
|
|
DdlEmpresaCRM.Enabled = false;
|
|
//DdlTipoProceso.Enabled = false;
|
|
|
|
//MOSTRAMOS BOTONES
|
|
BtnGuardarAcercamiento.Text = "Actualizar";
|
|
BtnGuardarAcercamiento.Visible = true;
|
|
BtnEliminarAcercamiento.Visible = true;
|
|
//DivVerBitacoraCompleta.Visible = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
Alert("La Empresa solicitada no existe, por favor revise su búsqueda.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
BtnGuardarAcercamiento.Enabled = false;
|
|
BtnEliminarAcercamiento.Enabled = false;
|
|
CveAcercamiento = -1;
|
|
CveEmpresaCRM = -1;
|
|
CveEtapaActual = -1;
|
|
CveTipoProceso = -1;
|
|
CveEncuestaProcesoCRM = -1;
|
|
CveEncuestaAplicadaProceso = -1;
|
|
}
|
|
ObjCRM.Dispose();
|
|
|
|
if (CveAcercamiento > 0)
|
|
{
|
|
//CARGAMOS Y SELECCIONAMOS CONTACTO PRINCIPAL Y ETAPA ACTUAL
|
|
CargaContactos(CveEmpresaCRM);
|
|
CargaEtapasProceso(CveTipoProceso);
|
|
DdlContactoPrincipal.SelectedValueExist(CveContactoPrincipal);
|
|
DdlEtapaProceso.SelectedValueExist(CveEtapaActual);
|
|
DesactivaEdicion();
|
|
|
|
if (CveEtapaActual > 0)
|
|
{
|
|
//CARGAMOS BITACORA
|
|
DivBitacora.Visible = true;
|
|
CargaEventoBitacora(HdfEtapaSeleccionada.Value.ToEntero());
|
|
}
|
|
}
|
|
|
|
CargaImagenes();
|
|
|
|
UpEncabezado.Update();
|
|
UPAcercamiento.Update();
|
|
UPBitacoraEtapas.Update();
|
|
UPBitacora.Update();
|
|
UpGuardar.Update();
|
|
UpGaleria.Update();
|
|
}
|
|
}
|
|
|
|
protected void DesactivaEdicion()
|
|
{
|
|
TxtNombreAcercamiento.Enabled = false;
|
|
TxtDescripcion.Enabled = false;
|
|
TxtFechaApertura.Enabled = false;
|
|
CETxtFechaApertura.EnabledOnClient = false;
|
|
DdlVendedor.Enabled = false;
|
|
}
|
|
|
|
protected void InicializaDatos()
|
|
{
|
|
NumeroEtapasProceso = -1;
|
|
CveEtapaActual = -1;
|
|
|
|
CveAcercamiento = -1;
|
|
CveEmpresaCRM = -1;
|
|
CveTipoProceso = -1;
|
|
CveEncuestaProcesoCRM = -1;
|
|
CveEncuestaAplicadaProceso = -1;
|
|
|
|
RecuperaCve();
|
|
TxtFechaApertura.Text = DateTime.Now.ToShortDateString();
|
|
}
|
|
|
|
protected void RecuperaCve()
|
|
{
|
|
if (Request["CveAcercamiento"] != null && !Request["CveAcercamiento"].ToString().Equals("") && Request["CveAcercamiento"].ToEntero() > 0)
|
|
{
|
|
ViewState["CveAcercamiento"] = Request["CveAcercamiento"];
|
|
}
|
|
else
|
|
{
|
|
ViewState["CveAcercamiento"] = -1;
|
|
}
|
|
}
|
|
|
|
protected void CargaDdl()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetProbabilidadAcercamiento(UsuarioActual.CveEmpresa, 1))
|
|
{
|
|
DdlProbabilidadAcercamiento.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}", CveTipoProceso));
|
|
}
|
|
if (ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlEmpresaCRM.DataSource = ObjCRM.DtResultados;
|
|
DdlEmpresaCRM.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
}
|
|
//if (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa, 1))
|
|
//{
|
|
// DdlTipoProceso.DataSource = ObjCRM.DtResultados;
|
|
// DdlTipoProceso.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
//}
|
|
if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa, 1))
|
|
{
|
|
DdlMedioCaptacion.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}",CveTipoProceso));
|
|
DdlMedioCaptacion.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
}
|
|
|
|
DdlVendedor.DataSource = get_GlobalDTVendedores(UsuarioActual.CveEmpresa);
|
|
ObjCRM.Dispose();
|
|
|
|
DdlProbabilidadAcercamiento.DataBind();
|
|
DdlEmpresaCRM.DataBind();
|
|
//DdlTipoProceso.DataBind();
|
|
DdlVendedor.DataBind();
|
|
DdlMedioCaptacion.DataBind();
|
|
}
|
|
|
|
protected void CargaRechazosMotivos()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
if (ObjCRM.GetRechazoMotivo(UsuarioActual.CveEmpresa, 1, CveTipoProceso))
|
|
{
|
|
DdlRechazoMotivo.DataSource = ObjCRM.DtResultados;
|
|
DdlRechazoMotivo.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
}
|
|
ObjCRM.Dispose();
|
|
DdlRechazoMotivo.DataBind();
|
|
}
|
|
|
|
protected void CargarTiposEventosBitacora()
|
|
{
|
|
ClsOIEventos ObjEventos = new ClsOIEventos();
|
|
|
|
if (ObjEventos.GetAgendaTipo())
|
|
{
|
|
DdlTipoAgenda.DataSource = ObjEventos.DtResultados;
|
|
DdlTipoAgenda.DataBind();
|
|
}
|
|
|
|
ObjEventos.Dispose();
|
|
limpiarModalAgendar();
|
|
}
|
|
|
|
|
|
protected void DdlEmpresaCRM_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (DdlEmpresaCRM.SelectedValue.ToEntero() > 0)
|
|
{
|
|
CargaContactos(DdlEmpresaCRM.SelectedValue.ToEntero());
|
|
UPAcercamiento.Update();
|
|
}
|
|
}
|
|
|
|
protected void CargaContactos(int CveEmpresaCRM)
|
|
{
|
|
DdlContactoPrincipal.Items.Clear();
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetContactoEmpresa(CveEmpresaCRM))
|
|
{
|
|
DdlContactoPrincipal.DataSource = ObjCRM.DtResultados;
|
|
DdlContactoAgenda.DataSource = ObjCRM.DtResultados;
|
|
}
|
|
DdlContactoPrincipal.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
DdlContactoAgenda.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
|
|
ObjCRM.Dispose();
|
|
|
|
DdlContactoPrincipal.DataBind();
|
|
DdlContactoAgenda.DataBind();
|
|
|
|
DdlContactoAgenda.SelectedValueExist(CveContactoPrincipal);
|
|
}
|
|
|
|
|
|
//protected void DdlTipoProceso_SelectedIndexChanged(object sender, EventArgs e)
|
|
//{
|
|
// if (DdlTipoProceso.SelectedValue.ToEntero() > 0)
|
|
// {
|
|
// CargaEtapasProceso(DdlTipoProceso.SelectedValue.ToEntero());
|
|
// UPAcercamiento.Update();
|
|
// }
|
|
//}
|
|
|
|
protected void CargaEtapasProceso(int CveTipoProceso)
|
|
{
|
|
//DDLs
|
|
DdlEtapaProceso.Items.Clear();
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetEtapaProceso(UsuarioActual.CveEmpresa, CveTipoProceso, CveEstatus: 1))
|
|
{
|
|
DTEtapasProceso = ObjCRM.DtResultados;
|
|
OrdenEtapaActual = DTEtapasProceso.FiltroPrimeroValor("Orden", String.Format("CveEtapaProceso = {0}", CveEtapaActual)).ToEntero();
|
|
|
|
//SI LA ETAPA ES CANCELACION HABILITA MOSTRAR LAS DOS ETAPAS ANTERIORES
|
|
if (DTEtapasProceso.FiltroPrimeroValor("CveEtapaProceso", String.Format("CveEtapaProceso = {0} AND CveTipoEtapa = 4", CveEtapaActual)).ToEntero() > 0)
|
|
{
|
|
DdlEtapaProceso.DataSource = DTEtapasProceso.FiltraParametros(String.Format("( Orden >= {0} ) AND ( Orden <= {1} )", (OrdenEtapaActual - 2), (OrdenEtapaActual + 1)));
|
|
}
|
|
else
|
|
{
|
|
DdlEtapaProceso.DataSource = DTEtapasProceso.FiltraParametros(String.Format("(( Orden >= {0} ) AND ( Orden <= {1} )) OR (CveTipoEtapa = 4)", (OrdenEtapaActual - 1), (OrdenEtapaActual + 1)));
|
|
}
|
|
}
|
|
ObjCRM.Dispose();
|
|
DdlEtapaProceso.DataBind();
|
|
}
|
|
protected void DdlEtapaProceso_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (ActivaFechaCierre(DdlEtapaProceso.SelectedValue.ToEntero()))
|
|
{
|
|
TxtFechaCierre.Text = DateTime.Now.ToShortDateString();
|
|
}
|
|
else
|
|
{
|
|
TxtFechaCierre.Text = "";
|
|
if (DTEtapasProceso.FiltraParametros(String.Format("CveEtapaProceso = {0} AND CveTipoEtapa = 4", DdlEtapaProceso.SelectedValue.ToEntero())).Rows.Count > 0)
|
|
{
|
|
LnkCerrarAcercamiento_Click(null, null);
|
|
}
|
|
}
|
|
|
|
//AUTOGUARDADO DE CAMBIO DE ETAPA
|
|
if (DTEtapasProceso.FiltroPrimeroValor("CveTipoEtapa", String.Format("CveEtapaProceso = {0}", DdlEtapaProceso.SelectedValue.ToEntero())).Contiene("1", "2", "3"))
|
|
GuardarCambioEtapa();
|
|
}
|
|
|
|
private void CargarPS()
|
|
{
|
|
DdlPS.setEsWebService(true);
|
|
if(CvePS > 0)
|
|
{
|
|
string productoAsignado = get_GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS: CvePS).FiltroPrimeroValor("PSCodigo");
|
|
DdlPS.SelectedValue = CvePS.ToString();
|
|
DdlPS.SelectedText = productoAsignado;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region "GUARDAR"
|
|
protected void BtnGuardarAcercamiento_Click(object sender, EventArgs e)
|
|
{
|
|
if (CveAcercamiento > 0)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
ClsEncuestas ObjDatosTecnicos = new ClsEncuestas(ObjCRM.IniciaTransacSQL());
|
|
//ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
|
|
|
|
Boolean HuboError = true;
|
|
|
|
String NombreAcercamiento = TxtNombreAcercamiento.Text;
|
|
String Descripcion = TxtDescripcion.Text == "" ? "-1" : TxtDescripcion.Text;
|
|
|
|
int CveEtapaProcesoActualActualizar = DdlEtapaProceso.SelectedValue.ToEntero();
|
|
|
|
int CveContactoPrincipal = DdlContactoPrincipal.SelectedValue.ToEntero();
|
|
int CveVendedor = DdlVendedor.SelectedValue.ToEntero();
|
|
int CveMedioCaptacion = DdlMedioCaptacion.SelectedValue.ToEntero();
|
|
int CveProbabilidadAcercamiento = DdlProbabilidadAcercamiento.SelectedValue.ToEntero();
|
|
|
|
//SE ACTUALIZARA CUANDO SE ACTUALIZE A FIN PROCESO CON ETAPA 4
|
|
//int CveRechazoMotivo = -1;
|
|
|
|
DateTime FechaApertura = TxtFechaApertura.Text.ToDateTime();
|
|
|
|
//FECHA CIERRE SE ENVIARA HASTA QUE LA ETAPA SEA ETAPA TIPO 3 O 4
|
|
DateTime? FechaCierre = null;
|
|
|
|
if (DTEtapasProceso.FiltraParametros(String.Format("CveEtapaProceso = {0} AND CveTipoEtapa IN(3, 4)", CveEtapaProcesoActualActualizar)).Rows.Count > 0)
|
|
{
|
|
FechaCierre = TxtFechaCierre.Text != "" ? TxtFechaCierre.Text.ToDateTime() : DateTime.Now;
|
|
}
|
|
|
|
Double Importe = TxtImporte.Text.ToDouble();
|
|
Double Comision = TxtComision.Text.ToDouble();
|
|
|
|
int Prioridad = DdlPrioridad.SelectedValue.ToEntero();
|
|
|
|
int CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
|
|
if (CveEncuestaProcesoCRM > 0)
|
|
{
|
|
CveEncuestaAplicadaProceso = GuardaDatosTecnicos(ObjDatosTecnicos, CveEncuestaAplicadaProceso);
|
|
}
|
|
|
|
if ((CveEncuestaAplicadaProceso != 0) && ObjCRM.UpdateAcercamiento(CveAcercamiento, CveContactoPrincipal, CveTipoProceso, CveEtapaProcesoActualActualizar, CveVendedor, CveMedioCaptacion, CveProbabilidadAcercamiento,
|
|
NombreAcercamiento, Descripcion, Importe, Comision, Prioridad, UsuarioActual.CveUsuario, CveEncuestaAplicadaProceso: CveEncuestaAplicadaProceso, FechaApertura: FechaApertura, FechaCierre: FechaCierre, CvePS:DdlPS.SelectedValue.ToEntero()))
|
|
{
|
|
//String MensajeBitacora = (CveEtapaProcesoActualActualizar != CveEtapaActual) ? String.Format("Se actualizó la etapa del acercamiento a {0}.", DTEtapasProceso.FiltroPrimeroValor("EtapaProceso", "CveEtapaProceso = " + CveEtapaProcesoActualActualizar)) : String.Format("Se actualizó el Acercamiento {0} con Vendedor {2} y Contacto Principal {3}.", NombreAcercamiento, DdlTipoProceso.SelectedItem, DdlVendedor.SelectedItem, DdlContactoPrincipal.SelectedValue == "-1" ? "aun no asignado" : DdlContactoPrincipal.SelectedItem.Text);
|
|
|
|
//if (ObjBitacora.AddEventoBitacora(MensajeBitacora, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoProcesoCRM: CveTipoProceso, CveAcercamientoCRM: CveAcercamiento, CveContactoCRM: CveContactoPrincipal, CveEtapaProcesoCRM: CveEtapaProcesoActualActualizar))
|
|
//{
|
|
HuboError = false;
|
|
CveEtapaActual = CveEtapaProcesoActualActualizar;
|
|
HdfEtapaSeleccionada.Value = CveEtapaProcesoActualActualizar.ToString();
|
|
Alert(String.Format("Se actualizó el acercamiento {0} de tipo {1}.", NombreAcercamiento, TipoProceso), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
//}
|
|
}
|
|
|
|
if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
|
|
|
|
ObjCRM.Dispose();
|
|
ObjDatosTecnicos.Dispose();
|
|
|
|
//CARGA BITACORA
|
|
if (!HuboError)
|
|
{
|
|
LblEncabezadoAcercamiento.Text = String.Format("<span class='bold' style='color: #32c5d2;'>{0}:</span> {1}", TipoProceso.ToUpper(), NombreAcercamiento.ToUpper());
|
|
CargaEtapasProceso(CveTipoProceso);
|
|
CargaEtapasBitacora();
|
|
CargaEventoBitacora(CveEtapaProcesoActualActualizar);
|
|
|
|
UpEncabezado.Update();
|
|
UPAcercamiento.Update();
|
|
UPBitacoraEtapas.Update();
|
|
UPBitacora.Update();
|
|
|
|
DdlEtapaProceso.SelectedValueExist(CveEtapaActual);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void GuardarCambioEtapa()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
String NombreAcercamiento = TxtNombreAcercamiento.Text;
|
|
String Descripcion = TxtDescripcion.Text == "" ? "-1" : TxtDescripcion.Text;
|
|
|
|
int CveEtapaProcesoActualActualizar = DdlEtapaProceso.SelectedValue.ToEntero();
|
|
|
|
int CveContactoPrincipal = DdlContactoPrincipal.SelectedValue.ToEntero();
|
|
int CveVendedor = DdlVendedor.SelectedValue.ToEntero();
|
|
int CveMedioCaptacion = DdlMedioCaptacion.SelectedValue.ToEntero();
|
|
int CveProbabilidadAcercamiento = DdlProbabilidadAcercamiento.SelectedValue.ToEntero();
|
|
|
|
DateTime FechaApertura = TxtFechaApertura.Text.ToDateTime();
|
|
DateTime? FechaCierre = null;
|
|
|
|
if (DTEtapasProceso.FiltraParametros(String.Format("CveEtapaProceso = {0} AND CveTipoEtapa IN(3, 4)", CveEtapaProcesoActualActualizar)).Rows.Count > 0)
|
|
{
|
|
FechaCierre = TxtFechaCierre.Text != "" ? TxtFechaCierre.Text.ToDateTime() : DateTime.Now;
|
|
}
|
|
|
|
Double Importe = TxtImporte.Text.ToDouble();
|
|
Double Comision = TxtComision.Text.ToDouble();
|
|
|
|
int Prioridad = DdlPrioridad.SelectedValue.ToEntero();
|
|
|
|
int CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
|
|
if (ObjCRM.UpdateAcercamiento(CveAcercamiento, CveContactoPrincipal, CveTipoProceso, CveEtapaProcesoActualActualizar, CveVendedor, CveMedioCaptacion, CveProbabilidadAcercamiento,
|
|
NombreAcercamiento, Descripcion, Importe, Comision, Prioridad, UsuarioActual.CveUsuario, CveEncuestaAplicadaProceso: CveEncuestaAplicadaProceso, FechaApertura: FechaApertura, FechaCierre: FechaCierre, CvePS: DdlPS.SelectedValue.ToEntero()))
|
|
{
|
|
CveEtapaActual = CveEtapaProcesoActualActualizar;
|
|
HdfEtapaSeleccionada.Value = CveEtapaProcesoActualActualizar.ToString();
|
|
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
|
|
//CARGA BITACORA
|
|
CargaEtapasProceso(CveTipoProceso);
|
|
CargaEtapasBitacora();
|
|
CargaEventoBitacora(CveEtapaProcesoActualActualizar);
|
|
DdlEtapaProceso.SelectedValueExist(CveEtapaProcesoActualActualizar);
|
|
|
|
UPAcercamiento.Update();
|
|
UPBitacoraEtapas.Update();
|
|
UPBitacora.Update();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region "ELIMINAR ACERCAMIENTO"
|
|
protected void BtnEliminarAcercamiento_Click(object sender, EventArgs e)
|
|
{
|
|
EliminarAcercamiento();
|
|
}
|
|
|
|
protected void EliminarAcercamiento()
|
|
{
|
|
Boolean HuboError = true;
|
|
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
ClsOIEventos objBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
|
|
|
|
if (ObjCRM.RemoveAcercamiento(CveAcercamiento, UsuarioActual.CveEmpresa))
|
|
{
|
|
if (objBitacora.AddEventoBitacora(String.Format("Se eliminó el Acercamiento {0} de tipo {1}", NombreAcercamiento, TipoProceso), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
|
|
{
|
|
HuboError = false;
|
|
}
|
|
}
|
|
if (!HuboError)
|
|
{
|
|
ObjCRM.Commit();
|
|
Alert("El Acercamiento ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion, String.Format("document.location.href=\"/CRM/EmpresaCRM.aspx?CveEmpresaCRM={0}\"", CveEmpresaCRM));
|
|
}
|
|
else
|
|
{
|
|
ObjCRM.RollBack();
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
objBitacora.Dispose();
|
|
}
|
|
#endregion
|
|
|
|
#region "FINALIZACION DE ACERCAMIENTO"
|
|
protected void ActivaOpcionCierreCancelacion()
|
|
{
|
|
// ACTIVAMOS OPCION CIERRE POR CANCELACION SI SE CREO ESTA ETAPA EN EL PROCESO
|
|
if (DTEtapasProceso.FiltraParametros("CveTipoEtapa = 4").Rows.Count > 0)
|
|
{
|
|
String TituloCierre = DTEtapasProceso.FiltroPrimeroValor("EtapaProceso", "CveTipoEtapa = 4");
|
|
|
|
LnkCerrarAcercamiento.Visible = true;
|
|
SpanTituloCierre.InnerText = TituloCierre;
|
|
}
|
|
else
|
|
{
|
|
LnkCerrarAcercamiento.Visible = false;
|
|
}
|
|
|
|
//UpAcciones.Update();
|
|
}
|
|
|
|
protected Boolean ActivaFechaCierre(int CveEtapaProceso)
|
|
{
|
|
Boolean activar = DTEtapasProceso.FiltraParametros(String.Format("CveEtapaProceso = {0} AND CveTipoEtapa = 3", CveEtapaProceso)).Rows.Count > 0;
|
|
if (activar)
|
|
{
|
|
TxtFechaCierre.Enabled = true;
|
|
CETxtFechaCierre.EnabledOnClient = true;
|
|
}
|
|
else
|
|
{
|
|
TxtFechaCierre.Enabled = false;
|
|
CETxtFechaCierre.EnabledOnClient = false;
|
|
}
|
|
return activar;
|
|
}
|
|
|
|
protected void LnkCerrarAcercamiento_Click(object sender, EventArgs e)
|
|
{
|
|
String TituloCierre = DTEtapasProceso.FiltroPrimeroValor("EtapaProceso", "CveTipoEtapa = 4");
|
|
int CveEtapaCierre = DTEtapasProceso.FiltroPrimeroValor("CveEtapaProceso", String.Format("CveTipoEtapa = 4", CveEtapaActual)).ToEntero();
|
|
|
|
if (CveEtapaCierre != CveEtapaActual)
|
|
{
|
|
TituloModalCierreMotivoRechazo.InnerText = String.Format("Registro de {0}", TituloCierre);
|
|
BtnRegistrarCierreCancelacion.Text = "Guardar";
|
|
}
|
|
else
|
|
{
|
|
TituloModalCierreMotivoRechazo.InnerText = String.Format("Editar {0}", TituloCierre);
|
|
BtnRegistrarCierreCancelacion.Text = "Actualizar";
|
|
}
|
|
|
|
this.RegistraScript("$('#ModalCierreMotivoRechazo').modal();");
|
|
UpCierreMotivoRechazo.Update();
|
|
}
|
|
|
|
protected void BtnRegistrarCierreCancelacion_Click(object sender, EventArgs e)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
//ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
|
|
|
|
//Boolean HuboError = true;
|
|
int CveEtapaCierre = DTEtapasProceso.FiltroPrimeroValor("CveEtapaProceso", "CveTipoEtapa = 4").ToEntero();
|
|
int CveRechazoMotivo = DdlRechazoMotivo.SelectedValue.ToEntero();
|
|
DateTime FechaCierre = TxtFechaCierreRechazo.Text.ToDateTime();
|
|
string Observacion = TxtObservacionRechazo.Text;
|
|
|
|
String TituloCierre = DTEtapasProceso.FiltroPrimeroValor("EtapaProceso", "CveTipoEtapa = 4");
|
|
|
|
if (ObjCRM.UpdateAcercamientoCierre(CveAcercamiento, CveEtapaCierre, CveRechazoMotivo, UsuarioActual.CveUsuario, FechaCierre, Observacion))
|
|
{
|
|
String MensajeBitacora = "";
|
|
if (CveEtapaActual == CveEtapaCierre)
|
|
MensajeBitacora = String.Format("Se actualizó el cierre del acercamiento, con motivo {1} y fecha de {0} al {2}.", TituloCierre, DdlRechazoMotivo.SelectedItem.Text, TxtFechaCierreRechazo.Text);
|
|
else
|
|
MensajeBitacora = String.Format("Se Cerró el acercamiento, con motivo {1} y fecha de {0} al {2}.", TituloCierre, DdlRechazoMotivo.SelectedItem.Text, TxtFechaCierreRechazo.Text);
|
|
|
|
//if (ObjBitacora.AddEventoBitacora(MensajeBitacora, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoProcesoCRM: CveTipoProceso, CveAcercamientoCRM: CveAcercamiento, CveEtapaProcesoCRM: CveEtapaCierre))
|
|
//{
|
|
//HuboError = false;
|
|
Alert(MensajeBitacora, ModExtensiones.TipoMensaje.MsgInformacion);
|
|
//}
|
|
}
|
|
|
|
//if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
|
|
|
|
ObjCRM.Dispose();
|
|
//ObjBitacora.Dispose();
|
|
|
|
CveEtapaActual = CveEtapaCierre;
|
|
|
|
CargaDatos();
|
|
CargaEtapasBitacora();
|
|
|
|
this.RegistraScript("$('#ModalCierreMotivoRechazo').modal('hide');");
|
|
}
|
|
#endregion
|
|
|
|
#region "STEPS - ETAPAS DE PROCESO PARA BITACORA "
|
|
protected void CargaEtapasBitacora()
|
|
{
|
|
//CARGA STEP DE PASOS
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if (ObjCRM.GetEtapaProceso(UsuarioActual.CveEmpresa, CveTipoProceso, CveEstatus: 1))
|
|
{
|
|
TipoProceso = ObjCRM.DtResultados.FiltroPrimeroValor("TipoProceso").ToUpper();
|
|
int CveEtapaCierreCancelacion = DTEtapasProceso.FiltroPrimeroValor("CveEtapaProceso", "CveTipoEtapa = 4").ToEntero();
|
|
|
|
NumeroEtapasProceso = ObjCRM.DtResultados.FiltraParametros("CveTipoEtapa IN(1,2,3)").Rows.Count;
|
|
//RptTabsEtapasProcesos.DataSource = ObjCRM.DtResultados.FiltraParametros("CveTipoEtapa IN(1,2,3)");
|
|
|
|
if (CveEtapaCierreCancelacion == CveEtapaActual)
|
|
RptStepsEtapasProceso.DataSource = ObjCRM.DtResultados.FiltraParametros("CveTipoEtapa IN(1,2,4)");
|
|
else
|
|
RptStepsEtapasProceso.DataSource = ObjCRM.DtResultados.FiltraParametros("CveTipoEtapa IN(1,2,3)");
|
|
|
|
}
|
|
ObjCRM.Dispose();
|
|
//RptTabsEtapasProcesos.DataBind();
|
|
RptStepsEtapasProceso.DataBind();
|
|
//SpanProceso.InnerText = TipoProceso + ":";
|
|
}
|
|
|
|
protected void RptStepsEtapasProceso_ItemDataBound(object sender, RepeaterItemEventArgs e)
|
|
{
|
|
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
|
|
{
|
|
|
|
DataRowView row = (DataRowView)e.Item.DataItem;
|
|
|
|
//VALIDACION DE CLASES DE COMPONENTE DIVETAPARPT
|
|
|
|
//- CLASES OBLIGATORIAS: col-md-n, mt-step-col , SIENDO N EL NUMERO DE ETAPAS.
|
|
// MAS DE 6 ETAPAS NO SE RECOMIENDA POR ESTETICA PERO ES FUNCIONAL.MAS DE 12 DISTORCIONAN LA DISTRUBUCION DEL COMPONENTE,
|
|
//- CLASES OPCIONALES APARIENCIA Y COMPORTAMIENTO DEL STEP: first, last, error, done, active, enabled, disabled, active, etapaactual
|
|
|
|
//ASIGNACION CLASES OBLIGATORIAS
|
|
String DivStepClases = String.Format("col-md-{0} mt-step-col", (12 / NumeroEtapasProceso) == 0 ? 1 : (12 / NumeroEtapasProceso));
|
|
|
|
// CALCULO DE ESPACIOS PARA CENTRADO
|
|
if (NumeroEtapasProceso.Contiene(5, 9, 10) && row["CveTipoEtapa"].ToEntero() == 1)
|
|
DivStepClases += " col-md-offset-1";
|
|
else if (NumeroEtapasProceso.Contiene(7, 8) && row["CveTipoEtapa"].ToEntero() == 1)
|
|
DivStepClases += " col-md-offset-2";
|
|
|
|
|
|
//VERIFICA SI ES ETAPA DE TIPO INICIAL o CIERRE
|
|
if (row["CveTipoEtapa"].ToEntero() == 1)
|
|
{
|
|
DivStepClases += " first";
|
|
}
|
|
else if (row["CveTipoEtapa"].ToEntero().Contiene(3, 4))
|
|
{
|
|
DivStepClases += " last";
|
|
//VERIFICA SI ES ETAPA DE TIPO CIERRE CANCELADO
|
|
if (row["CveTipoEtapa"].ToEntero() == 4)
|
|
DivStepClases += " error";
|
|
}
|
|
|
|
//VERIFICA SI ES UNA ETAPA YA REALIZADA
|
|
if (OrdenEtapaActual > row["Orden"].ToEntero())
|
|
DivStepClases += " done";
|
|
|
|
//VERIFICA EL ORDEN DE LA ETAPA PARA PERMITIR SU SELECCION
|
|
if (OrdenEtapaActual < row["Orden"].ToEntero())
|
|
DivStepClases += " disabled";
|
|
else
|
|
DivStepClases += " enabled";
|
|
|
|
//ESTABLE SI LA ETAPA ACTUAL ES LA SELECCIONADA
|
|
if (HdfEtapaSeleccionada.Value.ToEntero() == row["CveEtapaProceso"].ToEntero())
|
|
DivStepClases += " active";
|
|
|
|
//PINTA LA ETAPA SI ES LA ETAPA ACTUAL
|
|
if (CveEtapaActual == row["CveEtapaProceso"].ToEntero())
|
|
DivStepClases += " etapaactual";
|
|
|
|
//SE LE ASIGNAN LAS CLASES AL DIV DIVETAPARPT
|
|
((HtmlGenericControl)(e.Item.FindControl("DivEtapaRpt"))).Attributes["class"] += DivStepClases;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region "BITACORA - ARCHIVOS"
|
|
protected void BtnCambiaEtapaBitacora_Click(object sender, EventArgs e)
|
|
{
|
|
GVEventoBitacora.Columns[0].Visible = false;
|
|
CargaEventoBitacora(HdfEtapaSeleccionada.Value.ToEntero());
|
|
}
|
|
|
|
protected void LbtVerBitacoraCompleta_Click(object sender, EventArgs e)
|
|
{
|
|
GVEventoBitacora.Columns[0].Visible = true;
|
|
CargaEventoBitacora(-1);
|
|
HdfEtapaSeleccionada.Value = "-1";
|
|
CargaEtapasBitacora();
|
|
|
|
UPBitacoraEtapas.Update();
|
|
UPBitacora.Update();
|
|
}
|
|
|
|
private void CargaEventoBitacora(int CveEtapa)
|
|
{
|
|
ClsOIEventos ObjEventoBitacora = new ClsOIEventos();
|
|
|
|
string EtapaSeleccionada = CveEtapa > 0 ? DTEtapasProceso.FiltroPrimeroValor("EtapaProceso", "CveEtapaProceso = " + CveEtapa) : "";
|
|
TituloBitacora.InnerText = String.Format("Bitacora {0}", (CveEtapa > 0 ? (String.Format(" ({0})", EtapaSeleccionada)) : ""));
|
|
|
|
if (ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveAcercamientoCRM: CveAcercamiento))
|
|
{
|
|
DTEventosBitacora = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2");
|
|
if (CveEtapa == -1)
|
|
{
|
|
GVEventoBitacora.DataSource = DTEventosBitacora.FiltraParametros(String.Format("Archivo = '' OR Archivo IS NULL", CveEtapa));
|
|
RptArchivosBitacora.DataSource = DTEventosBitacora.FiltraParametros(String.Format("Archivo <> ''", CveEtapa));
|
|
}
|
|
else
|
|
{
|
|
GVEventoBitacora.DataSource = DTEventosBitacora.FiltraParametros(String.Format("CveEtapaProcesoCRM = {0} AND ( Archivo = '' OR Archivo IS NULL)", CveEtapa));
|
|
RptArchivosBitacora.DataSource = DTEventosBitacora.FiltraParametros(String.Format("CveEtapaProcesoCRM = {0} AND Archivo <> ''", CveEtapa));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GVEventoBitacora.DataSource = null;
|
|
}
|
|
|
|
ObjEventoBitacora.Dispose();
|
|
|
|
GVEventoBitacora.DataBind();
|
|
RptArchivosBitacora.DataBind();
|
|
}
|
|
|
|
protected void GVEventoBitacora_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.RowIndex == 0)
|
|
{
|
|
e.Row.Cells[1].Width = Unit.Pixel(150);
|
|
e.Row.Cells[2].Width = Unit.Pixel(150);
|
|
}
|
|
|
|
if (e.Row.DataKey("CveEtapaProcesoCRM").ToString().ToEntero() > 0)
|
|
{
|
|
e.Row.FCLabel("LblEtapa").Text = DTEtapasProceso.FiltroPrimeroValor("EtapaProceso", String.Format("CveEtapaProceso = {0}", e.Row.DataKey("CveEtapaProcesoCRM")));
|
|
}
|
|
|
|
if ((e.Row.DataKey("PosicionGPS").ToString() != ""))
|
|
{
|
|
e.Row.FCLinkButton("LnkVerUbicacion").Visible = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void DownloadFile(object sender, EventArgs e)
|
|
{
|
|
string filePath = string.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ((LinkButton)sender).CommandArgument);
|
|
System.IO.FileInfo Archivo = new System.IO.FileInfo(filePath);
|
|
|
|
HttpContext.Current.Response.Clear();
|
|
HttpContext.Current.Response.ClearContent();
|
|
HttpContext.Current.Response.ContentType = "application/octet-stream";
|
|
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath));
|
|
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString());
|
|
HttpContext.Current.Response.TransmitFile(filePath);
|
|
HttpContext.Current.Response.Flush();
|
|
HttpContext.Current.Response.End();
|
|
|
|
Archivo = null;
|
|
}
|
|
|
|
protected void EliminarFile(object sender, EventArgs e)
|
|
{
|
|
string cveEvento = string.Format("{0}",((LinkButton)sender).CommandArgument);
|
|
ClsOIEventos ObjEventoBitacora = new ClsOIEventos();
|
|
ObjEventoBitacora.RemoveAgendaBitacora( cveEvento.ToEntero(), UsuarioActual.CveEmpresa);
|
|
ObjEventoBitacora.Dispose();
|
|
UPAddEventoBitacora.Update();
|
|
|
|
//RECARGAMOS GRID BITACORA
|
|
CargaEventoBitacora(HdfEtapaSeleccionada.Value.ToEntero());
|
|
UPBitacora.Update();
|
|
}
|
|
|
|
protected void BtnGuardarEventoBitacora_Click(object sender, EventArgs e)
|
|
{
|
|
ClsOIEventos ObjEventoBitacora = new ClsOIEventos();
|
|
|
|
string FileExtension = "-1";
|
|
List<Archivo> filesgral = Anexo.getfiles().Archivos;
|
|
string filemove = "";
|
|
|
|
int CveEtapa = HdfEtapaSeleccionada.Value.ToEntero() == -1 ? CveEtapaActual : HdfEtapaSeleccionada.Value.ToEntero();
|
|
|
|
foreach (Archivo fileItem in filesgral)
|
|
{
|
|
FileExtension = System.IO.Path.GetExtension(string.Format(@"{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "");
|
|
filemove = fileItem.filename;
|
|
}
|
|
|
|
if (ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim(), string.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoProcesoCRM: CveTipoProceso, CveAcercamientoCRM: CveAcercamiento, CveEtapaProcesoCRM: CveEtapa))
|
|
{
|
|
if (filemove != "")
|
|
filemove.FilesMove(string.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString()), string.Format(@"Empresas\{0}\OI", UsuarioActual.CveEmpresa));
|
|
|
|
|
|
TxtEventoDescripcion.Text = "";
|
|
Anexo.Text = "[]";
|
|
|
|
RegistraScript("$('#ModalBitacora').modal('hide')");
|
|
Alert("La bitácora/observación se guardó correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
ObjEventoBitacora.Dispose();
|
|
UPAddEventoBitacora.Update();
|
|
|
|
//RECARGAMOS GRID BITACORA
|
|
CargaEventoBitacora(HdfEtapaSeleccionada.Value.ToEntero());
|
|
UPBitacora.Update();
|
|
}
|
|
|
|
protected void BtnGuardarAgenda_Click(object sender, EventArgs e)
|
|
{
|
|
ClsOIEventos ObjEventos = new ClsOIEventos();
|
|
DateTime FechaInicio = TxtFechaInicioAgenda.Text.ToDateTime();
|
|
int CveContactoAgendar = DdlContactoAgenda.SelectedValue.ToEntero();
|
|
int CveEmpresaCRM = DdlEmpresaCRM.SelectedValue.ToEntero();
|
|
int CveEtapa = HdfEtapaSeleccionada.Value.ToEntero() == -1 ? CveEtapaActual : HdfEtapaSeleccionada.Value.ToEntero();
|
|
|
|
if (ObjEventos.AddEventoAgenda(DdlTipoAgenda.SelectedValue.ToEntero(), TxtAsuntoAgenda.Text, TxtDescripcionAgenda.Text, DdlPrioridadAgenda.SelectedValue.ToEntero(), FechaInicio, FechaInicio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoProcesoCRM: CveTipoProceso, CveAcercamientoCRM: CveAcercamiento, CveContactoCRM: CveContactoAgendar, CveEtapaProcesoCRM: CveEtapa, CveEmpresaCRM:CveEmpresaCRM))
|
|
{
|
|
limpiarModalAgendar();
|
|
RegistraScript("$('#ModalAgenda').modal('hide')");
|
|
Alert("El Evento se agendó correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
|
|
}
|
|
ObjEventos.Dispose();
|
|
|
|
//RECARGAMOS GRID BITACORA
|
|
CargaEventoBitacora(HdfEtapaSeleccionada.Value.ToEntero());
|
|
UPBitacora.Update();
|
|
}
|
|
|
|
protected void limpiarModalAgendar()
|
|
{
|
|
DdlTipoAgenda.SelectedValueExist("1");
|
|
DdlPrioridadAgenda.SelectedValueExist("1");
|
|
TxtAsuntoAgenda.Text = "";
|
|
TxtDescripcionAgenda.Text = "";
|
|
TxtFechaInicioAgenda.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm");
|
|
|
|
UpModalAgenda.Update();
|
|
}
|
|
|
|
protected void RptArchivosBitacora_ItemDataBound(object sender, RepeaterItemEventArgs e)
|
|
{
|
|
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
|
|
{
|
|
DataRowView row = (DataRowView)e.Item.DataItem;
|
|
|
|
if (row["Archivo"].ToString() != "")
|
|
{
|
|
e.Item.FindControl("LinkArchivo").Visible = true;
|
|
((LinkButton)e.Item.FindControl("LinkArchivo")).CommandArgument = string.Format(@"OI\{0}", row["Archivo"].ToString());
|
|
ScriptManager.GetCurrent(this).RegisterPostBackControl(e.Item.FindControl("LinkArchivo")); // Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione
|
|
|
|
((Label)e.Item.FindControl("LblTipoArchivo")).Text = row["Archivo"].ToString().Split('.')[1].ToUpper();
|
|
|
|
((LinkButton)e.Item.FindControl("LinkDelete")).CommandArgument = row["CveEvento"].ToString();
|
|
|
|
}
|
|
}
|
|
|
|
// VALIDAMOS PARA MOSTRAR EL FOOTER CON EL TEXT DE DATOS NO ENCONTRADOS
|
|
Repeater rptDemo = sender as Repeater;
|
|
|
|
if (RptArchivosBitacora != null && RptArchivosBitacora.Items.Count < 1)
|
|
{
|
|
if (e.Item.ItemType == ListItemType.Footer)
|
|
{
|
|
Label LblEmptyRpt = e.Item.FindControl("LblEmptyRpt") as Label;
|
|
if (LblEmptyRpt != null)
|
|
{
|
|
e.Item.FindControl("DivRptArchivoBitacoraEmpty").Visible = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region "PERMISOS"
|
|
protected void VerificaPermisosEdicion()
|
|
{
|
|
if (!UsuarioActual.TienePermisoProceso(252))
|
|
{
|
|
BtnEliminarAcercamiento.Visible = false;
|
|
}
|
|
|
|
//SOLO VENDEDOR ASIGNADO PUEDE EDITAR
|
|
if (CveVendedorAsignado != UsuarioActual.CveVendedor)
|
|
{
|
|
BtnGuardarAcercamiento.Visible = false;
|
|
BtnEliminarAcercamiento.Visible = false;
|
|
|
|
DivAccionesBitacoraActividades.Visible = false;
|
|
DivAccionesBitacoraArchivos.Visible = false;
|
|
|
|
LnkCerrarAcercamiento.Visible = false;
|
|
|
|
HplAgregarCotizacion.Visible = false;
|
|
UpAddCotizacion.Update();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region "TAB DATOS TECNICOS"
|
|
protected void CargaDatosTecnicos()
|
|
{
|
|
ClsEncuestas objEncuesta = new ClsEncuestas();
|
|
|
|
if (objEncuesta.GetRespuestas(CveEncuestaProcesoCRM))
|
|
DTRespuestasDatosTecnicos = objEncuesta.DtResultados;
|
|
|
|
if (objEncuesta.GetDatosTecnicosEmpresaCRM(CveEncuestaProcesoCRM, CveEncuestaAplicadaProceso, UsuarioActual.Empresa.CveEmpresa))
|
|
{
|
|
GvDatosTecnicos.DataSource = objEncuesta.DtResultados;
|
|
if (objEncuesta.DtResultados.Rows.Count > 0)
|
|
{
|
|
//BtnModalReferenciasVerificar.Visible = true;
|
|
GvDatosTecnicos.Visible = true;
|
|
}
|
|
}
|
|
|
|
//UpModalReferenciasBtn.Update();
|
|
objEncuesta.Dispose();
|
|
|
|
GvDatosTecnicos.DataBind();
|
|
UpDatosTecnicos.Update();
|
|
}
|
|
|
|
protected void GvDatosTecnicos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
int EsOpcion = e.Row.DBCampo("CveTipoPregunta").ToEntero();
|
|
int CvePregunta = e.Row.DBCampo("CvePregunta").ToEntero();
|
|
|
|
DataTable dt = DTRespuestasDatosTecnicos.FiltraParametros(string.Format(" CvePregunta = {0} ", CvePregunta));
|
|
// e.Row.FCFilteredTextBoxExtender("filTxtResPuestaReferencias").Enabled = False
|
|
|
|
switch (EsOpcion)
|
|
{
|
|
case 1: // Texto Simple
|
|
{
|
|
var withBlock = e.Row.FindControl("DivTxtRespuestaDinamica");
|
|
withBlock.Visible = true;
|
|
|
|
e.Row.FCTextBox("TxtRespuestaDinamica").Text = e.Row.DataKey("Valor").ToString();
|
|
|
|
break;
|
|
}
|
|
|
|
case 2: //Radiobuttons
|
|
{
|
|
var DivwithBlock = e.Row.FindControl("DivRdlRespuestaDinamica");
|
|
DivwithBlock.Visible = true;
|
|
|
|
var withBlock = e.Row.FCRadioButtonList("RdlRespuestaDinamica");
|
|
withBlock.Visible = true;
|
|
withBlock.DataSource = dt;
|
|
withBlock.DataBind();
|
|
|
|
|
|
if (e.Row.FCRadioButtonList("RdlRespuestaDinamica").Items.Count > 0)
|
|
{
|
|
e.Row.FCRadioButtonList("RdlRespuestaDinamica").SelectedIndex = 0;
|
|
}
|
|
|
|
if (e.Row.DataKey("Valor").ToString() != "")
|
|
{
|
|
e.Row.FCRadioButtonList("RdlRespuestaDinamica").SelectedValue = e.Row.FCRadioButtonList("RdlRespuestaDinamica").Items.FindByText(e.Row.DataKey("Valor").ToString()).Value;
|
|
}
|
|
|
|
//e.Row.FCRequiredFieldValidator("RFVRdlRespuestaDinamica").ErrorMessage = string.Format("<i><span style='color: darkred;'>Campo requerido</span></i>");
|
|
break;
|
|
}
|
|
case 3: // DropDownList
|
|
{
|
|
var DivwithBlock = e.Row.FindControl("DivDdlRespuestaDinamica");
|
|
DivwithBlock.Visible = true;
|
|
|
|
var withBlock = e.Row.FCDropDownList("DdlRespuestaDinamica");
|
|
|
|
withBlock.DataSource = dt;
|
|
withBlock.DataBind();
|
|
withBlock.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
|
|
e.Row.FCDropDownList("DdlRespuestaDinamica").SelectedValueExist(e.Row.DataKey("CveRespuesta"));
|
|
break;
|
|
}
|
|
case 4: // Checks SI/NO
|
|
{
|
|
var DivwithBlock = e.Row.FindControl("DivChkRespuestaDinamica");
|
|
DivwithBlock.Visible = true;
|
|
|
|
var withBlock = e.Row.FCCheckBox("ChkRespuestaDinamica");
|
|
withBlock.Visible = true;
|
|
|
|
if (e.Row.DataKey("Valor").ToString() == "")
|
|
e.Row.FCCheckBox("ChkRespuestaDinamica").Checked = e.Row.DataKey("RespuestaDefault").ToString() == "1" ? true : false;
|
|
else
|
|
e.Row.FCCheckBox("ChkRespuestaDinamica").Checked = e.Row.DataKey("Valor").ToString() == "Si" ? true : false;
|
|
|
|
break;
|
|
}
|
|
|
|
case 5: // numerico
|
|
{
|
|
var DivwithBlock = e.Row.FindControl("DivTxtRespuestaDinamica");
|
|
DivwithBlock.Visible = true;
|
|
|
|
var withBlock = e.Row.FCTextBox("TxtRespuestaDinamica");
|
|
withBlock.Attributes.Add("onkeypress", "validate(event)");
|
|
|
|
e.Row.FCTextBox("TxtRespuestaDinamica").Text = e.Row.DataKey("Valor");
|
|
break;
|
|
}
|
|
case 6: // Multiline
|
|
{
|
|
var withBlock = e.Row.FindControl("DivTxtRespuestaDinamicaMultilinea");
|
|
withBlock.Visible = true;
|
|
|
|
e.Row.FCTextBox("TxtRespuestaDinamicaMultilinea").Text = e.Row.DataKey("Valor").ToString();
|
|
|
|
break;
|
|
}
|
|
case 7: // fecha
|
|
{
|
|
var withBlock = e.Row.FindControl("DivFechaDinamica");
|
|
withBlock.Visible = true;
|
|
|
|
e.Row.FCTextBox("TxtRespuestaFechaDinamica").Text = e.Row.DataKey("Valor");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected int GuardaDatosTecnicos(ClsEncuestas ObjDatosTecnicos, int CveEncuestaAplicada = -1)
|
|
{
|
|
int _CveEncuestaAplicada = CveEncuestaAplicada;
|
|
int CveRespuesta = -1;
|
|
string Respuesta = "-1";
|
|
int CveEncuestaAplicadaDetalle = -1;
|
|
Boolean ExisteRegistro = true;
|
|
DataTable dtRespuesta;
|
|
|
|
//NUEVA CAPTURA DE DATOS TECNICOS
|
|
if (_CveEncuestaAplicada == -1)
|
|
{
|
|
if (ObjDatosTecnicos.AddEncuestaAplicada(CveEncuestaProcesoCRM, -1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
_CveEncuestaAplicada = ObjDatosTecnicos.DtResultados.Rows[0][0].ToEntero();
|
|
}
|
|
}
|
|
|
|
foreach (GridViewRow drow in GvDatosTecnicos.Rows)
|
|
{
|
|
int EsOpcion = drow.DataKey("CveTipoPregunta").ToEntero();
|
|
int CvePregunta = drow.DataKey("CvePregunta").ToEntero();
|
|
|
|
CveEncuestaAplicadaDetalle = drow.DataKey("CveEncuestaAplicadaDetalle").ToEntero();
|
|
|
|
ExisteRegistro = CveEncuestaAplicadaDetalle > 0;
|
|
|
|
CveRespuesta = -1;
|
|
Respuesta = "-1";
|
|
|
|
dtRespuesta = DTRespuestasDatosTecnicos.FiltraParametros(string.Format(" CvePregunta = {0} ", CvePregunta));
|
|
|
|
switch (EsOpcion)
|
|
{
|
|
case 1: // TEXTO - RESPUESTA BIERTA
|
|
{
|
|
if (dtRespuesta.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dtRespuesta.FiltroPrimeroValor("CveRespuesta").ToString().ToEntero();
|
|
|
|
Respuesta = drow.FCTextBox("TxtRespuestaDinamica").Text;
|
|
break;
|
|
}
|
|
case 2: // RADIO BUTTON - OPCION MULTIPLE
|
|
{
|
|
CveRespuesta = drow.FCRadioButtonList("RdlRespuestaDinamica").SelectedValue.ToEntero();
|
|
Respuesta = drow.FCRadioButtonList("RdlRespuestaDinamica").SelectedItem.Text;
|
|
break;
|
|
}
|
|
case 3: // DDL - SELECCION
|
|
{
|
|
CveRespuesta = drow.FCDropDownList("DdlRespuestaDinamica").SelectedValue.ToEntero();
|
|
Respuesta = drow.FCDropDownList("DdlRespuestaDinamica").SelectedItem.Text;
|
|
break;
|
|
}
|
|
case 4: // CHECKBOX - SI / NO
|
|
{
|
|
Respuesta = drow.FCCheckBox("ChkRespuestaDinamica").Checked ? "Si" : "No";
|
|
CveRespuesta = -1;
|
|
break;
|
|
}
|
|
|
|
case 5: // TEXTBOX - NUMERO
|
|
{
|
|
Respuesta = drow.FCTextBox("TxtRespuestaDinamica").Text;
|
|
break;
|
|
}
|
|
case 6: // MULTILINE - RESPUESTA BIERTA
|
|
{
|
|
if (dtRespuesta.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dtRespuesta.FiltroPrimeroValor("CveRespuesta").ToString().ToEntero();
|
|
|
|
Respuesta = drow.FCTextBox("TxtRespuestaDinamicaMultilinea").Text;
|
|
break;
|
|
}
|
|
case 7: // FECHA
|
|
{
|
|
if (dtRespuesta.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dtRespuesta.FiltroPrimeroValor("CveRespuesta").ToString().ToEntero();
|
|
|
|
Respuesta = drow.FCTextBox("TxtRespuestaFechaDinamica").Text;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//ACTUALIZAMOS LOS DATOS TECNICOS
|
|
if (ExisteRegistro && !(ObjDatosTecnicos.UpdateDatosTecnicosCRM(CveEncuestaAplicadaDetalle, CveEncuestaAplicada, CvePregunta, CveRespuesta, Respuesta)))
|
|
{
|
|
//SI HAY ERROR REGRESA 0
|
|
_CveEncuestaAplicada = 0;
|
|
}
|
|
else if (!ExisteRegistro && !(ObjDatosTecnicos.AddEncuestaAplicadaDetalle(_CveEncuestaAplicada, CvePregunta, CveRespuesta, Respuesta)))
|
|
{
|
|
//SI HAY ERROR REGRESA 0
|
|
_CveEncuestaAplicada = 0;
|
|
}
|
|
dtRespuesta.Dispose();
|
|
}
|
|
// SI REGRESA _CveEncuestaAplicada = 0 HUBO ERROR
|
|
return _CveEncuestaAplicada;
|
|
}
|
|
#endregion
|
|
|
|
#region "MUESTRA UBICACION GEOGRAFICA"
|
|
protected void LnkVerUbicacion_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
string Lat = GvRow.DataKey("Lat");
|
|
string Long = GvRow.DataKey("Long");
|
|
this.RegistraScript(String.Format("initMap(); CreaMarcador({0}, {1}, '{2}', '{3}'); $('#ModalVerUbicacion').modal();", Lat, Long, "0", "Info"));
|
|
}
|
|
#endregion
|
|
|
|
#region "TAB IMAGENES"
|
|
protected void CargaImagenes()
|
|
{
|
|
var ObjCRM = new ClsCRM();
|
|
if (ObjCRM.GetImagenesAcercamiento(CveAcercamiento))
|
|
{
|
|
RptFotos.DataSource = ObjCRM.DtResultados;
|
|
}
|
|
ObjCRM.Dispose();
|
|
RptFotos.DataBind();
|
|
}
|
|
|
|
protected void BtnUpFotos_Click(object sender, EventArgs e)
|
|
{
|
|
bool TieneError = false;
|
|
var ObjCRM = new ClsCRM();
|
|
ObjCRM.IniciaTransacSQL();
|
|
try
|
|
{
|
|
foreach (var item in TxtUpFotos.getfiles().Archivos)
|
|
{
|
|
var FileExtension = "";
|
|
if (!string.IsNullOrEmpty(item.filename))
|
|
{
|
|
FileExtension = System.IO.Path.GetExtension(item.filename);
|
|
}
|
|
if (string.IsNullOrEmpty(FileExtension))
|
|
{
|
|
TieneError = true;
|
|
break;
|
|
}
|
|
|
|
int CveArchivo = ObjCRM.AddImagenAcercamiento("", TxtTituloImagen.Text, TxtDescripcionImagen.Text, UsuarioActual.CveUsuario, CveEmpresaCRM, CveAcercamiento, UsuarioActual.CveEmpresa);
|
|
if ((CveArchivo > 0))
|
|
{
|
|
string NombreNuevo = string.Format("{0}{1}", CveArchivo, FileExtension);
|
|
string DirectorioNuevo = string.Format("{0}Acercamientos\\{1}\\Imagenes\\", UsuarioActual.Empresa.Ruta, CveAcercamiento);
|
|
if (!Directory.Exists(DirectorioNuevo))
|
|
{
|
|
Directory.CreateDirectory(DirectorioNuevo);
|
|
}
|
|
DirectorioNuevo = DirectorioNuevo + NombreNuevo;
|
|
var DirectorioViejo = string.Format("{0}Temp\\{1}", AppDomain.CurrentDomain.BaseDirectory, item.filename);
|
|
|
|
if (ObjCRM.UpdateImagenAcercamiento(CveArchivo, NombreNuevo, TxtTituloImagen.Text, TxtDescripcionImagen.Text))
|
|
{
|
|
File.Move(DirectorioViejo, DirectorioNuevo);
|
|
}
|
|
else
|
|
{
|
|
TieneError = true;
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TieneError = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.OnError("Ocurrió un error al agregar una imagen", ex);
|
|
TieneError = true;
|
|
}
|
|
finally
|
|
{
|
|
if (TieneError)
|
|
{
|
|
ObjCRM.RollBack();
|
|
Alert("El archivo el eliminó correctamente.", ModExtensiones.TipoMensaje.MsgError);
|
|
}
|
|
else
|
|
{
|
|
ObjCRM.Commit();
|
|
Alert("El archivo se agregó correctamente");
|
|
}
|
|
ObjCRM.Dispose();
|
|
|
|
CargaImagenes();
|
|
UpGaleria.Update();
|
|
RegistraScript("$('#Modalupfotos').modal('hide');clickgaleria();");
|
|
}
|
|
}
|
|
|
|
protected void BtnEliminarFoto_Click(object sender, EventArgs e)
|
|
{
|
|
int CveArchivo = (sender as Button).CommandArgument.ToEntero();
|
|
if (CveArchivo > 0)
|
|
{
|
|
var ObjCRM = new ClsCRM();
|
|
bool Elimino = ObjCRM.RemoveImagenesAcercamiento(CveArchivo);
|
|
ObjCRM.Dispose();
|
|
|
|
if (Elimino)
|
|
{
|
|
Alert("El archivo se eliminó correctamente.");
|
|
CargaImagenes();
|
|
UpGaleria.Update();
|
|
RegistraScript("clickgaleria();");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region "TAB COTIZACIONES"
|
|
protected void CargaCotizaciones()
|
|
{
|
|
ClsVentas ObjVentas = new ClsVentas();
|
|
if (ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "Cot", "-1", -1, "-1", -1, -1, -1, -1, "-1", "-1", "-1", CveEmpresaCRM: CveEmpresaCRM, CveAcercamientoCRM: CveAcercamiento, CveUsuarioConsulta: UsuarioActual.CveUsuario))
|
|
{
|
|
GvCotizacion.DataSource = ObjVentas.DtResultados;
|
|
}
|
|
ObjVentas.Dispose();
|
|
GvCotizacion.DataBind();
|
|
UpCotizacion.Update();
|
|
|
|
HplAgregarCotizacion.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveEmpresaCRM={0}&CveAcercamientoCRM={1}&Op=Cot", CveEmpresaCRM, CveAcercamiento);
|
|
}
|
|
|
|
protected void GvCotizacion_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DataKey("CveEstatusFactura").ToEntero() > 0)
|
|
{
|
|
e.Row.FCLabel("lblEstatus").Text = String.Format("<b>{0}</b>", e.Row.DataKey("EstatusFactura"));
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region "TAB GASTOS"
|
|
protected void CargaGastos()
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
if (ObjCRM.GetAcercamientosGastos(CveAcercamiento))
|
|
{
|
|
GvGastos.DataSource = ObjCRM.DtResultados;
|
|
}
|
|
ObjCRM.Dispose();
|
|
GvGastos.DataBind();
|
|
UpGastos.Update();
|
|
}
|
|
|
|
protected void LbAddGastos_Click(object sender, EventArgs e)
|
|
{
|
|
LtlTituloModalGasto.Text = "Agregar Gasto";
|
|
BtnAgregarGastoModal.Text = "Agregar";
|
|
|
|
UpModalGastos.Update();
|
|
|
|
TxtDescripcionGasto.Text = "";
|
|
TxtImporteGasto.Text = "";
|
|
|
|
Actualizar = false;
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarGasto"));
|
|
}
|
|
|
|
protected void BtnAgregarGastoModal_Click(object sender, EventArgs e)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
|
|
if(!Actualizar)
|
|
{
|
|
if (ObjCRM.AddAcercamientosGastos(CveAcercamiento, TxtDescripcionGasto.Text, TxtImporteGasto.Text.ToDecimal(), UsuarioActual.CveUsuario))
|
|
{
|
|
CargaGastos();
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarGasto"), "jsHideModalFolioGarantia");
|
|
Alert("Gasto Agregado Correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
else
|
|
{
|
|
Alert("Ocurrió un error al guardar el Gasto", ModExtensiones.TipoMensaje.MsgError);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ObjCRM.UpdateAcercamientosGastos(CveAcercamientoGasto, TxtDescripcionGasto.Text, TxtImporteGasto.Text.ToDecimal()))
|
|
{
|
|
CargaGastos();
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarGasto"), "jsHideModalFolioGarantia");
|
|
Alert("Gasto Actualizado Correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
else
|
|
{
|
|
Alert("Ocurrió un error al actualizar el Gasto", ModExtensiones.TipoMensaje.MsgError);
|
|
}
|
|
}
|
|
|
|
Actualizar = false;
|
|
CveAcercamientoGasto = -1;
|
|
|
|
ObjCRM.Dispose();
|
|
}
|
|
|
|
protected void GvGastos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DBCampo("CveAcercamiento").ToEntero() < 1)
|
|
{
|
|
e.Row.CssClass = "Totales";
|
|
e.Row.Cells[0].Text = "Total";
|
|
e.Row.FCLinkButton("ImgE").Visible = false;
|
|
e.Row.FCLinkButton("imgD").Visible = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void ImgE_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
|
|
LtlTituloModalGasto.Text = "Editar Gasto";
|
|
BtnAgregarGastoModal.Text = "Actualizar";
|
|
Actualizar = true;
|
|
|
|
CveAcercamientoGasto = GvRow.DataKey("CveAcercamientoGasto").ToEntero();
|
|
|
|
TxtDescripcionGasto.Text = GvRow.DataKey("Descripcion");
|
|
TxtImporteGasto.Text = GvRow.DataKey("Importe");
|
|
|
|
UpModalGastos.Update();
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarGasto"));
|
|
}
|
|
|
|
protected void imgD_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
|
|
CveAcercamientoGasto = GvRow.DataKey("CveAcercamientoGasto").ToEntero();
|
|
|
|
if (ObjCRM.RemoveAcercamientosGastos(CveAcercamientoGasto))
|
|
{
|
|
CargaGastos();
|
|
Alert("Gasto eliminado Correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
else
|
|
{
|
|
Alert("Ocurrió un error al eliminar el Gasto", ModExtensiones.TipoMensaje.MsgError);
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
|
|
CveAcercamientoGasto = -1;
|
|
}
|
|
|
|
#endregion
|
|
} |