1111 lines
34 KiB
C#
1111 lines
34 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;
|
|
}
|
|
}
|
|
|
|
|
|
private int CveDireccionEditar
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["CveDireccionEditar"] == null)
|
|
{
|
|
ViewState["CveDireccionEditar"] = -1;
|
|
}
|
|
return ViewState["CveDireccionEditar"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveDireccionEditar"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private int CveDireccionOrigen
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["CveDireccionOrigen"] == null)
|
|
{
|
|
ViewState["CveDireccionOrigen"] = -1;
|
|
}
|
|
return ViewState["CveDireccionOrigen"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveDireccionOrigen"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveDireccionDestino
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["CveDireccionDestino"] == null)
|
|
{
|
|
ViewState["CveDireccionDestino"] = -1;
|
|
}
|
|
return ViewState["CveDireccionDestino"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveDireccionDestino"] = value;
|
|
}
|
|
}
|
|
private int CveTimbre
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["CveTimbre"] == null)
|
|
{
|
|
ViewState["CveTimbre"] = -1;
|
|
}
|
|
return ViewState["CveTimbre"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveTimbre"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaEstatus();
|
|
CargaCombosModalEntrega();
|
|
InicializaFechas();
|
|
CargaChoferes();
|
|
UPFiltros.Update();
|
|
CargarCentrosDeCosto(null, DdlSucursales, null, LblDdlSucursal);
|
|
|
|
CargaChoferes();
|
|
CargarCamiones();
|
|
|
|
|
|
CargaDatos();
|
|
CargaCombosDirecionesClientesSAT();
|
|
}
|
|
}
|
|
|
|
#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.AddDays(3).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(),UsuarioActual.CveUsuario))
|
|
{
|
|
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();
|
|
CveTimbre = GvRow.DataKey("CveTimbre").ToEntero();
|
|
|
|
int CveCliente = GvRow.DataKey("CveCliente").ToEntero();
|
|
int CveAlmacen = GvRow.DataKey("CveAlmacen").ToEntero();
|
|
|
|
DdlModalCamion.SelectedValueExist(GvRow.DataKey("CveCamion"));
|
|
DdlModalChofer.SelectedValueExist(GvRow.DataKey("CveChofer"));
|
|
|
|
TxtFechaEntrega.Text = GvRow.DataKey("FechaEntrega").ToDate().ToString("dd/MM/yyyy");
|
|
TxtFechaLlegada.Text = GvRow.DataKey("FechaLlegada").ToDate().ToString("dd/MM/yyyy");
|
|
TxtDistancia.Text = GvRow.DataKey("Distancia");
|
|
DdlConfigAuto.SelectedValueExist(GvRow.DataKey("CveConfigAutoTransporte"));
|
|
DdlConfigAuto_SelectedIndexChanged(null, null);
|
|
|
|
if (GvRow.DataKey("CveCamionRemolque1").ToEntero() > 0)
|
|
{
|
|
DdlRemolque1.SelectedValueExist(GvRow.DataKey("CveCamionRemolque1"));
|
|
DdlRemolque2.SelectedValueExist("-1");
|
|
DdlRemolque1_SelectedIndexChanged(null, null);
|
|
}
|
|
|
|
if (GvRow.DataKey("CveCamionRemolque2").ToEntero() > 0)
|
|
{
|
|
DdlRemolque2.SelectedValueExist(GvRow.DataKey("CveCamionRemolque2"));
|
|
}
|
|
CveDireccionOrigen = GvRow.DataKey("CveDireccionOrigen").ToEntero();
|
|
CveDireccionDestino = GvRow.DataKey("CveDireccionDestino").ToEntero();
|
|
|
|
ModalActualizaDirecciones( CveTimbre);
|
|
|
|
|
|
if (CveDireccionOrigen > 0)
|
|
{
|
|
DVDireccionOrigen.Visible = true;
|
|
|
|
LnkDireccionOrigen.Text = GvRow.DataKey("DireccionOrigen") + " <i class='fa fa-search' aria-hidden='true'></i>";
|
|
}
|
|
if (CveDireccionDestino > 0)
|
|
{
|
|
DVDireccionDestino.Visible = true;
|
|
LnkDireccionDestino.Text = GvRow.DataKey("Direccion") + " <i class='fa fa-search' aria-hidden='true'></i>";
|
|
}
|
|
|
|
|
|
UpModalEditarentrega.Update();
|
|
this.RegistraScript("$('#DivEditarEntrega').modal({ backdrop: 'static', keyboard: false });");
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ModalActualizaDirecciones(int CveTimbre)
|
|
{
|
|
ClsGenerales ObjGeneral = new ClsGenerales();
|
|
|
|
if (ObjGeneral.GetInvEntregaAlmacenRutaRep( -1, UsuarioActual.CveEmpresa, -1, new DateTime(1900,01,01), new DateTime(9000, 01, 01),-1, CveTimbre)) {
|
|
|
|
if (ObjGeneral.DtResultados.Rows.Count > 0)
|
|
{
|
|
if (CveDireccionOrigen > 0)
|
|
{
|
|
DVDireccionOrigen.Visible = true;
|
|
|
|
LnkDireccionOrigen.Text = ObjGeneral.DtResultados.Rows[0]["DireccionOrigen"].ToString() + " <i class='fa fa-search' aria-hidden='true'></i>";
|
|
}
|
|
if (CveDireccionDestino > 0)
|
|
{
|
|
DVDireccionDestino.Visible = true;
|
|
LnkDireccionDestino.Text = ObjGeneral.DtResultados.Rows[0]["Direccion"].ToString() + " <i class='fa fa-search' aria-hidden='true'></i>";
|
|
}
|
|
}
|
|
}
|
|
|
|
ObjGeneral.Dispose();
|
|
UpModalDirecciones.Update();
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
string TimbreTipoDocto = GvRow.DataKey("TimbreTipoDocto");
|
|
|
|
Timbres ObjTimbres = new Timbres(TimbreTipoDocto, 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);
|
|
CargaDatos();
|
|
}
|
|
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();
|
|
int CveSubProyecto = GvRow.DataKey("CveSubProyecto").ToEntero();
|
|
int CveEntregaAlmacen = GvRow.DataKey("CveEntregaAlmacen").ToEntero();
|
|
string TimbreTipoDocto = GvRow.DataKey("TimbreTipoDocto").ToString();
|
|
|
|
|
|
Timbrado ObjCancelacion = new Timbrado();
|
|
ClsGenerales ObjGenerales = new ClsGenerales();
|
|
ObjGenerales.IniciaTransacSQL ();
|
|
|
|
if (EstatusSATCancelado(FolioFiscalCancelar, UsuarioActual.Empresa.RFC, RFCReceptor))
|
|
{
|
|
if (ObjGenerales.CancelarTimbreTimbrado(CveTimbre, DateTime.Now, CvePACCancelacion,"", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa )){
|
|
ProcesoOK = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ModExtensiones.RespuestaCancelacionSAT Resp = ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscalCancelar, 0, RFCReceptor, RFCEmisor, CvePACCancelacion, CveSATMotivoCancelacion: 3);
|
|
|
|
if (Resp.Verificado) {
|
|
|
|
if (ObjGenerales.CancelarTimbreTimbrado(CveTimbre, DateTime.Now, CvePACCancelacion, ObjCancelacion.CancelacionAcuse, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
//regenero el tmbre
|
|
if (TimbreTipoDocto == "Tra")
|
|
{
|
|
CveTimbre = ObjGenerales.AddGralTimbre("Tra", CveSubProyecto, DateTime.Now, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen: CveEntregaAlmacen, AplicaCP: true);
|
|
}
|
|
ProcesoOK = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ProcesoOK)
|
|
{
|
|
ObjGenerales.Commit();
|
|
Alert("El complemento se cancelo correctamente.");
|
|
}
|
|
else
|
|
{
|
|
ObjGenerales.RollBack();
|
|
Alert("Se presento un error al cancelar el Folio Fiscal", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
ObjGenerales.Dispose();
|
|
}
|
|
|
|
|
|
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,-1,-1, DdlModalChofer.SelectedValue.ToEntero(), DdlModalCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveEmpresa,
|
|
TxtFechaLlegada.Text.ToDate(), CveCamionRemolque1: DdlRemolque1.SelectedValue.ToEntero(), CveCamionRemolque2: DdlRemolque2.SelectedValue.ToEntero(), Distancia: TxtDistancia.Text.ToEntero(),
|
|
CveConfigAutoTransporte: DdlConfigAuto.SelectedValue.ToEntero()))
|
|
{
|
|
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)
|
|
{
|
|
e.Row.Cells[11].Text = "";
|
|
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("Tipo") == "R" && e.Row.DataKey("Estatus") == "1")
|
|
{
|
|
e.Row.FCHyperLink("HplR").Visible = true;
|
|
e.Row.FCHyperLink("HplR").NavigateUrl = "/Inventarios/EntradasSalidas.aspx?CveEntregaAlmacen=" + e.Row.DBCampo("CveEntregaAlmacen");
|
|
}
|
|
|
|
if (e.Row.DataKey("Estatus").ToEntero() == 1)
|
|
{
|
|
LnkCancelaTimbre.Visible = true;
|
|
|
|
if (bool.Parse(e.Row.DataKey("AplicaCP")))
|
|
{
|
|
if (e.Row.FCHyperLink("HplPDF") != null)
|
|
e.Row.FCHyperLink("HplPDF").NavigateUrl = "/Compras/PopUpVerFactura.aspx?P=" + Extensiones.ModExtensiones.Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", e.Row.DataKey("CveTimbre"))) ;
|
|
}
|
|
else
|
|
{
|
|
if (e.Row.FCHyperLink("HplPDF")!= null)
|
|
e.Row.FCHyperLink("HplPDF").NavigateUrl = "/Compras/PopUpVerFactura.aspx?P=" + Extensiones.ModExtensiones.Encripta(String.Format("OP=CARPO&CVETIMBRE={0}", e.Row.DataKey("CveTimbre")));
|
|
}
|
|
|
|
string ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, e.Row.DataKey("TimbreTipoDocto"), e.Row.DataKey("SerieFolio"));
|
|
|
|
//if (File.Exists(ArchivoXML))
|
|
//{
|
|
// e.Row.Cells[12].Text = "<a CssClass='btn btn-circle btn-sm blue' target= '_blank' href=\"/Compras/PopUpVerFactura.aspx?P=" + Extensiones.ModExtensiones.Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", -1, "XML", e.Row.DataKey("SerieFolio"), e.Row.DataKey("TimbreTipoDocto"))) + "\" ><i class='fa fa-file-code-o'></i></a>";
|
|
//}
|
|
|
|
}
|
|
else
|
|
{
|
|
//e.Row.Cells[11].Text = "";
|
|
e.Row.Cells[12].Text = "";
|
|
e.Row.Cells[13].Text = "";
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CargaPersonalChofer()
|
|
{
|
|
DdlModalChofer.Items.Clear();
|
|
|
|
ClsAcarreos ObjAcar = new ClsAcarreos();
|
|
|
|
if (ObjAcar.GetChofer(-1, UsuarioActual.CveEmpresa, 1, -1))
|
|
{
|
|
DdlModalChofer.DataSource = ObjAcar.DtResultados;
|
|
}
|
|
ObjAcar.Dispose();
|
|
|
|
DdlModalChofer.DataBind();
|
|
DdlModalChofer.Items.Insert(0, new ListItem("Seleccione Uno", "-1"));
|
|
UpModalEditarentrega.Update();
|
|
}
|
|
|
|
protected void RdTipo_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
CargaPersonalChofer();
|
|
}
|
|
protected void DdlModalCamion_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
DvRemolque1.Visible = false;
|
|
DvRemolque2.Visible = false;
|
|
|
|
DdlRemolque1.SelectedValueExist(-1);
|
|
DdlRemolque2.SelectedValueExist(-1);
|
|
|
|
if (DdlModalCamion.SelectedValue.ToEntero() > 0)
|
|
{
|
|
using (ClsInventarios ObjInv = new ClsInventarios())
|
|
{
|
|
if (ObjInv.GetCamiones(DdlModalCamion.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, 1))
|
|
{
|
|
DdlConfigAuto.SelectedValueExist(ObjInv.DtResultados.FiltroPrimeroValor("CveConfigAutoTransporte"));
|
|
DdlConfigAuto_SelectedIndexChanged(null, null);
|
|
}
|
|
}
|
|
}
|
|
UpModalEditarentrega.Update();
|
|
}
|
|
|
|
public bool RequiereRemolque
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["RequiereRemolque"] == null)
|
|
ViewState["RequiereRemolque"] = false;
|
|
|
|
return bool.Parse(ViewState["RequiereRemolque"].ToString());
|
|
}
|
|
set
|
|
{
|
|
ViewState["RequiereRemolque"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
public bool MostrarRemolques
|
|
{
|
|
get
|
|
{
|
|
if (ViewState["MostrarRemolques"] == null)
|
|
ViewState["MostrarRemolques"] = false;
|
|
|
|
return bool.Parse(ViewState["MostrarRemolques"].ToString());
|
|
}
|
|
set
|
|
{
|
|
ViewState["MostrarRemolques"] = value;
|
|
}
|
|
}
|
|
|
|
protected void DdlConfigAuto_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
ValidaConfiguracionVeiculo();
|
|
}
|
|
private void ValidaConfiguracionVeiculo()
|
|
{
|
|
DvRemolque1.Visible = false;
|
|
DvRemolque2.Visible = false;
|
|
|
|
DdlRemolque1.SelectedValueExist(-1);
|
|
DdlRemolque2.SelectedValueExist(-1);
|
|
|
|
if (DdlConfigAuto.SelectedValue.ToEntero() > 0)
|
|
{
|
|
using (ClsGenerales ObjGrales = new ClsGenerales())
|
|
{
|
|
if (ObjGrales.GetCartaPorteConfigAutoTransportes())
|
|
{
|
|
string Remolque = ObjGrales.DtResultados.FiltroPrimeroValor("Remolque", $" CveConfigAutoTransporte ='{DdlConfigAuto.SelectedValue.ToEntero()}'");
|
|
|
|
if (Remolque == "1")
|
|
{
|
|
RequiereRemolque = true;
|
|
MostrarRemolques = true;
|
|
}
|
|
|
|
if (Remolque == "0, 1")
|
|
{
|
|
RequiereRemolque = false;
|
|
MostrarRemolques = true;
|
|
}
|
|
|
|
if (Remolque == "0")
|
|
{
|
|
RequiereRemolque = false;
|
|
MostrarRemolques = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
RequiereRemolque = false;
|
|
MostrarRemolques = false;
|
|
}
|
|
|
|
if (RequiereRemolque | MostrarRemolques)
|
|
DvRemolque1.Visible = true;
|
|
|
|
if (!RequiereRemolque)
|
|
DvConfiguracionVeiculo.Visible = false;
|
|
else
|
|
DvConfiguracionVeiculo.Visible = true;
|
|
|
|
UpModalEditarentrega.Update();
|
|
}
|
|
|
|
protected void DdlRemolque1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
DdlRemolque2.Items.Clear();
|
|
|
|
if (DdlRemolque1.SelectedValue.ToEntero() > 0)
|
|
{
|
|
DvRemolque2.Visible = true;
|
|
|
|
using (ClsInventarios ObjInv = new ClsInventarios())
|
|
{
|
|
if (ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, 2))
|
|
DdlRemolque2.DataSource = ObjInv.DtResultados.FiltraParametros($"CveCamion <> {DdlRemolque1.SelectedValue.ToEntero()}");
|
|
}
|
|
try
|
|
{
|
|
DdlRemolque2.DataBind();
|
|
}
|
|
catch { }
|
|
}
|
|
else
|
|
DvRemolque2.Visible = false;
|
|
|
|
DdlRemolque2.Items.Insert(0, new ListItem("Seleccione uno", "-1"));
|
|
|
|
UpModalEditarentrega.Update();
|
|
}
|
|
|
|
private bool validarRemolques()
|
|
{
|
|
bool Respuesta = false;
|
|
|
|
|
|
if (RequiereRemolque & DdlRemolque1.SelectedValue.ToEntero() <= 0)
|
|
Alert("La configuración de la carta porte requiere que seleccione un remolque", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
|
|
if (RequiereRemolque & DdlRemolque1.SelectedValue.ToEntero() > 0)
|
|
Respuesta = true;
|
|
|
|
return Respuesta;
|
|
}
|
|
|
|
|
|
public void CargarCamiones()
|
|
{
|
|
DdlModalCamion.Items.Clear();
|
|
DdlConfigAuto.Items.Clear();
|
|
|
|
using (ClsInventarios ObjInv = new ClsInventarios())
|
|
{
|
|
if (ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, 1))
|
|
DdlModalCamion.DataSource = ObjInv.DtResultados;
|
|
|
|
if (ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, 2))
|
|
DdlRemolque1.DataSource = ObjInv.DtResultados;
|
|
}
|
|
|
|
DdlModalCamion.DataBind();
|
|
DdlModalCamion.Items.Insert(0, new ListItem("Seleccione uno", "-1"));
|
|
|
|
|
|
DdlRemolque1.DataBind();
|
|
DdlRemolque1.Items.Insert(0, new ListItem("Seleccione uno", "-1"));
|
|
|
|
|
|
using (ClsGenerales ObjGrales = new ClsGenerales())
|
|
{
|
|
if (ObjGrales.GetCartaPorteConfigAutoTransportes())
|
|
DdlConfigAuto.DataSource = ObjGrales.DtResultados;
|
|
}
|
|
|
|
DdlConfigAuto.DataBind();
|
|
DdlConfigAuto.Items.Insert(0, new ListItem("Seleccione una", "-1"));
|
|
}
|
|
|
|
private void CargaCombosDirecionesClientesSAT()
|
|
{
|
|
CargaDirClientePais();
|
|
CargaDirClienteEstado();
|
|
CargaDirClienteMunicipio();
|
|
CargaDirClienteLocalidad();
|
|
CargaDirClienteColonia();
|
|
}
|
|
|
|
|
|
private void CargaDirClientePais()
|
|
{
|
|
DdlDirClientePais.DataSource = GlobalDTGralPaises;
|
|
DdlDirClientePais.DataBind();
|
|
DdlDirClientePais.SelectedValueExist("151");
|
|
}
|
|
|
|
private void CargaDirClienteEstado()
|
|
{
|
|
DdlDirClienteEstado.Items.Clear();
|
|
if (DdlDirClientePais.SelectedValue.ToEntero() > 0)
|
|
DdlDirClienteEstado.DataSource = get_GlobalDTGralEstados("-1", DdlDirClientePais.SelectedValue.ToEntero());
|
|
DdlDirClienteEstado.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlDirClienteEstado.DataBind();
|
|
}
|
|
|
|
private void CargaDirClienteMunicipio()
|
|
{
|
|
DdlDirClienteMunicipio.Items.Clear();
|
|
if (DdlDirClienteEstado.SelectedValue.ToEntero() > 0)
|
|
DdlDirClienteMunicipio.DataSource = get_GlobalDTGralMunicipios("-1", DdlDirClienteEstado.SelectedValue.ToEntero());
|
|
DdlDirClienteMunicipio.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlDirClienteMunicipio.DataBind();
|
|
}
|
|
|
|
private void CargaDirClienteColonia()
|
|
{
|
|
DdlDirClienteColonia.Items.Clear();
|
|
if (DdlDirClienteMunicipio.SelectedValue.ToEntero() > 0)
|
|
DdlDirClienteColonia.DataSource = get_GlobalDTGralColonias("-1", "-1", "-1", DdlDirClienteMunicipio.SelectedValue.ToEntero(), CodigoPostal: TxtEnvioCP.Text.Trim().Length > 0 ? TxtEnvioCP.Text.ToEntero() : -1);
|
|
DdlDirClienteColonia.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlDirClienteColonia.DataBind();
|
|
}
|
|
|
|
|
|
protected void CargaDirClienteLocalidad()
|
|
{
|
|
DdlDirClienteLocalidad.Items.Clear();
|
|
if (DdlDirClienteEstado.SelectedValue.ToEntero() > 0)
|
|
{
|
|
DdlDirClienteLocalidad.DataSource = get_GlobalDTLocalidad(DdlDirClienteEstado.SelectedValue.ToEntero(), DdlDirClienteMunicipio.SelectedValue.ToEntero());
|
|
DdlDirClienteLocalidad.DataBind();
|
|
}
|
|
|
|
DdlDirClienteLocalidad.Items.Insert(0, new ListItem("Seleccione una", "-1"));
|
|
}
|
|
|
|
|
|
protected void DdlDirClientePais_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
CargaDirClienteEstado();
|
|
CargaDirClienteMunicipio();
|
|
CargaDirClienteColonia();
|
|
CargaDirClienteLocalidad();
|
|
}
|
|
protected void DdlDirClienteEstado_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
CargaDirClienteMunicipio();
|
|
CargaDirClienteColonia();
|
|
CargaDirClienteLocalidad();
|
|
}
|
|
|
|
protected void DdlDirClienteMunicipio_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
CargaDirClienteColonia();
|
|
CargaDirClienteLocalidad();
|
|
}
|
|
|
|
protected void BtnDirClienteValidar_Click(object sender, EventArgs e)
|
|
{
|
|
DirClientevalidaCodigoPostal();
|
|
}
|
|
|
|
protected void DdlDirClienteColonia_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
DirClientevalidaCodigoPostal();
|
|
}
|
|
|
|
private void DirClientevalidaCodigoPostal()
|
|
{
|
|
int CPTxt = TxtEnvioCP.Text.ToEntero();
|
|
|
|
int CveColonia = DdlDirClienteColonia.SelectedValue.ToEntero();
|
|
|
|
if (CPTxt > 0 & CveColonia > 0)
|
|
{
|
|
int CP = get_GlobalDTGralColonias("-1", "-1", "-1", CveColonia: CveColonia).FiltroPrimeroValor("CP", "").ToEntero();
|
|
if (CPTxt != CP)
|
|
Alert("El código postal selecionado es diferente del codigo postal de la Colonia.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
|
|
public void EditDireccionOrigen_Click(object sender, EventArgs e)
|
|
{
|
|
//GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
//int CveDireccionOrigen = GvRow.DataKey("CveDireccionOrigen").ToEntero();
|
|
CveDireccionEditar = CveDireccionOrigen;
|
|
LblTitulodireccion.Text = "Actualizar dirección origen";
|
|
CargaDatosDireccion(CveDireccionOrigen);
|
|
}
|
|
|
|
public void EditDireccionDestino_Click(object sender, EventArgs e)
|
|
{
|
|
//GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
//LblTitulodireccion.Text = "Actualizar dirección destino";
|
|
//int CveDireccionDestino = GvRow.DataKey("CveDireccionDestino").ToEntero();
|
|
CveDireccionEditar = CveDireccionDestino;
|
|
LblTitulodireccion.Text = "Actualizar dirección Destino";
|
|
CargaDatosDireccion(CveDireccionDestino);
|
|
}
|
|
|
|
|
|
private void CargaDatosDireccion(int CveDireccion)
|
|
{
|
|
|
|
ClsClientes ObjClientes = new ClsClientes();
|
|
|
|
DataTable DT = new DataTable();
|
|
|
|
if (ObjClientes.DireccionEnvioGet(CveDireccion, -1,-1))
|
|
{
|
|
DT = ObjClientes.DtResultados;
|
|
}
|
|
|
|
ObjClientes.Dispose();
|
|
|
|
if (DT.Rows.Count > 0)
|
|
{
|
|
TxtEnvioDireccion.Text = DT.Rows[0]["EnvioDireccion"].ToString();
|
|
TxtEnvioNoExt.Text = DT.Rows[0]["EnvioNoExt"].ToString();
|
|
TxtEnvioNoInt.Text = DT.Rows[0]["EnvioNoInt"].ToString();
|
|
|
|
TxtEnvioCP.Text = DT.Rows[0]["EnvioCP"].ToString();
|
|
// TxtEnvioTel.Text = GvRow.DataKey("EnvioTel")
|
|
|
|
DdlDirClientePais.SelectedValueExist(DT.Rows[0]["CvePais"].ToString());
|
|
CargaDirClienteEstado();
|
|
DdlDirClienteEstado.SelectedValueExist(DT.Rows[0]["CveEstado"].ToString());
|
|
CargaDirClienteMunicipio();
|
|
DdlDirClienteMunicipio.SelectedValueExist(DT.Rows[0]["CveMunicipio"].ToString());
|
|
CargaDirClienteColonia();
|
|
DdlDirClienteLocalidad.SelectedValueExist(DT.Rows[0]["CveLocalidad"].ToString());
|
|
CargaDirClienteLocalidad();
|
|
|
|
DdlDirClienteColonia.SelectedValueExist(DT.Rows[0]["CveColonia"].ToString());
|
|
}
|
|
|
|
UpModalDVDireccionEnvio.Update();
|
|
RegistraScript("$('#divAddDireccionEnvio').modal('show');");
|
|
|
|
|
|
}
|
|
|
|
public void BtnAgregarDireccion_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
ClsClientes ObjCli = new ClsClientes();
|
|
bool ErrorProceso = false;
|
|
|
|
//CveDireccionEditar
|
|
if (!ObjCli.DireccionEnvioUpdate(-1, TxtEnvioDireccion.Text, TxtEnvioNoExt.Text, TxtEnvioNoInt.Text, "-1", "-1", "-1", TxtEnvioCP.Text.ToEntero(), "-1", UsuarioActual.CveUsuario, -1, CveDireccionEditar, "-1", -1, "-1",
|
|
DdlDirClientePais.SelectedValue.ToEntero(), DdlDirClienteEstado.SelectedValue.ToEntero(), DdlDirClienteMunicipio.SelectedValue.ToEntero(), DdlDirClienteLocalidad.SelectedValue.ToEntero(), DdlDirClienteColonia.SelectedValue.ToEntero())){
|
|
ErrorProceso = true;
|
|
}
|
|
|
|
ObjCli.Dispose();
|
|
|
|
if (!ErrorProceso)
|
|
{
|
|
Alert("Dirección actualizada correctamente.");
|
|
RegistraScript("$('#divAddDireccionEnvio').modal('hide');");
|
|
CargaDatos();
|
|
}
|
|
|
|
ModalActualizaDirecciones(CveTimbre);
|
|
|
|
}
|
|
|
|
private void LnkAgregarDireccion_Click(object sender, EventArgs e)
|
|
{
|
|
TxtEnvioDireccion.Text = "";
|
|
TxtEnvioNoExt.Text = "";
|
|
TxtEnvioNoInt.Text = "";
|
|
TxtEnvioCP.Text = "";
|
|
|
|
CargaCombosDirecionesClientesSAT();
|
|
TxtFechaLlegada.Text = "";
|
|
|
|
UpModalDVDireccionEnvio.Update();
|
|
RegistraScript("$('#divAddDireccionEnvio').modal('show');");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|