2129 lines
80 KiB
C#
2129 lines
80 KiB
C#
using ADSNetLibrary.SIGAPI.Models.CRM.Request;
|
|
using ADSNetLibrary.SIGAPI.Models.CRM.Response;
|
|
using ADSNetLibrary.SIGAPI.Models.Encuestas.Request;
|
|
using ADSNetLibrary.SIGAPI.Models.Ventas.Request;
|
|
using ADSNetLibrary.SIGAPI.Services;
|
|
using ADSNetLibrary.SIGAPI.Services.CRM;
|
|
using ADSNetLibrary.SIGAPI.Services.Encuestas;
|
|
|
|
using Extensiones;
|
|
using MoreLinq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
public partial class CRM_EmpresaCRM : ClsPaginas
|
|
{
|
|
#region "PROPIEDADES"
|
|
private int CveEmpresaCRM
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveEmpresaCRM"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveEmpresaCRM"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveEncuestaCRM
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveEncuestaCRM"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveEncuestaCRM"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveEncuestaAplicada
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveEncuestaAplicada"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveEncuestaAplicada"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveContactoEditado
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveContactoEditado"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveContactoEditado"] = value;
|
|
}
|
|
}
|
|
|
|
private Boolean EsEditar
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToBoolean(ViewState["EsEditar"].ToString());
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["EsEditar"] = value;
|
|
}
|
|
}
|
|
|
|
private Boolean EsEditarContacto
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToBoolean(ViewState["EsEditarContacto"].ToString());
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["EsEditarContacto"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable DTContactos
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["DTContactos"] == null)
|
|
{
|
|
ViewState["DTContactos"] = new DataTable();
|
|
}
|
|
|
|
return (DataTable)ViewState["DTContactos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTContactos"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable DTRespuestasDatosTecnicos
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTRespuestasDatosTecnicos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTRespuestasDatosTecnicos"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveVendedor
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveVendedor"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveVendedor"] = value;
|
|
}
|
|
}
|
|
|
|
private int VendedorTipo
|
|
{
|
|
get
|
|
{
|
|
if(ViewState["VendedorTipo"] == null)
|
|
{
|
|
ViewState["VendedorTipo"] = -1;
|
|
}
|
|
return ViewState["VendedorTipo"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["VendedorTipo"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
private int CveSubProyecto
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveSubProyecto"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveSubProyecto"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable TempDTContactos
|
|
{
|
|
get
|
|
{
|
|
|
|
return (DataTable)ViewState["TempDTContactos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["TempDTContactos"] = value;
|
|
}
|
|
}
|
|
|
|
private int IndexDTContacto
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IndexDTContacto"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IndexDTContacto"] = value;
|
|
}
|
|
}
|
|
private int CveCliente
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveCliente"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveCliente"] = value;
|
|
}
|
|
}
|
|
private Boolean CreoCliente
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToBoolean(ViewState["CreoCliente"].ToString());
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CreoCliente"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable DtMedioCaptacion
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DtMedioCaptacion"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DtMedioCaptacion"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable DtProbabilidadAcercamiento
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DtProbabilidadAcercamiento"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DtProbabilidadAcercamiento"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveGiroClasificacion
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveGiroClasificacion"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveGiroClasificacion"] = value;
|
|
}
|
|
}
|
|
|
|
private List<ResponseTipoProceso> ListTipoProceso
|
|
{
|
|
get
|
|
{
|
|
return (List<ResponseTipoProceso>)ViewState["ListTipoProceso"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["ListTipoProceso"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CreoCliente = false;
|
|
RecuperaCve();
|
|
CargaTipoProceso();
|
|
CargaMetodosCaptacion();
|
|
CargaVendedores();
|
|
CargaSucursales();
|
|
CargarTiposEventos();
|
|
LimitaFechasAcercamiento();
|
|
CargaDatos();
|
|
CargaAgentes();
|
|
CargaProcedimientos();
|
|
CargaTiposVenta();
|
|
|
|
//if( Request["CveEmpresaCRM"] != null)
|
|
//{
|
|
if (CveEncuestaCRM > 0)
|
|
{
|
|
CargaDatosTecnicos();
|
|
}
|
|
// }
|
|
|
|
|
|
VerificaPermisos();
|
|
CargaClasificaciones();
|
|
DdlPS.setEsWebService(true);
|
|
DdlPS.SelectedText = "Seleccione";
|
|
DdlPS.SelectedValue = "-1";
|
|
|
|
|
|
if(UsuarioActual.Empresa.Funcionalidad(578).ToString().ToEntero() == 1)
|
|
{
|
|
DVAgenteProcedimiento.Visible = true;
|
|
DVTipoVenta.Visible = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CargaTiposVenta()
|
|
{
|
|
DdlTipoVenta.DataSource = get_GlobalDTTipoVenta(UsuarioActual.CveEmpresa).FiltraParametros(" Estatus = 'true' ");
|
|
DdlTipoVenta.DataBind();
|
|
}
|
|
|
|
private void CargaProcedimientos()
|
|
{
|
|
DdlProcedimiento.DataSource = get_GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros(" Estatus = 'true' ");
|
|
DdlProcedimiento.DataBind();
|
|
}
|
|
|
|
private void CargaAgentes()
|
|
{
|
|
DdlMedico.DataSource = get_GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros(" Estatus = 'true' ");
|
|
DdlMedico.DataBind();
|
|
}
|
|
|
|
#region "GUARDAR EMPRESA"
|
|
|
|
protected void BtnGuardarEmpresa_Click(object sender, EventArgs e)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
|
|
ClsEncuestas ObjDatosTecnicos = new ClsEncuestas(ObjCRM.IniciaTransacSQL());
|
|
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
EmpresasCRMModel cRMModel = new EmpresasCRMModel();
|
|
ResponseContactoEmpresaCRM contacto = new ResponseContactoEmpresaCRM();
|
|
|
|
Boolean HuboError = false;
|
|
String NombreEmpresa = TxtNombreEmpresa.Text;
|
|
String RFC = TxtRFC.Text;
|
|
String Correo = TxtCorreoEmpresaCRM.Text.Trim();
|
|
|
|
String MedioCaptacion = DdlMedioCaptacion.SelectedValue == "-1" ? "" : DdlMedioCaptacion.SelectedItem.Text;
|
|
String Vendedor = DdlVendedorAsignado.SelectedValue == "-1" ? "" : DdlVendedorAsignado.SelectedItem.Text;
|
|
|
|
int CveMedioCaptacion = DdlMedioCaptacion.SelectedValue.ToEntero();
|
|
int CveVendedorActualizar = DdlVendedorAsignado.SelectedValue.ToEntero();
|
|
int CveSubProyecto = DdlSucursales.SelectedValue.ToEntero();
|
|
int CveTipoProceso = DdlTipoProceso2.SelectedValue.ToEntero();
|
|
|
|
if (!EsEditar)
|
|
{
|
|
//DATOS TECNICOS - si la empresa usa datos tecnicos
|
|
if (CveEncuestaCRM > 0)
|
|
{
|
|
CveEncuestaAplicada = GuardaDatosTecnicos(ObjDatosTecnicos);
|
|
}
|
|
|
|
//SI CVEENCUESTAAPLICADA = 0 HUBO ERROR
|
|
if ((CveEncuestaAplicada != 0))
|
|
{
|
|
string Mensaje = "";
|
|
//DATOS GENERALES
|
|
cRMModel = new EmpresasCRMModel()
|
|
{
|
|
Empresa = NombreEmpresa,
|
|
RFC = RFC,
|
|
CveMedioCaptacion = CveMedioCaptacion,
|
|
CveEmpresa = UsuarioActual.CveEmpresa,
|
|
CveUsuarioIng = UsuarioActual.CveUsuario,
|
|
CveEncuestaAplicada = CveEncuestaAplicada,
|
|
CveVendedorAsignado = CveVendedorActualizar,
|
|
CveSubProyecto = CveSubProyecto,
|
|
Correo = Correo,
|
|
CveGiroClasificacion = DdlGiroClasificacion.SelectedValue.ToEntero(),
|
|
CveCliente = -1,
|
|
CveEncuestaCRM = CveEncuestaCRM < 1 ? -1 : CveEncuestaCRM,
|
|
CveTipoProceso = CveTipoProceso
|
|
};
|
|
|
|
CveEmpresaCRM = cRMService.EmpresasCRMAdd(cRMModel).ToEntero();
|
|
if (CveEmpresaCRM <= 0)
|
|
{
|
|
HuboError = true;
|
|
}
|
|
|
|
//CveEmpresaCRM = ObjCRM.AddEmpresaCRM(NombreEmpresa, RFC, CveMedioCaptacion, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, CveEncuestaAplicada, CveVendedorActualizar, CveSubProyecto, Correo, DdlGiroClasificacion.SelectedValue.ToEntero());
|
|
|
|
if (CveEmpresaCRM > 0)
|
|
{
|
|
Mensaje = String.Format("Se registró la empresa {0} con datos RFC: {1}, Vendedor: {2}", NombreEmpresa, RFC, Vendedor);
|
|
if (CveMedioCaptacion != -1)
|
|
Mensaje += String.Format(", Medio de Captación: {0}", MedioCaptacion);
|
|
|
|
HuboError = false;
|
|
|
|
if (TempDTContactos.Rows.Count > 0)
|
|
{
|
|
Mensaje += " y Contactos: ";
|
|
// Nombre, TelefonoOficina, Celular, Correo, CveUsuarioIng, FechaIng
|
|
int numContactos = TempDTContactos.Rows.Count;
|
|
int i = 1;
|
|
|
|
foreach (DataRow row in TempDTContactos.Rows)
|
|
{
|
|
contacto.Nombre = row["Nombre"].ToString();
|
|
contacto.TelefonoOficina = row["TelefonoOficina"].ToString();
|
|
contacto.Celular = row["Celular"].ToString();
|
|
contacto.Correo = row["Correo"].ToString();
|
|
contacto.CveEmpresaCRM = CveEmpresaCRM;
|
|
contacto.CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
bool Contactoagregado = cRMService.EmpresasCRMContactoAdd(contacto);
|
|
if (Contactoagregado)
|
|
{
|
|
Mensaje += row["Nombre"].ToString() + ((i == numContactos) ? "" : ", ");
|
|
i++;
|
|
|
|
}
|
|
else
|
|
{
|
|
HuboError = true;
|
|
|
|
}
|
|
|
|
//if (!ObjCRM.AddContactoEmpresa(row["Nombre"].ToString(), row["TelefonoOficina"].ToString(), row["Celular"].ToString(), row["Correo"].ToString(), CveEmpresaCRM, UsuarioActual.CveUsuario))
|
|
|
|
|
|
}
|
|
}
|
|
|
|
if (!ObjBitacora.AddEventoBitacora(Mensaje, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
|
|
{
|
|
HuboError = true;
|
|
}
|
|
else
|
|
{
|
|
string asunto = String.Format("Se registró la empresa {0} con datos RFC: {1}, Vendedor: {2}", NombreEmpresa, RFC, Vendedor);
|
|
mandarCorreo(asunto, Mensaje);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//DATOS TECNICOS - si la empresa usa datos tecnicos
|
|
if (CveEncuestaCRM > 0)
|
|
{
|
|
CveEncuestaAplicada = GuardaDatosTecnicos(ObjDatosTecnicos, CveEncuestaAplicada);
|
|
}
|
|
|
|
if (CveEncuestaAplicada != 0)
|
|
{
|
|
cRMModel.Empresa = NombreEmpresa;
|
|
cRMModel.RFC = RFC;
|
|
cRMModel.CveMedioCaptacion = CveMedioCaptacion;
|
|
cRMModel.CveEmpresaCRM = CveEmpresaCRM;
|
|
cRMModel.CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
cRMModel.CveEncuestaAplicada = CveEncuestaAplicada;
|
|
cRMModel.CveVendedorAsignado = CveVendedorActualizar;
|
|
cRMModel.CveSubProyecto = CveSubProyecto;
|
|
cRMModel.Correo = Correo;
|
|
cRMModel.CveGiroClasificacion = DdlGiroClasificacion.SelectedValue.ToEntero();
|
|
cRMModel.CveCliente = -1;
|
|
if (cRMService.EmpresasCRMUpdate(cRMModel))
|
|
{
|
|
if (!ObjBitacora.AddEventoBitacora(String.Format("Se actualizó la empresa {0} con RFC {1}", NombreEmpresa, RFC), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
|
|
{
|
|
HuboError = true;
|
|
}
|
|
else
|
|
{
|
|
string asunto = String.Format("Se actualizó la empresa {0}", NombreEmpresa);
|
|
string mensaje = String.Format("Se actualizó la empresa {0} con RFC {1} por el usuario {2}", NombreEmpresa, RFC, UsuarioActual.Nombre);
|
|
mandarCorreo(asunto, mensaje);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
HuboError = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!HuboError)
|
|
{
|
|
ObjCRM.Commit();
|
|
if (!EsEditar)
|
|
Alert(String.Format("La Empresa <b>{0}</b> fue creada correctamente.", NombreEmpresa), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
else
|
|
Alert(String.Format("La Empresa <b>{0}</b> fue actualizada correctamente.", NombreEmpresa), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
else
|
|
{
|
|
Alert("Ocurrio un error la guardar la informacion de la empresa", ModExtensiones.TipoMensaje.MsgError);
|
|
ObjCRM.RollBack();
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
ObjBitacora.Dispose();
|
|
ObjDatosTecnicos.Dispose();
|
|
|
|
//RECARGAMOS DATOS GUARDADOS EN BD Y VERIFICAMOS PERMISOS
|
|
CargaDatos();
|
|
VerificaPermisos();
|
|
|
|
if (CveEncuestaCRM > 0)
|
|
{
|
|
CargaDatosTecnicos();
|
|
}
|
|
}
|
|
|
|
protected int GuardaDatosTecnicos(ClsEncuestas ObjDatosTecnicos, int CveEncuestaAplicada = -1)
|
|
{
|
|
var encuestaService = new EncuestaService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
int _CveEncuestaAplicada = CveEncuestaAplicada;
|
|
|
|
//NUEVA CAPTURA DE DATOS TECNICOS
|
|
if (!EsEditar)
|
|
{
|
|
var responseModelAddEncuestaAplicada = encuestaService.AddEncuestaAplicada(new RequestEncuestaAplicadaAdd() { CveEncuesta = CveEncuestaCRM, CveCliente = -1, CvePersonal = -1, CveUsuario = UsuarioActual.CveUsuario, CveEmpresa = UsuarioActual.CveEmpresa });
|
|
if (responseModelAddEncuestaAplicada.Result > 0)
|
|
{
|
|
DataTable dt;
|
|
_CveEncuestaAplicada = responseModelAddEncuestaAplicada.Result.ToEntero();
|
|
|
|
foreach (GridViewRow drow in GvDatosTecnicos.Rows)
|
|
{
|
|
int EsOpcion = drow.DataKey("CveTipoPregunta").ToEntero();
|
|
int CvePregunta = drow.DataKey("CvePregunta").ToEntero();
|
|
|
|
int CveRespuesta = -1;
|
|
string Respuesta = "-1";
|
|
|
|
dt = DTRespuestasDatosTecnicos.FiltraParametros(string.Format(" CvePregunta = {0} ", CvePregunta));
|
|
|
|
switch (EsOpcion)
|
|
{
|
|
case 1: // Texto - RESPUESTA BIERTA
|
|
{
|
|
if (dt.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dt.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 (dt.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dt.FiltroPrimeroValor("CveRespuesta").ToString().ToEntero();
|
|
|
|
Respuesta = drow.FCTextBox("TxtRespuestaDinamicaMultilinea").Text;
|
|
break;
|
|
}
|
|
case 7: // FECHA
|
|
{
|
|
if (dt.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dt.FiltroPrimeroValor("CveRespuesta").ToString().ToEntero();
|
|
|
|
Respuesta = drow.FCTextBox("TxtRespuestaFechaDinamica").Text;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//CREAMOS REGISTRO DE LOS DATOS TECNICOS
|
|
var responnseModelAddEncuestaAplicadaDetalle = encuestaService.AddEncuestaAplicadaDetalle(new RequestEncuestaAplicadaDetalleAdd() { CveEncuestaAplicada = _CveEncuestaAplicada, CvePregunta = CvePregunta, CveRespuesta = CveRespuesta, Valor = Respuesta });
|
|
if (!responnseModelAddEncuestaAplicadaDetalle.IsSuccess)
|
|
{
|
|
//SI HAY ERROR REGRESA 0
|
|
_CveEncuestaAplicada = 0;
|
|
}
|
|
dt.Dispose();
|
|
}
|
|
}
|
|
}
|
|
//ACTULIZACION DE DATOS TECNICOS
|
|
else
|
|
{
|
|
int CveEncuestaAplicadaDetalle = -1;
|
|
int CveRespuesta = -1;
|
|
string Respuesta = "-1";
|
|
Boolean ExisteRegistro = true;
|
|
|
|
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";
|
|
|
|
DataTable dt = DTRespuestasDatosTecnicos.FiltraParametros(string.Format(" CvePregunta = {0} ", CvePregunta));
|
|
|
|
switch (EsOpcion)
|
|
{
|
|
case 1: // TEXTO - RESPUESTA BIERTA
|
|
{
|
|
if (dt.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dt.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 (dt.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dt.FiltroPrimeroValor("CveRespuesta").ToString().ToEntero();
|
|
|
|
Respuesta = drow.FCTextBox("TxtRespuestaDinamicaMultilinea").Text;
|
|
break;
|
|
}
|
|
case 7: // FECHA
|
|
{
|
|
if (dt.Rows.Count == 0) CveRespuesta = -1; else CveRespuesta = dt.FiltroPrimeroValor("CveRespuesta").ToString().ToEntero();
|
|
|
|
Respuesta = drow.FCTextBox("TxtRespuestaFechaDinamica").Text;
|
|
break;
|
|
}
|
|
}
|
|
|
|
var responnseModelUpdateDatosTecnicosCRM = encuestaService.UpdateDatosTecnicosCRM(new RequestDatosTecnicosCRMUpdate() { CveEncuestaAplicadaDetalle = CveEncuestaAplicadaDetalle, CveEncuestaAplicada = CveEncuestaAplicada, CvePregunta = CvePregunta, CveRespuesta = CveRespuesta, Respuesta = Respuesta });
|
|
var responnseModelAddEncuestaAplicadaDetalle = encuestaService.AddEncuestaAplicadaDetalle(new RequestEncuestaAplicadaDetalleAdd() { CveEncuestaAplicada = _CveEncuestaAplicada, CvePregunta = CvePregunta, CveRespuesta = CveRespuesta, Valor = Respuesta });
|
|
//ACTUALIZAMOS LOS DATOS TECNICOS
|
|
if (ExisteRegistro && !responnseModelUpdateDatosTecnicosCRM.IsSuccess)
|
|
{
|
|
//SI HAY ERROR REGRESA 0
|
|
_CveEncuestaAplicada = 0;
|
|
}
|
|
else if (!ExisteRegistro && !responnseModelAddEncuestaAplicadaDetalle.IsSuccess)
|
|
{
|
|
//SI HAY ERROR REGRESA 0
|
|
_CveEncuestaAplicada = 0;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// SI REGRESA _CveEncuestaAplicada = 0 HUBO ERROR
|
|
return _CveEncuestaAplicada;
|
|
}
|
|
#endregion
|
|
|
|
#region "CARGA DATOS"
|
|
protected void RecuperaCve()
|
|
{
|
|
if (Request["CveEmpresaCRM"] != null && !Request["CveEmpresaCRM"].ToString().Equals("") && Request["CveEmpresaCRM"].ToEntero() > 0)
|
|
{
|
|
ViewState["CveEmpresaCRM"] = Request["CveEmpresaCRM"];
|
|
//HplAddCotizacion.Visible = true;
|
|
//HplAddCotizacion.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveEmpresaCRM={0}&Op=Cot", CveEmpresaCRM);
|
|
UpAcciones.Update();
|
|
}
|
|
else
|
|
{
|
|
ViewState["CveEmpresaCRM"] = -1;
|
|
|
|
}
|
|
CveContactoEditado = -1;
|
|
}
|
|
|
|
protected void CargaTipoProceso()
|
|
{
|
|
//ClsCRM ObjCRM = new ClsCRM();
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestTipoProceso tipoProceso = new RequestTipoProceso(UsuarioActual.CveEmpresa);
|
|
var ObjTipoProceso = cRMService.GetTipoProcesoCRM(tipoProceso);
|
|
|
|
if (ObjTipoProceso.Result.Count > 0)
|
|
{
|
|
DdlTipoProceso2.DataSource = ObjTipoProceso.Result;
|
|
DdlTipoProceso2.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
}
|
|
DdlTipoProceso2.DataBind();
|
|
//ObjCRM.Dispose();
|
|
}
|
|
|
|
protected void CargaMetodosCaptacion()
|
|
{
|
|
//ClsCRM ObjCRM = new ClsCRM();
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestMedioCaptacion MedioCaptacion = new RequestMedioCaptacion(UsuarioActual.CveEmpresa);
|
|
var ObjMedioCaptacion = cRMService.GetMedioCaptacionCRM(MedioCaptacion);
|
|
|
|
if (ObjMedioCaptacion.Result.Count > 0)
|
|
{
|
|
DataTable tempMedio;
|
|
tempMedio = ObjMedioCaptacion.Result.ToDataTable();
|
|
DdlMedioCaptacion.DataSource = tempMedio.FiltraParametros(String.Format("CveTipoProceso = {0}", DdlTipoProceso2.SelectedValue));
|
|
DdlMedioCaptacion.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
DdlMedioCaptacionAcercamiento.Items.Clear();
|
|
DdlMedioCaptacionAcercamiento.DataSource = tempMedio;
|
|
DtMedioCaptacion = tempMedio;
|
|
DdlMedioCaptacionAcercamiento.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
}
|
|
//ObjCRM.Dispose();
|
|
DdlMedioCaptacion.DataBind();
|
|
DdlMedioCaptacionAcercamiento.DataBind();
|
|
}
|
|
|
|
protected void CargaVendedores()
|
|
{
|
|
DdlVendedorAsignado.DataSource = get_GlobalDTVendedores(UsuarioActual.CveEmpresa);
|
|
DdlVendedorAsignado.DataBind();
|
|
DdlVendedorAsignado.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
}
|
|
|
|
protected void CargaSucursales()
|
|
{
|
|
DdlSucursales.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
|
DdlSucursales.DataBind();
|
|
DdlSucursales.Items.Insert(0, new ListItem("Todos ", "-1"));
|
|
}
|
|
|
|
protected void CargaDatos()
|
|
{
|
|
EsEditar = false;
|
|
CveEncuestaAplicada = -1;
|
|
CveVendedor = UsuarioActual.CveVendedor;
|
|
CveSubProyecto = -1;
|
|
|
|
// AQUI DEBE VALIDAR SI LA EMPRESACRM USA DATOS TECNICOS
|
|
if (UsuarioActual.Empresa.AplicaDatosTecnicosCRM && UsuarioActual.Empresa.CveEncuestaCRM > 0)
|
|
{
|
|
CveEncuestaCRM = UsuarioActual.Empresa.CveEncuestaCRM;
|
|
}
|
|
else
|
|
{
|
|
CveEncuestaCRM = -1;
|
|
}
|
|
|
|
if (CveEmpresaCRM > 0)
|
|
{
|
|
//ClsCRM ObjCRM = new ClsCRM();
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestEmpresasCRM parametros = new RequestEmpresasCRM(UsuarioActual.CveEmpresa, CveEmpresaCRM);
|
|
var objServicio = cRMService.GetEmpresasCRM(parametros);
|
|
if (objServicio.Result.Count > 0)
|
|
{
|
|
EsEditar = true;
|
|
LblEncabezadoEmpresa.Text = String.Format("Consulta de la Empresa: {0}", objServicio.Result[0].Empresa);
|
|
TxtNombreEmpresa.Text = objServicio.Result[0].Empresa;
|
|
TxtRFC.Text = objServicio.Result[0].RFC;
|
|
DdlTipoProceso2.SelectedValueExist(objServicio.Result[0].CveTipoProceso);
|
|
CargaMetodosCaptacion();
|
|
TxtCorreoEmpresaCRM.Text = objServicio.Result[0].Correo;
|
|
DdlMedioCaptacion.SelectedValueExist(objServicio.Result[0].CveMedioCaptacion);
|
|
CveEncuestaAplicada = objServicio.Result[0].CveEncuestaAplicada > 0 ? objServicio.Result[0].CveEncuestaAplicada.ToEntero() : -1;
|
|
CveVendedor = objServicio.Result[0].CveVendedorAsignado.ToEntero();
|
|
CveSubProyecto = objServicio.Result[0].CveSubProyecto.ToEntero();
|
|
CveCliente = objServicio.Result[0].CveCliente.ToEntero();
|
|
CveGiroClasificacion = objServicio.Result[0].CveGiroClasificacion > 0 ? objServicio.Result[0].CveGiroClasificacion.ToEntero() : -1;
|
|
|
|
if (!(CveCliente > 0))
|
|
{
|
|
HplCrearCliente.Visible = true;
|
|
HplCrearCliente.NavigateUrl = String.Format("/Ventas/Clientes.aspx?CveEmpresaCRM={0}", CveEmpresaCRM);
|
|
}
|
|
|
|
CargaContactos();
|
|
ActivaSeccionAcercamientos();
|
|
CargaAcercamientos();
|
|
|
|
InicializaAcercamientos();
|
|
|
|
CargaCotizaciones();
|
|
|
|
DivBitacora.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
Alert("La Empresa solicitada no existe, por favor revise su búsqueda.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
BtnGuardarEmpresa.Enabled = false;
|
|
BtnEliminarEmpresa.Enabled = false;
|
|
|
|
DivBitacora.Visible = false;
|
|
|
|
CveGiroClasificacion = -1;
|
|
}
|
|
|
|
UpDatos.Update();
|
|
|
|
BtnGuardarEmpresa.Text = "Actualizar";
|
|
BtnEliminarEmpresa.Visible = true;
|
|
UpGuardar.Update();
|
|
UPBitacora.Update();
|
|
}
|
|
else
|
|
{
|
|
CreaTempDTContactos();
|
|
CveGiroClasificacion = -1;
|
|
}
|
|
|
|
DdlVendedorAsignado.SelectedValueExist(CveVendedor);
|
|
DdlSucursales.SelectedValueExist(CveSubProyecto);
|
|
ActivaSeccionContactos();
|
|
|
|
//CARGA BITACORA
|
|
if (EsEditar)
|
|
{
|
|
LnkAgregarObservaciones.Visible = true;
|
|
LnkAgregarAgenda.Visible = true;
|
|
|
|
CargaEventoBitacora();
|
|
}
|
|
|
|
if(UsuarioActual.CveVendedor > 0)
|
|
{
|
|
ClsVtaVendedores ObjVendedores = new ClsVtaVendedores();
|
|
if (ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa))
|
|
{
|
|
if(ObjVendedores.DtResultados.Rows.Count > 0)
|
|
{
|
|
VendedorTipo = ObjVendedores.DtResultados.FiltroPrimeroValor("VendedorTipo", $"CveVendedor = {UsuarioActual.CveVendedor}").ToEntero();
|
|
}
|
|
}
|
|
ObjVendedores.Dispose();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
protected void DdlTipoProceso_Change(object sender, EventArgs e)
|
|
{
|
|
|
|
var tipoProceso = ListTipoProceso.Where(x => x.CveTipoProceso == DdlTipoProceso.SelectedValue.ToEntero()).FirstOrDefault();
|
|
if (tipoProceso != null)
|
|
{
|
|
DivComision.Visible = tipoProceso.RequiereComision;
|
|
DivMedioCaptacion.Visible = tipoProceso.RequiereMedioCaptacion;
|
|
DivImporte.Visible = tipoProceso.RequiereImporte;
|
|
DivProbabilidadAcercamiento.Visible = tipoProceso.RequiereProbabilidadAcercamiento;
|
|
DivPS.Visible = tipoProceso.RequierePS;
|
|
}
|
|
|
|
RfvMedioCaptacionAcercamiento.Enabled = DivMedioCaptacion.Visible;
|
|
RFVProbabilidad.Enabled = DivProbabilidadAcercamiento.Visible;
|
|
|
|
DdlMedioCaptacionAcercamiento.Items.Clear();
|
|
DdlMedioCaptacionAcercamiento.DataSource = DtMedioCaptacion.FiltraParametros(String.Format("CveTipoProceso = {0}", DdlTipoProceso.SelectedValue.ToEntero()));
|
|
DdlMedioCaptacionAcercamiento.DataBind();
|
|
if (DdlTipoProceso.SelectedValue != "-1")
|
|
{
|
|
DdlMedioCaptacionAcercamiento.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
DdlMedioCaptacionAcercamiento.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlMedioCaptacionAcercamiento.Enabled = false;
|
|
}
|
|
|
|
DdlProbabilidadAcercamiento.Items.Clear();
|
|
DdlProbabilidadAcercamiento.DataSource = DtProbabilidadAcercamiento.FiltraParametros(String.Format("CveTipoProceso = {0}", DdlTipoProceso.SelectedValue.ToEntero()));
|
|
DdlProbabilidadAcercamiento.DataBind();
|
|
DdlProbabilidadAcercamiento.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
|
|
UpAltaAcercamiento.Update();
|
|
}
|
|
#endregion
|
|
|
|
#region "ELIMINAR EMPRESA"
|
|
protected void BtnEliminarEmpresa_Click(object sender, EventArgs e)
|
|
{
|
|
EliminarEmpresa();
|
|
}
|
|
|
|
protected void EliminarEmpresa()
|
|
{
|
|
string ErrorEliminacionEmpresa = "";
|
|
Boolean HuboError = true;
|
|
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestContactoEmpresaCRM ContactoEmpresaCRM = new RequestContactoEmpresaCRM(CveEmpresaCRM);
|
|
RequestEmpresasCRM EmpresasCRM = new RequestEmpresasCRM(-1, CveEmpresaCRM);
|
|
RequestAcercamiento aceramientoGet = new RequestAcercamiento(UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM);
|
|
var objAcercamiento = cRMService.GetAceracamientoCRM(aceramientoGet);
|
|
|
|
ClsEncuestas objDatosTecnicos = new ClsEncuestas(ObjCRM.IniciaTransacSQL());
|
|
var encuestaService = new EncuestaService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
|
|
if (objAcercamiento.Result.Count == 0)
|
|
{
|
|
|
|
if (cRMService.EmpresasCRMContactoDelete(ContactoEmpresaCRM))
|
|
{
|
|
if (cRMService.EmpresasCRMDelete(EmpresasCRM))
|
|
{
|
|
HuboError = false;
|
|
var responseModelRemoveEncuestaAplicada = encuestaService.RemoveEncuestaAplicada(new RequestEncuestaAplicadaRemove() { CveEmpresa = UsuarioActual.CveEmpresa, CveEncuestaAplicada = CveEncuestaAplicada });
|
|
if (CveEncuestaAplicada > 0 && !responseModelRemoveEncuestaAplicada.IsSuccess)
|
|
{
|
|
HuboError = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
HuboError = true;
|
|
|
|
|
|
if (cRMService.Mensaje != null && cRMService.Mensaje != "")
|
|
{
|
|
ErrorEliminacionEmpresa = cRMService.Mensaje;
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
HuboError = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert("No se puede eliminar la empresa porque el prospecto cuenta con cotizaciones/facturaciones previa", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
|
|
if (!HuboError)
|
|
{
|
|
ObjCRM.Commit();
|
|
Alert("La Empresa ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion, "document.location.href=\"/CRM/CatEmpresasCRM.aspx\"");
|
|
}
|
|
else
|
|
{
|
|
ObjCRM.RollBack();
|
|
|
|
if(ErrorEliminacionEmpresa.Trim().Length > 0 && ErrorEliminacionEmpresa.Contains("547;"))
|
|
{
|
|
Alert("No se puede eliminar la empresa debido a que tiene registros realcionados.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
Alert("Ocurrio un error al intentar eliminar la empresa.", ModExtensiones.TipoMensaje.MsgError);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
objDatosTecnicos.Dispose();
|
|
}
|
|
#endregion
|
|
|
|
#region "TAB CONTACTOS"
|
|
protected void ActivaSeccionContactos()
|
|
{
|
|
if (CveEmpresaCRM > 0)
|
|
{
|
|
BtnAgregarContacto.Visible = true;
|
|
DivBuscadorContactos.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
BtnAgregarContacto.Visible = false;
|
|
DivBuscadorContactos.Visible = false;
|
|
}
|
|
}
|
|
|
|
protected void CreaTempDTContactos()
|
|
{
|
|
TempDTContactos = new DataTable();
|
|
|
|
//CveContacto, Nombre, TelefonoOficina, Celular, Correo, CveUsuarioIng, FechaIng
|
|
|
|
TempDTContactos.Columns.Add("Nombre", typeof(string));
|
|
TempDTContactos.Columns.Add("TelefonoOficina", typeof(string));
|
|
TempDTContactos.Columns.Add("Celular", typeof(string));
|
|
TempDTContactos.Columns.Add("Correo", typeof(string));
|
|
TempDTContactos.Columns.Add("CveUsuarioIng", typeof(string));
|
|
TempDTContactos.Columns.Add("FechaIng", typeof(string));
|
|
|
|
TempDTContactos.Columns.Add("CveContacto", typeof(string));
|
|
TempDTContactos.Columns.Add("CveTipoContacto", typeof(string));
|
|
TempDTContactos.Columns.Add("TipoContacto", typeof(string));
|
|
|
|
GVContactos.DataSource = TempDTContactos;
|
|
GVContactos.DataBind();
|
|
|
|
UpContactos.Update();
|
|
}
|
|
|
|
protected void CargaGVContactosTemporales()
|
|
{
|
|
GVContactos.DataSource = TempDTContactos;
|
|
GVContactos.DataBind();
|
|
|
|
UpContactos.Update();
|
|
}
|
|
|
|
protected void CargaContactos()
|
|
{
|
|
TempDTContactos = null;
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestContactoEmpresaCRM contactoEmpresaCRM = new RequestContactoEmpresaCRM(CveEmpresaCRM, UsuarioActual.CveEmpresa, -1);
|
|
|
|
|
|
var objCRM = cRMService.GetContactosEmpresasCRM(contactoEmpresaCRM);
|
|
if (objCRM.Result.Count > 0)
|
|
{
|
|
DTContactos = objCRM.Result.ToDataTable();
|
|
GVContactos.DataSource = DTContactos;
|
|
GVContactos.DataBind();
|
|
|
|
DdlContactoPrincipal.Items.Clear();
|
|
DdlContactoPrincipal.DataSource = DTContactos;
|
|
|
|
if (DTContactos.Rows.Count != 1)
|
|
DdlContactoPrincipal.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
|
|
DdlContactoPrincipal.DataBind();
|
|
|
|
DdlContactoAgenda.Items.Clear();
|
|
DdlContactoAgenda.DataSource = DTContactos;
|
|
DdlContactoAgenda.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
DdlContactoAgenda.DataBind();
|
|
}
|
|
}
|
|
|
|
protected void limpiarCamposModalContato()
|
|
{
|
|
if (EsEditarContacto)
|
|
{
|
|
LtlModalTitulo.Text = "Actualizar Contacto";
|
|
BtnGuardarContacto.Text = "Actualizar";
|
|
}
|
|
else
|
|
{
|
|
LtlModalTitulo.Text = "Agregar Contacto";
|
|
BtnGuardarContacto.Text = "Guardar";
|
|
}
|
|
TxtNombreContacto.Text = "";
|
|
TxtTelefonoOficina.Text = "";
|
|
TxtTelExt.Text = "";
|
|
TxtCelular.Text = "";
|
|
TxtCorreo.Text = "";
|
|
DdlTipocontacto.SelectedValueExist(-1);
|
|
DdlContactoSuperior.SelectedValueExist(-1);
|
|
}
|
|
|
|
protected void BtnAgregarContacto_Click(object sender, EventArgs e)
|
|
{
|
|
EsEditarContacto = false;
|
|
limpiarCamposModalContato();
|
|
UPModalContacto.Update();
|
|
|
|
CargaGridTipoContacto();
|
|
CargaContactoSuperior(-1);
|
|
|
|
RegistraScript("$('#DivModalContacto').modal();");
|
|
}
|
|
|
|
protected void LnkEditarContacto_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveContactoEditado = GvRow.DataKey("CveContacto").ToEntero();
|
|
|
|
CargaGridTipoContacto();
|
|
CargaContactoSuperior(CveContactoEditado);
|
|
|
|
EsEditarContacto = true;
|
|
limpiarCamposModalContato();
|
|
|
|
TxtNombreContacto.Text = GvRow.DataKey("Nombre").ToString();
|
|
TxtTelefonoOficina.Text = GvRow.DataKey("TelefonoOficina").ToString();
|
|
TxtTelExt.Text = GvRow.DataKey("TelExt").ToString();
|
|
TxtCelular.Text = GvRow.DataKey("Celular").ToString();
|
|
TxtCorreo.Text = GvRow.DataKey("Correo").ToString();
|
|
DdlTipocontacto.SelectedValueExist( GvRow.DataKey("CveTipoContacto").ToString());
|
|
DdlContactoSuperior.SelectedValueExist(GvRow.DataKey("CveContactoSuperior").ToString());
|
|
|
|
IndexDTContacto = GvRow.RowIndex;
|
|
|
|
|
|
|
|
UPModalContacto.Update();
|
|
|
|
|
|
RegistraScript("$('#DivModalContacto').modal();");
|
|
}
|
|
|
|
protected void BtnGuardarContacto_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
String NombreContacto = TxtNombreContacto.Text;
|
|
String TelefonoOficina = TxtTelefonoOficina.Text == "" ? "-1" : TxtTelefonoOficina.Text;
|
|
String TelExt = TxtTelExt.Text == "" ? "-1" : TxtTelExt.Text;
|
|
String Celular = TxtCelular.Text == "" ? "-1" : TxtCelular.Text;
|
|
String Correo = TxtCorreo.Text == "" ? "-1" : TxtCorreo.Text;
|
|
|
|
if (CveEmpresaCRM > 0)
|
|
{
|
|
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
|
|
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
ResponseContactoEmpresaCRM contacto = new ResponseContactoEmpresaCRM();
|
|
|
|
Boolean HuboError = true;
|
|
|
|
int CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
|
|
if (!EsEditarContacto)
|
|
{
|
|
contacto.Nombre = NombreContacto;
|
|
contacto.TelefonoOficina = TelefonoOficina;
|
|
contacto.TelExt = TelExt;
|
|
contacto.Celular = Celular;
|
|
contacto.Correo = Correo;
|
|
contacto.CveEmpresaCRM = CveEmpresaCRM;
|
|
contacto.CveUsuarioIng = CveUsuarioIng;
|
|
contacto.CveTipoContacto = DdlTipocontacto.SelectedValue.ToEntero();
|
|
contacto.CveContactoSuperior = DdlContactoSuperior.SelectedValue.ToEntero();
|
|
|
|
if (cRMService.EmpresasCRMContactoAdd(contacto))
|
|
{
|
|
TelefonoOficina = (TelefonoOficina != "-1" ? String.Format(", Teléfono de Oficina: {0:(###) ###-####}", Convert.ToInt64(TelefonoOficina)) : "");
|
|
TelExt = (TelExt != "-1" ? String.Format(", Teléfono extensión: {0}", TelExt):"");
|
|
Celular = (Celular != "-1" ? String.Format(", Celular: {0:(###) ###-####}", Convert.ToInt64(Celular)) : "");
|
|
Correo = (Correo != "-1" ? String.Format(", Correo: {0}", Correo) : "");
|
|
|
|
if (ObjBitacora.AddEventoBitacora(String.Format("Se registró un Contacto con Nombre: {0}{1}{2}{3}", NombreContacto, TelefonoOficina, Celular, Correo), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
|
|
{
|
|
string asunto = "Se registró un Contacto";
|
|
string mensaje = String.Format("Se registró un Contacto con Nombre: {0}{1}{2}{3}. Realzado por el usuario {4}", NombreContacto, TelefonoOficina, Celular, Correo, UsuarioActual.Nombre);
|
|
mandarCorreo(asunto, mensaje);
|
|
HuboError = false;
|
|
Alert("El Contacto fue creado correctamente.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
HuboError = true;
|
|
Alert(String.Format("Ocurrio un error al crear contacto: <b>{0}</b>. ", NombreContacto), ModExtensiones.TipoMensaje.MsgError);
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
contacto.Nombre = NombreContacto;
|
|
contacto.TelefonoOficina = TelefonoOficina;
|
|
contacto.TelExt = TelExt;
|
|
contacto.Celular = Celular;
|
|
contacto.Correo = Correo;
|
|
contacto.CveContacto = CveContactoEditado;
|
|
contacto.CveUsuarioIng = CveUsuarioIng;
|
|
contacto.CveTipoContacto = DdlTipocontacto.SelectedValue.ToEntero();
|
|
contacto.CveContactoSuperior = DdlContactoSuperior.SelectedValue.ToEntero();
|
|
|
|
if (cRMService.EmpresasCRMContactoUpdate(contacto))
|
|
{
|
|
//if (ObjBitacora.AddEventoBitacora(String.Format("Se actualizó el contacto {0}", NombreContacto), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
|
|
//{
|
|
HuboError = false;
|
|
Alert(String.Format("Se actualizó el contacto {0}.", NombreContacto), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
Alert(String.Format("Ocurrio un error al actualizar contacto: {0}.", NombreContacto), ModExtensiones.TipoMensaje.MsgError);
|
|
HuboError = true;
|
|
}
|
|
}
|
|
|
|
CargaContactos();
|
|
|
|
if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
|
|
|
|
ObjCRM.Dispose();
|
|
ObjBitacora.Dispose();
|
|
|
|
//CARGA BITACORA
|
|
if (!HuboError)
|
|
{
|
|
CargaEventoBitacora();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//SI NO EXISTE LA EMPRESA AGREGA LOS CONTATOS A TABLA TEMPORAL
|
|
// //CveContacto, Nombre, TelefonoOficina, Celular, Correo, CveUsuarioIng, FechaIng
|
|
DataRow rowContacto;
|
|
rowContacto = TempDTContactos.NewRow();
|
|
|
|
rowContacto["CveContacto"] = "-1";
|
|
rowContacto["Nombre"] = NombreContacto;
|
|
rowContacto["TelefonoOficina"] = TxtTelefonoOficina.Text;
|
|
rowContacto["Celular"] = TxtCelular.Text;
|
|
rowContacto["Correo"] = TxtCorreo.Text;
|
|
rowContacto["CveUsuarioIng"] = UsuarioActual.CveUsuario;
|
|
rowContacto["FechaIng"] = NowADS();
|
|
|
|
if (EsEditarContacto)
|
|
TempDTContactos.Rows.RemoveAt(IndexDTContacto);
|
|
|
|
TempDTContactos.Rows.Add(rowContacto);
|
|
|
|
CargaGVContactosTemporales();
|
|
}
|
|
|
|
limpiarCamposModalContato();
|
|
RegistraScript("$('#DivModalContacto').modal('hide');");
|
|
UpContactos.Update();
|
|
}
|
|
|
|
protected void GVContactos_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
|
{
|
|
if (CveEmpresaCRM > 0)
|
|
{
|
|
CveContactoEditado = GVContactos.Rows[e.RowIndex].DataKey("CveContacto").ToEntero();
|
|
String NombreContacto = GVContactos.Rows[e.RowIndex].DataKey("Nombre").ToString();
|
|
|
|
Boolean HuboError = true;
|
|
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
|
|
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestContactoEmpresaCRM contacto = new RequestContactoEmpresaCRM(-1, -1, CveContactoEditado);
|
|
if (cRMService.EmpresasCRMContactoDelete(contacto))
|
|
{
|
|
HuboError = false;
|
|
CargaContactos();
|
|
Alert("El Contacto ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
|
|
if (ObjBitacora.AddEventoBitacora(String.Format("Se eliminó el contacto {0}", NombreContacto), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
|
|
{
|
|
string asunto = "Se eliminó el contacto";
|
|
string mensaje = String.Format("Se eliminó el contacto {0} por el usuario {1}", NombreContacto, UsuarioActual.Nombre);
|
|
mandarCorreo(asunto, mensaje);
|
|
ObjCRM.Commit();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert(String.Format("Ocurrio un error al eliminar el contacto: {0}.", NombreContacto), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
ObjCRM.RollBack();
|
|
}
|
|
|
|
ObjCRM.Dispose();
|
|
ObjBitacora.Dispose();
|
|
|
|
UpContactos.Update();
|
|
|
|
//CARGA BITACORA
|
|
if (!HuboError)
|
|
{
|
|
CargaEventoBitacora();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TempDTContactos.Rows.RemoveAt(e.RowIndex);
|
|
CargaGVContactosTemporales();
|
|
//CargaGVContactosSucursal()
|
|
}
|
|
}
|
|
|
|
protected void GVContactos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DataKey("TelefonoOficina") != "")
|
|
e.Row.FCLabel("lblTelefonoOficina").Text = String.Format("{0:(###) ###-####}", Convert.ToInt64(e.Row.DataKey("TelefonoOficina")));
|
|
|
|
if (e.Row.DataKey("Celular") != "")
|
|
e.Row.FCLabel("lblCelular").Text = String.Format("{0:(###) ###-####}", Convert.ToInt64(e.Row.DataKey("Celular")));
|
|
}
|
|
}
|
|
|
|
|
|
protected void LnkNombreContactoAgenda_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
//CveContacto,Nombre,TelefonoOficina,Celular,Correo,CveUsuarioIng,FechaIng,CveTipoContacto
|
|
int CveContacto = GvRow.DataKey("CveContacto").ToEntero();
|
|
string NombreContacto = GvRow.DataKey("Nombre");
|
|
|
|
TempDTContactos = null;
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestContactoEmpresaCRM contactoEmpresaCRM = new RequestContactoEmpresaCRM(CveEmpresaCRM, UsuarioActual.CveEmpresa, CveContacto);
|
|
|
|
|
|
var objCRM = cRMService.GetContactosEmpresaAgendaCRM(contactoEmpresaCRM);
|
|
|
|
if (objCRM.Result.Count > 0)
|
|
{
|
|
GvContactoAgenda.DataSource = objCRM.Result.ToDataTable();
|
|
GvContactoAgenda.DataBind();
|
|
|
|
UpModalContactoAgenda.Update();
|
|
LblModalContactoAgendaTitulo.Text = $"Agenda: {NombreContacto}";
|
|
RegistraScript("$('#DVModalContactoAgenda').modal('show');");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region "BITACORA"
|
|
private void CargaEventoBitacora()
|
|
{
|
|
ClsOIEventos ObjEventoBitacora = new ClsOIEventos();
|
|
|
|
if (ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
|
|
GVEventoBitacora.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2");
|
|
else
|
|
GVEventoBitacora.DataSource = null;
|
|
|
|
ObjEventoBitacora.Dispose();
|
|
GVEventoBitacora.DataBind();
|
|
|
|
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 = "";
|
|
|
|
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, CveEmpresaCRM: CveEmpresaCRM))
|
|
{
|
|
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();
|
|
|
|
CargaEventoBitacora();
|
|
UPAddEventoBitacora.Update();
|
|
}
|
|
|
|
protected void GVEventoBitacora_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.RowIndex == 0)
|
|
{
|
|
e.Row.Cells[0].Width = Unit.Pixel(175);
|
|
e.Row.Cells[1].Width = Unit.Pixel(175);
|
|
e.Row.Cells[2].Width = Unit.Pixel(100);
|
|
e.Row.Cells[4].Width = Unit.Pixel(30);
|
|
}
|
|
|
|
if (e.Row.DBCampo("Archivo").ToString() != "")
|
|
{
|
|
e.Row.FCLinkButton("LinkArchivo").Visible = true;
|
|
e.Row.FCLinkButton("LinkArchivo").CommandArgument = string.Format(@"OI\{0}", e.Row.DBCampo("Archivo").ToString());
|
|
ScriptManager.GetCurrent(this).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")); // Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region "AGENDA"
|
|
protected void limpiarModalAgendar()
|
|
{
|
|
DdlTipoAgenda.SelectedValueExist("1");
|
|
DdlPrioridadAgenda.SelectedValueExist("1");
|
|
TxtAsuntoAgenda.Text = "";
|
|
TxtDescripcionAgenda.Text = "";
|
|
TxtFechaInicioAgenda.Text = NowADS().ToString("dd/MM/yyyy HH:mm");
|
|
|
|
UpModalAgenda.Update();
|
|
}
|
|
|
|
protected void BtnGuardarAgenda_Click(object sender, EventArgs e)
|
|
{
|
|
ClsOIEventos ObjEventos = new ClsOIEventos();
|
|
DateTime FechaInicio = TxtFechaInicioAgenda.Text.ToDateTime();
|
|
|
|
if (ObjEventos.AddEventoAgenda(DdlTipoAgenda.SelectedValue.ToEntero(), TxtAsuntoAgenda.Text, TxtDescripcionAgenda.Text, DdlPrioridadAgenda.SelectedValue.ToEntero(), FechaInicio, FechaInicio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM, CveContactoCRM: DdlContactoAgenda.SelectedValue.ToEntero()))
|
|
{
|
|
mandarCorreo(TxtAsuntoAgenda.Text, TxtDescripcionAgenda.Text);
|
|
limpiarModalAgendar();
|
|
RegistraScript("$('#ModalAgenda').modal('hide')");
|
|
Alert("El Evento se agendó correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
|
|
|
|
}
|
|
ObjEventos.Dispose();
|
|
CargaEventoBitacora();
|
|
}
|
|
|
|
protected void CargarTiposEventos()
|
|
{
|
|
ClsOIEventos ObjEventos = new ClsOIEventos();
|
|
|
|
if (ObjEventos.GetAgendaTipo())
|
|
{
|
|
DdlTipoAgenda.DataSource = ObjEventos.DtResultados;
|
|
DdlTipoAgenda.DataBind();
|
|
}
|
|
|
|
ObjEventos.Dispose();
|
|
limpiarModalAgendar();
|
|
}
|
|
|
|
//protected void LnkAgregarEvento_Click(object sender, EventArgs e)
|
|
//{
|
|
// RegistraScript(String.Format("AbrirVentana('/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveEmpresaCRM={0}&TB_iframe=true&height=370&width=600');", CveEmpresaCRM));
|
|
//}
|
|
#endregion
|
|
|
|
#region "CARGAR DATOS TECNICOS - ENCUESTA"
|
|
protected void CargaDatosTecnicos()
|
|
{
|
|
var encuestaService = new EncuestaService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
var responseGenericGetRespuestas = encuestaService.GetRespuestas(CveEncuestaCRM);
|
|
if (responseGenericGetRespuestas.IsSuccess)
|
|
{
|
|
DTRespuestasDatosTecnicos = responseGenericGetRespuestas.Result.ToDataTable();
|
|
}
|
|
|
|
var responseGenericGetDatosTecnicosEmpresaCRM = encuestaService.GetDatosTecnicosEmpresaCRM(new RequestDatosTecnicosEmpresaCRMGet() { CveEmpresa = UsuarioActual.Empresa.CveEmpresa, CveEncuesta = CveEncuestaCRM, CveEncuestaAplicada = CveEncuestaAplicada, CvePregunta = -1 });
|
|
if (responseGenericGetDatosTecnicosEmpresaCRM.IsSuccess)
|
|
{
|
|
|
|
|
|
var DTTemp = responseGenericGetDatosTecnicosEmpresaCRM.Result.ToDataTable();
|
|
GvDatosTecnicos.DataSource = DTTemp;
|
|
if (DTTemp.Rows.Count > 0)
|
|
{
|
|
GvDatosTecnicos.Visible = true;
|
|
}
|
|
}
|
|
|
|
//ClsEncuestas objEncuesta = new ClsEncuestas();
|
|
|
|
//if (objEncuesta.GetRespuestas(CveEncuestaCRM))
|
|
// DTRespuestasDatosTecnicos = objEncuesta.DtResultados;
|
|
|
|
//if (objEncuesta.GetDatosTecnicosEmpresaCRM(CveEncuestaCRM, CveEncuestaAplicada, 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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region "TAB ACERCAMIENTOS"
|
|
protected void ActivaSeccionAcercamientos()
|
|
{
|
|
if (CveEmpresaCRM > 0)
|
|
{
|
|
LimitaFechasAcercamiento();
|
|
LnkAgregarAcercamiento.Visible = true;
|
|
DivBuscadorAcercamientos.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
LnkAgregarAcercamiento.Visible = false;
|
|
DivBuscadorAcercamientos.Visible = false;
|
|
}
|
|
}
|
|
|
|
protected void LimitaFechasAcercamiento()
|
|
{
|
|
//ACTIVAMOS RANGO DE FECHAS PARA CAPTURA DE ACERCAMIENTO
|
|
CETxtFechaApertura.StartDate = NowADS().AddDays(-1);
|
|
CETxtFechaApertura.EndDate = NowADS();
|
|
|
|
RVFechaApertura.MinimumValue = NowADS().AddDays(-1).ToShortDateString();
|
|
RVFechaApertura.MaximumValue = NowADS().ToShortDateString();
|
|
}
|
|
|
|
protected void InicializaAcercamientos()
|
|
{
|
|
DdlTipoProceso.Items.Clear();
|
|
DdlProbabilidadAcercamiento.Items.Clear();
|
|
DdlVendedor.Items.Clear();
|
|
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestProbalidadAcercamiento ProbalidadAcercamiento = new RequestProbalidadAcercamiento(UsuarioActual.CveEmpresa, 1);
|
|
var ObjProbalidadAcercamiento = cRMService.GetProbabilidadAceracamientoCRM(ProbalidadAcercamiento);
|
|
|
|
RequestTipoProceso tipoProceso = new RequestTipoProceso(UsuarioActual.CveEmpresa, 1);
|
|
var ObjTipoProceso = cRMService.GetTipoProcesoCRM(tipoProceso);
|
|
|
|
if (ObjTipoProceso.Result.Count > 0)
|
|
{
|
|
|
|
DdlTipoProceso.DataSource = ObjTipoProceso.Result;
|
|
DdlTipoProceso.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
DdlMedioCaptacionAcercamiento.Enabled = false;
|
|
DdlTipoProceso.DataBind();
|
|
}
|
|
ListTipoProceso = ObjTipoProceso.Result;
|
|
|
|
if (ObjProbalidadAcercamiento.Result.Count > 0)
|
|
{
|
|
//DdlProbabilidadAcercamiento.DataSource = ObjCRM.DtResultados;
|
|
//DdlProbabilidadAcercamiento.DataBind();
|
|
DdlProbabilidadAcercamiento.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
DtProbabilidadAcercamiento = ObjProbalidadAcercamiento.Result.ToDataTable();
|
|
}
|
|
|
|
DdlVendedor.DataSource = get_GlobalDTVendedores(UsuarioActual.CveEmpresa);
|
|
DdlVendedor.DataBind();
|
|
DdlVendedor.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
DdlVendedor.SelectedValueExist(CveVendedor);
|
|
|
|
if (CveVendedor > 0)
|
|
{
|
|
DdlVendedor.Enabled = false;
|
|
DdlVendedorAsignado.Enabled = false;
|
|
}
|
|
|
|
|
|
if (UsuarioActual.TienePermisoProceso(336)) //permiso para editar vendedor
|
|
{
|
|
DdlVendedorAsignado.Enabled = true;
|
|
}
|
|
|
|
}
|
|
|
|
protected void limpiarCamposModalAcercamiento()
|
|
{
|
|
TxtAcercamiento.Text = "";
|
|
TxtDescripcionAcercamiento.Text = "";
|
|
TxtFechaApertura.Text = NowADS().ToShortDateString();
|
|
TxtFechaCierre.Text = "";
|
|
TxtImporte.Text = "0.00";
|
|
TxtComision.Text = "0.00";
|
|
|
|
DdlTipoProceso.SelectedValueExist("-1");
|
|
DdlContactoPrincipal.SelectedValueExist("-1");
|
|
DdlVendedor.SelectedValueExist(CveVendedor);
|
|
DdlMedioCaptacionAcercamiento.SelectedValueExist("-1");
|
|
DdlProbabilidadAcercamiento.SelectedValueExist("-1");
|
|
DdlPrioridadAcercamiento.SelectedValueExist("1");
|
|
|
|
DdlMedico.SelectedValueExist("-1");
|
|
DdlProcedimiento.SelectedValueExist("-1");
|
|
DdlTipoVenta.SelectedValueExist("-1");
|
|
}
|
|
|
|
|
|
protected void CargaAcercamientos()
|
|
{
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestAcercamiento aceramientoGet = new RequestAcercamiento(UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM);
|
|
var objAcercamiento = cRMService.GetAceracamientoCRM(aceramientoGet);
|
|
if (objAcercamiento.IsSuccess)
|
|
{
|
|
GVAcercamientos.DataSource = objAcercamiento.Result;
|
|
GVAcercamientos.DataBind();
|
|
}
|
|
}
|
|
|
|
protected void LnkAgregarAcercamiento_Click(object sender, EventArgs e)
|
|
{
|
|
if (DTContactos.Rows.Count == 0)
|
|
{
|
|
Alert("Para crear un nuevo acercamiento/Oportunidad es necesario agregar al menos un Contacto.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
else
|
|
{
|
|
CargaMetodosCaptacion();
|
|
InicializaAcercamientos();
|
|
limpiarCamposModalAcercamiento();
|
|
RegistraScript("$('#DivModalAltaAcercamiento').modal();");
|
|
UpAltaAcercamiento.Update();
|
|
//Confirmacion("Se le redireccionara para realizar el Registro del Acercamiento, ¿Desea continuar?", "", "document.location.href=\"/CRM/Acercamiento.aspx\"", "");
|
|
}
|
|
|
|
}
|
|
|
|
protected void BtnGuardarAcercamiento_Click(object sender, EventArgs e)
|
|
{
|
|
ClsCRM ObjCRM = new ClsCRM();
|
|
ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
|
|
|
|
|
|
Boolean HuboError = true;
|
|
String NombreAcercamiento = TxtAcercamiento.Text;
|
|
String Descripcion = TxtDescripcionAcercamiento.Text == "" ? "-1" : TxtDescripcionAcercamiento.Text;
|
|
int CveTipoProceso = DdlTipoProceso.SelectedValue.ToEntero();
|
|
RequestEtapaProceso EtapaProceso = new RequestEtapaProceso(UsuarioActual.CveEmpresa, CveTipoProceso: CveTipoProceso);
|
|
var ObjEtapaProceso = cRMService.GetEtapaProcesoCRM(EtapaProceso);
|
|
DataTable tempDT = null;
|
|
|
|
if (ObjEtapaProceso.Result.Count > 0)
|
|
{
|
|
tempDT = ObjEtapaProceso.Result.ToDataTable();
|
|
}
|
|
int CveEtapaProcesoActual = tempDT.FiltroPrimeroValor("CveEtapaProceso").ToEntero();
|
|
int CveContactoPrincipal = DdlContactoPrincipal.SelectedValue.ToEntero();
|
|
int CveVendedor = DdlVendedor.SelectedValue.ToEntero();
|
|
int CveMedioCaptacion = DdlMedioCaptacionAcercamiento.SelectedValue.ToEntero();
|
|
int CveProbabilidadAcercamiento = DdlProbabilidadAcercamiento.SelectedValue.ToEntero();
|
|
|
|
int CveRechazoMotivo = -1;
|
|
|
|
DateTime FechaApertura = TxtFechaApertura.Text.ToDateTime();
|
|
DateTime FechaCierre = TxtFechaCierre.Text.ToDateTime();
|
|
|
|
Double Importe = TxtImporte.Text.ToDouble();
|
|
Double Comision = TxtComision.Text.ToDouble();
|
|
|
|
int Prioridad = DdlPrioridadAcercamiento.SelectedValue.ToEntero();
|
|
|
|
int CveUsuarioIng = UsuarioActual.CveUsuario;
|
|
|
|
int CveAcercamiento = -1;
|
|
|
|
if (tempDT.Rows.Count > 0)
|
|
{
|
|
var AcercamientoModel = new AcercamientoModel()
|
|
{
|
|
CveEmpresaCRM = CveEmpresaCRM,
|
|
CveContactoPrincipal = CveContactoPrincipal,
|
|
CveTipoProceso = CveTipoProceso,
|
|
CveEtapaProcesoActual = CveEtapaProcesoActual,
|
|
CveVendedor = CveVendedor,
|
|
CveMedioCaptacion = CveMedioCaptacion,
|
|
CveRechazoMotivo = CveRechazoMotivo,
|
|
CveProbabilidadAcercamiento = CveProbabilidadAcercamiento,
|
|
FechaApertura = FechaApertura,
|
|
FechaCierre = FechaCierre > ModExtensiones.MinFecha ? FechaCierre : (DateTime)System.Data.SqlTypes.SqlDateTime.Null,
|
|
NombreAcercamiento = NombreAcercamiento,
|
|
Descripcion = Descripcion,
|
|
Importe = Importe,
|
|
Comision = Comision,
|
|
Prioridad = Prioridad,
|
|
CveEmpresa = UsuarioActual.CveEmpresa,
|
|
CveUsuarioIng = CveUsuarioIng,
|
|
CvePS = DdlPS.SelectedValue.ToEntero(),
|
|
CveMedico = DdlMedico.SelectedValue.ToEntero(),
|
|
CveProcedimiento = DdlProcedimiento.SelectedValue.ToEntero(),
|
|
CveTipoVenta = DdlTipoVenta.SelectedValue.ToEntero()
|
|
};
|
|
|
|
|
|
|
|
CveAcercamiento = cRMService.AcercamientoAdd(AcercamientoModel).ToEntero();
|
|
}
|
|
else
|
|
{
|
|
Alert("No tiene 'Etapa Proceso' con el 'Proceso' seleccionado al agregar el Acercamiento/Oportunidad", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
|
|
if (CveAcercamiento > 0)
|
|
{
|
|
if (ObjBitacora.AddEventoBitacora(String.Format("Se registró el Acercamiento/Oportunidad {0} como Proceso de Tipo {1}, con Vendedor {2} y Contacto Principal {3}.", NombreAcercamiento, DdlTipoProceso.SelectedItem, DdlVendedor.SelectedItem, DdlContactoPrincipal.SelectedValue == "-1" ? "aun no asignado" : DdlContactoPrincipal.SelectedItem.Text), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM, CveTipoProcesoCRM: CveTipoProceso, CveAcercamientoCRM: CveAcercamiento, CveContactoCRM: CveContactoPrincipal, CveEtapaProcesoCRM: CveEtapaProcesoActual))
|
|
{
|
|
string asunto = String.Format("Se registró el Acercamiento/Oportunidad {0}", NombreAcercamiento);
|
|
string mensaje = String.Format("Se registró el Acercamiento/Oportunidad {0} como Proceso de Tipo {1}, con Vendedor {2} y Contacto Principal {3}.", NombreAcercamiento, DdlTipoProceso.SelectedItem, DdlVendedor.SelectedItem, DdlContactoPrincipal.SelectedValue == "-1" ? "aun no asignado" : DdlContactoPrincipal.SelectedItem.Text);
|
|
mandarCorreo(asunto, mensaje);
|
|
HuboError = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert("Ocurrio un error al agregar el Acercamiento/Oportunidad", ModExtensiones.TipoMensaje.MsgError);
|
|
HuboError = false;
|
|
}
|
|
|
|
|
|
CargaAcercamientos();
|
|
|
|
if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
|
|
|
|
ObjCRM.Dispose();
|
|
ObjBitacora.Dispose();
|
|
|
|
RegistraScript("$('#DivModalAltaAcercamiento').modal('hide');");
|
|
|
|
UPAcercamientos.Update();
|
|
|
|
//CARGA BITACORA
|
|
if (!HuboError)
|
|
{
|
|
Alert(String.Format("Se registró el acercamiento/Oportunidad <b>{0}</b> como proceso de tipo <b>{1}</b>.<br/><br/> Se le redireccionara al Detalle del Acercamiento/Oportunidad.", NombreAcercamiento, DdlTipoProceso.SelectedItem), ModExtensiones.TipoMensaje.MsgInformacion, String.Format("document.location.href=\"/CRM/Acercamiento.aspx?CveAcercamiento={0}\"", CveAcercamiento));
|
|
CargaEventoBitacora();
|
|
}
|
|
limpiarCamposModalAcercamiento();
|
|
}
|
|
|
|
protected void GVAcercamientos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DataKey("CveAcercamiento").ToEntero() > 0)
|
|
e.Row.FCHyperLink("HplNombreAcercamiento").NavigateUrl = String.Format("/CRM/Acercamiento.aspx?CveAcercamiento={0}", e.Row.DataKey("CveAcercamiento"));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region "PERMISOS"
|
|
protected void VerificaPermisos()
|
|
{
|
|
|
|
if (CveEmpresaCRM > 0)
|
|
{
|
|
if (!UsuarioActual.TienePermisoProceso(250))
|
|
BtnEliminarEmpresa.Visible = false;
|
|
|
|
if (!UsuarioActual.TienePermisoProceso(251))
|
|
{
|
|
LnkAgregarAcercamiento.Visible = false;
|
|
}
|
|
|
|
if ((UsuarioActual.CveVendedor != CveVendedor) & VendedorTipo != 2)
|
|
{
|
|
if (UsuarioActual.CveUsuario != 100)
|
|
{
|
|
BtnGuardarEmpresa.Visible = false;
|
|
BtnEliminarEmpresa.Visible = false;
|
|
BtnAgregarContacto.Visible = false;
|
|
//LnkAgregarAcercamiento.Visible = false;
|
|
DivAccionesBitacora.Visible = false;
|
|
GVContactos.Columns[4].Visible = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region "COTIZACIONES"
|
|
protected void CargaCotizaciones()
|
|
{
|
|
|
|
IVentaService ventaService = new VentaService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestVentas requestVentas = new RequestVentas(UsuarioActual.CveEmpresa, TipoDocto: "Cot", CveEmpresaCRM: CveEmpresaCRM, CveUsuarioConsulta: UsuarioActual.CveUsuario);
|
|
var objVentas = ventaService.GetVentas(requestVentas);
|
|
if (objVentas.IsSuccess)
|
|
{
|
|
GvCotizacion.DataSource = objVentas.Result;
|
|
}
|
|
|
|
//if (ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "Cot", "-1", -1, "-1", -1, -1, -1, -1, "-1", "-1", "-1", CveEmpresaCRM: CveEmpresaCRM, CveUsuarioConsulta: UsuarioActual.CveUsuario))
|
|
//{
|
|
// GvCotizacion.DataSource = ObjVentas.DtResultados;
|
|
//}
|
|
|
|
GvCotizacion.DataBind();
|
|
UpCotizacion.Update();
|
|
}
|
|
|
|
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"));
|
|
}
|
|
|
|
if(e.Row.DataKey("Total").ToDecimal() != 0)
|
|
{
|
|
e.Row.Cells[5].Text = e.Row.DataKey("Total").ToDecimal().ToString("###,###,###.00");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
private void mandarCorreo(string Asunto, string body)
|
|
{
|
|
DataTable Usuarios = get_GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa);
|
|
int CveUsuario = Usuarios.FiltroPrimeroValor("CveUsuario", String.Format("CveVendedor = {0}", DdlVendedorAsignado.SelectedValue)).ToEntero();
|
|
if (CveUsuario != UsuarioActual.CveUsuario)
|
|
{
|
|
string correoVendedor = Usuarios.FiltroPrimeroValor("Correo", String.Format("CveUsuario = {0}", CveUsuario));
|
|
ClsSisMail Mail = new ClsSisMail();
|
|
List<ClsSisMail.ArchivoMail> LSRutasMail = new List<ClsSisMail.ArchivoMail>();
|
|
//ClsSisMail.ArchivoMail itemMail = new ClsSisMail.ArchivoMail();
|
|
Mail.SendMail(ClsPaginas.EmpresaNotificaciones, correoVendedor, Asunto, body);
|
|
}
|
|
}
|
|
|
|
protected void DdlTipoProcesos_Change(Object sender, EventArgs e)
|
|
{
|
|
DdlMedioCaptacion.Items.Clear();
|
|
CargaMetodosCaptacion();
|
|
UpDatos.Update();
|
|
}
|
|
|
|
private void CargaClasificaciones()
|
|
{
|
|
DataTable dtGiroClasificaciones = get_GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa);
|
|
DdlGiroClasificacion.DataSource = dtGiroClasificaciones;
|
|
DdlGiroClasificacion.DataBind();
|
|
DdlGiroClasificacion.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlGiroClasificacion.SelectedValueExist(CveGiroClasificacion);
|
|
}
|
|
|
|
|
|
#region "TIPO CONTACTO"
|
|
|
|
|
|
protected void LnkAgregartipoContacto_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
CargaGridTipoContacto();
|
|
RegistraScript("$('#DivModalTipoContacto').modal('show');");
|
|
}
|
|
|
|
|
|
private void LimpiaTipoContacto()
|
|
{
|
|
TxtTipoContacto.Text = "";
|
|
UpModalTipoContacto.Update();
|
|
}
|
|
|
|
private void CargaGridTipoContacto()
|
|
{
|
|
DdlTipocontacto.Items.Clear();
|
|
DdlTipocontacto.SelectedValue = null;
|
|
|
|
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
|
|
RequestTipoContacto requestTipoContacto = new RequestTipoContacto(-1,"-1",-1,UsuarioActual.CveEmpresa);
|
|
|
|
var ObjTIpocontacto = cRMService.TipoContactoGet(requestTipoContacto);
|
|
|
|
if (ObjTIpocontacto.Result.Count > 0)
|
|
{
|
|
GvModalTipoContacto.DataSource = ObjTIpocontacto.Result;
|
|
DdlTipocontacto.DataSource = ObjTIpocontacto.Result;
|
|
}
|
|
|
|
GvModalTipoContacto.DataBind();
|
|
|
|
DdlTipocontacto.DataBind();
|
|
DdlTipocontacto.Items.Insert(0, new ListItem("Seleccione Uno", "-1"));
|
|
|
|
UpModalTipoContacto.Update();
|
|
UPModalContacto.Update();
|
|
|
|
cRMService = null;
|
|
}
|
|
|
|
private void CargaContactoSuperior(int CveConcactoOmitir)
|
|
{
|
|
|
|
DdlContactoSuperior.Items.Clear();
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
RequestContactoEmpresaCRM contactoEmpresaCRM = new RequestContactoEmpresaCRM(CveEmpresaCRM, UsuarioActual.CveEmpresa,-1);
|
|
var objcontactoEmpresa = cRMService.GetContactosEmpresasCRM(contactoEmpresaCRM);
|
|
|
|
if (objcontactoEmpresa.Result.Count > 0)
|
|
{
|
|
DdlContactoSuperior.DataSource = objcontactoEmpresa.Result.ToDataTable().FiltraParametros((CveConcactoOmitir>0 ?$" CveContacto <> {CveConcactoOmitir} ": "" ));
|
|
DdlContactoSuperior.DataBind();
|
|
}
|
|
DdlContactoSuperior.Items.Insert(0, new ListItem("Sin Asignar ", "-1"));
|
|
|
|
UPModalContacto.Update();
|
|
|
|
|
|
}
|
|
protected void btnAgregarTipoContacto_Click(object sender, EventArgs e)
|
|
{
|
|
bool ErrorProceso = false;
|
|
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
|
|
TipoContactoModel TipoContacto = new TipoContactoModel();
|
|
|
|
TipoContacto.TipoContacto = TxtTipoContacto.Text;
|
|
TipoContacto.CveUsuario = UsuarioActual.CveUsuario;
|
|
TipoContacto.CveEmpresa = UsuarioActual.CveEmpresa;
|
|
|
|
if (!cRMService.TipoContactoAdd(TipoContacto))
|
|
{
|
|
Alert("Se presento un error al agregar el tipo de contacto", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
|
|
if (!ErrorProceso)
|
|
{
|
|
CargaGridTipoContacto();
|
|
LimpiaTipoContacto();
|
|
}
|
|
}
|
|
|
|
protected void LnkEliminarTipoContacto_Click(object sender, EventArgs e)
|
|
{
|
|
bool ErrorProceso = false;
|
|
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
|
|
int CveTipoContactoEliminar = GvRow.DataKey("CveTipoContacto").ToEntero();
|
|
|
|
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
|
|
|
TipoContactoModel TipoContacto = new TipoContactoModel();
|
|
TipoContacto.CveTipoContacto = CveTipoContactoEliminar;
|
|
TipoContacto.CveEmpresa = UsuarioActual.CveEmpresa;
|
|
|
|
if (cRMService.TipoContactoRemove(TipoContacto))
|
|
{
|
|
Alert("Tipo Contacto eliminado correctamente.");
|
|
}else{
|
|
Alert("Se presento un error al eliminar el tipo de contacto.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
|
|
if (!ErrorProceso)
|
|
{
|
|
CargaGridTipoContacto();
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |