512 lines
14 KiB
C#
512 lines
14 KiB
C#
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.Data;
|
|
using Microsoft.Reporting.WebForms;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
public partial class General_RepEntregaAlmacenRuta : ClsPaginas
|
|
{
|
|
#region PROPIEDADES
|
|
private DataTable DTDatos
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTDatos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTDatos"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveEntregaAlmacen
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveEntregaAlmacen"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveEntregaAlmacen"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveVenta
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveVenta"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveVenta"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveMovimiento
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveMovimiento"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveMovimiento"] = value;
|
|
}
|
|
}
|
|
|
|
private String SerieFolio
|
|
{
|
|
get
|
|
{
|
|
return ViewState["SerieFolio"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["SerieFolio"] = value;
|
|
}
|
|
}
|
|
|
|
private String NombreCliente
|
|
{
|
|
get
|
|
{
|
|
return ViewState["NombreCliente"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["NombreCliente"] = value;
|
|
}
|
|
}
|
|
|
|
private String Destinatario
|
|
{
|
|
get
|
|
{
|
|
return ViewState["Destinatario"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["Destinatario"] = value;
|
|
}
|
|
}
|
|
|
|
private String Paqueteria
|
|
{
|
|
get
|
|
{
|
|
return ViewState["Paqueteria"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["Paqueteria"] = value;
|
|
}
|
|
}
|
|
private String Guia
|
|
{
|
|
get
|
|
{
|
|
return ViewState["Guia"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["Guia"] = value;
|
|
}
|
|
}
|
|
|
|
private String Rastreo
|
|
{
|
|
get
|
|
{
|
|
return ViewState["Rastreo"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["Rastreo"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
private DataTable DTMovimientos
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTMovimientos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTMovimientos"] = value;
|
|
}
|
|
}
|
|
|
|
private int CvePaqueteriaGuiaReasignar
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CvePaqueteriaGuiaReasignar"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CvePaqueteriaGuiaReasignar"] = value;
|
|
}
|
|
}
|
|
|
|
private String Folio
|
|
{
|
|
get
|
|
{
|
|
return ViewState["Folio"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["Folio"] = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaEstatus();
|
|
CargaCombosModalEntrega();
|
|
InicializaFechas();
|
|
CargaChoferes();
|
|
UPFiltros.Update();
|
|
CargarCentrosDeCosto(null, DdlSucursales, null, LblDdlSucursal);
|
|
CargaDatos();
|
|
}
|
|
}
|
|
|
|
#region CARGA DDL
|
|
protected void CargaCombosModalEntrega()
|
|
{
|
|
ClsInventarios ObjInventarios = new ClsInventarios();
|
|
|
|
if (ObjInventarios.GetCamiones(-1, UsuarioActual.CveEmpresa) && ObjInventarios.DtResultados.Rows.Count > 0)
|
|
{
|
|
DdlModalCamion.DataSource = ObjInventarios.DtResultados;
|
|
}
|
|
|
|
ObjInventarios.Dispose();
|
|
DdlModalCamion.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlModalCamion.DataBind();
|
|
|
|
ClsAcarreos ObjAcar = new ClsAcarreos();
|
|
|
|
if (ObjAcar.GetChofer(-1, UsuarioActual.CveEmpresa, 1, -1))
|
|
{
|
|
DdlModalChofer.DataSource = ObjAcar.DtResultados;
|
|
DdlModalChofer.DataBind();
|
|
}
|
|
ObjAcar.Dispose();
|
|
DdlModalChofer.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
}
|
|
protected void CargaChoferes()
|
|
{
|
|
ClsAcarreos ObjAcar = new ClsAcarreos();
|
|
|
|
if (ObjAcar.GetChofer(-1, UsuarioActual.CveEmpresa, 1, -1))
|
|
{
|
|
DdlChofer.DataSource = ObjAcar.DtResultados;
|
|
}
|
|
ObjAcar.Dispose();
|
|
DdlChofer.DataBind();
|
|
DdlChofer.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
}
|
|
|
|
|
|
protected void CargaEstatus()
|
|
{
|
|
|
|
DdlEstatus.Items.Insert(0, new ListItem("Todos ", "-1"));
|
|
DdlEstatus.Items.Insert(1, new ListItem("Registrado", "0"));
|
|
DdlEstatus.Items.Insert(2, new ListItem("Timbrado", "1"));
|
|
DdlEstatus.Items.Insert(3, new ListItem("Cancelado ", "2"));
|
|
}
|
|
protected void InicializaFechas()
|
|
{
|
|
|
|
TxtFechaI.Text = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");
|
|
TxtFechaF.Text = DateTime.Now.ToString("dd/MM/yyyy");
|
|
}
|
|
#endregion
|
|
|
|
#region CARGA DATOS
|
|
protected void CargaDatos()
|
|
{
|
|
ClsGenerales ObjGeneral = new ClsGenerales();
|
|
|
|
if (ObjGeneral.GetInvEntregaAlmacenRutaRep(DdlSucursales.SelectedValue.ToEntero(),UsuarioActual.CveEmpresa, DdlEstatus.SelectedValue.ToEntero(), TxtFechaI.Text.ToDate(), TxtFechaF.Text.ToDate(), DdlChofer.SelectedValue.ToEntero()))
|
|
{
|
|
DTDatos = ObjGeneral.DtResultados;
|
|
GVDatos.DataSource = DTDatos;
|
|
}
|
|
|
|
ObjGeneral.Dispose();
|
|
GVDatos.DataBind();
|
|
UPDatos.Update();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region BOTONES
|
|
|
|
protected void BtnConsultar_Click(object sender, EventArgs e)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void imgEditar_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
|
|
CveEntregaAlmacen = GvRow.DataKey("CveEntregaAlmacen").ToEntero();
|
|
|
|
int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
|
|
int CveDireccionOrigen = GvRow.DataKey("CveDireccionOrigen").ToEntero();
|
|
int CveAlmacen = GvRow.DataKey("CveAlmacen").ToEntero();
|
|
|
|
CargaModalCombosDirecciones(CveCliente, CveDireccionOrigen, CveAlmacen);
|
|
|
|
DdlModalDireccionOrigen.SelectedValueExist(GvRow.DataKey("CveDireccionOrigen"));
|
|
DdlModalDireccionDestino.SelectedValueExist(GvRow.DataKey("CveDireccionDestino"));
|
|
|
|
DdlModalCamion.SelectedValueExist(GvRow.DataKey("CveCamion"));
|
|
DdlModalChofer.SelectedValueExist(GvRow.DataKey("CveChofer"));
|
|
|
|
TxtmodalFechaEntrega.Text = GvRow.DataKey("FechaEntrega").ToDate().ToString("dd/MM/yyyy");
|
|
|
|
|
|
UpModalEditarentrega.Update();
|
|
this.RegistraScript("$('#DivEditarEntrega').modal('show');");
|
|
}
|
|
|
|
|
|
private void CargaModalCombosDirecciones(int CveCliente, int CveDireccionOrigen, int CveAlmacen )
|
|
{
|
|
|
|
DdlModalDireccionOrigen.Items.Clear();
|
|
DdlModalDireccionDestino.Items.Clear();
|
|
|
|
DataTable DTDireccionesCliente = new DataTable();
|
|
ClsClientes ObjClientes = new ClsClientes();
|
|
if (ObjClientes.DireccionEnvioGet(-1, CveCliente, -1))
|
|
{
|
|
DTDireccionesCliente = ObjClientes.DtResultados ;
|
|
}
|
|
ObjClientes.Dispose();
|
|
|
|
DdlModalDireccionDestino.DataSource = DTDireccionesCliente;
|
|
DdlModalDireccionDestino.DataBind();
|
|
DdlModalDireccionDestino.Items.Insert(0,new ListItem("Seleccione Una", "-1"));
|
|
|
|
string Almacen = get_GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen: CveAlmacen).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacen}");
|
|
if (CveDireccionOrigen > 0)
|
|
{
|
|
DdlModalDireccionOrigen.DataSource = DTDireccionesCliente.FiltraParametros($"CveDireccionEnvio = {CveDireccionOrigen}");
|
|
DdlModalDireccionOrigen.DataBind();
|
|
DdlModalDireccionOrigen.Items.Insert(0, new ListItem($"Almacen: {Almacen}", "-2"));
|
|
}else
|
|
{
|
|
DdlModalDireccionOrigen.Items.Insert(0, new ListItem($"Almacen: {Almacen}", "-2"));
|
|
}
|
|
DTDireccionesCliente.Dispose();
|
|
}
|
|
|
|
|
|
protected void LnkTimbrar_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton LnkCancelarFolioFiscal = (LinkButton)sender;
|
|
GridViewRow GvRow = (GridViewRow)LnkCancelarFolioFiscal.BindingContainer;
|
|
int cvetimbre = GvRow.DataKey("CveTimbre").ToEntero();
|
|
|
|
Timbres ObjTimbres = new Timbres("Tra", cvetimbre, UsuarioActual);
|
|
StringBuilder MensajeAlert = new StringBuilder();
|
|
MensajeAlert.AppendFormat("Folio: <b>{0}</b> ", ObjTimbres.ObjFactura.SerieFolio);
|
|
if (ObjTimbres.MsgError =="" && ObjTimbres.Timbrar())
|
|
{
|
|
MensajeAlert.AppendFormat("<a class='texto' style='color:#337ab7' href='/Compras/PopUpVerFactura.aspx?P={0}' target='_blank'>XML <i class='fa fa-file'></i></i></a> ", ModExtensiones.Encripta(String.Format("OP=DesXmlTra&CveTimbre={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", cvetimbre, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto)));
|
|
Alert(MensajeAlert.ToString(), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
else
|
|
{
|
|
MensajeAlert.AppendFormat("<ul><li>{0}</li></ul>", ObjTimbres.MsgError);
|
|
Alert(MensajeAlert.ToString(), ModExtensiones.TipoMensaje.MsgError);
|
|
}
|
|
|
|
}
|
|
|
|
protected void LnkCancelaTimbre_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
bool ProcesoOK = false;
|
|
LinkButton LnkCancelarFolioFiscal = (LinkButton)sender;
|
|
GridViewRow GvRow = (GridViewRow)LnkCancelarFolioFiscal.BindingContainer;
|
|
|
|
int CveTimbre = GvRow.DataKey("CveTimbre").ToEntero();
|
|
string FolioFiscalCancelar = GvRow.DataKey("FolioFiscal").ToString();
|
|
string RFCReceptor = GvRow.DataKey("RFCReceptor").ToString();
|
|
string RFCEmisor = GvRow.DataKey("RFCEmisor").ToString();
|
|
int CvePACCancelacion = GvRow.DataKey("CvePAC").ToEntero();
|
|
|
|
Timbrado ObjCancelacion = new Timbrado();
|
|
ClsGenerales ObjGenerales = new ClsGenerales();
|
|
|
|
if (EstatusSATCancelado(FolioFiscalCancelar, UsuarioActual.Empresa.RFC, RFCReceptor))
|
|
{
|
|
if (ObjGenerales.CancelarTimbreTimbrado(CveTimbre, DateTime.Now, CvePACCancelacion,"", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa )){
|
|
ProcesoOK = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if( ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscalCancelar, 0, RFCReceptor, RFCEmisor, CvePACCancelacion,CveSATMotivoCancelacion: 3)) {
|
|
|
|
if (ObjGenerales.CancelarTimbreTimbrado(CveTimbre, DateTime.Now, CvePACCancelacion, ObjCancelacion.CancelacionAcuse, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
Alert("El complemento se cancelo correctamente.");
|
|
ProcesoOK = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert("Se presento un error al cancelar el Folio Fiscal", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
ObjGenerales.Dispose();
|
|
|
|
if (ProcesoOK)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
}
|
|
|
|
|
|
public bool EstatusSATCancelado(string FolioFiscal, string RFCDe, string RFCReceptor)
|
|
{
|
|
bool respuesta = false;
|
|
var Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, RFCDe, RFCReceptor, "0", true);
|
|
if (Vigencia is object)
|
|
{
|
|
if (Vigencia.Estado.ToUpper() == "CANCELADO")
|
|
{
|
|
respuesta = true;
|
|
}
|
|
else
|
|
{
|
|
respuesta = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
respuesta = false;
|
|
}
|
|
|
|
return respuesta;
|
|
}
|
|
|
|
|
|
protected void BtnModalEditarentrega_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
bool ProcesoOK = true ;
|
|
|
|
ClsGenerales ObjGral = new ClsGenerales();
|
|
if(!ObjGral.UpdateInvEntregaAlmacenRuta(CveEntregaAlmacen,DdlModalDireccionOrigen.SelectedValue.ToEntero(), DdlModalDireccionDestino.SelectedValue.ToEntero(), DdlModalChofer.SelectedValue.ToEntero(), DdlModalCamion.SelectedValue.ToEntero(), TxtmodalFechaEntrega.Text.ToDate(), UsuarioActual.CveEmpresa))
|
|
{
|
|
ProcesoOK = false;
|
|
}
|
|
ObjGral.Dispose();
|
|
|
|
if (ProcesoOK)
|
|
{
|
|
this.RegistraScript("$('#DivEditarEntrega').modal('hide');");
|
|
Alert("Entrega Actualizada correctamente.");
|
|
CargaDatos();
|
|
}
|
|
|
|
}
|
|
|
|
protected void BtnEliminarGuia_Click(object sender, EventArgs e)
|
|
{
|
|
//EliminaGuia();
|
|
//this.RegistraScript("$('#DivEditarGuia').modal('hide');");
|
|
//CargaDatos();
|
|
}
|
|
|
|
protected void GVDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
LinkButton LnkEditar = e.Row.FCLinkButton("LnkEditar");
|
|
LinkButton LnkTimbrar = e.Row.FCLinkButton("LnkTimbrar");
|
|
LinkButton LnkCancelaTimbre = e.Row.FCLinkButton("LnkCancelaTimbre");
|
|
|
|
LnkEditar.Visible = false;
|
|
LnkTimbrar.Visible = false;
|
|
LnkCancelaTimbre.Visible = false;
|
|
|
|
if (e.Row.DataKey("Estatus").ToEntero() == 0)
|
|
{
|
|
LnkEditar.Visible = true;
|
|
LnkTimbrar.Visible = true;
|
|
}
|
|
|
|
if (e.Row.DataKey("Estatus").ToEntero() == 1)
|
|
{
|
|
LnkCancelaTimbre.Visible = true;
|
|
}
|
|
|
|
if (e.Row.DataKey("Estatus").ToEntero() == 2)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
switch (e.Row.DataKey("Tipo"))
|
|
{
|
|
case "E":
|
|
e.Row.FCLabel("LtTipo").CssClass = "label label-sm label-success";
|
|
break;
|
|
case "T":
|
|
e.Row.FCLabel("LtTipo").CssClass = "label label-sm label-success";
|
|
break;
|
|
default:
|
|
e.Row.FCLabel("LtTipo").CssClass = "label label-sm label-warning";
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |