diff --git a/CRM/Acercamiento.aspx.cs b/CRM/Acercamiento.aspx.cs
index bd33d2fb3..b58db10e3 100644
--- a/CRM/Acercamiento.aspx.cs
+++ b/CRM/Acercamiento.aspx.cs
@@ -9,6 +9,13 @@ using System.Data;
using Extensiones;
using System.Web.UI.HtmlControls;
+using ADSNetLibrary.SIGAPI.Services.CRM;
+using ADSNetLibrary.SIGAPI.Models.CRM.Request;
+using ADSNetLibrary.SIGAPI.Models.CRM.Response;
+using ADSNetLibrary.SIGAPI.Models.Ventas.Request;
+using ADSNetLibrary.SIGAPI.Models.Ventas.Response;
+using MoreLinq;
+using ADSNetLibrary.SIGAPI.Services;
public partial class CRM_Acercamiento : ClsPaginas
{
@@ -246,6 +253,19 @@ public partial class CRM_Acercamiento : ClsPaginas
ViewState["CvePS"] = value;
}
}
+
+ private Boolean TieneCotizacion
+ {
+ get
+ {
+ return (Boolean)ViewState["TieneCotizacion"];
+ }
+
+ set
+ {
+ ViewState["TieneCotizacion"] = value;
+ }
+ }
#endregion
protected void Page_Load(object sender, EventArgs e)
@@ -290,65 +310,61 @@ public partial class CRM_Acercamiento : ClsPaginas
{
if (CveAcercamiento > 0)
{
- ClsCRM ObjCRM = new ClsCRM();
-
- if (ObjCRM.GetAcercamiento(UsuarioActual.CveEmpresa, CveAcercamiento: CveAcercamiento) && ObjCRM.DtResultados.Rows.Count > 0)
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestAcercamiento AcercamientoModel = new RequestAcercamiento(UsuarioActual.CveEmpresa, CveAcercamiento);
+ var objAcercamiento = cRMService.GetAceracamientoCRM(AcercamientoModel);
+ if (objAcercamiento.Result.Count > 0)
{
- LblEncabezadoAcercamiento.Text = String.Format("
{0}: {1}", ObjCRM.DtResultados.FiltroPrimeroValor("TipoProceso").ToUpper(), ObjCRM.DtResultados.FiltroPrimeroValor("NombreAcercamiento").ToUpper());
- CveTipoProceso = ObjCRM.DtResultados.FiltroPrimeroValor("CveTipoProceso").ToEntero();
+ LblEncabezadoAcercamiento.Text = String.Format("
{0}: {1}", objAcercamiento.Result[0].TipoProceso.ToUpper(), objAcercamiento.Result[0].NombreAcercamiento.ToUpper());
+ CveTipoProceso = objAcercamiento.Result[0].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"));
+ TxtNombreAcercamiento.Text = objAcercamiento.Result[0].NombreAcercamiento;
+ TxtDescripcion.Text = objAcercamiento.Result[0].Descripcion;
+ TxtFechaApertura.Text = objAcercamiento.Result[0].FechaApertura.ToDateTime().ToShortDateString();
+ TxtFechaCierre.Text = (objAcercamiento.Result[0].FechaCierre.ToString() == "") ? "" : objAcercamiento.Result[0].FechaCierre.ToDateTime().ToShortDateString();
+ TxtImporte.Text = String.Format("{0:C2}", objAcercamiento.Result[0].Importe.ToEntero());
+ TxtComision.Text = String.Format("{0:C2}", objAcercamiento.Result[0].Comision.ToEntero());
+ DdlProbabilidadAcercamiento.SelectedValueExist(objAcercamiento.Result[0].CveProbabilidadAcercamiento);
+ DdlPrioridad.SelectedValueExist(objAcercamiento.Result[0].Prioridad);
CargaDdl();
//SECCION DATOS DE LA EMPRESA
- DdlEmpresaCRM.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveEmpresaCRM"));
- //DdlContactoPrincipal.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveContactoPrincipal"));
+ DdlEmpresaCRM.SelectedValueExist(objAcercamiento.Result[0].CveEmpresaCRM);
+
//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"));
+ DdlEtapaProceso.SelectedValueExist(objAcercamiento.Result[0].CveEtapaProcesoActual);
+ DdlVendedor.SelectedValueExist(objAcercamiento.Result[0].CveVendedor);
+ DdlMedioCaptacion.SelectedValueExist(objAcercamiento.Result[0].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");
+ TxtFechaCierreRechazo.Text = (objAcercamiento.Result[0].FechaCierre.ToString() == "") ? DateTime.Now.ToShortDateString() : objAcercamiento.Result[0].FechaCierre.ToDateTime().ToShortDateString();
+ DdlRechazoMotivo.SelectedValueExist(objAcercamiento.Result[0].CveRechazoMotivo);
+ TxtObservacionRechazo.Text = objAcercamiento.Result[0].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;
+ NombreAcercamiento = objAcercamiento.Result[0].NombreAcercamiento.ToUpper();
+ CveEmpresaCRM = objAcercamiento.Result[0].CveEmpresaCRM.ToEntero();
+ CveVendedorAsignado = objAcercamiento.Result[0].CveVendedor.ToEntero();
+ CveContactoPrincipal = (objAcercamiento.Result[0].CveTipoProceso.ToEntero() > 0) ? objAcercamiento.Result[0].CveContactoPrincipal.ToEntero() : -1;
- CveEtapaActual = ObjCRM.DtResultados.FiltroPrimeroValor("CveEtapaProcesoActual").ToEntero();
-
+ CveEtapaActual = objAcercamiento.Result[0].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();
+ CveEncuestaProcesoCRM = (objAcercamiento.Result[0].CveEncuestaProcesoCRM.ToEntero() > 0) ? objAcercamiento.Result[0].CveEncuestaProcesoCRM.ToEntero() : -1;
+ CveEncuestaAplicadaProceso = (objAcercamiento.Result[0].CveEncuestaAplicadaProceso.ToEntero() > 0) ? objAcercamiento.Result[0].CveEncuestaAplicadaProceso.ToEntero() : -1;
+
+ CvePS = objAcercamiento.Result[0].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);
@@ -361,7 +377,6 @@ public partial class CRM_Acercamiento : ClsPaginas
CveEncuestaProcesoCRM = -1;
CveEncuestaAplicadaProceso = -1;
}
- ObjCRM.Dispose();
if (CveAcercamiento > 0)
{
@@ -429,47 +444,53 @@ public partial class CRM_Acercamiento : ClsPaginas
protected void CargaDdl()
{
- ClsCRM ObjCRM = new ClsCRM();
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestProbalidadAcercamiento ProbalidadAcercamiento = new RequestProbalidadAcercamiento(UsuarioActual.CveEmpresa, 1);
+ var ObjProbalidadAcercamiento = cRMService.GetProbabilidadAceracamientoCRM(ProbalidadAcercamiento);
+ RequestEmpresasCRM EmpresaCRM = new RequestEmpresasCRM(UsuarioActual.CveEmpresa, -1);
+ var objEmpresaCRM = cRMService.GetEmpresasCRM(EmpresaCRM);
+ RequestMedioCaptacion MedioCaptacion = new RequestMedioCaptacion(UsuarioActual.CveEmpresa);
+ var ObjMedioCaptacion = cRMService.GetMedioCaptacionCRM(MedioCaptacion);
- if (ObjCRM.GetProbabilidadAcercamiento(UsuarioActual.CveEmpresa, 1))
+ if (ObjProbalidadAcercamiento.Result.Count > 0)
{
- DdlProbabilidadAcercamiento.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}", CveTipoProceso));
+ DataTable DtProbabilidadAcercamiento = ObjProbalidadAcercamiento.Result.ToDataTable();
+ DdlProbabilidadAcercamiento.DataSource = DtProbabilidadAcercamiento.FiltraParametros(String.Format("CveTipoProceso = {0}", CveTipoProceso));
}
- if (ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa))
+
+
+ if (objEmpresaCRM.Result.Count > 0)
{
- DdlEmpresaCRM.DataSource = ObjCRM.DtResultados;
+ DdlEmpresaCRM.DataSource = objEmpresaCRM.Result;
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))
+
+
+ if (ObjMedioCaptacion.Result.Count > 0)
{
- DdlMedioCaptacion.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}",CveTipoProceso));
+ DataTable DTMedioCaptacion = ObjMedioCaptacion.Result.ToDataTable();
+ DdlMedioCaptacion.DataSource = DTMedioCaptacion.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))
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestRechazoMotivo RequestRechazoMotivo = new RequestRechazoMotivo(UsuarioActual.CveEmpresa, 1, CveTipoProceso);
+ var objRequestRechazoMotivo = cRMService.GetRechazoMotivoCRM(RequestRechazoMotivo);
+ if (objRequestRechazoMotivo.Result.Count > 0)
{
- DdlRechazoMotivo.DataSource = ObjCRM.DtResultados;
+ DdlRechazoMotivo.DataSource = objRequestRechazoMotivo.Result;
DdlRechazoMotivo.Items.Insert(0, new ListItem("Seleccione ", "-1"));
}
- ObjCRM.Dispose();
DdlRechazoMotivo.DataBind();
}
@@ -500,17 +521,19 @@ public partial class CRM_Acercamiento : ClsPaginas
protected void CargaContactos(int CveEmpresaCRM)
{
DdlContactoPrincipal.Items.Clear();
- ClsCRM ObjCRM = new ClsCRM();
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestContactoEmpresaCRM contactoEmpresaCRM = new RequestContactoEmpresaCRM(CveEmpresaCRM, UsuarioActual.CveEmpresa);
+ var objcontactoEmpresa = cRMService.GetContactosEmpresasCRM(contactoEmpresaCRM);
- if (ObjCRM.GetContactoEmpresa(CveEmpresaCRM))
+ if (objcontactoEmpresa.Result.Count > 0)
{
- DdlContactoPrincipal.DataSource = ObjCRM.DtResultados;
- DdlContactoAgenda.DataSource = ObjCRM.DtResultados;
+ DdlContactoPrincipal.DataSource = objcontactoEmpresa.Result;
+ DdlContactoAgenda.DataSource = objcontactoEmpresa.Result;
}
DdlContactoPrincipal.Items.Insert(0, new ListItem("Seleccione ", "-1"));
DdlContactoAgenda.Items.Insert(0, new ListItem("Seleccione ", "-1"));
- ObjCRM.Dispose();
+ //ObjCRM.Dispose();
DdlContactoPrincipal.DataBind();
DdlContactoAgenda.DataBind();
@@ -532,11 +555,13 @@ public partial class CRM_Acercamiento : ClsPaginas
{
//DDLs
DdlEtapaProceso.Items.Clear();
- ClsCRM ObjCRM = new ClsCRM();
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestEtapaProceso EtapaProceso = new RequestEtapaProceso(UsuarioActual.CveEmpresa, 1, CveTipoProceso);
+ var ObjEtapaProceso = cRMService.GetEtapaProcesoCRM(EtapaProceso);
- if (ObjCRM.GetEtapaProceso(UsuarioActual.CveEmpresa, CveTipoProceso, CveEstatus: 1))
+ if (ObjEtapaProceso.Result.Count > 0)
{
- DTEtapasProceso = ObjCRM.DtResultados;
+ DTEtapasProceso = ObjEtapaProceso.Result.ToDataTable();
OrdenEtapaActual = DTEtapasProceso.FiltroPrimeroValor("Orden", String.Format("CveEtapaProceso = {0}", CveEtapaActual)).ToEntero();
//SI LA ETAPA ES CANCELACION HABILITA MOSTRAR LAS DOS ETAPAS ANTERIORES
@@ -549,7 +574,6 @@ public partial class CRM_Acercamiento : ClsPaginas
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)
@@ -590,16 +614,16 @@ public partial class CRM_Acercamiento : ClsPaginas
if (CveAcercamiento > 0)
{
ClsCRM ObjCRM = new ClsCRM();
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ AcercaminetoModel AcercaminetoModel = new AcercaminetoModel();
+
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();
@@ -629,9 +653,25 @@ public partial class CRM_Acercamiento : ClsPaginas
{
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()))
+ AcercaminetoModel.CveAcercamiento = CveAcercamiento;
+ AcercaminetoModel.CveContactoPrincipal = CveContactoPrincipal;
+ AcercaminetoModel.CveTipoProceso = CveTipoProceso;
+ AcercaminetoModel.CveEtapaProcesoActual = CveEtapaProcesoActualActualizar;
+ AcercaminetoModel.CveVendedor = CveVendedor;
+ AcercaminetoModel.CveMedioCaptacion = CveMedioCaptacion;
+ AcercaminetoModel.CveProbabilidadAcercamiento = CveProbabilidadAcercamiento;
+ AcercaminetoModel.NombreAcercamiento = NombreAcercamiento;
+ AcercaminetoModel.Descripcion = Descripcion;
+ AcercaminetoModel.Importe = Importe;
+ AcercaminetoModel.Comision = Comision;
+ AcercaminetoModel.Prioridad = Prioridad;
+ AcercaminetoModel.CveUsuarioIng = UsuarioActual.CveUsuario;
+ AcercaminetoModel.CveEncuestaAplicadaProceso = CveEncuestaAplicadaProceso;
+ AcercaminetoModel.FechaApertura = FechaApertura;
+ AcercaminetoModel.FechaCierre = (DateTime)FechaCierre;
+ AcercaminetoModel.CvePS = DdlPS.SelectedValue.ToEntero();
+
+ if (cRMService.AcercamientoUpdate(AcercaminetoModel))
{
//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);
@@ -644,9 +684,6 @@ public partial class CRM_Acercamiento : ClsPaginas
//}
}
- if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
-
- ObjCRM.Dispose();
ObjDatosTecnicos.Dispose();
//CARGA BITACORA
@@ -669,8 +706,8 @@ public partial class CRM_Acercamiento : ClsPaginas
protected void GuardarCambioEtapa()
{
- ClsCRM ObjCRM = new ClsCRM();
-
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ AcercaminetoModel AcercaminetoModel = new AcercaminetoModel();
String NombreAcercamiento = TxtNombreAcercamiento.Text;
String Descripcion = TxtDescripcion.Text == "" ? "-1" : TxtDescripcion.Text;
@@ -696,15 +733,30 @@ public partial class CRM_Acercamiento : ClsPaginas
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()))
+ AcercaminetoModel.CveAcercamiento = CveAcercamiento;
+ AcercaminetoModel.CveContactoPrincipal = CveContactoPrincipal;
+ AcercaminetoModel.CveTipoProceso = CveTipoProceso;
+ AcercaminetoModel.CveEtapaProcesoActual = CveEtapaProcesoActualActualizar;
+ AcercaminetoModel.CveVendedor = CveVendedor;
+ AcercaminetoModel.CveMedioCaptacion = CveMedioCaptacion;
+ AcercaminetoModel.CveProbabilidadAcercamiento = CveProbabilidadAcercamiento;
+ AcercaminetoModel.NombreAcercamiento = NombreAcercamiento;
+ AcercaminetoModel.Descripcion = Descripcion;
+ AcercaminetoModel.Importe = Importe;
+ AcercaminetoModel.Comision = Comision;
+ AcercaminetoModel.Prioridad = Prioridad;
+ AcercaminetoModel.CveUsuarioIng = UsuarioActual.CveUsuario;
+ AcercaminetoModel.CveEncuestaAplicadaProceso = CveEncuestaAplicadaProceso;
+ AcercaminetoModel.FechaApertura = FechaApertura;
+ AcercaminetoModel.FechaCierre = (DateTime)FechaCierre;
+ AcercaminetoModel.CvePS = DdlPS.SelectedValue.ToEntero();
+
+ if (cRMService.AcercamientoUpdate(AcercaminetoModel))
{
CveEtapaActual = CveEtapaProcesoActualActualizar;
HdfEtapaSeleccionada.Value = CveEtapaProcesoActualActualizar.ToString();
-
}
- ObjCRM.Dispose();
//CARGA BITACORA
CargaEtapasProceso(CveTipoProceso);
@@ -731,25 +783,28 @@ public partial class CRM_Acercamiento : ClsPaginas
ClsCRM ObjCRM = new ClsCRM();
ClsOIEventos objBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestAcercamiento acercamiento = new RequestAcercamiento(UsuarioActual.CveEmpresa, CveAcercamiento);
- if (ObjCRM.RemoveAcercamiento(CveAcercamiento, UsuarioActual.CveEmpresa))
+ if (TieneCotizacion)
{
- if (objBitacora.AddEventoBitacora(String.Format("Se eliminó el Acercamiento {0} de tipo {1}", NombreAcercamiento, TipoProceso), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
+ if (cRMService.AcercamientoDelete(acercamiento))
{
- HuboError = false;
+ 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)
+ {
+ Alert("El Acercamiento ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion, String.Format("document.location.href=\"/CRM/EmpresaCRM.aspx?CveEmpresaCRM={0}\"", CveEmpresaCRM));
}
- }
- 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();
+ Alert("No se puede eliminar el acercamiento porque el prospecto cuenta con cotizaciones/facturaciones previas.", ModExtensiones.TipoMensaje.MsgError);
}
- ObjCRM.Dispose();
objBitacora.Dispose();
}
#endregion
@@ -811,7 +866,8 @@ public partial class CRM_Acercamiento : ClsPaginas
protected void BtnRegistrarCierreCancelacion_Click(object sender, EventArgs e)
{
- ClsCRM ObjCRM = new ClsCRM();
+ //ClsCRM ObjCRM = new ClsCRM();
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
//ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
//Boolean HuboError = true;
@@ -822,7 +878,16 @@ public partial class CRM_Acercamiento : ClsPaginas
String TituloCierre = DTEtapasProceso.FiltroPrimeroValor("EtapaProceso", "CveTipoEtapa = 4");
- if (ObjCRM.UpdateAcercamientoCierre(CveAcercamiento, CveEtapaCierre, CveRechazoMotivo, UsuarioActual.CveUsuario, FechaCierre, Observacion))
+
+ AcercaminetoModel acercamiento = new AcercaminetoModel();
+ acercamiento.CveAcercamiento = CveAcercamiento;
+ acercamiento.CveEtapaProcesoActual = CveEtapaCierre;
+ acercamiento.CveRechazoMotivo = CveRechazoMotivo;
+ acercamiento.CveUsuarioIng = UsuarioActual.CveUsuario;
+ acercamiento.FechaCierre = FechaCierre;
+ acercamiento.ObservacionRechazo = Observacion;
+
+ if (cRMService.AcercamientoCierreUpdate(acercamiento))
{
String MensajeBitacora = "";
if (CveEtapaActual == CveEtapaCierre)
@@ -839,7 +904,7 @@ public partial class CRM_Acercamiento : ClsPaginas
//if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
- ObjCRM.Dispose();
+ //ObjCRM.Dispose();
//ObjBitacora.Dispose();
CveEtapaActual = CveEtapaCierre;
@@ -855,23 +920,27 @@ public partial class CRM_Acercamiento : ClsPaginas
protected void CargaEtapasBitacora()
{
//CARGA STEP DE PASOS
- ClsCRM ObjCRM = new ClsCRM();
+ //ClsCRM ObjCRM = new ClsCRM();
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestEtapaProceso EtapaProceso = new RequestEtapaProceso(UsuarioActual.CveEmpresa, 1, CveTipoProceso);
+ var ObjEtapaProceso = cRMService.GetEtapaProcesoCRM(EtapaProceso);
- if (ObjCRM.GetEtapaProceso(UsuarioActual.CveEmpresa, CveTipoProceso, CveEstatus: 1))
+ if (ObjEtapaProceso.Result.Count > 0)
{
- TipoProceso = ObjCRM.DtResultados.FiltroPrimeroValor("TipoProceso").ToUpper();
+ DataTable DTTemp = ObjEtapaProceso.Result.ToDataTable();
+ TipoProceso = DTTemp.FiltroPrimeroValor("TipoProceso").ToUpper();
int CveEtapaCierreCancelacion = DTEtapasProceso.FiltroPrimeroValor("CveEtapaProceso", "CveTipoEtapa = 4").ToEntero();
- NumeroEtapasProceso = ObjCRM.DtResultados.FiltraParametros("CveTipoEtapa IN(1,2,3)").Rows.Count;
+ NumeroEtapasProceso = DTTemp.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)");
+ RptStepsEtapasProceso.DataSource = DTTemp.FiltraParametros("CveTipoEtapa IN(1,2,4)");
else
- RptStepsEtapasProceso.DataSource = ObjCRM.DtResultados.FiltraParametros("CveTipoEtapa IN(1,2,3)");
+ RptStepsEtapasProceso.DataSource = DTTemp.FiltraParametros("CveTipoEtapa IN(1,2,3)");
}
- ObjCRM.Dispose();
+ //ObjCRM.Dispose();
//RptTabsEtapasProcesos.DataBind();
RptStepsEtapasProceso.DataBind();
//SpanProceso.InnerText = TipoProceso + ":";
@@ -1027,19 +1096,6 @@ public partial class CRM_Acercamiento : ClsPaginas
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();
@@ -1059,7 +1115,7 @@ public partial class CRM_Acercamiento : ClsPaginas
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(@"{0}OI", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:false);
+ filemove.FilesMove(string.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString()), string.Format(@"Empresas\{0}\OI", UsuarioActual.CveEmpresa));
TxtEventoDescripcion.Text = "";
@@ -1122,9 +1178,6 @@ public partial class CRM_Acercamiento : ClsPaginas
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();
-
}
}
@@ -1401,7 +1454,7 @@ public partial class CRM_Acercamiento : ClsPaginas
return _CveEncuestaAplicada;
}
#endregion
-
+
#region "MUESTRA UBICACION GEOGRAFICA"
protected void LnkVerUbicacion_Click(object sender, EventArgs e)
{
@@ -1416,9 +1469,13 @@ public partial class CRM_Acercamiento : ClsPaginas
protected void CargaImagenes()
{
var ObjCRM = new ClsCRM();
- if (ObjCRM.GetImagenesAcercamiento(CveAcercamiento))
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestImagenesAcercamiento ImagenesAcercamiento = new RequestImagenesAcercamiento(CveAcercamiento);
+
+ var objImagenesAcercamiento = cRMService.ImagenesAcercamientoGet(ImagenesAcercamiento);
+ if (objImagenesAcercamiento.Result.Count > 0)
{
- RptFotos.DataSource = ObjCRM.DtResultados;
+ RptFotos.DataSource = objImagenesAcercamiento.Result;
}
ObjCRM.Dispose();
RptFotos.DataBind();
@@ -1429,6 +1486,9 @@ public partial class CRM_Acercamiento : ClsPaginas
bool TieneError = false;
var ObjCRM = new ClsCRM();
ObjCRM.IniciaTransacSQL();
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestImagenesAcercamiento ImagenesAcercamiento = new RequestImagenesAcercamiento(CveAcercamiento, UsuarioActual.CveEmpresa, CveEmpresaCRM, -1, "", TxtTituloImagen.Text, TxtDescripcionImagen.Text, "-1", UsuarioActual.CveUsuario);
+
try
{
foreach (var item in TxtUpFotos.getfiles().Archivos)
@@ -1444,11 +1504,11 @@ public partial class CRM_Acercamiento : ClsPaginas
break;
}
- int CveArchivo = ObjCRM.AddImagenAcercamiento("", TxtTituloImagen.Text, TxtDescripcionImagen.Text, UsuarioActual.CveUsuario, CveEmpresaCRM, CveAcercamiento, UsuarioActual.CveEmpresa);
+ int CveArchivo = cRMService.ImagenesAcercamientoAdd(ImagenesAcercamiento).ToEntero();
if ((CveArchivo > 0))
{
string NombreNuevo = string.Format("{0}{1}", CveArchivo, FileExtension);
- string DirectorioNuevo = string.Format("{0}Acercamientos\\{1}\\Imagenes\\", UsuarioActual.Empresa.Ruta, CveAcercamiento);
+ string DirectorioNuevo = string.Format("{0}\\Empresas\\{1}\\Acercamientos\\{2}\\Imagenes\\", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, CveAcercamiento);
if (!Directory.Exists(DirectorioNuevo))
{
Directory.CreateDirectory(DirectorioNuevo);
@@ -1456,7 +1516,9 @@ public partial class CRM_Acercamiento : ClsPaginas
DirectorioNuevo = DirectorioNuevo + NombreNuevo;
var DirectorioViejo = string.Format("{0}Temp\\{1}", AppDomain.CurrentDomain.BaseDirectory, item.filename);
- if (ObjCRM.UpdateImagenAcercamiento(CveArchivo, NombreNuevo, TxtTituloImagen.Text, TxtDescripcionImagen.Text))
+ RequestImagenesAcercamiento ImagenesAcercamientoUpdate = new RequestImagenesAcercamiento(CveAcercamiento, UsuarioActual.CveEmpresa, CveEmpresaCRM, CveArchivo, NombreNuevo, TxtTituloImagen.Text, TxtDescripcionImagen.Text);
+
+ if (cRMService.ImagenesAcercamientoUpdate(ImagenesAcercamientoUpdate))
{
File.Move(DirectorioViejo, DirectorioNuevo);
}
@@ -1504,7 +1566,10 @@ public partial class CRM_Acercamiento : ClsPaginas
if (CveArchivo > 0)
{
var ObjCRM = new ClsCRM();
- bool Elimino = ObjCRM.RemoveImagenesAcercamiento(CveArchivo);
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestImagenesAcercamiento ImagenesAcercamiento = new RequestImagenesAcercamiento(-1, CveArchivo: CveArchivo);
+
+ bool Elimino = cRMService.ImagenesAcercamientoDelete(ImagenesAcercamiento);
ObjCRM.Dispose();
if (Elimino)
@@ -1522,9 +1587,14 @@ public partial class CRM_Acercamiento : ClsPaginas
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))
+ IVentaService ventaService = new VentaService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestVentas requestVentas = new RequestVentas(UsuarioActual.CveEmpresa, TipoDocto: "Cot", CveEmpresaCRM: CveEmpresaCRM, CveUsuarioConsulta: UsuarioActual.CveUsuario, CveAcercamientoCRM: CveAcercamiento);
+ var objVentas = ventaService.GetVentas(requestVentas);
+
+ if (objVentas.IsSuccess)
{
- GvCotizacion.DataSource = ObjVentas.DtResultados;
+ GvCotizacion.DataSource = objVentas.Result;
+ TieneCotizacion = objVentas.Result.Count > 0;
}
ObjVentas.Dispose();
GvCotizacion.DataBind();
@@ -1549,9 +1619,14 @@ public partial class CRM_Acercamiento : ClsPaginas
protected void CargaGastos()
{
ClsCRM ObjCRM = new ClsCRM();
- if (ObjCRM.GetAcercamientosGastos(CveAcercamiento))
+
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestAcermientoGastos AcermientoGastos = new RequestAcermientoGastos(CveAcercamiento);
+
+ var objAcermientoGastos = cRMService.AcercamientosGastosGet(AcermientoGastos);
+ if (objAcermientoGastos.Result.Count > 0)
{
- GvGastos.DataSource = ObjCRM.DtResultados;
+ GvGastos.DataSource = objAcermientoGastos.Result;
}
ObjCRM.Dispose();
GvGastos.DataBind();
@@ -1576,10 +1651,11 @@ public partial class CRM_Acercamiento : ClsPaginas
protected void BtnAgregarGastoModal_Click(object sender, EventArgs e)
{
ClsCRM ObjCRM = new ClsCRM();
-
- if(!Actualizar)
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestAcermientoGastos AcermientoGastos = new RequestAcermientoGastos(CveAcercamiento, -1, TxtDescripcionGasto.Text, TxtImporteGasto.Text.ToDecimal(), UsuarioActual.CveUsuario);
+ if (!Actualizar)
{
- if (ObjCRM.AddAcercamientosGastos(CveAcercamiento, TxtDescripcionGasto.Text, TxtImporteGasto.Text.ToDecimal(), UsuarioActual.CveUsuario))
+ if (cRMService.AcercamientosGastosAdd(AcermientoGastos))
{
CargaGastos();
@@ -1593,7 +1669,7 @@ public partial class CRM_Acercamiento : ClsPaginas
}
else
{
- if (ObjCRM.UpdateAcercamientosGastos(CveAcercamientoGasto, TxtDescripcionGasto.Text, TxtImporteGasto.Text.ToDecimal()))
+ if (cRMService.AcercamientosGastosUpdate(AcermientoGastos))
{
CargaGastos();
@@ -1647,10 +1723,11 @@ public partial class CRM_Acercamiento : ClsPaginas
{
ClsCRM ObjCRM = new ClsCRM();
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
CveAcercamientoGasto = GvRow.DataKey("CveAcercamientoGasto").ToEntero();
-
- if (ObjCRM.RemoveAcercamientosGastos(CveAcercamientoGasto))
+ RequestAcermientoGastos AcermientoGastos = new RequestAcermientoGastos(CveAcercamiento, CveAcercamientoGasto: CveAcercamientoGasto);
+ if (cRMService.AcercamientosGastosDelete(AcermientoGastos))
{
CargaGastos();
Alert("Gasto eliminado Correctamente", ModExtensiones.TipoMensaje.MsgInformacion);
diff --git a/CRM/CatEmpresasCRM.aspx.cs b/CRM/CatEmpresasCRM.aspx.cs
index 89eff8ed4..d7b7b4a1f 100644
--- a/CRM/CatEmpresasCRM.aspx.cs
+++ b/CRM/CatEmpresasCRM.aspx.cs
@@ -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();
}
@@ -156,8 +187,11 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas
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();
}
}
diff --git a/CRM/EmpresaCRM.aspx.cs b/CRM/EmpresaCRM.aspx.cs
index d411c482a..5728ac656 100644
--- a/CRM/EmpresaCRM.aspx.cs
+++ b/CRM/EmpresaCRM.aspx.cs
@@ -6,8 +6,14 @@ using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
-
+using ADSNetLibrary.SIGAPI.Services.CRM;
+using ADSNetLibrary.SIGAPI.Models.CRM.Request;
+using ADSNetLibrary.SIGAPI.Models.CRM.Response;
+using ADSNetLibrary.SIGAPI.Models.Ventas.Request;
+using ADSNetLibrary.SIGAPI.Models.Ventas.Response;
using Extensiones;
+using MoreLinq;
+using ADSNetLibrary.SIGAPI.Services;
public partial class CRM_EmpresaCRM : ClsPaginas
{
@@ -236,7 +242,7 @@ public partial class CRM_EmpresaCRM : ClsPaginas
{
if (!IsPostBack)
{
- CreoCliente = false;
+ CreoCliente = false;
RecuperaCve();
CargaTipoProceso();
CargaMetodosCaptacion();
@@ -265,8 +271,11 @@ public partial class CRM_EmpresaCRM : ClsPaginas
ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
ClsEncuestas ObjDatosTecnicos = new ClsEncuestas(ObjCRM.IniciaTransacSQL());
- Boolean HuboError = false;
+ 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();
@@ -277,6 +286,7 @@ public partial class CRM_EmpresaCRM : ClsPaginas
int CveMedioCaptacion = DdlMedioCaptacion.SelectedValue.ToEntero();
int CveVendedorActualizar = DdlVendedorAsignado.SelectedValue.ToEntero();
int CveSubProyecto = DdlSucursales.SelectedValue.ToEntero();
+ int CveTipoProceso = DdlTipoProceso2.SelectedValue.ToEntero();
if (!EsEditar)
{
@@ -291,7 +301,30 @@ public partial class CRM_EmpresaCRM : ClsPaginas
{
string Mensaje = "";
//DATOS GENERALES
- CveEmpresaCRM = ObjCRM.AddEmpresaCRM(NombreEmpresa, RFC, CveMedioCaptacion, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, CveEncuestaAplicada, CveVendedorActualizar, CveSubProyecto, Correo, DdlGiroClasificacion.SelectedValue.ToEntero());
+ 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)
{
@@ -310,19 +343,36 @@ public partial class CRM_EmpresaCRM : ClsPaginas
foreach (DataRow row in TempDTContactos.Rows)
{
- if (!ObjCRM.AddContactoEmpresa(row["Nombre"].ToString(), row["TelefonoOficina"].ToString(), row["Celular"].ToString(), row["Correo"].ToString(), CveEmpresaCRM, UsuarioActual.CveUsuario))
- HuboError = true;
- else
+ 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))
+
- i++;
}
}
if (!ObjBitacora.AddEventoBitacora(Mensaje, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
{
HuboError = true;
- }else
+ }
+ else
{
string asunto = String.Format("Se registró la empresa {0} con datos RFC: {1}, Vendedor: {2}", NombreEmpresa, RFC, Vendedor);
mandarCorreo(asunto, Mensaje);
@@ -338,16 +388,35 @@ public partial class CRM_EmpresaCRM : ClsPaginas
CveEncuestaAplicada = GuardaDatosTecnicos(ObjDatosTecnicos, CveEncuestaAplicada);
}
- if ((CveEncuestaAplicada != 0) && ObjCRM.UpdateEmpresCRM(NombreEmpresa, RFC, CveMedioCaptacion, CveEmpresaCRM, CveVendedorActualizar, UsuarioActual.CveUsuario, CveSubProyecto: CveSubProyecto, Correo: Correo,CveGiroClasificacion:DdlGiroClasificacion.SelectedValue.ToEntero()))
+ if (CveEncuestaAplicada != 0)
{
- if (!ObjBitacora.AddEventoBitacora(String.Format("Se actualizó la empresa {0} con RFC {1}", NombreEmpresa, RFC), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
+ 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;
- }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);
}
}
}
@@ -360,7 +429,11 @@ public partial class CRM_EmpresaCRM : ClsPaginas
else
Alert(String.Format("La Empresa
{0} fue actualizada correctamente.", NombreEmpresa), ModExtensiones.TipoMensaje.MsgInformacion);
}
- else { ObjCRM.RollBack(); }
+ else
+ {
+ Alert("Ocurrio un error la guardar la informacion de la empresa", ModExtensiones.TipoMensaje.MsgError);
+ ObjCRM.RollBack();
+ }
ObjCRM.Dispose();
ObjBitacora.Dispose();
@@ -568,29 +641,39 @@ public partial class CRM_EmpresaCRM : ClsPaginas
protected void CargaTipoProceso()
{
- ClsCRM ObjCRM = new ClsCRM();
- if (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa))
+ //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 = ObjCRM.DtResultados;
- DdlTipoProceso2.Items.Insert(0, new ListItem("Seleccione","-1"));
+ DdlTipoProceso2.DataSource = ObjTipoProceso.Result;
+ DdlTipoProceso2.Items.Insert(0, new ListItem("Seleccione", "-1"));
}
DdlTipoProceso2.DataBind();
- ObjCRM.Dispose();
+ //ObjCRM.Dispose();
}
protected void CargaMetodosCaptacion()
{
- ClsCRM ObjCRM = new ClsCRM();
- if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa, -1))
+ //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)
{
- DdlMedioCaptacion.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}", DdlTipoProceso2.SelectedValue));
+ 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 = ObjCRM.DtResultados;
- DtMedioCaptacion = ObjCRM.DtResultados;
+ DdlMedioCaptacionAcercamiento.DataSource = tempMedio;
+ DtMedioCaptacion = tempMedio;
DdlMedioCaptacionAcercamiento.Items.Insert(0, new ListItem("Seleccione ", "-1"));
}
- ObjCRM.Dispose();
+ //ObjCRM.Dispose();
DdlMedioCaptacion.DataBind();
DdlMedioCaptacionAcercamiento.DataBind();
}
@@ -628,26 +711,25 @@ public partial class CRM_EmpresaCRM : ClsPaginas
if (CveEmpresaCRM > 0)
{
- ClsCRM ObjCRM = new ClsCRM();
-
- if (ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa, CveEmpresaCRM) && 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, CveEmpresaCRM);
+ var objServicio = cRMService.GetEmpresasCRM(parametros);
+ if (objServicio.Result.Count > 0)
{
EsEditar = true;
-
- LblEncabezadoEmpresa.Text = String.Format("Consulta de la Empresa: {0}", ObjCRM.DtResultados.FiltroPrimeroValor("Empresa").ToUpper());
-
- TxtNombreEmpresa.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Empresa");
- TxtRFC.Text = ObjCRM.DtResultados.FiltroPrimeroValor("RFC");
- DdlTipoProceso2.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveTipoProceso"));
+ 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 = ObjCRM.DtResultados.FiltroPrimeroValor("Correo");
- DdlMedioCaptacion.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveMedioCaptacion"));
-
- CveEncuestaAplicada = ObjCRM.DtResultados.FiltroPrimeroValor("CveEncuestaAplicada") != "" ? ObjCRM.DtResultados.FiltroPrimeroValor("CveEncuestaAplicada").ToEntero() : -1;
- CveVendedor = ObjCRM.DtResultados.FiltroPrimeroValor("CveVendedorAsignado").ToEntero();
- CveSubProyecto = ObjCRM.DtResultados.FiltroPrimeroValor("CveSubProyecto").ToEntero();
- CveCliente = ObjCRM.DtResultados.FiltroPrimeroValor("CveCliente").ToEntero();
- CveGiroClasificacion = ObjCRM.DtResultados.FiltroPrimeroValor("CveGiroClasificacion") != "" ? ObjCRM.DtResultados.FiltroPrimeroValor("CveGiroClasificacion").ToEntero() : -1;
+ 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))
{
@@ -655,11 +737,11 @@ public partial class CRM_EmpresaCRM : ClsPaginas
HplCrearCliente.NavigateUrl = String.Format("/Ventas/Clientes.aspx?CveEmpresaCRM={0}", CveEmpresaCRM);
}
- CargaContactos(ObjCRM);
+ CargaContactos();
ActivaSeccionAcercamientos();
- CargaAcercamientos(ObjCRM);
+ CargaAcercamientos();
- InicializaAcercamientos(ObjCRM);
+ InicializaAcercamientos();
CargaCotizaciones();
@@ -676,7 +758,6 @@ public partial class CRM_EmpresaCRM : ClsPaginas
CveGiroClasificacion = -1;
}
- ObjCRM.Dispose();
UpDatos.Update();
BtnGuardarEmpresa.Text = "Actualizar";
@@ -707,14 +788,15 @@ public partial class CRM_EmpresaCRM : ClsPaginas
protected void DdlTipoProceso_Change(object sender, EventArgs e)
{
DdlMedioCaptacionAcercamiento.Items.Clear();
- DdlMedioCaptacionAcercamiento.DataSource = DtMedioCaptacion.FiltraParametros(String.Format("CveTipoProceso = {0}",DdlTipoProceso.SelectedValue.ToEntero()));
+ DdlMedioCaptacionAcercamiento.DataSource = DtMedioCaptacion.FiltraParametros(String.Format("CveTipoProceso = {0}", DdlTipoProceso.SelectedValue.ToEntero()));
DdlMedioCaptacionAcercamiento.DataBind();
if (DdlTipoProceso.SelectedValue != "-1")
{
DdlMedioCaptacionAcercamiento.Enabled = true;
- }else
+ }
+ else
{
- DdlMedioCaptacionAcercamiento.Items.Insert(0,new ListItem("Seleccione","-1"));
+ DdlMedioCaptacionAcercamiento.Items.Insert(0, new ListItem("Seleccione", "-1"));
DdlMedioCaptacionAcercamiento.Enabled = false;
}
@@ -738,20 +820,40 @@ public partial class CRM_EmpresaCRM : ClsPaginas
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());
-
- if (ObjCRM.RemoveContactoEmpresa(-1, CveEmpresaCRM))
+ if (objAcercamiento.Result.Count == 0)
{
- if (ObjCRM.RemoveEmpresaCRM(CveEmpresaCRM))
- {
- HuboError = false;
- if (CveEncuestaAplicada > 0 && !objDatosTecnicos.RemoveEncuestaAplicada(CveEncuestaAplicada, UsuarioActual.CveEmpresa))
+ if (cRMService.EmpresasCRMContactoDelete(ContactoEmpresaCRM))
+ {
+ if (cRMService.EmpresasCRMDelete(EmpresasCRM))
+ {
+ HuboError = false;
+ if (CveEncuestaAplicada > 0 && !objDatosTecnicos.RemoveEncuestaAplicada(CveEncuestaAplicada, UsuarioActual.CveEmpresa))
+ {
+ HuboError = true;
+ }
+ }
+ else
{
HuboError = true;
}
+
}
+ else
+ {
+ HuboError = true;
+ }
+ }
+ else
+ {
+ Alert("No se puede eliminar la empresa porque el prospecto cuenta con cotizaciones/facturaciones previa", ModExtensiones.TipoMensaje.MsgAdvertencia);
}
if (!HuboError)
@@ -759,7 +861,12 @@ public partial class CRM_EmpresaCRM : ClsPaginas
ObjCRM.Commit();
Alert("La Empresa ha sido eliminado.", ModExtensiones.TipoMensaje.MsgInformacion, "document.location.href=\"/CRM/CatEmpresasCRM.aspx\"");
}
- else { ObjCRM.RollBack(); }
+ else
+ {
+ ObjCRM.RollBack();
+ Alert("Ocurrio un error al intentar eliminar la empresa.", ModExtensiones.TipoMensaje.MsgError);
+
+ }
ObjCRM.Dispose();
objDatosTecnicos.Dispose();
@@ -810,13 +917,15 @@ public partial class CRM_EmpresaCRM : ClsPaginas
UpContactos.Update();
}
- protected void CargaContactos(ClsCRM objCRM)
+ protected void CargaContactos()
{
TempDTContactos = null;
-
- if (objCRM.GetContactoEmpresa(CveEmpresaCRM))
+ 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.DtResultados;
+ DTContactos = objCRM.Result.ToDataTable();
GVContactos.DataSource = DTContactos;
GVContactos.DataBind();
@@ -897,13 +1006,23 @@ public partial class CRM_EmpresaCRM : ClsPaginas
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)
{
- if (ObjCRM.AddContactoEmpresa(NombreContacto, TelefonoOficina, Celular, Correo, CveEmpresaCRM, CveUsuarioIng))
+ contacto.Nombre = NombreContacto;
+ contacto.TelefonoOficina = TelefonoOficina;
+ contacto.Celular = Celular;
+ contacto.Correo = Correo;
+ contacto.CveEmpresaCRM = CveEmpresaCRM;
+ contacto.CveUsuarioIng = CveUsuarioIng;
+
+ if (cRMService.EmpresasCRMContactoAdd(contacto))
{
TelefonoOficina = (TelefonoOficina != "-1" ? String.Format(", Teléfono de Oficina: {0:(###) ###-####}", Convert.ToInt64(TelefonoOficina)) : "");
Celular = (Celular != "-1" ? String.Format(", Celular: {0:(###) ###-####}", Convert.ToInt64(Celular)) : "");
@@ -912,16 +1031,29 @@ public partial class CRM_EmpresaCRM : ClsPaginas
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);
+ 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:
{0}. ", NombreContacto), ModExtensiones.TipoMensaje.MsgError);
+
+ }
}
else
{
- if (ObjCRM.UpdateContactoEmpresa(NombreContacto, TelefonoOficina, Celular, Correo, CveContactoEditado, UsuarioActual.CveUsuario))
+ contacto.Nombre = NombreContacto;
+ contacto.TelefonoOficina = TelefonoOficina;
+ contacto.Celular = Celular;
+ contacto.Correo = Correo;
+ contacto.CveContacto = CveContactoEditado;
+ contacto.CveUsuarioIng = CveUsuarioIng;
+
+ if (cRMService.EmpresasCRMContactoUpdate(contacto))
{
//if (ObjBitacora.AddEventoBitacora(String.Format("Se actualizó el contacto {0}", NombreContacto), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM: CveEmpresaCRM))
//{
@@ -929,9 +1061,14 @@ public partial class CRM_EmpresaCRM : ClsPaginas
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(ObjCRM);
+ CargaContactos();
if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
@@ -984,22 +1121,25 @@ public partial class CRM_EmpresaCRM : ClsPaginas
ClsCRM ObjCRM = new ClsCRM();
ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
- if (ObjCRM.RemoveContactoEmpresa(CveContactoEditado))
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ RequestContactoEmpresaCRM contacto = new RequestContactoEmpresaCRM(-1, -1, CveContactoEditado);
+ if (cRMService.EmpresasCRMContactoDelete(contacto))
{
HuboError = false;
- CargaContactos(ObjCRM);
+ 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);
+ 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();
}
@@ -1068,7 +1208,7 @@ public partial class CRM_EmpresaCRM : ClsPaginas
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(@"{0}OI", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:false);
+ filemove.FilesMove(string.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString()), string.Format(@"Empresas\{0}\OI", UsuarioActual.CveEmpresa));
TxtEventoDescripcion.Text = "";
@@ -1332,33 +1472,34 @@ public partial class CRM_EmpresaCRM : ClsPaginas
RVFechaApertura.MaximumValue = DateTime.Now.ToShortDateString();
}
- protected void InicializaAcercamientos(ClsCRM ObjCRM)
+ protected void InicializaAcercamientos()
{
DdlTipoProceso.Items.Clear();
DdlProbabilidadAcercamiento.Items.Clear();
DdlVendedor.Items.Clear();
- if (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa, 1))
+ 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 = ObjCRM.DtResultados;
-
- if (ObjCRM.DtResultados.Rows.Count > 0)
- {
- DdlTipoProceso.Items.Insert(0, new ListItem("Seleccione ", "-1"));
-
- DdlMedioCaptacionAcercamiento.Enabled = false;
- }
+ DdlTipoProceso.DataSource = ObjTipoProceso.Result;
+ DdlTipoProceso.Items.Insert(0, new ListItem("Seleccione ", "-1"));
+ DdlMedioCaptacionAcercamiento.Enabled = false;
DdlTipoProceso.DataBind();
}
- if (ObjCRM.GetProbabilidadAcercamiento(UsuarioActual.CveEmpresa, 1))
+ if (ObjProbalidadAcercamiento.Result.Count > 0)
{
//DdlProbabilidadAcercamiento.DataSource = ObjCRM.DtResultados;
//DdlProbabilidadAcercamiento.DataBind();
DdlProbabilidadAcercamiento.Items.Insert(0, new ListItem("Seleccione ", "-1"));
-
- DtProbabilidadAcercamiento = ObjCRM.DtResultados;
+ DtProbabilidadAcercamiento = ObjProbalidadAcercamiento.Result.ToDataTable();
}
DdlVendedor.DataSource = get_GlobalDTVendedores(UsuarioActual.CveEmpresa);
@@ -1388,27 +1529,28 @@ public partial class CRM_EmpresaCRM : ClsPaginas
}
- protected void CargaAcercamientos(ClsCRM objCRM)
+ protected void CargaAcercamientos()
{
- if (objCRM.GetAcercamiento(UsuarioActual.CveEmpresa, CveEmpresaCRM))
+ 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 = objCRM.DtResultados;
+ GVAcercamientos.DataSource = objAcercamiento.Result;
GVAcercamientos.DataBind();
}
}
protected void LnkAgregarAcercamiento_Click(object sender, EventArgs e)
{
- if(DTContactos.Rows.Count == 0)
+ if (DTContactos.Rows.Count == 0)
{
Alert("Para crear un nuevo acercamiento es necesario agregar al menos un Contacto.", ModExtensiones.TipoMensaje.MsgAdvertencia);
}
else
{
- ClsCRM ObjCRM = new ClsCRM();
CargaMetodosCaptacion();
- InicializaAcercamientos(ObjCRM);
- ObjCRM.Dispose();
+ InicializaAcercamientos();
limpiarCamposModalAcercamiento();
this.RegistraScript("$('#DivModalAltaAcercamiento').modal();");
UpAltaAcercamiento.Update();
@@ -1421,17 +1563,24 @@ public partial class CRM_EmpresaCRM : ClsPaginas
{
ClsCRM ObjCRM = new ClsCRM();
ClsOIEventos ObjBitacora = new ClsOIEventos(ObjCRM.IniciaTransacSQL());
+ ICRMService cRMService = new CRMService(System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString);
+ AcercaminetoModel AcercamientoModel = new AcercaminetoModel();
+
+
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;
- ObjCRM.GetEtapaProceso(UsuarioActual.CveEmpresa, CveTipoProceso);
- int CveEtapaProcesoActual = ObjCRM.DtResultados.FiltroPrimeroValor("CveEtapaProceso").ToEntero();
-
+ 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();
@@ -1450,28 +1599,52 @@ public partial class CRM_EmpresaCRM : ClsPaginas
int CveAcercamiento = -1;
- if (ObjCRM.DtResultados.Rows.Count > 0)
+ if (tempDT.Rows.Count > 0)
{
- CveAcercamiento = ObjCRM.AddAcercamiento(CveEmpresaCRM, CveContactoPrincipal, CveTipoProceso, CveEtapaProcesoActual, CveVendedor, CveMedioCaptacion, CveRechazoMotivo, CveProbabilidadAcercamiento,
- FechaApertura, NombreAcercamiento, Descripcion, Importe, Comision, Prioridad, UsuarioActual.CveEmpresa, CveUsuarioIng, CvePS:DdlPS.SelectedValue.ToEntero());
- }else
+ AcercamientoModel.CveEmpresaCRM = CveEmpresaCRM;
+ AcercamientoModel.CveContactoPrincipal = CveContactoPrincipal;
+ AcercamientoModel.CveTipoProceso = CveTipoProceso;
+ AcercamientoModel.CveEtapaProcesoActual = CveEtapaProcesoActual;
+ AcercamientoModel.CveVendedor = CveVendedor;
+ AcercamientoModel.CveMedioCaptacion = CveMedioCaptacion;
+ AcercamientoModel.CveRechazoMotivo = CveRechazoMotivo;
+ AcercamientoModel.CveProbabilidadAcercamiento = CveProbabilidadAcercamiento;
+ AcercamientoModel.FechaApertura = FechaApertura;
+ AcercamientoModel.FechaCierre = (DateTime)System.Data.SqlTypes.SqlDateTime.Null;
+ AcercamientoModel.NombreAcercamiento = NombreAcercamiento;
+ AcercamientoModel.Descripcion = Descripcion;
+ AcercamientoModel.Importe = Importe;
+ AcercamientoModel.Comision = Comision;
+ AcercamientoModel.Prioridad = Prioridad;
+ AcercamientoModel.CveEmpresa = UsuarioActual.CveEmpresa;
+ AcercamientoModel.CveUsuarioIng = CveUsuarioIng;
+ AcercamientoModel.CvePS = DdlPS.SelectedValue.ToEntero();
+
+ CveAcercamiento = cRMService.AcercamientoAdd(AcercamientoModel).ToEntero();
+ }
+ else
{
- Alert("No tiene 'Etapa Proceso' con el 'Proceso' seleccionado al agregar el Acercamiento",ModExtensiones.TipoMensaje.MsgAdvertencia);
+ Alert("No tiene 'Etapa Proceso' con el 'Proceso' seleccionado al agregar el Acercamiento", ModExtensiones.TipoMensaje.MsgAdvertencia);
}
if (CveAcercamiento > 0)
{
if (ObjBitacora.AddEventoBitacora(String.Format("Se registró el Acercamiento {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 {0}",NombreAcercamiento);
+ string asunto = String.Format("Se registró el Acercamiento {0}", NombreAcercamiento);
string mensaje = String.Format("Se registró el Acercamiento {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", ModExtensiones.TipoMensaje.MsgError);
+ HuboError = false;
+ }
- CargaAcercamientos(ObjCRM);
+ CargaAcercamientos();
if (!HuboError) { ObjCRM.Commit(); } else { ObjCRM.RollBack(); }
@@ -1504,7 +1677,7 @@ public partial class CRM_EmpresaCRM : ClsPaginas
#region "PERMISOS"
protected void VerificaPermisos()
{
-
+
if (CveEmpresaCRM > 0)
{
if (!UsuarioActual.TienePermisoProceso(250))
@@ -1515,10 +1688,9 @@ public partial class CRM_EmpresaCRM : ClsPaginas
LnkAgregarAcercamiento.Visible = false;
}
-
- if (!UsuarioActual.TienePermisoProceso(330))
+ if ((UsuarioActual.CveVendedor != CveVendedor))
{
- if ((UsuarioActual.CveVendedor != CveVendedor))
+ if (UsuarioActual.CveUsuario != 100)
{
BtnGuardarEmpresa.Visible = false;
BtnEliminarEmpresa.Visible = false;
@@ -1529,12 +1701,6 @@ public partial class CRM_EmpresaCRM : ClsPaginas
}
}
-
-
-
-
-
-
}
}
#endregion
@@ -1543,10 +1709,18 @@ public partial class CRM_EmpresaCRM : ClsPaginas
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, CveUsuarioConsulta: UsuarioActual.CveUsuario))
+ 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.DtResultados;
+ 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;
+ //}
ObjVentas.Dispose();
GvCotizacion.DataBind();
UpCotizacion.Update();
@@ -1565,15 +1739,15 @@ public partial class CRM_EmpresaCRM : ClsPaginas
#endregion
private void mandarCorreo(string Asunto, string body)
{
- DataTable Usuarios = get_GlobalDTUsuarios(CveEmpresa:UsuarioActual.CveEmpresa);
- int CveUsuario = Usuarios.FiltroPrimeroValor("CveUsuario",String.Format("CveVendedor = {0}",DdlVendedorAsignado.SelectedValue)).ToEntero();
+ DataTable Usuarios = get_GlobalDTUsuarios(CveEmpresa: 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
LSRutasMail = new List();
//ClsSisMail.ArchivoMail itemMail = new ClsSisMail.ArchivoMail();
- Mail.SendMail(ClsPaginas.EmpresaNotificaciones, correoVendedor, Asunto,body);
+ Mail.SendMail(ClsPaginas.EmpresaNotificaciones, correoVendedor, Asunto, body);
}
}
diff --git a/CRM/RegPrePolizaS.aspx.vb b/CRM/RegPrePolizaS.aspx.vb
new file mode 100644
index 000000000..bcb621de3
--- /dev/null
+++ b/CRM/RegPrePolizaS.aspx.vb
@@ -0,0 +1,2083 @@
+
+
+Imports System.Data
+Imports Extensiones
+Imports System.Linq
+Imports System.Web.Services
+Imports GemBox.Spreadsheet
+Imports Microsoft.Reporting.WebForms
+Imports System.IO
+Imports iTextSharp.text.pdf
+
+Partial Class ContabilidadC_RegPrePolizaS
+ Inherits ClsPaginas
+
+
+#Region "Propiedades"
+ Public Property ArregloMovs As ArrayList
+ Get
+ Return CType(ViewState("ArregloMovs"), ArrayList)
+ End Get
+ Set(value As ArrayList)
+ ViewState("ArregloMovs") = value
+ End Set
+ End Property
+ Public Property DtMovimientos As DataTable
+ Get
+ Return CType(ViewState("DtMovimientos"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtMovimientos") = value
+ End Set
+ End Property
+ Public Property DtCuentasContables As DataTable
+ Get
+ Return CType(ViewState("DtCuentasContables"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtCuentasContables") = value
+ End Set
+ End Property
+ Public Property TipoPlantilla As Integer
+ Get
+ Return CType(ViewState("TipoPlantilla"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("TipoPlantilla") = value
+ End Set
+ End Property
+ Public Property CveMoneda As Integer
+ Get
+ Return CType(ViewState("CveMoneda"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveMoneda") = value
+ End Set
+ End Property
+ Private ReadOnly Property CvePrePoliza As Integer
+ Get
+ Return ViewState("CvePrePoliza").ToString.ToEntero
+ End Get
+ End Property
+
+ 'PARA CREAR IE
+ Private Property CveConcepto As Integer
+ Get
+ Return ViewState("CveConcepto").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveConcepto") = value
+ End Set
+ End Property
+ Private Property CveTipoTransaccion As Integer
+ Get
+ Return ViewState("CveTipoTransaccion").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveTipoTransaccion") = value
+ End Set
+ End Property
+ Private Property CveCuenta As Integer
+ Get
+ Return ViewState("CveCuenta").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveCuenta") = value
+ End Set
+ End Property
+ Private Property Folio As String
+ Get
+ Return ViewState("Folio").ToString
+ End Get
+ Set(value As String)
+ ViewState("Folio") = value
+ End Set
+ End Property
+ Private Property ImporteDocumento As Decimal
+ Get
+ Return ViewState("ImporteDocumento").ToString.ToDecimal
+ End Get
+ Set(value As Decimal)
+ ViewState("ImporteDocumento") = value
+ End Set
+ End Property
+ Private Property Observaciones As String
+ Get
+ Return ViewState("Observaciones").ToString
+ End Get
+ Set(value As String)
+ ViewState("Observaciones") = value
+ End Set
+ End Property
+ Private Property Beneficiario As String
+ Get
+ Return ViewState("Beneficiario").ToString
+ End Get
+ Set(value As String)
+ ViewState("Beneficiario") = value
+ End Set
+ End Property
+ Private Property RowIndex As Integer
+ Get
+ Return ViewState("RowIndex").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("RowIndex") = value
+ End Set
+ End Property
+ Private Property Actualizar As Boolean
+ Get
+ Return CBool(ViewState("Actualizar").ToString)
+ End Get
+ Set(value As Boolean)
+ ViewState("Actualizar") = value
+ End Set
+ End Property
+
+ Private ReadOnly Property CvePeriodo As Integer
+ Get
+ Return CType(ViewState("CvePeriodo"), Integer)
+ End Get
+ End Property
+ Private ReadOnly Property CveProyecto As Integer
+ Get
+ Return CType(ViewState("CveProyecto"), Integer)
+ End Get
+ End Property
+ Private ReadOnly Property CveSubProyecto As Integer
+ Get
+ Return CType(ViewState("CveSubProyecto"), Integer)
+ End Get
+ End Property
+ Private ReadOnly Property CveTurno As Integer
+ Get
+ Return CType(ViewState("CveTurno"), Integer)
+ End Get
+ End Property
+ Public Property IndiceGrid As Integer
+ Get
+ Return CType(ViewState("IndiceGrid"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("IndiceGrid") = value
+ End Set
+ End Property
+ Public Property IdPoliza As Integer
+ Get
+ Return CType(ViewState("IdPoliza"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("IdPoliza") = value
+ End Set
+ End Property
+ Public Property Tick As String
+ Get
+ Return CType(ViewState("Tick"), String)
+ End Get
+ Set(value As String)
+ ViewState("Tick") = value
+ End Set
+ End Property
+
+ Public Property CveIE As Integer
+ Get
+ Return CType(ViewState("CveIE"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveIE") = value
+ End Set
+ End Property
+
+ Public Property TipoPoliza As String
+ Get
+ Return CType(ViewState("TipoPoliza"), String)
+ End Get
+ Set(value As String)
+ ViewState("TipoPoliza") = value
+ End Set
+ End Property
+#End Region
+
+ Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
+
+ If Not Page.IsPostBack Then
+ Tick = DateTime.Now.Ticks.ToString
+
+ CveMoneda = 1
+ ViewState("CvePrePoliza") = 0
+ ViewState("CvePeriodo") = "0"
+ CveConcepto = -1
+ CveTipoTransaccion = -1
+ CveCuenta = -1
+ Folio = "-1"
+ ImporteDocumento = -1
+ Observaciones = "-1"
+ Beneficiario = "-1"
+ Actualizar = False
+ IdPoliza = -1
+
+
+ If IfNull(Request("Tipo"), "").ToString = "NOMPROV" Then
+ DivTipoGasto.Visible = True
+ ThTipoGasto.Visible = True
+ CargaTiposGasto()
+ End If
+
+ If Request("CvePrePoliza") IsNot Nothing AndAlso IsNumeric(Request("CvePrePoliza")) AndAlso Request("CvePrePoliza").ToEntero > 0 Then
+ ViewState("CvePrePoliza") = Request("CvePrePoliza").ToEntero
+ CreaDT()
+ CargaPrePoliza()
+ If IfNull(Request("Tipo"), "").ToString <> "NOMPROV" Then
+ GvPrePoliza.Columns(5).Visible = False
+ DivTG.Visible = False
+ GvMov.Columns(5).Visible = False
+ End If
+
+ Exit Sub
+ Else
+ CreaDT()
+ BtnEliminar.Visible = False
+ LnkExcel.Visible = True
+ LnkImprimirPDF.Visible = False
+ End If
+
+
+ TipoPlantilla = -1
+ If IfNull(Request("Tipo"), "").ToString = "Ing" Then
+ TipoPlantilla = 1
+ LblEncabezado.Text = "Otros Ingresos"
+ End If
+
+ CargaPlantillas(TipoPlantilla)
+
+ If UsuarioActual.CveRol = 1 Then trNotificar.Visible = True
+
+ CargaConceptos()
+ CargaSubProyectos()
+ CargaCuentasContables()
+
+ 'crea tabla temporal
+ ArregloMovs = New ArrayList
+
+ CargaCuentas()
+
+ 'If Request("CvePeriodo") IsNot Nothing AndAlso IsNumeric(Request("CvePeriodo")) AndAlso Request("CvePeriodo").ToEntero > 0 Then
+ ' ViewState("CvePeriodo") = Request("CvePeriodo").ToEntero
+ ' ViewState("CveProyecto") = Request("CveProyecto").ToEntero
+ ' ViewState("CveSubProyecto") = Request("CveSubProyecto").ToEntero
+ ' ViewState("CveTurno") = Request("CveTurno").ToEntero
+
+ ' DdlPlantilla.Items.Add(New ListItem("Pago Nomina", "61"))
+ ' DdlPlantilla.SelectedValue = "61"
+ ' DdlPlantilla.Enabled = False
+ ' DivAgregarConceptos.Visible = False
+
+ ' CargaNomina()
+
+ ' RegistraScript("$(document).ready(function () { calculateCargo(); Sys.Application.add_load(function (s, e) { calculateCargo(); }); } );", 1)
+ ' RegistraScript("$(document).ready(function () { calculateAbono(); Sys.Application.add_load(function (s, e) { calculateAbono(); }); } );", 2)
+ ' RegistraScript("$(document).ready(function () { comparar(); Sys.Application.add_load(function (s, e) { comparar(); }); } );", 3)
+ 'End If
+
+ If IfNull(Request("Tipo"), "").ToString <> "NOMPROV" Then
+ GvPrePoliza.Columns(4).Visible = False
+ GvMov.Columns(4).Visible = False
+ End If
+
+
+
+ End If
+
+ End Sub
+
+ Private Sub CreaDT()
+ DtMovimientos = New DataTable("Movimientos")
+ Dim IDMov As DataColumn = DtMovimientos.Columns.Add("IdMov", Type.GetType("System.Int32")) : IDMov.AutoIncrement = True
+ With DtMovimientos.Columns
+ .Add("CodigoCuenta", Type.GetType("System.String"))
+ .Add("Cuenta", Type.GetType("System.String"))
+ .Add("Referencia", Type.GetType("System.String"))
+ .Add("Concepto", Type.GetType("System.String"))
+ .Add("Cargo", Type.GetType("System.Double"))
+ .Add("Abono", Type.GetType("System.Double"))
+ .Add("TipoMovto", Type.GetType("System.Int32"))
+ .Add("EsComodin", Type.GetType("System.Int32"))
+ .Add("CveConcepto", Type.GetType("System.Int32"))
+ .Add("CveSubProyecto", Type.GetType("System.Int32"))
+ .Add("Descripcion", Type.GetType("System.String"))
+ .Add("CveProveedor", Type.GetType("System.Int32"))
+ .Add("CvePersonal", Type.GetType("System.Int32"))
+ .Add("CveCompra", Type.GetType("System.Int32"))
+ .Add("CveCliente", Type.GetType("System.Int32"))
+ .Add("CveVenta", Type.GetType("System.Int32"))
+ .Add("CveClasificacion", Type.GetType("System.Int32"))
+ .Add("MultipleSubProyecto", Type.GetType("System.Boolean"))
+ .Add("CveTipoGasto", Type.GetType("System.Int32"))
+ .Add("CvePrePolizaDetalle", Type.GetType("System.Int32"))
+ .Add("CveConceptoContable", Type.GetType("System.Int32"))
+ .Add("IdCtaContable", Type.GetType("System.Int32"))
+ .Add("ConceptoContable", Type.GetType("System.String"))
+ .Add("CveCuenta", Type.GetType("System.Int32"))
+ End With
+ End Sub
+
+ 'Private Sub CargaNomina()
+ ' Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero
+ ' Dim ObjNomina As New ClsNominas
+ ' Dim ObjConta As New ClsContabilidad
+
+ ' Dim Dt As DataTable = Nothing
+ ' Dim Cuenta As String = ""
+ ' Dim Concepto As String = ""
+ ' Dim IdCuenta As Integer = 0
+ ' Dim TipoMovto As Integer
+ ' Dim CveConcepto As Integer
+ ' Dim CodigoCuenta As String = ""
+ ' Dim NombreCuenta As String = ""
+ ' Dim Referencia As String = ""
+ ' Dim EsComodin As Integer = 0
+ ' DtMovimientos.Clear()
+
+ ' If ObjNomina.GetProvisionNomina(CveProyecto, CveSubProyecto, CveTurno, CvePeriodo, UsuarioActual.CveEmpresa) Then
+ ' Dt = ObjNomina.DtResultados
+
+ ' For Each drt As DataRow In Dt.Rows
+ ' Dim dr As DataRow = DtMovimientos.NewRow
+
+ ' If drt("NombreCompleto").ToString = "" AndAlso ObjConta.GetRetCuenta(31, UsuarioActual.CveEmpresa) Then
+ ' CveConcepto = 98
+ ' Cuenta = "Nominas por Pagar"
+ ' IdCuenta = ObjConta.DtResultados(0)("IdCtaContable").ToString.ToEntero
+ ' Concepto = "Pago Nomina"
+ ' Referencia = "Pago Nomina"
+ ' Else
+ ' Concepto = drt("NombreCompleto")
+ ' Referencia = ""
+ ' CveConcepto = drt("CveConceptoContable").ToString.ToEntero
+ ' Cuenta = drt("ConceptoContable").ToString
+ ' IdCuenta = drt("IdCtaContable").ToString.ToEntero
+ ' End If
+
+ ' Dim drr As DataRow = DtCuentasContables.FiltroPrimero($"Id={IdCuenta}")
+ ' CodigoCuenta = If(drr IsNot Nothing, drr("CuentaFormato").ToString(), "")
+ ' NombreCuenta = If(drr IsNot Nothing, drr("Nombre").ToString(), "")
+
+ ' TipoMovto = drt("TipoMovto")
+
+ ' If TipoMovto = 0 Then
+ ' dr("Cargo") = Math.Abs(drt("Importe").ToString.ToDecimal)
+ ' dr("Abono") = 0
+ ' Else
+ ' dr("Cargo") = 0
+ ' dr("Abono") = Math.Abs(drt("Importe").ToString.ToDecimal)
+ ' End If
+
+ ' dr("IdCuenta") = IdCuenta
+ ' dr("CodigoCuenta") = CodigoCuenta & "
" & NombreCuenta
+ ' dr("Cuenta") = Cuenta
+ ' dr("Concepto") = Concepto
+ ' dr("Descripcion") = Concepto
+ ' dr("Referencia") = Referencia
+ ' dr("TipoMovto") = TipoMovto
+ ' dr("EsComodin") = EsComodin
+ ' dr("CveConcepto") = CveConcepto
+ ' dr("CveProveedor") = "-1"
+ ' dr("CveSubProyecto") = drt("CveSubProyecto")
+ ' dr("CvePersonal") = drt("CvePersonal")
+ ' dr("CveClasificacion") = drt("CveClasificacion")
+ ' dr("CveTipoGasto") = drt("CveTipoGasto")
+
+ ' DtMovimientos.Rows.Add(dr)
+ ' Next
+
+ ' GvMov.DataSource = DtMovimientos
+ ' GvMov.DataBind()
+ ' UPMovs.Update()
+ ' End If
+
+ 'End Sub
+
+ Private Sub CargaPrePoliza()
+ BtnEliminar.Visible = True
+ LblEncabezado.Text = "Edición de Póliza"
+
+ Dim ObjContabilidad As New ClsContabilidad
+ If ObjContabilidad.GetPrePoliza(CvePrePoliza, UsuarioActual.CveEmpresa) Then
+ Dim dr As DataRow = ObjContabilidad.DtResultados.FiltroPrimero("")
+ If dr IsNot Nothing Then
+ DivAgregarConceptos.Visible = False
+ DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza")
+ TxtFechaDocumento.Text = dr("Fecha")
+ TxtConcepto.Text = dr("Concepto")
+ DivDatosPoliza.Visible = True
+ TipoPoliza = DdlTipoPoliza.SelectedItem.Text
+ Folio = dr("FolioPoliza").ToString
+
+ If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then
+ 'DivAgregarConceptos.Visible = True
+ LnkAddConcepto.Visible = True
+ CargaConceptos()
+ CargaSubProyectos()
+ CargaCuentasContables()
+ End If
+
+ ObjContabilidad.GetContabilizacionDiarioDetalle(CvePrePoliza)
+
+ DtMovimientos = ObjContabilidad.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
+ GvPrePoliza.DataSource = DtMovimientos
+ GvPrePoliza.DataBind()
+
+ If UsuarioActual.CveRol = 1 AndAlso DtMovimientos.COUNT("TC", "TC > 1") > 0 Then
+ GvPrePoliza.Columns(7).Visible = True
+ End If
+
+ If DtMovimientos.FiltraParametros("CveConceptoContable IN (2,17)").Rows.Count > 0 Then
+ LnkComplementoPago.Visible = True
+ End If
+
+ If UsuarioActual.Empresa.TipoContabilizacion = 1 Then
+ If dr("FolioPoliza").ToString.ToEntero > 0 Then
+ divContabilizada.Visible = True
+ LblFolio.Text = dr("FolioPoliza").ToString
+ Folio = dr("FolioPoliza").ToString
+
+ End If
+ Else
+ If dr("IdPoliza").ToString.ToEntero > 0 Then
+ HplContabilizada.NavigateUrl = String.Format("RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza"))
+ divContabilizada.Visible = True
+ IdPoliza = dr("IdPoliza").ToString.ToEntero
+ ElseIf TxtTotalCargos.Text.ToDouble = TxtTotalAbonos.Text.ToDouble Then
+ 'sino está contabilizada, se activa el botón
+ BtnContabilizar.Visible = True
+ End If
+ End If
+
+ divDatosPrincipales.Visible = False
+ divObservaciones.Visible = False
+ UPMovs.Visible = False
+ UPMovs.Update()
+ UPPDocumento.Update()
+ UpPrePoliza.Update()
+
+ RegistraScript("comparar();")
+
+ If Request("Tipo") IsNot Nothing AndAlso IsNumeric(Request("Tipo")) AndAlso Request("Tipo").ToEntero = 1 AndAlso UsuarioActual.CveUsuario <> 100 Then
+ 'For Each row As GridViewRow In GvPrePoliza.Rows
+ ' row.FCTextBox("TxtCargo").Enabled = False
+ ' row.FCTextBox("TxtAbono").Enabled = False
+ 'Next
+ End If
+ LnkExcel.Visible = False
+ LnkImprimirPDF.Visible = True
+ Else
+ Alert("El documento solicitado no existe, favor de revisar su búsqueda.", TipoMensaje.MsgAdvertencia)
+ BtnEliminar.Visible = False
+ End If
+
+ End If
+
+ ObjContabilidad.Dispose()
+ UpPoliza.Update()
+ End Sub
+
+ Private Sub GvPrePoliza_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPrePoliza.RowDataBound
+
+ If e.Row.RowType = DataControlRowType.DataRow Then
+
+ ''Asignamos los Subproyectos
+ 'e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
+ 'e.Row.FCDropDownList("DdlSubProyecto").DataBind()
+ 'e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem(" - ", "-1"))
+ 'e.Row.FCDropDownList("DdlSubProyecto").SelectedValueExist(e.Row.DataKey("CveSubProyecto"))
+
+ 'Asignamos los Tipos de Gasto
+ 'e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
+ 'e.Row.FCDropDownList("DdlTipoGasto").DataBind()
+ 'e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1"))
+ 'e.Row.FCDropDownList("DdlTipoGasto").SelectedValueExist(e.Row.DataKey("CveTipoGasto"))
+
+ 'ASignamos las CuentasContables
+ 'e.Row.FCDropDownList("DdlCtaContable").DataSource = Session("DtCuentas")
+ 'e.Row.FCDropDownList("DdlCtaContable").DataBind()
+ 'e.Row.FCDropDownList("DdlCtaContable").Items.Insert(0, New ListItem("Sin Asignar", "0"))
+ 'e.Row.FCDropDownList("DdlCtaContable").SelectedValueExist(e.Row.DataKey("IdCtaContable"))
+
+ If e.Row.DataKey("IdCtaContable") > 0 Then
+ Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", e.Row.DataKey("IdCtaContable")))
+ If drr IsNot Nothing Then
+ e.Row.FCLiteral("DdlCtaContable").Text = drr("CuentaFormato").ToString() + " - " + drr("Nombre").ToString()
+ End If
+ End If
+
+ TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + e.Row.FCLiteral("TxtCargo").Text.ToDouble).ToString.FormatoNumero
+ TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + e.Row.FCLiteral("TxtAbono").Text.ToDouble).ToString.FormatoNumero
+
+ Dim CveConceptoContable As Integer = e.Row.DataKey("CveConceptoContable").ToEntero
+
+ If CveConceptoContable.Contiene(1, 2, 13, 38, 207, 203, 39, 61, 62, 63) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta"))
+ If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 234, 235, 240) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra"))
+ If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen"))
+ If CveConceptoContable.Contiene(30, 204) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE"))
+
+ 'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable
+
+ End If
+
+ If e.Row.RowType = DataControlRowType.Header Then
+ 'e.Row.FCDropDownList("DdlSubProyectoFiltro").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
+ 'e.Row.FCDropDownList("DdlSubProyectoFiltro").DataBind()
+ 'e.Row.FCDropDownList("DdlSubProyectoFiltro").Items.Insert(0, New ListItem("Todos", "-1"))
+ End If
+
+ End Sub
+
+ Private Sub CargaPlantillas(TipoPlantilla As Integer)
+
+ 'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
+ 'GvPlantillas.DataBind()
+
+ If UsuarioActual.CveEmpresa.Contiene(120) Then
+ DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, -1)
+ DdlPlantilla2.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, -1)
+
+ Else
+ DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
+ DdlPlantilla2.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
+
+ End If
+
+
+ DdlPlantilla.DataBind()
+ DdlPlantilla.Items.Insert(0, New ListItem("Plantilla Personalizada", "53"))
+
+ DdlPlantilla2.DataBind()
+ DdlPlantilla2.Items.Insert(0, New ListItem("Plantilla Personalizada", "53"))
+ End Sub
+
+ Private Sub CargaConceptos()
+ DdlConceptosContables.DataSource = GlobalDTContaConceptosContables(-1)
+ DdlConceptosContables.DataBind()
+ End Sub
+
+ Private Sub DdlConceptosContables_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConceptosContables.SelectedIndexChanged
+ If DdlConceptosContables.SelectedValue.ToEntero.Contiene(5, 17, 201, 206, 14, 15, 16, 19, 25, 26, 21) Then
+ CargaProveedores()
+ DdlProveedores.Visible = True
+ DdlCompras.Visible = True
+ Else
+ DdlProveedores.Visible = False
+ DdlCompras.Visible = False
+ End If
+
+ If DdlConceptosContables.SelectedValue.ToEntero.Contiene(28, 29) Then
+ CargaPersonal()
+ DdlPersonal.Visible = True
+ Else
+ DdlPersonal.Visible = False
+ End If
+ If DdlConceptosContables.SelectedValue.ToEntero.Contiene(1, 2, 203, 207, 13, 61, 8, 9, 62, 63, 38, 39, 12, 91) Then
+ CargaClientes()
+ DdlClientes.Visible = True
+ DdlVentas.Visible = True
+ Else
+ DdlClientes.Visible = False
+ DdlVentas.Visible = False
+ End If
+ End Sub
+
+ Private Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedores.SelectedIndexChanged
+ CargaCompras(DdlProveedores.SelectedValue.ToEntero)
+ End Sub
+
+ Private Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientes.selectedindexchange
+ CargaVentas(DdlClientes.SelectedValue.ToEntero)
+ End Sub
+
+ Private Sub CargaSubProyectos()
+ DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
+ DdlSubProyecto.DataBind()
+ DdlSubProyecto.Items.Insert(0, New ListItem(" - ", "-1"))
+ DdlSubProyectoFiltroMov.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
+ DdlSubProyectoFiltroMov.DataBind()
+ DdlSubProyectoFiltroMov.Items.Insert(0, New ListItem("Todos", "-1"))
+ End Sub
+
+ Private Sub CargaCuentasContables()
+ Dim ObjConta As New ClsContabilidad
+ If ObjConta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then
+ DdlCtaContable.DataSource = ObjConta.DtResultados
+ DtCuentasContables = ObjConta.DtResultados
+ End If
+ ObjConta.Dispose()
+ DdlCtaContable.DataBind()
+ DdlCtaContable.Items.Insert(0, New ListItem("Sin Asignar", "0"))
+ End Sub
+
+ Private Sub CargaTiposGasto()
+ DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
+ DdlTipoGasto.DataBind()
+ DdlTipoGasto.Items.Insert(0, New ListItem("Sin Asignar", "0"))
+ End Sub
+
+ Private Sub CargaProveedores()
+ DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
+ DdlProveedores.DataBind()
+ DdlProveedores.Items.Insert(0, New ListItem(" - ", "-1"))
+ End Sub
+
+ Private Sub CargaCompras(CveProveedor As Integer)
+ If Not DdlConceptosContables.SelectedValue.ToEntero.Contiene(21) Then
+ Dim ObjCompras As New ClsCompras
+
+ DdlCompras.ClearSelection()
+ If ObjCompras.GetCompras(-1, "-1", "-1", CveProveedor, -1, UsuarioActual.CveEmpresa) Then
+ DdlCompras.DataSource = ObjCompras.DtResultados.FiltraParametros("Saldo > 0")
+ DdlCompras.DataBind()
+ DdlCompras.Items.Insert(0, New ListItem(" - ", "-1"))
+ Else
+ DdlCompras.DataSource = Nothing
+ DdlCompras.DataBind()
+ DdlCompras.Items.Insert(0, New ListItem(" - ", "-1"))
+ End If
+ ObjCompras.Dispose()
+ End If
+ End Sub
+
+ Private Sub CargaClientes()
+ DdlClientes.setEsWebService(True)
+ DdlClientes.Attributes.Add("data-metodo", "getcliente")
+ DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
+ DdlClientes.DataBind()
+ ' DdlClientes.Items.Insert(0, New ListItem(" - ", "-1"))
+ End Sub
+
+ Private Sub CargaVentas(CveCliente As Integer)
+ Dim ObjVentas As New ClsVentas
+
+ DdlVentas.ClearSelection()
+ If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1", CveCliente, -1, -1, -1, "-1", "-1", "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
+ DdlVentas.DataSource = ObjVentas.DtResultados '.FiltraParametros("Saldo > 0")
+ DdlVentas.DataBind()
+ DdlVentas.Items.Insert(0, New ListItem(" - ", "-1"))
+ Else
+ DdlVentas.DataSource = Nothing
+ DdlVentas.DataBind()
+ DdlVentas.Items.Insert(0, New ListItem(" - ", "-1"))
+ End If
+ ObjVentas.Dispose()
+ End Sub
+
+ Private Sub CargaPersonal()
+ DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
+ DdlPersonal.DataBind()
+ DdlPersonal.Items.Insert(0, New ListItem(" - ", "-1"))
+ End Sub
+
+
+ Protected Sub DdlPlantilla_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPlantilla.SelectedIndexChanged
+
+ TxtTotalAbonos.Text = ""
+ TxtTotalCargos.Text = ""
+
+ If DdlPlantilla.SelectedValue.ToEntero <= 0 Then
+ Alert("Seleccione un Movimiento Válido", TipoMensaje.MsgAdvertencia)
+ DdlPlantilla.SelectedValue = "-1"
+ Exit Sub
+ End If
+
+ If DdlPlantilla.SelectedValue.ToEntero = 53 Then 'Plantilla Personalizada
+ DivAgregarConceptos.Visible = True
+ Else
+ DivAgregarConceptos.Visible = False
+ End If
+
+
+
+ Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero
+
+ Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla).FiltraParametros(String.Format("CveEmpresa={0}", UsuarioActual.CveEmpresa), "Orden")
+ Dim Cuenta As String = ""
+ Dim IdCuenta As Integer = 0
+ Dim CodigoCuenta As String = ""
+ Dim NombreCuenta As String = ""
+ Dim EsComodin As Integer = 0
+ DtMovimientos.Clear()
+
+ For Each drt As DataRow In Dt.Rows
+
+ Cuenta = drt("ConceptoContable").ToString
+ IdCuenta = 0
+ CodigoCuenta = ""
+ NombreCuenta = ""
+ If drt("IdCtaContable").ToString.ToEntero > 0 Then 'DtCuentasContables
+ Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", drt("IdCtaContable").ToString))
+ If drr IsNot Nothing Then
+ IdCuenta = drt("IdCtaContable").ToString.ToEntero
+ CodigoCuenta = drr("CuentaFormato").ToString()
+ NombreCuenta = drr("Nombre").ToString()
+ 'Cuenta = drr("Nombre").ToString()
+ End If
+ EsComodin = 0
+ End If
+
+ Dim dr As DataRow = DtMovimientos.NewRow
+
+ dr("CodigoCuenta") = CodigoCuenta & "
" & NombreCuenta
+ dr("Cuenta") = Cuenta 'TxtCuentaContable.Text
+ dr("Referencia") = If(drt("CveConcepto").ToString.Contiene("29", "130"), drt("Personal"), drt("RazonSocial"))
+ dr("Concepto") = TxtObservaciones.Text
+ dr("TipoMovto") = If(drt("TipoMovto").ToString = "False", 0, 1)
+ dr("EsComodin") = EsComodin
+ dr("CveConcepto") = drt("CveConcepto")
+ dr("CveSubProyecto") = drt("CveSubProyectoNegativo")
+ dr("Cargo") = TxtCargo.Text.ToDouble
+ dr("Abono") = TxtAbono.Text.ToDouble
+ dr("CveProveedor") = drt("CveProveedor")
+ dr("CvePersonal") = drt("CvePersonal")
+ dr("CveClasificacion") = -1
+ dr("MultipleSubProyecto") = drt("MultipleSubProyecto")
+ dr("CveCuenta") = drt("CveCuenta")
+ 'dr("FolioPoliza") = 0 'drt("FolioPoliza")
+
+ DtMovimientos.Rows.Add(dr)
+ Next
+
+
+ GvMov.DataSource = DtMovimientos
+ GvMov.DataBind()
+ UPMovs.Update()
+
+ End Sub
+
+ Protected Sub GvMov_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMov.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+
+ e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
+ e.Row.Height = Unit.Pixel(1)
+ e.Row.Cells(0).ToolTip = e.Row.DBCampo("CveCuenta")
+
+ If e.Row.DBCampo("TipoMovto") = "1" Then
+ e.Row.FCTextBox("TxtAbono").Visible = True
+ Else
+ e.Row.FCTextBox("TxtCargo").Visible = True
+ End If
+
+ e.Row.FCTextBox("TxtAbono").Text = If(e.Row.DBCampo("Abono") = 0, "", e.Row.DBCampo("Abono"))
+ e.Row.FCTextBox("TxtCargo").Text = If(e.Row.DBCampo("Cargo") = 0, "", e.Row.DBCampo("Cargo"))
+ e.Row.FCTextBox("TxtConcepto").Text = e.Row.DBCampo("Descripcion")
+
+ If CvePeriodo > 0 Then
+ e.Row.FCTextBox("TxtCargo").Enabled = False
+ e.Row.FCTextBox("TxtAbono").Enabled = False
+ End If
+
+ e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
+ e.Row.FCDropDownList("DdlSubProyecto").DataBind()
+ e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem(" - ", "-1"))
+ e.Row.FCDropDownList("DdlSubProyecto").SelectedValue = e.Row.DBCampo("CveSubProyecto")
+
+ 'Asignamos los Tipos de Gasto
+ e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
+ e.Row.FCDropDownList("DdlTipoGasto").DataBind()
+ e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1"))
+ e.Row.FCDropDownList("DdlTipoGasto").SelectedValue = e.Row.DBCampo("CveTipoGasto")
+
+ If DdlPlantilla.SelectedValue.ToEntero = 53 Then 'Plantilla Personalizada
+ e.Row.FCDropDownList("DdlSubProyecto").Enabled = True
+ e.Row.FCLinkButton("imgD").Visible = True
+ Else
+ e.Row.FCDropDownList("DdlSubProyecto").Enabled = False
+ End If
+
+ If e.Row.DBCampo("MultipleSubProyecto") = "True" Then
+ e.Row.FCDropDownList("DdlSubProyecto").Enabled = True
+ End If
+
+ 'Agregamos la opcion para vincular los movimientos bancarios
+ If e.Row.DataKey("CveConcepto").ToEntero.Contiene(41) Then
+ Dim ObjMovimientos As New ClsMovimientos
+ Dim DdlSaldos As DropDownList = e.Row.FCDropDownList("DdlSaldos")
+
+ Select Case e.Row.DataKey("CveConcepto").ToEntero
+
+ 'Acreedores
+ Case 41
+ If (ObjMovimientos.GetAcreedoresSaldosDetalles(-1, CveMoneda, UsuarioActual.CveEmpresa)) Then
+ DdlSaldos.Visible = True
+ DdlSaldos.DataSource = ObjMovimientos.DtResultados.FiltraParametros($"CveIE > 0 AND CveProveedor = {e.Row.DataKey("CveProveedor").ToEntero}")
+ DdlSaldos.DataBind()
+ DdlSaldos.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End If
+
+ End Select
+
+ ObjMovimientos.Dispose()
+ End If
+
+ If e.Row.DataKey("CveConcepto").ToEntero.Contiene(30) Then
+ e.Row.FCLinkButton("ImgBancos").Visible = True
+
+
+ If CveTipoTransaccion > 0 And CveCuenta > 0 And Folio.Length > 0 And ImporteDocumento > 0 And Beneficiario.Length > 0 Then
+ e.Row.FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green"
+ End If
+ End If
+ End If
+ End Sub
+
+ Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
+ Dim TotalCargos, TotalAbonos As Decimal
+
+ If CvePrePoliza > 0 Then
+ TotalCargos = TxtTotalCargos.Text.ToDecimal
+ TotalAbonos = TxtTotalAbonos.Text.ToDecimal
+ Else
+ For Each Gvr As GridViewRow In GvMov.Rows
+ TotalCargos += Gvr.FCTextBox("TxtCargo").Text.ToDecimal
+ TotalAbonos += Gvr.FCTextBox("TxtAbono").Text.ToDecimal
+ Next
+ End If
+
+ If Not (TotalCargos = TotalAbonos AndAlso (GvPrePoliza.Rows.Count > 0 Or GvMov.Rows.Count > 0)) Then
+ Alert($"La suma de los movimientos no son iguales ({TotalCargos}-{TotalAbonos})", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If CvePrePoliza > 0 Then
+ 'Nuevo Modulo Charlie
+ ActualizarPrePoliza()
+ Else
+ Dim MensajeAlert = New StringBuilder
+ Dim ObjIE As New ClsBancos()
+ Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
+ ' Dim ObjNom As New ClsNominas(ObjIE.IniciaTransacSQL)
+ Dim Conta As ClsContPAQi = Nothing
+ Dim IDPoliza As Integer = 0
+ Dim MsgError As String = ""
+ Dim CveIE As Integer
+ Dim FolioIE As String = ""
+
+ Try
+ Dim CvePrePoliza As Integer
+ Dim ConceptoPoliza As String = TxtObservaciones.Text
+ CvePrePoliza = ObjMov.AddPrePolizas("Contabilidad/RegPrePoliza", DdlPlantilla.SelectedValue.ToEntero, TotalCargos, TotalAbonos, 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=DdlTipoPolizaAdd.SelectedValue.ToEntero)
+
+ If CvePrePoliza > 0 Then
+ Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:
"
+ Dim idCuentaContabilizacion As Long = 1
+ Dim Importe As Double = 0
+ Dim TipoMovto As Boolean = False
+ Dim IdCtaContable As Integer = 0
+
+ 'Registra movimieno bancario
+ If CveConcepto = 30 Then
+ CveIE = ObjIE.AddBancos_IE(CveCuenta, CveTipoTransaccion, TxtFecha.Text, Folio, Beneficiario, ImporteDocumento, CveMoneda, 0, Observaciones, "", False, False, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ If CveIE < 0 Then MsgError = "No se pudo registrar movimiento bancario"
+ If ObjIE.GetBancosIE(CveIE, -1, -1, "-1", -1, "-1", "-1", -1, -1, -1, -1, -1, MinFecha, MaxFecha, MinFecha, MaxFecha, MinFecha, MaxFecha, -1, -1, UsuarioActual.CveEmpresa) Then
+ FolioIE = ObjIE.Folio
+ End If
+ End If
+
+
+
+ 'inserto las compras que voy a pagarDdlSaldos
+ For Each gvr As GridViewRow In GvMov.Rows
+ 'If gvr.DataKey("IDCuenta").ToEntero > 0 Then
+ ' IdCtaContable = gvr.DataKey("IDCuenta")
+ 'End If
+
+ If gvr.DataKey("TipoMovto").ToDouble > 0 Then
+ Importe = gvr.FCTextBox("TxtAbono").Text.ToDouble
+ TipoMovto = True
+ Else
+ Importe = gvr.FCTextBox("TxtCargo").Text.ToDouble
+ TipoMovto = False
+ End If
+
+ If CveConcepto <> 30 Then
+
+ If CveConcepto = 41 Then
+ CveIE = gvr.FCDropDownList("DdlSaldos").SelectedValue.ToEntero
+ Else
+ CveIE = -1
+ End If
+
+ End If
+
+
+ If idCuentaContabilizacion = 1 AndAlso (IdCtaContable = 0) Then
+ idCuentaContabilizacion = 0
+ End If
+ If Importe <> 0 Then
+ Dim tCveCuenta As Integer = gvr.DataKey("CveCuenta").ToEntero
+
+ 'If gvr.datakey("CveConcepto") = "299" Then
+ ' tCveCuenta = gvr.DataKey("CveCuenta").ToEntero
+ 'End If
+
+ If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, gvr.FCLiteral("LtlReferencia").Text, gvr.DataKey("CveConcepto").ToEntero, gvr.FCTextBox("TxtConcepto").Text,
+ TxtFecha.Text.ToDate, IdCtaContable, -1, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CveIE:=CveIE,
+ CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, CveCompra:=gvr.DataKey("CveCompra").ToEntero,
+ CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero,
+ ImporteMX:=Importe, CveTipoGasto:=gvr.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero,
+ CveCliente:=gvr.DataKey("CveCliente").ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCuenta:=tCveCuenta) Then
+ Else
+ MsgError = "No se pudo insertar el detalle de la póliza2"
+ Exit For
+ End If
+ End If
+ Next
+
+ If MsgError = "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 1) Then
+ If ObjMov.ValorPolizaDescuadre > 0 Then
+ GuardaLogAD($"Contabilidad/RegPrePolizas | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
+ MsgError = ObjMov.MensajePolizaDescuadre
+ End If
+ End If
+
+
+ 'El movimiento 2 es el de Pago
+ If ChkAutoConta.Checked AndAlso UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then
+ If idCuentaContabilizacion > 0 Then
+ If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
+
+ 'MENSAJE PRINCIPAL
+ MensajeAlert.AppendFormat("
Folio de Salida: {1}", ObjMov.ContaIdPoliza, ObjMov.ContaFolio)
+ 'Alert(MensajeAlert.ToString, ModExtensiones.TipoMensaje.MsgInformacion)
+ Else
+ Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico")
+ End If
+ Else
+ Alert("No se puede contabilizar la Prepoliza debido a que una o mas cuentas son inválidas")
+ End If
+ Else
+ MensajeAlert.AppendFormat("
Folio: {1}", CvePrePoliza, ObjMov.ContaFolio)
+ End If
+
+ Else
+ MsgError = "No se pudo insertar la póliza"
+ End If
+ Catch ex As Exception
+ MsgError = "Error"
+ End Try
+
+ If MsgError = "" Then
+ 'MENSAJE IE
+ If CveIE Then
+ MensajeAlert.AppendFormat("
Folio Bancario: {1}", CveIE, FolioIE)
+ Alert(MensajeAlert.ToString, ModExtensiones.TipoMensaje.MsgInformacion, "window.location.reload()")
+ Else
+ Alert(If(MensajeAlert.ToString = "", "Se registro con exito.", MensajeAlert.ToString), TipoMensaje.MsgInformacion, "window.location.reload()")
+ End If
+
+ ObjIE.Commit()
+ If Conta IsNot Nothing Then Conta.Commit()
+
+ UPPDocumento.Update()
+
+ TxtObservaciones.Text = ""
+ GvMov.DataBind()
+ TxtFecha.Text = ""
+ TxtObservaciones.Text = ""
+ Else
+ Alert(MsgError.ToString, ModExtensiones.TipoMensaje.MsgError)
+ ObjIE.RollBack()
+ If Conta IsNot Nothing Then Conta.RollBack()
+ End If
+
+ ObjIE.Dispose()
+ ObjMov.Dispose()
+ If Conta IsNot Nothing Then Conta.Dispose()
+ End If
+ End Sub
+
+ Private Sub ActualizarPrePoliza()
+
+ Dim OcurrioError As Boolean = False
+ Dim ObjContabilidad As New ClsContabilidad
+ ObjContabilidad.IniciaTransacSQL()
+
+ ObjContabilidad.UpdatePrePoliza(MinFecha, -1, DdlTipoPoliza.SelectedValue.ToEntero, -1, CvePrePoliza, UsuarioActual.CveEmpresa, Concepto:=TxtConcepto.Text, FechaPoliza:=TxtFechaDocumento.Text.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario)
+
+ For Each row As GridViewRow In GvPrePoliza.Rows
+ If row.DataKey("CvePrePolizaDetalle").ToEntero > 0 Then
+ If row.FCCheckBox("chkModificado").Checked Then
+ If Not ObjContabilidad.UpdatePrePolizasDetalle(row.DataKey("CvePrePolizaDetalle").ToEntero, row.FCLiteral("TxtConcepto").Text, row.DataKey("CveSubProyecto").ToEntero,
+ row.DataKey("IdCtaContable").ToEntero, If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
+ row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), CveTipoGasto:=If(DdlTipoGasto.Visible, row.DataKey("CveTipoGasto").ToEntero, row.DataKey("CveTipoGasto").ToEntero),
+ CveConceptoContable:=row.DataKey("CveConceptoContable").ToEntero, CveProveedor:=row.DataKey("CveProveedor").ToEntero, CveCompra:=row.DataKey("CveCompra").ToEntero,
+ CveCliente:=row.DataKey("CveCliente").ToEntero, CveVenta:=row.DataKey("CveVenta").ToEntero, CvePersonal:=row.DataKey("CvePersonal").ToEntero, Referencia:=row.FCLiteral("TxtRef").Text, CveCuenta:=row.DataKey("CveCuenta").ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
+ OcurrioError = True
+ Exit For
+ End If
+ End If
+ Else
+ If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePoliza, If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
+ row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), row.DataKey("Referencia").ToString,
+ row.DataKey("CveConceptoContable").ToEntero, row.FCLiteral("TxtConcepto").Text, Now,
+ row.DataKey("IdCtaContable").ToEntero, 0, CveSubProyecto:=row.DataKey("CveSubProyecto").ToEntero,
+ CveTipoGasto:=If(DdlTipoGasto.Visible, row.DataKey("CveTipoGasto").ToEntero, row.DataKey("CveTipoGasto").ToEntero),
+ ImporteMX:=If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
+ row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), CveProveedor:=row.DataKey("CveProveedor").ToEntero,
+ CveCompra:=row.DataKey("CveCompra").ToEntero, CveCliente:=row.DataKey("CveCliente").ToEntero, CveVenta:=row.DataKey("CveVenta").ToEntero,
+ CvePersonal:=row.DataKey("CvePersonal").ToEntero) Then
+ OcurrioError = True
+ Exit For
+ End If
+ End If
+
+ Next
+
+ If Not OcurrioError Then
+ ObjContabilidad.Commit()
+ Alert("La PrePoliza se actualizó correctamente.", TipoMensaje.MsgInformacion)
+ Else
+ ObjContabilidad.RollBack()
+ Alert("Ocurrio un error al actualizar la PrePoliza.", TipoMensaje.MsgError)
+ End If
+
+ ObjContabilidad.Dispose()
+ CargaPrePoliza()
+ End Sub
+ Protected Sub LnkAddConcepto_Click(sender As Object, e As EventArgs)
+ RegistraScript(String.Format("$('#{0}').modal();", "DivEditConcepto"))
+ LtlTitulo.Text = "Agregar Concepto"
+ BtnAceptar.Text = "Agregar"
+ LimpiaCampos()
+
+ CargaConceptosContablesE()
+ CargaSubProyectoE()
+ CargaTipoGastoE()
+ CargaCtaContableE()
+
+
+ UpdatePanel1.Update()
+ End Sub
+ Protected Sub GvPrePoliza_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvPrePoliza.RowUpdating
+ RegistraScript(String.Format("$('#{0}').modal();", "DivEditConcepto"))
+ LtlTitulo.Text = "Editar Concepto"
+ BtnAceptar.Text = "Aceptar"
+ LimpiaCampos()
+ IndiceGrid = e.RowIndex
+
+ Dim CveConceptoContable As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveConceptoContable").ToEntero
+ Dim CveProveedor As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveProveedor").ToEntero
+ Dim CveCompra As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveCompra").ToEntero
+ Dim CvePersonal As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CvePersonal").ToEntero
+ Dim CveCliente As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveCliente").ToEntero
+ Dim CveVenta As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveVenta").ToEntero
+ 'Dim FolioFactura As String = GvPrePoliza.Rows(IndiceGrid).FCHyperLink("HlReferencia").Text
+ Dim Concepto As String = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtConcepto").Text
+ Dim Referencia As String = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtRef").Text
+ Dim CveSubProyecto As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveSubProyecto").ToString.ToEntero
+ Dim CveTipoGasto As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveTipoGasto").ToString.ToEntero
+ Dim CveCuenta As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveCuenta").ToString.ToEntero
+ Dim Cargo As Double = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtCargo").Text.ToDouble
+ Dim Abono As Double = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtAbono").Text.ToDouble
+
+ CargaConceptosContablesE()
+ DdlConceptosContablesE.SelectedValueExist(CveConceptoContable)
+ DdlConceptosContablesE_SelectedIndexChanged(DdlConceptosContablesE, e)
+
+ DdlProveedoresE.SelectedValueExist(CveProveedor)
+ DdlProveedoresE_SelectedIndexChanged(DdlProveedoresE, e)
+ DdlComprasE.SelectedValueExist(CveCompra)
+
+ DdlPersonalE.SelectedValueExist(CvePersonal)
+
+ DdlClientesE.SelectedValue = CveCliente
+ DdlClientesE.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("NombreComercial", $"CveCliente={CveCliente}")
+ DdlClientesE_SelectedIndexChanged(DdlClientesE, e)
+ DdlVentasE.SelectedValueExist(CveVenta)
+
+ TxtConceptoE.Text = Concepto
+ TxtReferenciaE.Text = Referencia
+
+ CargaSubProyectoE()
+ DdlSubProyectoE.SelectedValueExist(CveSubProyecto)
+ CargaTipoGastoE()
+ DdlTipoGastoE.SelectedValueExist(CveTipoGasto)
+ CargaCtaContableE()
+ DdlCtaContableE.SelectedValueExist(CveCuenta)
+
+ If Cargo <> 0 Then
+ TxtCargoE.Text = Cargo
+ End If
+
+ If Abono <> 0 Then
+ TxtAbonoE.Text = Abono
+ End If
+
+ UpdatePanel1.Update()
+
+ End Sub
+ Private Sub LimpiaCampos()
+ IndiceGrid = -1
+ TxtConceptoE.Text = ""
+ TxtCargoE.Text = ""
+ TxtAbonoE.Text = ""
+ TxtReferenciaE.Text = ""
+ End Sub
+ Private Sub CargaConceptosContablesE()
+ DdlConceptosContablesE.DataSource = GlobalDTContaConceptosContables(-1)
+ DdlConceptosContablesE.DataBind()
+ End Sub
+ Private Sub CargaSubProyectoE()
+ DdlSubProyectoE.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
+ DdlSubProyectoE.DataBind()
+ DdlSubProyectoE.Items.Insert(0, New ListItem(" - ", "-1"))
+ End Sub
+ Private Sub CargaTipoGastoE()
+ DdlTipoGastoE.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
+ DdlTipoGastoE.DataBind()
+ DdlTipoGastoE.Items.Insert(0, New ListItem("Sin Asignar", "0"))
+ End Sub
+ Private Sub CargaCtaContableE()
+ Dim ObjConta As New ClsContabilidad
+ If ObjConta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then
+ DdlCtaContableE.DataSource = ObjConta.DtResultados
+ End If
+ ObjConta.Dispose()
+
+ DdlCtaContableE.DataBind()
+ DdlCtaContableE.Items.Insert(0, New ListItem("Sin Asignar", "0"))
+ End Sub
+ Private Sub DdlConceptosContablesE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConceptosContablesE.SelectedIndexChanged
+ If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(5, 17, 201, 206, 14, 15, 16, 19, 25, 26, 21) Then
+ CargaProveedoresE()
+ DdlProveedoresE.Visible = True
+ DdlComprasE.Visible = True
+ Else
+ DdlProveedoresE.Visible = False
+ DdlComprasE.Visible = False
+ End If
+
+ If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(28, 29) Then
+ CargaPersonalE()
+ DdlPersonalE.Visible = True
+ Else
+ DdlPersonalE.Visible = False
+ End If
+
+ If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(51) Then
+ CargaClasificacionesE()
+ DdlClasificacionesE.Visible = True
+ Else
+ DdlClasificacionesE.Visible = False
+ End If
+ If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(1, 2, 203, 207, 13, 61, 8, 9, 62, 63, 38, 39, 12, 91) Then
+ CargaClientesE()
+ DdlClientesE.Visible = True
+ DdlVentasE.Visible = True
+ Else
+ DdlClientesE.Visible = False
+ DdlVentasE.Visible = False
+ End If
+ End Sub
+ Private Sub CargaProveedoresE()
+ DdlProveedoresE.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
+ DdlProveedoresE.DataBind()
+ DdlProveedoresE.Items.Insert(0, New ListItem(" - ", "-1"))
+ End Sub
+ Private Sub CargaComprasE(CveProveedor As Integer)
+ If Not DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(21) Then
+ Dim ObjCompras As New ClsCompras
+
+ DdlComprasE.ClearSelection()
+ If ObjCompras.GetCompras(-1, "-1", "-1", CveProveedor, -1, UsuarioActual.CveEmpresa) Then
+ DdlComprasE.DataSource = ObjCompras.DtResultados.FiltraParametros("Saldo > 0")
+ DdlComprasE.DataBind()
+ DdlComprasE.Items.Insert(0, New ListItem(" - ", "-1"))
+ Else
+ DdlComprasE.DataSource = Nothing
+ DdlComprasE.DataBind()
+ DdlComprasE.Items.Insert(0, New ListItem(" - ", "-1"))
+ End If
+ ObjCompras.Dispose()
+ End If
+ End Sub
+ Private Sub CargaClientesE()
+ DdlClientesE.setEsWebService(True)
+ DdlClientesE.Attributes.Add("data-metodo", "getcliente")
+ DdlClientesE.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
+ DdlClientesE.DataBind()
+ ' DdlClientes.Items.Insert(0, New ListItem(" - ", "-1"))
+ End Sub
+ Private Sub CargaVentasE(CveCliente As Integer)
+ Dim ObjVentas As New ClsVentas
+
+ DdlVentasE.ClearSelection()
+ If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1", CveCliente, -1, -1, -1, "-1", "-1", "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
+ DdlVentasE.DataSource = ObjVentas.DtResultados '.FiltraParametros("Saldo > 0")
+ DdlVentasE.DataBind()
+ DdlVentasE.Items.Insert(0, New ListItem(" - ", "-1"))
+ Else
+ DdlVentasE.DataSource = Nothing
+ DdlVentasE.DataBind()
+ DdlVentasE.Items.Insert(0, New ListItem(" - ", "-1"))
+ End If
+ ObjVentas.Dispose()
+ End Sub
+ Private Sub CargaPersonalE()
+ DdlPersonalE.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
+ DdlPersonalE.DataBind()
+ DdlPersonalE.Items.Insert(0, New ListItem(" - ", "-1"))
+ End Sub
+
+ Private Sub CargaClasificacionesE()
+ DdlClasificacionesE.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
+ DdlClasificacionesE.DataBind()
+ DdlClasificacionesE.Items.Insert(0, New ListItem(" - ", "-1"))
+ End Sub
+ Private Sub DdlProveedoresE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedoresE.SelectedIndexChanged
+ CargaComprasE(DdlProveedoresE.SelectedValue.ToEntero)
+ End Sub
+ Private Sub DdlClientesE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientesE.selectedindexchange
+ CargaVentasE(DdlClientesE.SelectedValue.ToEntero)
+ End Sub
+ Protected Sub BtnAceptar_Click(sender As Object, e As EventArgs) Handles BtnAceptar.Click
+
+ If IndiceGrid = -1 Then
+ If DtMovimientos Is Nothing Then CreaDT()
+ If CvePrePoliza > 0 Then
+ Dim dr As DataRow = DtMovimientos.NewRow
+ dr("IdCtaContable") = DdlCtaContableE.SelectedValue
+ dr("ConceptoContable") = DdlConceptosContablesE.SelectedItem.Text
+ dr("CveConceptoContable") = DdlConceptosContablesE.SelectedValue
+ dr("Concepto") = TxtConceptoE.Text
+ dr("Referencia") = TxtReferenciaE.Text
+ dr("TipoMovto") = If(Math.Abs(TxtCargoE.Text.ToDouble) > 0, 0, 1)
+ dr("Cargo") = TxtCargoE.Text.ToDouble
+ dr("Abono") = TxtAbonoE.Text.ToDouble
+ dr("ImporteMN") = If(Math.Abs(TxtCargoE.Text.ToDouble) > 0, TxtCargoE.Text.ToDouble, TxtAbonoE.Text.ToDouble)
+ dr("CveSubProyecto") = DdlSubProyectoE.SelectedValue
+ dr("SubProyecto") = DdlSubProyectoE.SelectedItem.Text
+ dr("CveProveedor") = DdlProveedoresE.SelectedValue.ToEntero
+ dr("CveCompra") = DdlComprasE.SelectedValue.ToEntero
+ dr("CvePersonal") = DdlPersonalE.SelectedValue.ToEntero
+ dr("CveCliente") = DdlClientesE.SelectedValue.ToEntero
+ dr("CveVenta") = DdlVentasE.SelectedValue.ToEntero
+ dr("FolioFactura") = If(DdlComprasE.Visible = True, DdlComprasE.SelectedItem.ToString, If(DdlVentasE.Visible = True, DdlVentasE.SelectedItem.ToString, ""))
+
+
+ TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbonoE.Text.ToDouble).ToString.FormatoNumero
+ TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargoE.Text.ToDouble).ToString.FormatoNumero
+ DtMovimientos.Rows.Add(dr)
+ DtMovimientos.AcceptChanges()
+
+ If CvePrePoliza > 0 Then
+ GvPrePoliza.DataSource = DtMovimientos
+ GvPrePoliza.DataBind()
+ UpPrePoliza.Update()
+ End If
+ Else
+ 'Dim dr As DataRow = DtMovimientos.NewRow
+ 'Dim CodigoCuenta As String = ""
+ 'Dim NombreCuenta As String = ""
+
+ 'dr("IdCuenta") = DdlCtaContableE.SelectedValue
+
+ 'If DdlCtaContableE.SelectedValue.ToEntero > 0 Then
+ ' Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", DdlCtaContableE.SelectedValue))
+ ' If drr IsNot Nothing Then
+ ' CodigoCuenta = drr("CuentaFormato").ToString()
+ ' NombreCuenta = drr("Nombre").ToString()
+ ' End If
+ 'End If
+
+ 'dr("CodigoCuenta") = CodigoCuenta & "
" & NombreCuenta
+ 'dr("Cuenta") = DdlConceptosContablesE.SelectedItem.Text
+ 'dr("Referencia") = TxtReferenciaE.Text
+ 'dr("Concepto") = TxtConceptoE.Text
+ 'dr("TipoMovto") = If(Math.Abs(TxtCargoE.Text.ToDouble) > 0, 0, 1)
+ 'dr("EsComodin") = 0
+ 'dr("CveConcepto") = DdlConceptosContablesE.SelectedValue
+ 'dr("CveConceptoContable") = DdlConceptosContablesE.SelectedValue
+ 'dr("ConceptoContable") = DdlConceptosContablesE.SelectedItem.Text
+ 'dr("Cargo") = TxtCargoE.Text.ToDouble
+ 'dr("Abono") = TxtAbonoE.Text.ToDouble
+ ''dr("Descripcion") = TxtDescripcionE.Text
+ 'dr("CveSubProyecto") = DdlSubProyectoE.SelectedValue
+ 'dr("CveProveedor") = DdlProveedoresE.SelectedValue.ToEntero
+ 'dr("CveCompra") = DdlComprasE.SelectedValue.ToEntero
+ 'dr("CvePersonal") = DdlPersonalE.SelectedValue.ToEntero
+ 'dr("CveClasificacion") = -1
+ 'dr("CveCliente") = DdlClientesE.SelectedValue.ToEntero
+ 'dr("CveVenta") = DdlVentasE.SelectedValue.ToEntero
+
+ 'TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbonoE.Text.ToDouble).ToString.FormatoNumero
+ 'TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargoE.Text.ToDouble).ToString.FormatoNumero
+ 'DtMovimientos.Rows.Add(dr)
+ 'DtMovimientos.AcceptChanges()
+
+ 'GvMov.DataSource = DtMovimientos
+ 'GvMov.DataBind()
+ 'UPMovs.Update()
+ 'Actualizar = False
+
+ End If
+ Else
+ Dim CvePrePolizaDetalle As Integer = GvPrePoliza.DataKeys(IndiceGrid).Value.ToString.ToEntero
+ Dim Rows As DataRow() = DtMovimientos.Select("CvePrePolizaDetalle = " & CvePrePolizaDetalle)
+
+ If Rows.Count > 0 Then
+ Dim dr As DataRow = Rows(0)
+ dr("IdCtaContable") = DdlCtaContableE.SelectedValue
+ dr("ConceptoContable") = DdlConceptosContablesE.SelectedItem.Text
+ dr("CveConceptoContable") = DdlConceptosContablesE.SelectedValue
+ dr("Concepto") = TxtConceptoE.Text
+ dr("Referencia") = TxtReferenciaE.Text
+ dr("TipoMovto") = If(Math.Abs(TxtCargoE.Text.ToDouble) > 0, 0, 1)
+ dr("ImporteMN") = If(Math.Abs(TxtCargoE.Text.ToDouble) > 0, TxtCargoE.Text.ToDouble, TxtAbonoE.Text.ToDouble)
+ dr("CveSubProyecto") = DdlSubProyectoE.SelectedValue
+ dr("SubProyecto") = DdlSubProyectoE.SelectedItem.Text
+ dr("CveProveedor") = DdlProveedoresE.SelectedValue.ToEntero
+ dr("CveCompra") = DdlComprasE.SelectedValue.ToEntero
+ dr("CvePersonal") = DdlPersonalE.SelectedValue.ToEntero
+ dr("CveCliente") = DdlClientesE.SelectedValue.ToEntero
+ dr("CveVenta") = DdlVentasE.SelectedValue.ToEntero
+ dr("FolioFactura") = If(DdlComprasE.Visible = True, DdlComprasE.SelectedItem.ToString, If(DdlVentasE.Visible = True, DdlVentasE.SelectedItem.ToString, ""))
+ dr("CveCuenta") = DdlCtaContableE.SelectedValue.ToEntero
+ dr("CodigoNombreCuenta") = DdlCtaContableE.SelectedItem.Text
+
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnConceptoContable").Value = DdlConceptosContablesE.SelectedValue.ToEntero
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnProveedor").Value = DdlProveedoresE.SelectedValue.ToEntero
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnCompra").Value = DdlComprasE.SelectedValue.ToEntero
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnPersonal").Value = DdlPersonalE.SelectedValue.ToEntero
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnCliente").Value = DdlClientesE.SelectedValue.ToEntero
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnVenta").Value = DdlVentasE.SelectedValue.ToEntero
+
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnSubProyecto").Value = DdlSubProyectoE.SelectedValue.ToEntero
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnTipoGasto").Value = DdlTipoGastoE.SelectedValue.ToEntero
+ 'GvPrePoliza.Rows(IndiceGrid).FCHiddenField("HdnCtaContable").Value = DdlCtaContableE.SelectedValue.ToEntero
+
+ If TxtCargoE.Text <> "" Then
+ dr("Cargo") = TxtCargoE.Text.ToDouble
+ dr("Abono") = "".ToDouble
+ Else
+ dr("Abono") = TxtAbonoE.Text.ToDouble
+ dr("Cargo") = "".ToDouble
+ End If
+
+ TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbonoE.Text.ToDouble).ToString.FormatoNumero
+ TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargoE.Text.ToDouble).ToString.FormatoNumero
+ DtMovimientos.AcceptChanges()
+ GvPrePoliza.EditIndex = -1
+
+ If CvePrePoliza > 0 Then
+ GvPrePoliza.DataSource = DtMovimientos
+ GvPrePoliza.DataBind()
+ UpPrePoliza.Update()
+ End If
+ GvPrePoliza.Columns(11).Visible = True
+
+ GvPrePoliza.Rows(IndiceGrid).FCCheckBox("chkModificado").Checked = True
+ End If
+ End If
+
+ UpPrePoliza.Update()
+ RegistraScript("$('#DivEditConcepto').modal('hide')", "hidemodal")
+ End Sub
+ Protected Sub GvMov_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvMov.RowDeleting
+
+ Dim idMov As Integer = GvMov.DataKeys(e.RowIndex).Value.ToString.ToEntero
+
+ Dim Rows As DataRow() = DtMovimientos.Select("IDMov = " & idMov)
+ If Rows.Count > 0 Then
+ DtMovimientos.Rows.Remove(Rows(0))
+ DtMovimientos.AcceptChanges()
+ End If
+ GvMov.DataSource = DtMovimientos
+ GvMov.DataBind()
+
+ TxtTotalAbonos.Text = DtMovimientos.SUM("Abono").FormatoNumero
+ TxtTotalCargos.Text = DtMovimientos.SUM("Cargo").FormatoNumero
+
+ 'saco de la póliza el importe del cheque, que coincida la cuenta contable con la bancaria
+
+ End Sub
+
+ Private Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
+
+ If DtMovimientos Is Nothing Then CreaDT()
+
+ If Actualizar Then
+
+ Dim Rows As DataRow() = DtMovimientos.Select("IDMov = " & HdnCve.Value)
+
+ If Rows.Count > 0 Then
+ Dim dr As DataRow = Rows(0)
+ Dim CodigoCuenta As String = ""
+ Dim NombreCuenta As String = ""
+ dr("CveCuenta") = DdlCtaContable.SelectedValue
+
+ If DdlCtaContable.SelectedValue.ToEntero > 0 Then
+ Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("CveCuenta={0}", DdlCtaContable.SelectedValue))
+ If drr IsNot Nothing Then
+ CodigoCuenta = drr("CuentaFormato").ToString()
+ NombreCuenta = drr("Nombre").ToString()
+ End If
+ End If
+
+ dr("CodigoCuenta") = CodigoCuenta & "
" & NombreCuenta
+ dr("Cuenta") = DdlConceptosContables.SelectedItem
+ dr("Referencia") = TxtReferencia.Text
+ dr("Concepto") = TxtObservaciones.Text
+ dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1)
+ dr("EsComodin") = 0
+ dr("CveConcepto") = DdlConceptosContables.SelectedValue
+ dr("Cargo") = TxtCargo.Text.ToDouble
+ dr("Abono") = TxtAbono.Text.ToDouble
+ dr("Descripcion") = TxtDescripcion.Text
+ dr("CveSubProyecto") = DdlSubProyecto.SelectedValue
+ dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero
+ dr("CveCompra") = DdlCompras.SelectedValue.ToEntero
+ dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero
+ dr("CveClasificacion") = -1
+ dr("CveCliente") = DdlClientes.SelectedValue.ToEntero
+ dr("CveVenta") = DdlVentas.SelectedValue.ToEntero
+ dr("CveCuenta") = DdlCtaContable.SelectedValue.ToEntero
+ End If
+ GvMov.DataSource = DtMovimientos
+ GvMov.DataBind()
+ UPMovs.Update()
+ LbCancelarEdicion.Visible = False
+ LbAgregar.Text = "Agregar"
+
+ Else
+
+ If CvePrePoliza > 0 Then
+ Dim dr As DataRow = DtMovimientos.NewRow
+ dr("IdCtaContable") = -1 'DdlCtaContable.SelectedValue
+ dr("ConceptoContable") = DdlConceptosContables.SelectedItem.Text
+ dr("CveConceptoContable") = DdlConceptosContables.SelectedValue
+ dr("Concepto") = TxtDescripcion.Text
+ dr("Referencia") = TxtReferencia.Text
+ dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1)
+ dr("Cargo") = TxtCargo.Text.ToDouble
+ dr("Abono") = TxtAbono.Text.ToDouble
+ dr("ImporteMN") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, TxtCargo.Text.ToDouble, TxtAbono.Text.ToDouble)
+ dr("CveSubProyecto") = DdlSubProyecto.SelectedValue
+ dr("SubProyecto") = DdlSubProyecto.SelectedItem.Text
+ dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero
+ dr("CveCompra") = DdlCompras.SelectedValue.ToEntero
+ dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero
+ dr("CveCliente") = DdlClientes.SelectedValue.ToEntero
+ dr("CveVenta") = DdlVentas.SelectedValue.ToEntero
+
+
+ TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbono.Text.ToDouble).ToString.FormatoNumero
+ TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargo.Text.ToDouble).ToString.FormatoNumero
+ DtMovimientos.Rows.Add(dr)
+ DtMovimientos.AcceptChanges()
+
+ If CvePrePoliza > 0 Then
+ GvPrePoliza.DataSource = DtMovimientos
+ GvPrePoliza.DataBind()
+ UpPrePoliza.Update()
+ End If
+ Else
+ Dim dr As DataRow = DtMovimientos.NewRow
+ Dim CodigoCuenta As String = ""
+ Dim NombreCuenta As String = ""
+
+ dr("CveCuenta") = DdlCtaContable.SelectedValue
+
+ If DdlCtaContable.SelectedValue.ToEntero > 0 Then
+ Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("CveCuenta={0}", DdlCtaContable.SelectedValue))
+ If drr IsNot Nothing Then
+ CodigoCuenta = drr("CuentaFormato").ToString()
+ NombreCuenta = drr("Nombre").ToString()
+ End If
+ End If
+
+ dr("CodigoCuenta") = CodigoCuenta & "
" & NombreCuenta
+ dr("Cuenta") = DdlConceptosContables.SelectedItem.Text
+ dr("Referencia") = TxtReferencia.Text
+ dr("Concepto") = TxtObservaciones.Text
+ dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1)
+ dr("EsComodin") = 0
+ dr("CveConcepto") = DdlConceptosContables.SelectedValue
+ dr("CveConceptoContable") = DdlConceptosContables.SelectedValue
+ dr("ConceptoContable") = DdlConceptosContables.SelectedItem.Text
+ dr("Cargo") = TxtCargo.Text.ToDouble
+ dr("Abono") = TxtAbono.Text.ToDouble
+ dr("Descripcion") = TxtDescripcion.Text
+ dr("CveSubProyecto") = DdlSubProyecto.SelectedValue
+ dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero
+ dr("CveCompra") = DdlCompras.SelectedValue.ToEntero
+ dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero
+ dr("CveClasificacion") = -1
+ dr("CveCliente") = DdlClientes.SelectedValue.ToEntero
+ dr("CveVenta") = DdlVentas.SelectedValue.ToEntero
+
+ TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbono.Text.ToDouble).ToString.FormatoNumero
+ TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargo.Text.ToDouble).ToString.FormatoNumero
+ DtMovimientos.Rows.Add(dr)
+ DtMovimientos.AcceptChanges()
+
+ 'If CvePrePoliza > 0 Then
+ ' GvPrePoliza.DataSource = DtMovimientos
+ ' GvPrePoliza.DataBind()
+ ' UpPrePoliza.Update()
+ 'End If
+
+ GvMov.DataSource = DtMovimientos
+ GvMov.DataBind()
+ UPMovs.Update()
+ Actualizar = False
+
+ End If
+
+ End If
+
+ TxtCargo.Text = ""
+ TxtAbono.Text = ""
+ TxtReferencia.Text = ""
+ TxtDescripcion.Text = ""
+ End Sub
+
+#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE"
+ Public Sub Bancos_Click(sender As Object, e As EventArgs)
+ Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
+ RowIndex = GvRow.RowIndex
+
+ If GvRow.FCTextBox("TxtAbono").Text = "" Then
+ CargaTipoTransaccion("Ing")
+ Else
+ CargaTipoTransaccion("Egs")
+ End If
+
+
+ TxtDocumentoImporte.Text = If(GvRow.FCTextBox("TxtAbono").Text = "", GvRow.FCTextBox("TxtCargo").Text.FormatoNumero, GvRow.FCTextBox("TxtAbono").Text.FormatoNumero)
+ UpBancos.Update()
+ RegistraScript(String.Format("$('#{0}').modal();", "DivContadoModal"))
+ End Sub
+ Private Sub CargaTipoTransaccion(Tipo As String)
+ DdlTipoTransaccion.Items.Clear()
+ DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros($"Tipo = '{Tipo}' AND Estatus = 1 ")
+ DdlTipoTransaccion.DataBind()
+ DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
+ End Sub
+ Private Sub CargaCuentas()
+ DdlCuenta.Items.Clear()
+ DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) '.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", DdlMoneda.SelectedValue))
+ DdlCuenta.DataBind()
+ DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End Sub
+ Private Sub BtnContado_Click(sender As Object, e As EventArgs) Handles BtnContado.Click
+ CveConcepto = 30
+ CveTipoTransaccion = DdlTipoTransaccion.SelectedValue.ToEntero
+ CveCuenta = DdlCuenta.SelectedValue.ToEntero
+ Folio = TxtDocumentoFolio.Text
+ ImporteDocumento = TxtDocumentoImporte.Text.ToDecimal
+ Observaciones = TxtDocumentoObservaciones.Text
+ Beneficiario = TxtDocumentoBeneficiario.Text
+ RegistraScript(String.Format("$('#{0}').modal('hide');", "DivContadoModal"))
+ GvMov.Rows(RowIndex).FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green"
+ UPMovs.Update()
+ End Sub
+
+ Private Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
+ Dim ObjContabilidad As New ClsContabilidad
+
+ If ObjContabilidad.RemovePrePolizas(CvePrePoliza, UsuarioActual.CveEmpresa) Then
+ Alert("La Prepóliza ha sido eliminada", TipoMensaje.MsgInformacion)
+ Else
+ Alert("La Prepóliza ha podido ser eliminada", TipoMensaje.MsgError)
+ End If
+
+ ObjContabilidad.Dispose()
+ End Sub
+#End Region
+
+ Protected Sub DdlTipoGasto_SelectedIndexChanged(sender As Object, e As EventArgs)
+ If UpPrePoliza.Visible Then
+ For Each Gvr As GridViewRow In GvPrePoliza.Rows
+ Gvr.FCDropDownList("DdlTipoGasto").SelectedValueExist(DdlTipoGasto.SelectedValue)
+ Next
+ UpPrePoliza.Update()
+ End If
+ If UPMovs.Visible Then
+ For Each Gvr As GridViewRow In GvMov.Rows
+ Gvr.FCDropDownList("DdlTipoGasto").SelectedValueExist(DdlTipoGasto.SelectedValue)
+ Next
+ UPMovs.Update()
+ End If
+ End Sub
+ Protected Sub DdlSubProyectoFiltro_SelectedIndexChanged(sender As Object, e As EventArgs)
+ Dim Ddl As DropDownList = CType(sender, DropDownList)
+ For Each Gvr As GridViewRow In GvPrePoliza.Rows
+ If Ddl.SelectedValue.ToEntero > 0 Then
+ If Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero = Ddl.SelectedValue.ToEntero Or Not Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero > 0 Then
+ Gvr.Visible = True
+ Else
+ Gvr.Visible = False
+ End If
+ Else
+ Gvr.Visible = True
+ End If
+ Next
+ UpPrePoliza.Update()
+ RegistraScript("calculateAbono()", "cargo")
+ RegistraScript("calculateCargo()", "abono")
+ RegistraScript("comparar()", "compara")
+ End Sub
+ Protected Sub DdlSubProyectoFiltroMov_SelectedIndexChanged(sender As Object, e As EventArgs)
+ For Each Gvr As GridViewRow In GvMov.Rows
+ If DdlSubProyectoFiltroMov.SelectedValue.ToEntero > 0 Then
+ If Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero = DdlSubProyectoFiltroMov.SelectedValue.ToEntero Or Not Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero > 0 Then
+ Gvr.Visible = True
+ Else
+ Gvr.Visible = False
+ End If
+ Else
+ Gvr.Visible = True
+ End If
+ Next
+ UpPrePoliza.Update()
+ RegistraScript("calculateAbono()", "cargo")
+ RegistraScript("calculateCargo()", "abono")
+ RegistraScript("comparar()", "compara")
+ End Sub
+
+ Private Sub GvMov_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvMov.RowEditing
+ Actualizar = True
+ GvMov.DataKeys(e.NewEditIndex).Value.ToString.ToEntero
+ Dim idMov As Integer = GvMov.DataKeys(e.NewEditIndex).Value.ToString.ToEntero
+
+ Dim DrM As DataRow = DtMovimientos.Rows(e.NewEditIndex)
+
+ If DrM IsNot Nothing Then
+ HdnCve.Value = idMov.ToString
+
+ DdlCtaContable.SelectedValue = DrM("CveCuenta")
+ TxtReferencia.Text = DrM("Referencia")
+ TxtObservaciones.Text = DrM("Concepto")
+ ' (Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1) = dr("TipoMovto")
+ DrM("EsComodin") = 0
+ DdlConceptosContables.SelectedValue = DrM("CveConcepto").ToString
+ TxtCargo.Text = DrM("Cargo").ToString
+ TxtAbono.Text = DrM("Abono").ToString
+ TxtDescripcion.Text = DrM("Descripcion")
+ DdlSubProyecto.SelectedValue = DrM("CveSubProyecto")
+ DdlProveedores.SelectedValue = DrM("CveProveedor")
+ DdlCompras.SelectedValue = DrM("CveCompra")
+ DdlPersonal.SelectedValue = DrM("CvePersonal")
+ ' DrM("CveClasificacion") = -1
+ DdlClientes.SelectedValue = DrM("CveCliente")
+ DdlVentas.SelectedValue = DrM("CveVenta")
+ LbCancelarEdicion.Visible = True
+ LbAgregar.Text = "Actualizar"
+
+ End If
+
+ UPPDocumento.Update()
+ DivAgregarConceptos.Visible = True
+
+ 'If DtMovimientos Is Nothing Then CreaDT()
+
+ 'Dim dr As DataRow = DtMovimientos.NewRow
+ 'Dim CodigoCuenta As String = ""
+ 'Dim NombreCuenta As String = ""
+
+ 'dr("IdCuenta") = DdlCtaContable.SelectedValue
+
+ 'If DdlCtaContable.SelectedValue.ToEntero > 0 Then
+ ' Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", DdlCtaContable.SelectedValue))
+ ' If drr IsNot Nothing Then
+ ' CodigoCuenta = drr("CuentaFormato").ToString()
+ ' NombreCuenta = drr("Nombre").ToString()
+ ' End If
+ 'End If
+
+ 'dr("CodigoCuenta") = CodigoCuenta & "
" & NombreCuenta
+ 'dr("Cuenta") = DdlConceptosContables.SelectedItem
+ 'dr("Referencia") = TxtReferencia.Text
+ 'dr("Concepto") = TxtObservaciones.Text
+ 'dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1)
+ 'dr("EsComodin") = 0
+ 'dr("CveConcepto") = DdlConceptosContables.SelectedValue
+ 'dr("Cargo") = TxtCargo.Text.ToDouble
+ 'dr("Abono") = TxtAbono.Text.ToDouble
+ 'dr("Descripcion") = TxtDescripcion.Text
+ 'dr("CveSubProyecto") = DdlSubProyecto.SelectedValue
+ 'dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero
+ 'dr("CveCompra") = DdlCompras.SelectedValue.ToEntero
+ 'dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero
+ 'dr("CveClasificacion") = -1
+ 'dr("CveCliente") = DdlClientes.SelectedValue.ToEntero
+ 'dr("CveVenta") = DdlVentas.SelectedValue.ToEntero
+
+ 'TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbono.Text.ToDouble).ToString.FormatoNumero
+ 'TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargo.Text.ToDouble).ToString.FormatoNumero
+ 'DtMovimientos.Rows.Add(dr)
+
+ 'If CvePrePoliza > 0 Then
+ ' GvPrePoliza.DataSource = DtMovimientos
+ ' GvPrePoliza.DataBind()
+ 'End If
+
+
+ 'GvMov.DataSource = DtMovimientos
+ 'GvMov.DataBind()
+ 'UPMovs.Update()
+
+
+ End Sub
+
+ Private Sub LbCancelarEdicion_Click(sender As Object, e As EventArgs) Handles LbCancelarEdicion.Click
+ LbCancelarEdicion.Visible = False
+ TxtObservaciones.Text = ""
+ Actualizar = False
+ LbAgregar.Text = "Agregar"
+ End Sub
+
+ Private Sub BtnContabilizar_Click(sender As Object, e As EventArgs) Handles BtnContabilizar.Click
+
+ Dim ObjConta As New ClsContabilidad
+
+ If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
+ Alert(String.Format("Prepóliza contabilizada.
Folio:Ver Póliza", ObjConta.ContaIdPoliza), ModExtensiones.TipoMensaje.MsgInformacion)
+ Else
+
+ Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia)
+ End If
+
+ ObjConta.Dispose()
+
+
+ End Sub
+
+
+#Region "COMPLEMENTO DE PAGO"
+
+ Private Sub GeneraTimbre(CvePrePoliza As Integer)
+ Dim Str As New StringBuilder
+ Dim Banco As New ClsBancos
+ Banco.IniciaTransacSQL()
+ If Banco.GeneraTimbrePago(-1, -1, UsuarioActual, CvePrePoliza:=CvePrePoliza) Then
+ If Banco.Mensaje = "" Then
+ Banco.Commit()
+ PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False)
+ Str.AppendFormat("Folio: {0} ", Banco.ComplementoSerieFolio)
+ Str.AppendFormat("XML ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
+ Str.AppendFormat("PDF ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
+ MandaCorreo(Banco.ComplementoSerieFolio, Banco.CobranzaCorreo)
+ End If
+ Else
+ Banco.RollBack()
+ Str.AppendFormat("No se genero complemento por el siguiente motivo: {0}", Banco.Mensaje)
+ End If
+ Banco.Dispose()
+ Alert(Str.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();")
+ End Sub
+
+ Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True)
+ Try
+ Dim Msg As String = ""
+ If NombreArchivo <> "-1" Then '
+ Dim ObjMail As New ClsSisMail()
+ Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo)
+ Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo)
+ Dim Cuerpo As String = "Se hace entrega del comprobante de pago"
+ Dim Asunto As String = "Entrega de comprobante de pago"
+ If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then
+ Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
+ LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF})
+ LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML})
+ If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then
+ If ConAlerta Then
+ 'RegistraScript("$('#ModalDivMail').modal('hide');")
+ Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
+ End If
+ Else
+ Msg = "No se pudo enviar el correo electrónico."
+ End If
+ Else
+ Msg = "No se pudo adjuntar el correo electrónico."
+ End If
+ End If
+ If ConAlerta AndAlso Msg <> "" Then
+ Alert(Msg, TipoMensaje.MsgError)
+ End If
+ Catch ex As Exception
+ OnError("Ocurrió error al mandar MAIL", ex)
+ End Try
+ End Sub
+
+ Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs)
+ GeneraTimbre(CvePrePoliza)
+ End Sub
+#End Region
+
+
+
+#Region "E X C E L"
+
+
+ Private Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
+ RegistraScript(String.Format("$('#{0}').modal();", "DivCargaExcel"))
+
+ End Sub
+
+ Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
+ Dim NombreArchivo As String
+ SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
+ Dim workbook As New ExcelFile()
+ Dim worksheet = workbook.Worksheets.Add(DdlPlantilla2.SelectedItem.Text.ToString)
+
+ Dim CvePlantilla As Integer = DdlPlantilla2.SelectedValue.ToEntero
+ Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla).FiltraParametros(String.Format("CveEmpresa={0}", UsuarioActual.CveEmpresa), "Orden")
+
+ Dim DtExcel As DataTable = (From row As DataRow In Dt.Rows
+ Select New With
+ {
+ .ConceptoAdministrativo = row.Item("ConceptoContable"),
+ .Cuenta = row.Item("Codigo"),
+ .NombreCuenta = row.Item("NombreCuenta"),
+ .Cargo = "",
+ .Abono = "",
+ .Referencia = "",
+ .Concepto = "",
+ .SubProyecto = row.Item("SubProyecto"),
+ .CveConceptoContable = row.Item("CveConcepto"),
+ .CveSubProyecto = IIf(row.Item("CveSubProyecto").ToString.ToEntero > 0, row.Item("CveSubProyecto"), -1),
+ .IdCtaContable = IIf(row.Item("IdCtaContable").ToString.ToEntero > 0, row.Item("IdCtaContable"), -1),
+ .CveCuenta = row.Item("CveCuenta")
+ }).QueryToDataTable(True)
+
+ worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
+ {
+ .ColumnHeaders = True,
+ .StartRow = 0,
+ .StartColumn = 0
+ })
+
+ Dim columnCount = worksheet.CalculateMaxUsedColumns()
+ For i = 0 To columnCount
+ worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
+ Next
+ worksheet.Columns("I").Hidden = True
+ worksheet.Columns("J").Hidden = True
+ worksheet.Columns("K").Hidden = True
+ worksheet.Columns("L").Hidden = True
+
+
+ NombreArchivo = DdlPlantilla2.SelectedItem.Text.ToString
+ workbook.Save(Response, $"{NombreArchivo}.xlsx", SaveOptions.XlsxDefault)
+
+
+ End Sub
+
+ Protected Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
+ If TxtExcel.getfiles().Archivos.Count > 0 Then
+ Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
+
+ Dim Directorio As String = Server.MapPath("~") & file.patch
+
+ Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
+ CargarArchivo(Directorio, file.filename, Tipo)
+ Else
+ Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
+ End If
+ End Sub
+ Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
+ Dim dt As New DataTable
+ ' Conexion As Odbc.OdbcConnection = Nothing
+ Dim ErrorArchivo = False
+ Dim ErrorExcel = False
+ DdlPlantilla.SelectedValue = DdlPlantilla2.SelectedValue
+ dt = ReadExcelFile(Ruta + FileName, True)
+
+
+ If Not ErrorArchivo Then
+
+ If Not dt.Columns(0).ColumnName = "ConceptoAdministrativo" Then
+ Alert("El nombre de la primera columna debe ser 'ConceptoAdmin'. Favor de corregirlo", TipoMensaje.MsgError)
+ Exit Sub
+ End If
+ If Not dt.Columns(1).ColumnName = "Cuenta" Then
+ Alert("El nombre de la segunda columna debe ser 'Cuenta'.Favor de corregirlo", TipoMensaje.MsgError)
+ Exit Sub
+ End If
+ If Not dt.Columns(2).ColumnName = "NombreCuenta" Then
+ Alert("El nombre de la tercera columna debe ser 'NombreCuenta'.Favor de corregirlo", TipoMensaje.MsgError)
+ Exit Sub
+ End If
+ If Not dt.Columns(3).ColumnName = "Cargo" Then
+ Alert("El nombre de la cuarta columna debe ser 'Cargo'. Favor de corregirlo", TipoMensaje.MsgError)
+ Exit Sub
+ End If
+ If Not dt.Columns(4).ColumnName = "Abono" Then
+ Alert("El nombre de la quinta columna debe ser 'Abono' .Favor de corregirlo", TipoMensaje.MsgError)
+ Exit Sub
+ End If
+ If Not dt.Columns(5).ColumnName = "Referencia" Then
+ Alert("El nombre de la sexta columna debe ser 'Referencia'. Favor de corregirlo", TipoMensaje.MsgError)
+ Exit Sub
+ End If
+ If Not dt.Columns(6).ColumnName = "Concepto" Then
+ Alert("El nombre de la séptima columna debe ser 'Concepto'.Favor de corregirlo", TipoMensaje.MsgError)
+ Exit Sub
+ End If
+ If Not dt.Columns(7).ColumnName = "SubProyecto" Then
+ Alert("El nombre de la octava columna debe ser 'SubProyecto'. Favor de corregirlo", TipoMensaje.MsgError)
+ Exit Sub
+ End If
+ End If
+
+ If Not ErrorArchivo Then
+
+ DtMovimientos.Clear()
+
+ Dim ObjConta As New ClsContabilidad()
+ ObjConta.IniciaTransacSQL()
+ Try
+
+
+ For Each Row As DataRow In dt.FiltraParametros("ConceptoAdministrativo <> ''").Rows
+
+ Dim NombreCuenta As String = Row("NombreCuenta").ToString
+ Dim Cuenta As String = Row("Cuenta").ToString
+ Dim ConceptoAdministrativo As String = Row("ConceptoAdministrativo").ToString
+
+ Dim CveSubProyecto As Integer = -1
+ Dim TipoMovto As Boolean = If(Row("Cargo").ToString.ToDecimal <> 0, False, True)
+ Dim CveConceptoContable As Integer = GlobalDTContaConceptosContables(-1).FiltroPrimeroValor("CveConceptoContable", String.Format("ConceptoContable ='{0}'", Row("ConceptoAdministrativo"))).ToEntero ' Row("CveConceptoContable").ToString.ToEntero
+ 'Dim IdCtaContable As Integer = Row("IdCtaContable").ToString.ToEntero
+ Dim CveClasificacion As Integer = -1
+ Dim CveCuenta As Integer = -1
+ Dim ObjConta2 As New ClsContabilidad
+ If ObjConta2.GetCuentas(-1, Row("Cuenta").ToString.Replace("-", ""), 1, UsuarioActual.CveEmpresa) Then
+ CveCuenta = ObjConta2.DtResultados.FiltroPrimeroValor("CveCuenta", "").ToEntero
+ NombreCuenta = ObjConta2.DtResultados.FiltroPrimeroValor("CtaCodigo", "")
+ End If
+ ObjConta2.Dispose()
+
+ If CveCuenta <= 0 AndAlso CveConceptoContable <> 30 Then
+ Alert(String.Format("La cuenta {0} no se reconoció, favor de verificar el archivo.", Row("Cuenta").ToString))
+ DtMovimientos.Clear()
+ Exit For
+ End If
+
+ 'sino viene el cveconcepto, busca por le nombre del concepto
+ If CveConceptoContable = 0 Then
+ Alert(String.Format("El concepto {0} no se reconoció, favor de verificar el archivo.", Row("ConceptoAdministrativo")))
+ DtMovimientos.Clear()
+ Exit For
+ End If
+
+ If Row("SubProyecto").ToString.Trim <> "" Then
+ CveSubProyecto = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=-1).FiltroPrimeroValor("CveSubProyecto", String.Format("SubProyecto = '{0}'", Row("SubProyecto").ToString.Trim)).ToEntero 'Row("CveSubProyecto").ToString.ToEntero
+
+ If CveSubProyecto = 0 Then
+ Alert(String.Format("El subproyecto {0} no se reconoció, favor de verificar el archivo.", Row("SubProyecto")))
+ DtMovimientos.Clear()
+ Exit For
+ End If
+
+ End If
+
+ If CveConceptoContable = 69 Then
+ CveClasificacion = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", "").ToEntero
+ End If
+
+ Dim dr As DataRow = DtMovimientos.NewRow
+ Dim CodigoCuenta As String = ""
+
+ dr("CodigoCuenta") = NombreCuenta 'Cuenta & "
" & NombreCuenta
+ dr("Cuenta") = ConceptoAdministrativo
+ dr("Referencia") = Row("Referencia").ToString
+ dr("Concepto") = Row("Concepto").ToString
+ dr("TipoMovto") = TipoMovto
+ dr("EsComodin") = 0
+ dr("CveConcepto") = CveConceptoContable
+ dr("CveConceptoContable") = CveConceptoContable
+ dr("ConceptoContable") = Row("ConceptoAdministrativo").ToString
+ dr("Cargo") = Row("Cargo").ToString.ToDecimal.RoundSQL
+ dr("Abono") = Row("Abono").ToString.ToDecimal.RoundSQL
+ dr("Descripcion") = Row("Concepto").ToString
+ dr("CveSubProyecto") = CveSubProyecto
+ dr("CveProveedor") = -1
+ dr("CveCompra") = -1
+ dr("CvePersonal") = -1
+ dr("CveClasificacion") = CveClasificacion
+ dr("CveCliente") = -1
+ dr("CveVenta") = -1
+ dr("CveCuenta") = CveCuenta
+
+
+ DtMovimientos.Rows.Add(dr)
+ DtMovimientos.AcceptChanges()
+ Next
+
+ TxtTotalCargos.Text = DtMovimientos.SUMD("Cargo").ToString.FormatoNumero
+ TxtTotalAbonos.Text = DtMovimientos.SUMD("Abono").ToString.FormatoNumero
+
+ GvMov.DataSource = DtMovimientos
+ GvMov.DataBind()
+ UPMovs.Update()
+
+ Catch ex As Exception
+ Alert("No se pudo cargar el excel")
+ End Try
+ End If
+ End Sub
+#End Region
+
+#Region "Paquete Egresos"
+ Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs)
+ ImprimirPolizaPDF(IdPoliza)
+ End Sub
+ Private Function ImprimirPolizaPDF(IdPoliza As Integer) As String
+ Dim ObjConta As New ClsContabilidad
+ 'Dim ObjPoliza As New ClsContPAQi(UsuarioActual.Empresa)
+
+ Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/Polizas.rdlc", UsuarioActual.Empresa.Ruta))
+ Dim params As New List(Of ReportParameter)
+ Dim Bytes As Byte() = Nothing
+
+
+ 'If ObjPoliza.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjPoliza.DtResultados.Rows.Count > 0 Then
+ If ObjConta.GetPrePolizasDetalle(CvePrePoliza) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
+ Dim dtVC As DataTable
+ Dim dr As DataRow
+ dtVC = ObjConta.DtResultados.FiltraParametros("Contabilizable = 1", "Orden")
+ dr = dtVC.Rows(0)
+ Dim ruta As String = ""
+ params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
+ params.Add(New ReportParameter("TipoPoliza", dr("TipoPoliza").ToString))
+ params.Add(New ReportParameter("Finicio", dr("Fecha").ToString.ToDate.ToShortDateString))
+ params.Add(New ReportParameter("FFin", dr("Fecha").ToString.ToDate.ToShortDateString))
+ params.Add(New ReportParameter("Fecha", dr("Fecha").ToString.ToDate.ToShortDateString))
+ 'params.Add(New ReportParameter("Nombre", dr("Cuenta").ToString))
+ 'params.Add(New ReportParameter("Cuenta", dr("Codigo").ToString))
+ params.Add(New ReportParameter("Numero", dr("FolioPoliza").ToString))
+ params.Add(New ReportParameter("Moneda", ""))
+ params.Add(New ReportParameter("CodigoPostal", ""))
+ If UsuarioActual.CveEmpresa = 119 Then
+ params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre")))
+ End If
+ If UsuarioActual.CveEmpresa = 140 Then
+ params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
+ End If
+ If Archivo.Exists Then
+ ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc"
+ Else
+ ruta = "Empresas/Grales/Formatos/Polizas.rdlc"
+ End If
+ ImprimirbytesPDF(StreamPDF(ruta, dtVC, params, "ppoliza"), String.Format("{0}-{1}", TipoPoliza, dr("FolioPoliza").ToString), "PDF", True)
+
+ End If
+ Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)
+ ObjConta.Dispose()
+
+ End Function
+
+
+#End Region
+
+End Class
+
diff --git a/Compras/eFacturas.aspx b/Compras/eFacturas.aspx
index 5e0ac6e38..1a81be565 100644
--- a/Compras/eFacturas.aspx
+++ b/Compras/eFacturas.aspx
@@ -410,7 +410,7 @@
-
+
diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb
index 8ce5406bd..f3e2ed114 100644
--- a/Compras/eFacturas.aspx.vb
+++ b/Compras/eFacturas.aspx.vb
@@ -805,18 +805,20 @@ Partial Class Compras_eFacturas
End If
End If
-
- If ObjDatos.GetFacturas(-1, Folio, FechaI, FechaF, RFC, Proveedor, DdlValidado.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, DdlClasificacionProv.SelectedValue.ToEntero, DdlCveTipoProveedor.SelectedValue.ToEntero, DdlTipoComprobante.SelectedValue.ToString, UsuarioActual.CveEmpresa, Opcion:=2) Then
-
- If ObjDatos.DtResultados.Rows.Count > 0 Then
-
- DTTrasaldos = ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'T'")
-
- End If
- End If
-
LblRegistros.Text = String.Format("{0} Registros", ObjDatos.DtResultados.FiltraParametros("TipoComprobante <> 'P' and TipoComprobante <> 'T' ").Rows.Count.ToString("N0"))
LblTotalPagos.Text = String.Format("{0} Pagos", ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'P'").Rows.Count.ToString("N0"))
+
+ If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then
+ TabTraslados.Visible = True
+ If ObjDatos.GetFacturas(-1, Folio, FechaI, FechaF, RFC, Proveedor, DdlValidado.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, DdlClasificacionProv.SelectedValue.ToEntero, DdlCveTipoProveedor.SelectedValue.ToEntero, DdlTipoComprobante.SelectedValue.ToString, UsuarioActual.CveEmpresa, Opcion:=2) Then
+
+ If ObjDatos.DtResultados.Rows.Count > 0 Then
+
+ DTTrasaldos = ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'T'")
+
+ End If
+ End If
+ End If
LblTotalTraslados.Text = String.Format("{0} Traslados", ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'T'").Rows.Count.ToString("N0"))
If DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then
@@ -988,13 +990,14 @@ Partial Class Compras_eFacturas
Case "E"
e.Row.FCLabel("LtTipoComprobante").Text = "Egreso"
e.Row.FCLabel("LtTipoComprobante").CssClass = "label label-sm label-warning"
- e.Row.FCLabel("LtTipoComprobante").Attributes.Add("data-toggle", "tooltip")
+ e.Row.FCLabel("LtTipoComprobante").Attributes.Add("data-toggle", "tooltip") '
e.Row.FCLabel("LtTipoComprobante").Attributes.Add("title", "Egreso")
Case "P"
e.Row.FCLabel("LtTipoComprobante").Text = "Pago"
e.Row.FCLabel("LtTipoComprobante").CssClass = "label label-sm label-primary"
e.Row.FCLabel("LtTipoComprobante").Attributes.Add("data-toggle", "tooltip")
e.Row.FCLabel("LtTipoComprobante").Attributes.Add("title", "Complemento Pago")
+
End Select
e.Row.Cells(2).Attributes.Add("data-order", e.Row.DBCampo("FechaFactura").ToDate.Ticks.ToString)
diff --git a/Contabilidad/RepIVA.aspx b/Contabilidad/RepIVA.aspx
index 9796dade0..644b42cd9 100644
--- a/Contabilidad/RepIVA.aspx
+++ b/Contabilidad/RepIVA.aspx
@@ -132,13 +132,12 @@
-
+
-
+
-
-
+
@@ -149,11 +148,10 @@
-
-
-
+
+
-
+
diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb
index 4917f0a79..03b143199 100644
--- a/General/SaldosIniciales.aspx.vb
+++ b/General/SaldosIniciales.aspx.vb
@@ -255,7 +255,7 @@ Partial Class General_SaldosIniciales
Alert("El nombre de la quinta columna debe ser 'Fecha'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
- If Not dt.Columns(5).ColumnName = "SubTotal" Then
+ If Not dt.Columns(5).ColumnName.ToLower = "subtotal" Then
Alert("El nombre de la sexta columna debe ser 'SubTotal'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
@@ -275,11 +275,11 @@ Partial Class General_SaldosIniciales
Alert("El nombre de la décima columna debe ser 'Tipo Documento'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
- If Not dt.Columns(10).ColumnName = "Ret IVA" Then
+ If Not dt.Columns(10).ColumnName.ToLower.Contiene("ret iva", "ret iva") Then
Alert("El nombre de la onceava columna debe ser 'Ret IVA'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
- If Not dt.Columns(11).ColumnName = "Ret ISR" Then
+ If Not dt.Columns(11).ColumnName.ToLower = "ret isr" Then
Alert("El nombre de la doceava columna debe ser 'Ret ISR'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
@@ -289,7 +289,7 @@ Partial Class General_SaldosIniciales
Exit Sub
End If
- If Not dt.Columns(13).ColumnName = "Tipo Cambio" Then
+ If Not dt.Columns(13).ColumnName.Contiene("Tipo Cambio", "Tipo de Cambio") Then
Alert("El nombre de la catorceava columna debe ser 'Tipo Cambio'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
@@ -1127,7 +1127,7 @@ Partial Class General_SaldosIniciales
Dim CodProvee As String = "" 'Row("CodProvee2").ToString
'Moneda
- If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN") Then
+ If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN", "MONEDA NACIONAL") Then
CveMoneda = 1
ElseIf Moneda.ToUpper.Contiene("DOLARES", "DOLAR", "USD", "DÓLARES") Then
CveMoneda = 2
@@ -1792,6 +1792,7 @@ Partial Class General_SaldosIniciales
Dim almacenActual As String = almacenSinRepetir("Almacen").ToString.Trim
'Dim CveAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"Almacen = '{almacenActual}'").ToEntero
Dim CveAlmacen As Integer = AlmacenRef.FiltroPrimeroValor("CveAlmacen", $"Almacen = '{almacenActual}'").ToEntero
+
If CveAlmacen > 0 Then
Dim movimientoCabecera As Integer = ObjMovimientos.AddMovimiento(CveAlmacen, DdlConceptoAlmacen.SelectedValue.ToEntero, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1)
listadoMovimientos += $"movimiento con folio {ObjMovimientos.Folio}
"
@@ -1807,8 +1808,9 @@ Partial Class General_SaldosIniciales
If CveUM > 0 Then
Dim Cantidad As Decimal = nuevaEntrada("Existencia").ToString.ToDecimal
Dim Valor As Decimal = nuevaEntrada("Valor").ToString.ToDecimal
+ Dim Serie As String = If(dt.Columns.Contains("Serie"), nuevaEntrada("Serie").ToString.Trim, "")
- If Not ObjMovimientos.AddMovimientoDetalle(movimientoCabecera, Cantidad, CveUM, CvePS, (Valor / Cantidad), -1, -1) Then
+ If Not ObjMovimientos.AddMovimientoDetalle(movimientoCabecera, Cantidad, CveUM, CvePS, (Valor / Cantidad), -1, -1, Serie:=Serie) Then
mensajeError = "No se logró generar el detalle del movimiento"
Throw New Exception()
End If
diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb
index d6556f4de..fcae2a7bd 100644
--- a/Inventarios/EntradasSalidas.aspx.vb
+++ b/Inventarios/EntradasSalidas.aspx.vb
@@ -777,13 +777,14 @@ Partial Class Inventarios_EntradasSalidas
If drM("CveEstatusTimbrado").ToString.ToEntero > 0 Then
HplDescargaXml.Visible = True
HplDescargaXml.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "XML", drM("TimbreSerieFolio"), "Tra")))
- HplDescargaPdf.Visible = True
- HplDescargaPdf.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "PDF", drM("TimbreSerieFolio"), "Tra")))
If drM("AplicaCP").ToString = "True" Then
HplCartaPorteTimbre.Visible = True
- HplCartaPorteTimbre.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPOTIMBRE&CVEMOV={0}", CveMovimiento)))
+ HplCartaPorteTimbre.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPOTIMBRE&CVEMOV={0}&CVETIMBRE={1}", CveMovimiento, drM("CveTimbre"))))
Else
+ HplDescargaPdf.Visible = True
+ HplDescargaPdf.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "PDF", drM("TimbreSerieFolio"), "Tra")))
+
HplCartaPorte.Visible = True
HplCartaPorte.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimiento)))
End If
diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb
index a71cb65b7..8672666da 100644
--- a/Inventarios/EntregaAlmacen.aspx.vb
+++ b/Inventarios/EntregaAlmacen.aspx.vb
@@ -931,9 +931,15 @@ Partial Class Inventarios_EntregaAlmacen
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
- If CBool(e.Row.DBCampo("AplicaSerie")) Then
+ 'código temporal
+ Dim AplicaSerie As Boolean = CBool(e.Row.DBCampo("AplicaSerie"))
+ If UsuarioActual.CveEmpresa = 140 AndAlso Not CveSubProyecto.Contiene(11793, 11993, 11794, 11795) Then
+ AplicaSerie = False
+ End If
+
+ If AplicaSerie Then
e.Row.FCButton("BtnSerie").Visible = True
- e.Row.FCButton("BtnSerie").Text = If(e.Row.DBCampo("Inv_CveMetodoInventario").ToString() = "5", "Serie", "Lote-Batch")
+ e.Row.FCButton("BtnSerie").Text = "Serie"
e.Row.FCButton("BtnSerie").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec"), e.Row.DBCampo("Inv_CveMetodoInventario"))
e.Row.FCTextBox("TbCantidadF").Enabled = False
e.Row.FCCheckBox("cbInv").Enabled = False
@@ -1040,7 +1046,7 @@ Partial Class Inventarios_EntregaAlmacen
e.Row.FCTextBox("TbCantidadF").Text = "0"
'NO BLOQUEA PARA ROL AD
If UsuarioActual.CveRol = 1 Then
- If e.Row.DBCampo("Inv_CveMetodoInventario").Contiene("5", "6") Then
+ If AplicaSerie Then
e.Row.FCTextBox("TbCantidadF").Enabled = False
Else
e.Row.FCTextBox("TbCantidadF").Text = e.Row.DBCampo("CantidadF").ToDecimal.ToString("#,##0.######")
@@ -1094,18 +1100,20 @@ Partial Class Inventarios_EntregaAlmacen
CveUMSerie = Argumentos(1).ToEntero()
PSSerie = Argumentos(2).ToString()
CveConsecSerie = Argumentos(4).ToEntero()
- CveMetodoInventario = Argumentos(5).ToEntero()
-
- If CveMetodoInventario = 5 Then
- RegistraScript("$('#DivSerie').modal('show')")
- CargaSerie()
- UpSerie.Update()
- ElseIf CveMetodoInventario = 6 Then
+ CveMetodoInventario = Argumentos(5).ToEntero()
+
+
+ If CveMetodoInventario = 6 Then
RegistraScript("$('#DivLote').modal('show')")
- CargaLote()
+ CargaLote()
UpLoteBatch.Update()
- End If
-
+ Else
+ RegistraScript("$('#DivSerie').modal('show')")
+ CargaSerie()
+ UpSerie.Update()
+ End If
+
+
End Sub
#Region " AGREGA POR SERIE/LOTE "
@@ -1193,7 +1201,7 @@ Partial Class Inventarios_EntregaAlmacen
'SI TIENE SALIDA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD
Dim Contador = 0
For Each Gvr As GridViewRow In GvDatos.Rows
- If Gvr.DataKey("AplicaSerieLote") = "True" Then
+ If Gvr.DataKey("AplicaSerie") = "True" Then
Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count
Gvr.FCCheckBox("cbInv").Enabled = False
Gvr.FCCheckBox("cbInv").Checked = True
@@ -2319,8 +2327,9 @@ Partial Class Inventarios_EntregaAlmacen
Dim CveTamaño As Integer = RowGarantia("CveTamaño").ToString().ToEntero()
Dim CveUM As Integer = RowGarantia("CveUnidadMedida").ToString().ToEntero()
Dim PU As Decimal = RowGarantia("Importe").ToString().ToDecimal() ' / RowGarantia("Cantidad").ToString().ToDouble()
+ Dim Serie As String = RowGarantia("Comprobante").ToString
- If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU) Then
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU, Serie:=Serie) Then
ErrorMovInv = True
TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
Exit For
diff --git a/Inventarios/EntregaAlmacenRuta.aspx b/Inventarios/EntregaAlmacenRuta.aspx
index 85f2ffb50..a86fa953e 100644
--- a/Inventarios/EntregaAlmacenRuta.aspx
+++ b/Inventarios/EntregaAlmacenRuta.aspx
@@ -60,8 +60,8 @@