Cambio CRM a la API
This commit is contained in:
@@ -8,6 +8,11 @@ using System.Web.UI.WebControls;
|
||||
using System.Data;
|
||||
using GemBox.Spreadsheet;
|
||||
using Extensiones;
|
||||
using ADSNetLibrary.SIGAPI.Services.CRM;
|
||||
using ADSNetLibrary.SIGAPI.Models.CRM.Request;
|
||||
using ADSNetLibrary.SIGAPI.Models.CRM.Response;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MoreLinq;
|
||||
|
||||
public partial class CRM_CatEmpresasCRM : ClsPaginas
|
||||
{
|
||||
@@ -44,40 +49,60 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas
|
||||
|
||||
protected void CargaDatos()
|
||||
{
|
||||
ClsCRM ObjCRM = new ClsCRM();
|
||||
|
||||
if (ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa, CveMedioCaptacion: DdlMedioCaptacion.SelectedValue.ToEntero()) && ObjCRM.DtResultados.Rows.Count > 0)
|
||||
//ClsCRM ObjCRM = new ClsCRM();
|
||||
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
||||
RequestEmpresasCRM parametros = new RequestEmpresasCRM(UsuarioActual.CveEmpresa, -1, CveMedioCaptacion: DdlMedioCaptacion.SelectedValue.ToEntero());
|
||||
var objServicio = cRMService.GetEmpresasCRM(parametros);
|
||||
if (objServicio.Result.Count > 0)
|
||||
{
|
||||
TmpDT = ObjCRM.DtResultados;
|
||||
GVDatos.DataSource = TmpDT;
|
||||
GVDatos.DataSource = objServicio.Result;
|
||||
TmpDT = objServicio.Result.ToDataTable();
|
||||
}
|
||||
ObjCRM.Dispose();
|
||||
//if (ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa, CveMedioCaptacion: DdlMedioCaptacion.SelectedValue.ToEntero()) && ObjCRM.DtResultados.Rows.Count > 0)
|
||||
//{
|
||||
// TmpDT = ObjCRM.DtResultados;
|
||||
// GVDatos.DataSource = TmpDT;
|
||||
//}
|
||||
//ObjCRM.Dispose();
|
||||
GVDatos.DataBind();
|
||||
UPDatos.Update();
|
||||
}
|
||||
|
||||
protected void CargaMediosCaptacion()
|
||||
{
|
||||
ClsCRM ObjCRM = new ClsCRM();
|
||||
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
||||
RequestMedioCaptacion MedioCaptacion = new RequestMedioCaptacion(UsuarioActual.CveEmpresa, 1);
|
||||
var ObjMedioCaptacion = cRMService.GetMedioCaptacionCRM(MedioCaptacion);
|
||||
|
||||
if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa, 1))
|
||||
if (ObjMedioCaptacion.Result.Count > 0)
|
||||
{
|
||||
DdlMedioCaptacion.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}",DdlTipoProceso.SelectedValue));
|
||||
DataTable DTMedioCaptacion = ObjMedioCaptacion.Result.ToDataTable();
|
||||
DdlMedioCaptacion.DataSource = DTMedioCaptacion.FiltraParametros(String.Format("CveTipoProceso = {0}", DdlTipoProceso.SelectedValue));
|
||||
DdlMedioCaptacion.DataBind();
|
||||
DdlMedioCaptacion.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
DdlMedioCaptacion.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
||||
}
|
||||
ObjCRM.Dispose();
|
||||
|
||||
//if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa, 1))
|
||||
//{
|
||||
// DdlMedioCaptacion.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}",DdlTipoProceso.SelectedValue));
|
||||
// DdlMedioCaptacion.DataBind();
|
||||
// DdlMedioCaptacion.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
//}
|
||||
//ObjCRM.Dispose();
|
||||
}
|
||||
|
||||
protected void CargaTipoProcesos()
|
||||
{
|
||||
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 (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa))
|
||||
if (ObjTipoProceso.Result.Count > 0)
|
||||
{
|
||||
DdlTipoProceso.DataSource = ObjCRM.DtResultados;
|
||||
DdlTipoProceso.DataSource = ObjTipoProceso.Result;
|
||||
DdlTipoProceso.DataBind();
|
||||
}
|
||||
DdlTipoProceso.DataBind();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -85,24 +110,30 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas
|
||||
protected void GVDatos_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
int CveEmpresaCRM = GVDatos.Rows[e.RowIndex].DataKey("CveEmpresaCRM").ToEntero();
|
||||
Boolean HuboError = true;
|
||||
//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);
|
||||
|
||||
ObjCRM.IniciaTransacSQL();
|
||||
|
||||
if (ObjCRM.RemoveContactoEmpresa(-1, CveEmpresaCRM))
|
||||
if (objAcercamiento.Result.Count == 0)
|
||||
{
|
||||
if (ObjCRM.RemoveEmpresaCRM(CveEmpresaCRM))
|
||||
if (cRMService.EmpresasCRMContactoDelete(ContactoEmpresaCRM))
|
||||
{
|
||||
HuboError = false;
|
||||
Alert("La Empresa ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion);
|
||||
if (cRMService.EmpresasCRMDelete(EmpresasCRM))
|
||||
{
|
||||
//HuboError = false;
|
||||
Alert("La Empresa ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
|
||||
|
||||
ObjCRM.Dispose();
|
||||
else
|
||||
{
|
||||
Alert("No se puede eliminar la empresa porque el prospecto cuenta con cotizaciones/facturaciones previa", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
CargaDatos();
|
||||
}
|
||||
|
||||
@@ -152,12 +183,15 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas
|
||||
if( TxtExcel.getfiles().Archivos.Count > 0 )
|
||||
{
|
||||
Archivo file = TxtExcel.getfiles().Archivos[0];
|
||||
string Directorio = Server.MapPath("~") + file.path;
|
||||
string Directorio = Server.MapPath("~") + file.patch;
|
||||
|
||||
DataTable dt = ReadExcelFile(Directorio + file.filename, true);
|
||||
DataRowCollection Rows = dt.Rows;
|
||||
ClsCRM ObjCRM = new ClsCRM();
|
||||
ObjCRM.IniciaTransacSQL();
|
||||
ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
|
||||
RequestMedioCaptacion RequestMedioCaptacion = new RequestMedioCaptacion(UsuarioActual.CveEmpresa);
|
||||
var ObjMedioCaptacion = cRMService.GetMedioCaptacionCRM(RequestMedioCaptacion);
|
||||
EmpresasCRMModel cRMModel = new EmpresasCRMModel();
|
||||
|
||||
bool TieneError = false;
|
||||
|
||||
foreach (DataRow row in Rows)
|
||||
@@ -178,9 +212,10 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas
|
||||
int CveMedioCaptacion = -1;
|
||||
if (MedioCaptacion != "" || Agente != "") {
|
||||
|
||||
if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa))
|
||||
if (ObjMedioCaptacion.Result.Count > 0)
|
||||
{
|
||||
DataRow MediosCaptacion = ObjCRM.DtResultados.FiltroPrimero(String.Format("MedioCaptacion = '{0}'",MedioCaptacion));
|
||||
DataTable tempMedio = ObjMedioCaptacion.Result.ToDataTable();
|
||||
DataRow MediosCaptacion = tempMedio.FiltroPrimero(String.Format("MedioCaptacion = '{0}'",MedioCaptacion));
|
||||
if(MediosCaptacion != null)
|
||||
{
|
||||
CveMedioCaptacion = MediosCaptacion["CveMedioCaptacion"].ToString().ToEntero();
|
||||
@@ -228,24 +263,30 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas
|
||||
TieneError = true;
|
||||
break;
|
||||
}
|
||||
|
||||
TieneError = (!(ObjCRM.AddEmpresaCRM(NombreEmpresa, RFC, CveMedioCaptacion, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, -1, CveVendedor, CveSubProyecto, Mail, CveGiro) > 0));
|
||||
|
||||
cRMModel.Empresa = NombreEmpresa;
|
||||
cRMModel.RFC = RFC;
|
||||
cRMModel.CveMedioCaptacion = CveMedioCaptacion;
|
||||
cRMModel.CveEmpresa = UsuarioActual.CveEmpresa;
|
||||
cRMModel.CveUsuarioIng = UsuarioActual.CveUsuario;
|
||||
cRMModel.CveEncuestaAplicada = -1;
|
||||
cRMModel.CveVendedorAsignado = CveVendedor;
|
||||
cRMModel.CveSubProyecto = CveSubProyecto;
|
||||
cRMModel.Correo = Mail;
|
||||
cRMModel.CveGiroClasificacion = CveGiro;
|
||||
long CveEmpresaCRM = cRMService.EmpresasCRMAdd(cRMModel).ToEntero();
|
||||
TieneError = CveEmpresaCRM < 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (TieneError)
|
||||
{
|
||||
ObjCRM.RollBack();
|
||||
}else
|
||||
{
|
||||
ObjCRM.Commit();
|
||||
Alert("Prospectos agregados correctamente");
|
||||
TxtExcel.Text = "";
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivCargasMasivas"));
|
||||
}
|
||||
|
||||
ObjCRM.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user