Commit inicial Ventas Productivo
This commit is contained in:
165
Ventas/RepCancelacionesPorAtender.aspx.cs
Normal file
165
Ventas/RepCancelacionesPorAtender.aspx.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Extensiones;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
|
||||
public partial class Ventas_RepCancelacionesPorAtender : ClsPaginas
|
||||
{
|
||||
private string PACUsuario = "rene.molina@adsistemas.mx";
|
||||
private string PACContrasenia = "rene2018";
|
||||
private string XmlPendientes
|
||||
{
|
||||
get { return (ViewState["XmlPendientes"] == null) ? "" : ViewState["XmlPendientes"].ToString(); }
|
||||
set { ViewState["XmlPendientes"] = value; }
|
||||
}
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
CargarPendientes();
|
||||
}
|
||||
}
|
||||
private void CargarPendientes()
|
||||
{
|
||||
Cancelacion.CancelacionSoapClient objServicio = new Cancelacion.CancelacionSoapClient();
|
||||
Cancelacion.StructCancel resp = objServicio.ObtienePendientes(UsuarioActual.Empresa.RFC, "UserTest", "1234567890");
|
||||
if (resp.Estado == 0)
|
||||
{
|
||||
string XmlPendientes = DecodeBase64(resp.Xml);
|
||||
StringReader theReader = new StringReader(XmlPendientes);
|
||||
DataSet theDataSet = new DataSet();
|
||||
theDataSet.ReadXml(theReader);
|
||||
if (theDataSet.Tables[0].Rows[0]["Uuid"].ToString() != "null")
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (DataRow item in theDataSet.Tables[0].Rows)
|
||||
{
|
||||
sb.AppendFormat("{0};", item["Uuid"].ToString());
|
||||
}
|
||||
var ObjVentas = new ClsVentas();
|
||||
if (ObjVentas.GetFacturasCanceladasPendientes(sb.ToString(), UsuarioActual.CveEmpresa))
|
||||
{
|
||||
GvDatos.DataSource = ObjVentas.DtResultados;
|
||||
}
|
||||
ObjVentas.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
GvDatos.DataSource = null;
|
||||
Alert("No se encontraron cancelaciones pendientes");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GvDatos.DataSource = null;
|
||||
Alert("Error al obtener cancelaciones pendientes: " + resp.Descripcion, ModExtensiones.TipoMensaje.MsgError);
|
||||
}
|
||||
GvDatos.DataBind();
|
||||
UPDatos.Update();
|
||||
}
|
||||
protected void btnAceptar_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
Cancelacion.CancelacionSoapClient objServicio = new Cancelacion.CancelacionSoapClient();
|
||||
try
|
||||
{
|
||||
|
||||
string ArchivoLLave = "", ArchivoCertificado = "", ClaveReceptor = "", RFCReceptor = "";
|
||||
|
||||
ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\\{UsuarioActual.Empresa.ArchivoKey}";
|
||||
ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\\{UsuarioActual.Empresa.ArchivoCer}";
|
||||
ClaveReceptor = UsuarioActual.Empresa.ContraseñaKey;
|
||||
RFCReceptor = UsuarioActual.Empresa.RFC;
|
||||
|
||||
if (!string.IsNullOrEmpty(ArchivoCertificado) && !string.IsNullOrEmpty(ArchivoLLave))
|
||||
{
|
||||
string CertB64 = Convert.ToBase64String(File.ReadAllBytes(ArchivoCertificado));
|
||||
string KeyB64 = Convert.ToBase64String(File.ReadAllBytes(ArchivoLLave));
|
||||
string Uuid = GvRow.DataKey("FolioFiscal");
|
||||
string Total = GvRow.DataKey("Total");
|
||||
string RFC = GvRow.DataKey("RFC");
|
||||
|
||||
//var acusesat = Timbrado.VerificarVigenciaSAT(Uuid, RFC, RFCReceptor, Total, true);
|
||||
//if (acusesat != null && acusesat.EsCancelable.Contains("Cancelable"))
|
||||
//{
|
||||
Cancelacion.StructCancel resp = objServicio.AceptaRechaza(RFCReceptor, PACUsuario, PACContrasenia, CertB64, KeyB64, ClaveReceptor, Uuid, "Aceptación");
|
||||
if (resp.Estado == 0)
|
||||
{
|
||||
Alert("Aceptación de cancelación exitosa");
|
||||
CargarPendientes();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("Error en la aceptación: " + resp.Descripcion, ModExtensiones.TipoMensaje.MsgError);
|
||||
}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Alert("No de pudo comprobar el estatus de la cancelación", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Alert(ex.ToString(), ModExtensiones.TipoMensaje.MsgError);
|
||||
}
|
||||
}
|
||||
protected void btnRechazar_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
Cancelacion.CancelacionSoapClient objServicio = new Cancelacion.CancelacionSoapClient();
|
||||
|
||||
try
|
||||
{
|
||||
string ArchivoLLave = "", ArchivoCertificado = "", ClaveReceptor = "", RFCReceptor = "";
|
||||
|
||||
ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\\{UsuarioActual.Empresa.ArchivoKey}";
|
||||
ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\\{UsuarioActual.Empresa.ArchivoCer}";
|
||||
ClaveReceptor = UsuarioActual.Empresa.ContraseñaKey;
|
||||
RFCReceptor = UsuarioActual.Empresa.RFC;
|
||||
|
||||
if (!string.IsNullOrEmpty(ArchivoCertificado) && !string.IsNullOrEmpty(ArchivoLLave))
|
||||
{
|
||||
string CertB64 = Convert.ToBase64String(File.ReadAllBytes(ArchivoCertificado));
|
||||
string KeyB64 = Convert.ToBase64String(File.ReadAllBytes(ArchivoLLave));
|
||||
string Uuid = GvRow.DataKey("FolioFiscal");
|
||||
|
||||
//var acusesat = Timbrado.VerificarVigenciaSAT(Uuid, "", RFCReceptor, total, true);
|
||||
|
||||
Cancelacion.StructCancel resp = objServicio.AceptaRechaza(RFCReceptor, PACUsuario, PACContrasenia, CertB64, KeyB64, ClaveReceptor, Uuid, "Rechazo");
|
||||
if (resp.Estado == 0)
|
||||
{
|
||||
Alert("Aceptación de cancelación exitosa");
|
||||
CargarPendientes();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("Error en la aceptación: " + resp.Descripcion, ModExtensiones.TipoMensaje.MsgError);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Alert(ex.ToString(), ModExtensiones.TipoMensaje.MsgError);
|
||||
}
|
||||
}
|
||||
private string DecodeBase64(string strXMLCodificado)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] decbuff = Convert.FromBase64String(strXMLCodificado);
|
||||
return System.Text.Encoding.UTF8.GetString(decbuff);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user