diff --git a/CRM/CatEmpresasCRM.aspx.cs b/CRM/CatEmpresasCRM.aspx.cs index 3f91131e8..729929056 100644 --- a/CRM/CatEmpresasCRM.aspx.cs +++ b/CRM/CatEmpresasCRM.aspx.cs @@ -176,59 +176,62 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas string Correo = row["Correo"].ToString(); int CveMedioCaptacion = -1; - if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa)) - { - DataRow MediosCaptacion = ObjCRM.DtResultados.FiltroPrimero(String.Format("MedioCaptacion = '{0}'",MedioCaptacion)); - if(MediosCaptacion != null) + if (MedioCaptacion != "" || Agente != "") { + + if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa)) { - CveMedioCaptacion = MediosCaptacion["CveMedioCaptacion"].ToString().ToEntero(); + DataRow MediosCaptacion = ObjCRM.DtResultados.FiltroPrimero(String.Format("MedioCaptacion = '{0}'",MedioCaptacion)); + if(MediosCaptacion != null) + { + CveMedioCaptacion = MediosCaptacion["CveMedioCaptacion"].ToString().ToEntero(); + }else + { + Alert(String.Format("El medio de captación '{0}' no fue encontrado", MedioCaptacion), ModExtensiones.TipoMensaje.MsgAdvertencia); + TieneError = true; + break; + } + } + + int CveVendedor = -1; + DataRow Vendedor = get_GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("Vendedor = '{0}'",Agente)); + if (Vendedor != null) + { + CveVendedor = Vendedor["CveVendedor"].ToString().ToEntero(); }else { - Alert(String.Format("El medio de captación '{0}' no fue encontrado", MedioCaptacion), ModExtensiones.TipoMensaje.MsgAdvertencia); + Alert(String.Format("El vendedor '{0}' no fue encontrado", Agente), ModExtensiones.TipoMensaje.MsgAdvertencia); TieneError = true; break; } - } - int CveVendedor = -1; - DataRow Vendedor = get_GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("Vendedor = '{0}'",Agente)); - if (Vendedor != null) - { - CveVendedor = Vendedor["CveVendedor"].ToString().ToEntero(); - }else - { - Alert(String.Format("El vendedor '{0}' no fue encontrado", MedioCaptacion), ModExtensiones.TipoMensaje.MsgAdvertencia); - TieneError = true; - break; - } + int CveSubProyecto = -1; + DataRow SubProyecto = get_GlobalDTSubProyectos(-1,CveEmpresa:UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("SubProyecto = '{0}'",Sucursal)); + if(SubProyecto != null) + { + CveSubProyecto = SubProyecto["CveSubProyecto"].ToString().ToEntero(); + }else + { + Alert(String.Format("El SubProyecto '{0}'", Sucursal), ModExtensiones.TipoMensaje.MsgAdvertencia); + TieneError = true; + break; + } - int CveSubProyecto = -1; - DataRow SubProyecto = get_GlobalDTSubProyectos(-1,CveEmpresa:UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("SubProyecto = '{0}'",Sucursal)); - if(SubProyecto != null) - { - CveSubProyecto = SubProyecto["CveSubProyecto"].ToString().ToEntero(); - }else - { - Alert(String.Format("El SubProyecto '{0}'", Sucursal), ModExtensiones.TipoMensaje.MsgAdvertencia); - TieneError = true; - break; - } + int CveGiro = -1; + DataRow GiroDt = get_GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("ClienteClasificacion = '{0}'", Giro)); + if (GiroDt != null) + { + CveGiro = GiroDt["CveClienteClasificacion"].ToString().ToEntero(); + } + else + { + Alert(String.Format("El Giro de Empresa '{0}', No está especificado", Giro), ModExtensiones.TipoMensaje.MsgAdvertencia); + TieneError = true; + break; + } - int CveGiro = -1; - DataRow GiroDt = get_GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("ClienteClasificacion = '{0}'", Giro)); - if (GiroDt != null) - { - CveGiro = GiroDt["CveClienteClasificacion"].ToString().ToEntero(); - } - else - { - Alert(String.Format("El Giro de Empresa '{0}', No está especificado", Giro), ModExtensiones.TipoMensaje.MsgAdvertencia); - TieneError = true; - break; - } - - TieneError = (!(ObjCRM.AddEmpresaCRM(NombreEmpresa, RFC, CveMedioCaptacion, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, -1, CveVendedor, CveSubProyecto, Mail, CveGiro) > 0)); + TieneError = (!(ObjCRM.AddEmpresaCRM(NombreEmpresa, RFC, CveMedioCaptacion, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, -1, CveVendedor, CveSubProyecto, Mail, CveGiro) > 0)); + } } if (TieneError) diff --git a/CRM/EmpresaCRM.aspx b/CRM/EmpresaCRM.aspx index 3e8c7d744..46b0baf93 100644 --- a/CRM/EmpresaCRM.aspx +++ b/CRM/EmpresaCRM.aspx @@ -88,8 +88,8 @@