diff --git a/Ventas/RepCancelacionesPorRespuesta.aspx.cs b/Ventas/RepCancelacionesPorRespuesta.aspx.cs index 48fb356ac..96c2c35c3 100644 --- a/Ventas/RepCancelacionesPorRespuesta.aspx.cs +++ b/Ventas/RepCancelacionesPorRespuesta.aspx.cs @@ -34,39 +34,48 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas private void CargaDatos() { HdnLigaRefacturar.Value = ""; + if (Request["CveVenta"] != null) { this.CveVenta = Request["CveVenta"].ToString().ToEntero(); } + var ObjVentas = new ClsVentas(); if (ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -2, -1, "-1", "-1", "-1", CveUsuarioConsulta: UsuarioActual.CveUsuario)) - { - if (CveVenta > 0) - { - DtVentas = ObjVentas.DtResultados.FiltraParametros($"CveVenta={CveVenta}"); - } - else - { - DtVentas = ObjVentas.DtResultados.Copy(); + { + + if (Request["CveVenta"] != null && Request["CveVenta"].ToString().ToEntero() > 0) + { + DtVentas = ObjVentas.DtResultados.FiltraParametros($"CveVenta={Request["CveVenta"].ToString().ToEntero()}"); + } + else + { + DtVentas = ObjVentas.DtResultados.Copy(); } } + ObjVentas.Dispose(); GvDatos.DataSource = DtVentas.FiltraParametros("CveEstatusFactura = 20 AND CveEstatusRefacturacion = 0"); + var DtRefacturar = DtVentas.FiltraParametros("CveEstatusRefacturacion IN (1,3)"); - if (DtRefacturar.Rows.Count > 0) + if (DtRefacturar != null && DtRefacturar.Rows.Count > 0) { DivRefacturar.Visible = true; GvRefacturaciones.DataSource = DtRefacturar; GvRefacturaciones.DataBind(); } + GvDatos.DataBind(); UPDatos.Update(); } protected void BtnValidar_Click(object sender, EventArgs e) { - HdnLigaRefacturar.Value = ""; + this.HdnLigaRefacturar.Value = ""; + this.CveVenta = -1; + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); - int CveVenta = GvRow.DataKey("CveVenta").ToEntero(); + this.CveVenta = GvRow.DataKey("CveVenta").ToEntero(); + int CveCliente = GvRow.DataKey("CveCliente").ToEntero(); string Total = GvRow.DataKey("Total"); string SubTotal = GvRow.DataKey("SubTotal"); @@ -92,9 +101,12 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas } protected void BtnValidarRefacturacion_Click(object sender, EventArgs e) { - HdnLigaRefacturar.Value = ""; + this.HdnLigaRefacturar.Value = ""; + this.CveVenta = -1; + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); - int CveVenta = GvRow.DataKey("CveVenta").ToEntero(); + this.CveVenta = GvRow.DataKey("CveVenta").ToEntero(); + int CveCliente = GvRow.DataKey("CveCliente").ToEntero(); string Total = GvRow.DataKey("Total"); string SubTotal = GvRow.DataKey("SubTotal"); @@ -134,6 +146,7 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas private MRespuestaSAT VerificarVigenciaSAT(int CveVenta, int CveCliente, string Folio, string TipoDocto, string uuid, string emisor, string receptor, string total, bool EsRefacturacion = false) { HdnLigaRefacturar.Value = ""; + var retorno = new MRespuestaSAT() { Mensaje = "", @@ -291,7 +304,10 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas } protected void LnkValidar_Click(object sender, EventArgs e) - { + { + this.HdnLigaRefacturar.Value = ""; + this.CveVenta = -1; + if (DtVentas != null) { var sb = new StringBuilder(); @@ -328,7 +344,14 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas } public void BtnEnviarMailCancelacion_Click(object sender, EventArgs e) { - ImprimeCancelacion(CveVenta); + if (this.CveVenta > 0) + { + ImprimeCancelacion(this.CveVenta); + } + else + { + Alert("No se encontro la factura para enviar el acuse", TipoMensaje.MsgAdvertencia); + } } public void ImprimeCancelacion(int CveVenta)