diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index 23ef846b9..9845e2643 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -1463,7 +1463,7 @@ Public Class ClsClientes #Region "D I R E C C I O N D E E N V I O " Public Function DireccionEnvioAdd(CveCliente As Integer, EnvioDireccion As String, EnvioNoExt As String, EnvioNoInt As String, EnvioColonia As String, EnvioCiudad As String, EnvioEstado As String, EnvioCP As Integer, EnvioContacto As String, CveUsuario As Integer, Estatus As Integer, Optional CveClienteSucursal As Integer = -1, Optional EnvioDepartamento As String = "-1", Optional EnvioTel As String = "-1", - Optional CvePais As Integer = -1, Optional CveEstado As Integer = -1, Optional CveMunicipio As Integer = -1, Optional CveLocalidad As Integer = -1, Optional CveColonia As Integer = -1) As Integer + Optional CvePais As Integer = -1, Optional CveEstado As Integer = -1, Optional CveMunicipio As Integer = -1, Optional CveLocalidad As Integer = -1, Optional CveColonia As Integer = -1, Optional CveEmpresa As Integer = -1) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Vta_ClientesDireccionesEnvioAdd") @@ -1488,6 +1488,7 @@ Public Class ClsClientes .Add("@CveMunicipio", SqlDbType.Int).Value = CveMunicipio .Add("@CveLocalidad", SqlDbType.Int).Value = CveLocalidad .Add("@CveColonia", SqlDbType.Int).Value = CveColonia + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveDireccionEnvio", SqlDbType.Int).Direction = ParameterDirection.Output End With diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index 3f019b83f..f9f6cf177 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -3617,8 +3617,7 @@ Public Class ClsGenerales Public Function AddGralTimbre(TipoDocto As String, CveSubProyecto As Integer, Fecha As DateTime, CveUsuario As Integer, CveEmpresa As Integer, Optional Serie As String = "-1", Optional Folio As Integer = -1, Optional Estatus As Integer = 0, - Optional CveEntregaAlmacen As Integer = -1, - Optional AplicaCP As Boolean = False) As Integer + Optional CveEntregaAlmacen As Integer = -1, Optional AplicaCP As Boolean = False) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Gral_TimbreAdd") @@ -3663,7 +3662,7 @@ Public Class ClsGenerales With SqlAdapter.SelectCommand.Parameters .Add("@CveTimbre", SqlDbType.Int).Value = CveTimbre .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaI", SqlDbType.Date).Value = FechaI .Add("@FechaF", SqlDbType.Date).Value = FechaF .Add("@Estatus", SqlDbType.Int).Value = Estatus .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa @@ -3785,13 +3784,17 @@ Public Class ClsGenerales .Add("@CveCamion", SqlDbType.Int).Value = CveCamion .Add("@FechaEntrega", SqlDbType.DateTime).Value = FechaEntrega .Add("@FechaLlegada", SqlDbType.DateTime).Value = FechaLlegada + .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + .Add("@Orden", SqlDbType.Int).Value = Orden .Add("@FolioReferencia", SqlDbType.VarChar).Value = FolioReferencia .Add("@Referencia", SqlDbType.VarChar).Value = Referencia - .Add("@FechaLimite", SqlDbType.DateTime).Value = FechaLimite - .Add("@Orden", SqlDbType.Int).Value = Orden - .Add("@Tipo", SqlDbType.VarChar).Value = Tipo .Add("@Estatus", SqlDbType.VarChar).Value = Estatus .Add("@Distancia", SqlDbType.Int).Value = Distancia + + .Add("@FechaLimite", SqlDbType.DateTime).Value = FechaLimite + + + .Add("@CveEntregaAlmacen", SqlDbType.Int).Direction = ParameterDirection.Output End With diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 4bb7de6c7..fe926d470 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4944,6 +4944,7 @@ Public Class ClsPaginas PaginaDict.Add("/Inventarios/CatUnidades.aspx".ToUpper(), 2056) PaginaDict.Add("/Inventarios/EntregaAlmacenRuta.aspx".ToUpper(), 1320) PaginaDict.Add("/Inventarios/RepEntregaAlmacenRuta.aspx".ToUpper(), 1319) + PaginaDict.Add("/Inventarios/CartaPorteManual.aspx".ToUpper(), 1321) diff --git a/App_Code/Timbres.vb b/App_Code/Timbres.vb index a8263dfde..4183d3016 100644 --- a/App_Code/Timbres.vb +++ b/App_Code/Timbres.vb @@ -119,7 +119,8 @@ Public Class Timbres Dim Distancia As Integer = 1 Dim ObjGrales As New ClsGenerales - If ObjGrales.GetGralTimbre(CveTimbre, "-1", FI, FF, 0, UsuarioActual.CveEmpresa, -1) Then + + If ObjGrales.GetGralTimbre(CveTimbre, Obj.TipoDocto, FI, FF, 0, UsuarioActual.CveEmpresa, -1) Then If ObjGrales.DtResultados.Rows.Count = 1 Then Dim DtMovimientos As DataTable = Nothing @@ -144,20 +145,20 @@ Public Class Timbres End If If ObjGrales.GetGralMovimientosDetalleTimbre(CveTimbre, UsuarioActual.CveEmpresa) Then - DtMovimientos = ObjGrales.DtResultados - Else - TieneError = True - _MsgError.AppendLine("Error al obtener Movimientos") - End If + DtMovimientos = ObjGrales.DtResultados + Else + TieneError = True + _MsgError.AppendLine("Error al obtener Movimientos") + End If - ObjFactura.DtDetalle = DtMovimientos + ObjFactura.DtDetalle = DtMovimientos - AplicaCP = Boolean.Parse(drT("AplicaCP").ToString) + AplicaCP = Boolean.Parse(drT("AplicaCP").ToString) - ObjFactura.CveSubProyecto = drT("CveSubProyecto").ToString.ToEntero + ObjFactura.CveSubProyecto = drT("CveSubProyecto").ToString.ToEntero - ObjFactura.SetSubProyecto() - ObjFactura.SetSubProyectoMatriz() + ObjFactura.SetSubProyecto() + ObjFactura.SetSubProyectoMatriz() If AplicaCP Then @@ -331,15 +332,17 @@ Public Class Timbres _MsgError.AppendLine("timbrado son detalle de productos") End If - End If + End If - Else - TieneError = True + Else + TieneError = True _MsgError.AppendLine("Consultar datos de timbrado") End If ObjGrales.Dispose() - + Else + Timbre = Nothing + _MsgError.AppendLine("Consultar datos de timbrado") End If Return Timbre End Function diff --git a/Bin/GoCfdi.dll b/Bin/GoCfdi.dll index 9ccff8cbe..72be2e8c0 100644 Binary files a/Bin/GoCfdi.dll and b/Bin/GoCfdi.dll differ diff --git a/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc b/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc index 54b24800a..3de89a586 100644 --- a/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc +++ b/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc @@ -52,7 +52,13 @@ 3.00921cm - 10.82134cm + 6.3532cm + + + 2.5cm + + + 1.90464cm 2.35479cm @@ -150,6 +156,86 @@ + + + + true + true + + + + + =Fields!CodigoMaterialPeligroso.Value + + + + + + + CodigoMaterialPeligroso + + 5pt + + + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Embalaje.Value + + + + + + + Embalaje + + 5pt + + + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + @@ -280,6 +366,86 @@ + + + 0.52062cm + + + true + true + + + + + Cod. Material Peligroso + + + + + + + Textbox37 + + + #4f81bd + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.52062cm + + + true + true + + + + + Embalaje + + + + + + + Textbox40 + + + #4f81bd + 2pt + 2pt + 2pt + 2pt + + + + + 0.52062cm @@ -385,7 +551,7 @@ 6.39415cm 0.38395cm 1.12062cm - 19.11271cm + 19.04921cm + + + + Placa: + + + + =Parameters!PlacaVM.Value + + + + + + + + + Año: + + + + =Parameters!AnioVM.Value + + + + + + + + + Textbox2 1.13111in @@ -1925,52 +2145,13 @@ - Placa: + - - =Parameters!PlacaVM.Value - - - - - - - - - Año: - - - - =Parameters!AnioVM.Value - - - - - - + + + + + Carta Porte Manual + + + + + +
  • + +
  • +
    +
    + + + + +
    + + + + + + + + +
    + <%--
    + + + + +
    +
    +
    + + TRASPASO ENTRE ALMACENES +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
    + +
    +
    + + +
    + +
    + + +
    + +
    +
    +
    + + + +
    +
    +
    --%> + + + + +
    +
    +
    +
    + + EMISIÓN DE TRASLADO +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + +
    + +
    + + +
    +
    +
    + +
    +
    + + + + + + + + + + + + + + +
    +
    + +
    + +
    + +
    + + + + + +
    + + +
    +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + <%-- +
    +
    + + + + + + + + +
    +
    --%> +
    +
    + + + + +
    +
    +
    +
    + +
    +
    +
    +
    + + + + + +
    +
    +
    + + Direcciones +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + + + + + + + + + + + Tipo + + +
    + +
    +
    +
    + + + + + Dirección + + +
    + +
    +
    +
    + + + + Estado + + +
    + +
    +
    +
    + + + + Municipio + + +
    + +
    +
    +
    + + + + Localidad + + +
    + +
    +
    +
    + + + + + Colonia + + +
    + +
    +
    +
    + + + + C.P. + + +
    + +
    +
    +
    + + + + + + + +
    +
    +
    +
    + +
    +
    +
    +
    + + +
    +
    + +
    + + + +
    + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #CantidadUnidadProducto + Sección AlmacenSerieLoteFecha CaducidadComandos
    + + + + + + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    + <%-- --%> + + + + + Destino: + + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + +
    +
    + +
    +
    + + +
    +
    + + <%----%> +
    +
    +
    +
    + +
    +
    + + + + +
    +
    + + + +
    + +
    + + +
    + + <%-- --%> + + + + + + + + + + + + + + + +
    + + + + + diff --git a/Inventarios/CartaPorteManual.aspx.vb b/Inventarios/CartaPorteManual.aspx.vb new file mode 100644 index 000000000..c8b85b178 --- /dev/null +++ b/Inventarios/CartaPorteManual.aspx.vb @@ -0,0 +1,1341 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.IO +Imports Extensiones +Imports GemBox.Spreadsheet + +Partial Class Inventarios_CartaPorteManual + Inherits ClsPaginas + +#Region "PROPIEDADES" + Public Property DtMovimientos() As DataTable + Get + Return CType(ViewState("DtMovimientos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientos") = value + End Set + End Property + + 'Private Property DtTraslado As DataTable + ' Get + ' Return CType(ViewState("DtTraslado"), DataTable) + ' End Get + ' Set(value As DataTable) + ' ViewState("DtTraslado") = value + ' End Set + 'End Property + + + 'Private Property CveAlmacenTransitorio As Integer + ' Get + ' Return CType(ViewState("CveAlmacenTransitorio"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveAlmacenTransitorio") = value + ' End Set + 'End Property + 'Private Property CveAlmacenDestino As Integer + ' Get + ' Return CType(ViewState("CveAlmacenDestino"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveAlmacenDestino") = value + ' End Set + 'End Property + 'Private Property CveUsuarioResponsable As Integer + ' Get + ' Return CType(ViewState("CveUsuarioResponsable"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveUsuarioResponsable") = value + ' End Set + 'End Property + 'Private Property CvePSSerie As Integer + ' Get + ' Return CType(ViewState("CvePSSerie"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CvePSSerie") = value + ' End Set + 'End Property + 'Private Property CveUMSerie As Integer + ' Get + ' Return CType(ViewState("CveUMSerie"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveUMSerie") = value + ' End Set + 'End Property + 'Private Property CargadoDeMov As Boolean + ' Get + ' Return CType(ViewState("CargadoDeMov"), Boolean) + ' End Get + ' Set(value As Boolean) + ' ViewState("CargadoDeMov") = value + ' End Set + 'End Property + 'Private Property CveMovimientoSalida As Integer + ' Get + ' Return CType(ViewState("CveMovimientoSalida"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveMovimientoSalida") = value + ' End Set + 'End Property + 'Private Property CveMov As Integer + ' Get + ' Return CType(ViewState("CveMov"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveMov") = value + ' End Set + 'End Property + Private Property ObjFactura As Modelos.Factura + Get + Return CType(ViewState("ObjFactura"), Modelos.Factura) + End Get + Set(value As Modelos.Factura) + ViewState("ObjFactura") = value + End Set + End Property + Private Property Folio As Integer + Get + Return CType(ViewState("Folio"), Integer) + End Get + Set(value As Integer) + ViewState("Folio") = value + End Set + End Property + Private Property MensajeAlert As StringBuilder + Get + Return CType(ViewState("MensajeAlert"), StringBuilder) + End Get + Set(value As StringBuilder) + ViewState("MensajeAlert") = value + End Set + End Property + + 'Private Property CveMovimientoTimbrado As Integer + ' Get + ' Return CType(ViewState("CveMovimientoTimbrado"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveMovimientoTimbrado") = value + ' End Set + 'End Property + + 'Private Property CantidadTotal As Decimal + ' Get + ' Return CType(ViewState("CantidadTotal"), Decimal) + ' End Get + ' Set(value As Decimal) + ' ViewState("CantidadTotal") = value + ' End Set + 'End Property + 'Private Property CvePS As Integer + ' Get + ' Return CType(ViewState("CvePS"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CvePS") = value + ' End Set + 'End Property + 'Private Property TipoSeccionAlmacen As Integer + ' Get + ' Return CType(ViewState("TipoSeccionAlmacen"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("TipoSeccionAlmacen") = value + ' End Set + 'End Property + + 'Private Property FolioBusqueda As Integer + ' Get + ' Return CType(ViewState("FolioBusqueda"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("FolioBusqueda") = value + ' End Set + 'End Property + + + Private Property FechaSalida As Date + Get + If ViewState("FechaEntrega") Is Nothing Then + ViewState("FechaEntrega") = Now + End If + Return ViewState("FechaEntrega").ToString.ToDate + End Get + Set(value As Date) + ViewState("FechaEntrega") = value + End Set + End Property + + Private Property FechaLlegada As Date + Get + If ViewState("FechaLlegada") Is Nothing Then + ViewState("FechaLlegada") = Now + End If + Return ViewState("FechaLlegada").ToString.ToDate + End Get + Set(value As Date) + ViewState("FechaLlegada") = 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 + + TxtFecha.Text = Now.ToShortDateString + CEFecha.EndDate = Now.AddDays(-1) + RVFecha.MaximumValue = Now.ToShortDateString + + Folio = 0 + + CargaCombos() + CreaDT() + + 'If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + ' DivCodigoSeriePS.Visible = True + 'Else + ' DivCodigoSeriePS.Visible = False + 'End If + + 'If UsuarioActual.CveEmpresa.Contiene(141, 152, 158, 159, 160, 161, 162, 163) Then + ' ChkEmitirTimbrado.Visible = False + ' divEmitir.Visible = False + 'End If + + If UsuarioActual.CveEmpresa.Contiene(1, 119, 140, 2) Then + + If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then + ChkEmitirTimbrado.Checked = True + End If + + ChkEmitirCartaPorte.Visible = True + + End If + + + 'If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 Then + + ' TxtFecha.Enabled = False + ' ImgFecha.Visible = False + 'End If + + End If + End Sub + +#Region "CARGA DATOS" + + Protected Sub CreaDT() + Dim dt As New DataTable + + Dim column As DataColumn = New DataColumn("No") + column.DataType = Type.GetType("System.Int32") + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + + dt.Columns.Add(column) + + + + dt.Columns.Add("Cantidad", Type.GetType("System.Double")) + dt.Columns.Add("CveUM", Type.GetType("System.Int32")) + dt.Columns.Add("UnidadMedida") + dt.Columns.Add("UM") + dt.Columns.Add("CvePS", Type.GetType("System.Int32")) + dt.Columns.Add("CveAF", Type.GetType("System.Int32")) + dt.Columns.Add("PS") + dt.Columns.Add("Observaciones") + dt.Columns.Add("CveSeccionAlmacen", Type.GetType("System.Int32")) + dt.Columns.Add("SeccionAlmacen") + dt.Columns.Add("CveSeccionAlmacenDestino", Type.GetType("System.Int32")) + dt.Columns.Add("SeccionAlmacenDestino") + dt.Columns.Add("Serie") + dt.Columns.Add("Lote") + dt.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime")) + + + + dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32")) + dt.Columns.Add("EstatusExistencia") + + dt.Columns.Add("TotalImporte", Type.GetType("System.Double")) + dt.Columns.Add("PU", Type.GetType("System.Double")) + dt.Columns.Add("Descuento", Type.GetType("System.Double")) + dt.Columns.Add("SATClaveUM") + dt.Columns.Add("SATClaveProdServ") + dt.Columns.Add("Noidentificacion") + dt.Columns.Add("CuentaPredial") + dt.Columns.Add("Obs") + dt.Columns.Add("ImporteIVA", Type.GetType("System.Double")) + dt.Columns.Add("PorcentajeIVA", Type.GetType("System.Double")) + dt.Columns.Add("ClaveMaterialPeligroso") + dt.Columns.Add("ClaveEmbalaje") + dt.Columns.Add("Embalaje") + dt.Columns.Add("PesoKg", Type.GetType("System.Decimal")) + + + DtMovimientos = dt + + CargaGvDatos() + + End Sub + + + Private Sub CargaCombos() + CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto, AplicaTodos:="") + + DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) + + DdlChofer.DataSource = GlobalDTChoferes(UsuarioActual.CveEmpresa) + DdlChofer.DataBind() + + DdlChofer.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) + ' TxtFechaEntrega.Text = Now.ToShortDateString + TxtFechaLlegada.Text = Now.ToShortDateString + + + + CargaPS() + + + CargarCamiones() + End Sub + + Private Sub CargaPS() + + + Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + DdlProducto2.setEsWebService(EsWS) + + If DdlProducto2.UsaWebService Then + + If UsuarioActual.Empresa.Funcionalidad(141) = "1" Then + DdlProducto2.ddlWS.Attributes.Add("data-pagina", "inv/traspaso") + DdlProducto2.ddlWS.Attributes.Add("Data-onresult", "CargaExistenciaAlmacenes") + + End If + + End If + + End Sub + + +#End Region + +#Region " AGREGAR " + Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click + BtnAgregarPS(txtCantidad.Text.ToDecimal) + End Sub + Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs) + BtnAgregarPS(1) + End Sub + Private Sub BtnAgregarPS(Cantidad As Decimal) + Dim CveProducto As Integer = DdlProducto2.SelectedValue.ToEntero + Dim FuncionalidadSinSerie = True + + If CveProducto > 0 Then + + If TxtnSerie.Visible Then + Cantidad = 1 + If TxtnSerie.Text = "" Then + Alert("Serie es necesario", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + Exit Sub + End If + If txtCantidad.Text.ToDouble > 1 Then + FuncionalidadSinSerie = False + End If + End If + Dim DrPS As DataRow = Nothing + + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveProducto).FiltroPrimero("") ' Estado = -1 + + If DrPS IsNot Nothing Then + + 'codigo temporal + Dim tLote As String + Dim tCaducidad As Date + + tLote = If(TxtnLote.Visible, TxtnLote.Text, "-1") + tCaducidad = If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha) + + + AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, "", CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(TxtnSerie.Visible, TxtnSerie.Text, ""), Lote:=If(tLote = "-1", "", tLote), FechaCaducidad:=tCaducidad, CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie) + + + End If + + End If + End Sub + + + + Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Observaciones As String = "", Optional CveSeccionAlmacen As Integer = -1, Optional SeccionAlmacen As String = "", Optional Serie As String = "", Optional Lote As String = "", Optional FechaCaducidad As Date = MinFecha, Optional Limpia As Boolean = True, Optional CveSeccionAlmacenDestino As Integer = -1) + If Cantidad <= 0 Then + Alert("La cantidad debe ser mayor a cero (0). Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + + Dim CveClasificacion As Integer + + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + If DrPS IsNot Nothing Then + CveClasificacion = DrPS("CveClasificacion").ToString.ToEntero + Dim DrUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimero($"CveUnidadMedida = {CveUnidadMedida}") + + Dim registro As DataRow = DtMovimientos.NewRow + registro.Item("Cantidad") = Cantidad + registro.Item("CveUM") = CveUnidadMedida + registro.Item("UM") = DrUM("UnidadMedida") + registro.Item("UnidadMedida") = DrUM("UnidadMedida") + registro.Item("CvePS") = CvePS + registro.Item("PS") = DrPS("PSCodigo") + registro.Item("Observaciones") = Observaciones + registro.Item("Serie") = Serie + registro.Item("Lote") = Lote + If FechaCaducidad > MinFecha Then registro.Item("FechaCaducidad") = FechaCaducidad + registro.Item("CveClasificacion") = CveClasificacion + registro.Item("CveAF") = -1 + registro.Item("EstatusExistencia") = "1" + registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen + registro.Item("SeccionAlmacen") = SeccionAlmacen + registro.Item("CveSeccionAlmacenDestino") = CveSeccionAlmacenDestino + + registro.Item("TotalImporte") = 0 + registro.Item("PU") = 0 + registro.Item("Descuento") = 0 + registro.Item("SATClaveUM") = DrPS("SATClaveUnidadMedida") + registro.Item("SATClaveProdServ") = DrPS("SATClavePS") + registro.Item("Noidentificacion") = DrPS("Codigo") + registro.Item("CuentaPredial") = "" + registro.Item("Obs") = "" + + registro.Item("ImporteIVA") = 0 + registro.Item("PorcentajeIVA") = 0 + registro("ClaveMaterialPeligroso") = DrPS("ClaveMaterialPeligroso") + registro("ClaveEmbalaje") = DrPS("ClaveEmbalaje") + registro("PesoKg") = DrPS("PesoKg") + + DtMovimientos.Rows.Add(registro) + RegistraScript("playsonidito('beep-07.wav')") + + End If + + + CargaGvDatos() + + If Limpia Then + LimpiaAgregar() + Else + txtCantidad.Text = (txtCantidad.Text.ToDouble - 1.0).ToString + TxtnSerie.Text = "" + TxtnSerie.Focus() + End If + End Sub + + Private Sub LimpiaAgregar() + 'DdlClasificacion.SelectedValue = "-1" + 'DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty) + txtCantidad.Text = "" + 'TxtnObservaciones.Text = "" + TxtnSerie.Text = "" + TxtnSerie.Visible = False + TxtnLote.Text = "" + TxtnFechaCaducidad.Text = "" + + txtCantidad.Focus() + 'If TxtCodigoPS.Visible Then + ' TxtCodigoPS.Focus() + 'End If + End Sub + + +#End Region + +#Region " GUARDAR " + Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click + + + Dim CountPs As Integer = 0 + Dim CounDirecciones As Integer = 0 + + + + MensajeAlert = New StringBuilder + + For Each GvRowPS As GridViewRow In GvDatos.Rows + CountPs = CountPs + 1 + Next + + If CountPs = 0 Then + Alert("No hay productos agregados", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + For Each GvRow As GridViewRow In GvDireccionesEnvio.Rows + CounDirecciones = CounDirecciones + 1 + Next + + + If CounDirecciones <> 2 Then + Alert("Debe de agregar dos direcciones", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + + If DdlChofer.SelectedValue.ToEntero <= 0 Then + Alert("Debe de seleccionar un chofer", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If DdlUnidadCamion.SelectedValue.ToEntero <= 0 Then + Alert("Debe de seleccionar una unidad", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If DdlChofer.SelectedValue.ToEntero <= 0 Then + Alert("Debe seleccionar un Chofer", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + + Exit Sub + End If + + + + Dim CveTimbre As Integer = -1 + Dim ErrorProceso As Boolean = False + + Dim CveDireccionOrigen As Integer = -1 + Dim CveDireccionDestino As Integer = -1 + + + Dim ObjGral As New ClsGenerales() + Dim ObjClientes As New ClsClientes(ObjGral.IniciaTransacSQL()) + + + + For Each GvRow As GridViewRow In GvDireccionesEnvio.Rows + Dim Tipo As Integer = GvRow.DataKey("Tipo").ToEntero + + Dim EnvioDireccion As String = GvRow.DataKey("EnvioDireccion") + Dim EnvioNoExt As String = GvRow.DataKey("EnvioNoExt") + Dim EnvioNoInt As String = GvRow.DataKey("EnvioNoInt") + Dim EnvioCP As Integer = GvRow.DataKey("EnvioCP").ToEntero + + Dim CvePais As Integer = GvRow.DataKey("CvePais").ToEntero + Dim CveEstado As Integer = GvRow.DataKey("CveEstado").ToEntero + Dim CveMunicipio As Integer = GvRow.DataKey("CveMunicipio").ToEntero + Dim CveLocalidad As Integer = GvRow.DataKey("CveLocalidad").ToEntero + Dim CveColonia As Integer = GvRow.DataKey("CveColonia").ToEntero + + + If Tipo = 1 Then + + CveDireccionOrigen = ObjClientes.DireccionEnvioAdd(-1, EnvioDireccion, EnvioNoExt, EnvioNoInt, "", "", "", EnvioCP, "", UsuarioActual.CveUsuario, 1, -1, "", + CvePais:=CvePais, CveEstado:=CveEstado, CveMunicipio:=CveMunicipio, CveLocalidad:=CveLocalidad, CveColonia:=CveColonia) + + Else + CveDireccionDestino = ObjClientes.DireccionEnvioAdd(-1, EnvioDireccion, EnvioNoExt, EnvioNoInt, "", "", "", EnvioCP, "", UsuarioActual.CveUsuario, 1, -1, "", + CvePais:=CvePais, CveEstado:=CveEstado, CveMunicipio:=CveMunicipio, CveLocalidad:=CveLocalidad, CveColonia:=CveColonia) + End If + + Next + + + If Not (CveDireccionOrigen > 0 And CveDireccionDestino > 0) Then + ErrorProceso = True + End If + + + Dim FechallegadaMM As DateTime = (FechaLlegada.ToString("dd/MM/yyyy") & " 23:59:59").ToDateTime + + Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(DdlSubProyecto.SelectedValue.ToEntero, CveDireccionOrigen, CveDireccionDestino, -1, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, FechaSalida, FechallegadaMM, "T", "-1", "-1", FechaLlegada, 1, 1, TxtDistancia.Text.ToEntero) + + If CveEntregaAlmacen > 0 Then + + For Each GvRowPS As GridViewRow In GvDatos.Rows + If Not ObjGral.AddEntregaAlmacenRutaDetalle(CveEntregaAlmacen, GvRowPS.DataKey("CvePS").ToEntero, GvRowPS.DataKey("Cantidad").ToEntero, GvRowPS.DataKey("CveUM").ToEntero, UsuarioActual.CveUsuario) Then + ErrorProceso = True + Exit For + End If + Next + + CveTimbre = ObjGral.AddGralTimbre("Man", DdlSubProyecto.SelectedValue.ToEntero, TxtFecha.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen:=CveEntregaAlmacen, AplicaCP:=ChkEmitirCartaPorte.Checked) + + If Not CveTimbre > 0 Then + + ErrorProceso = True + End If + Else + ErrorProceso = True + End If + + 'End If + + + + + If Not ErrorProceso Then + ObjGral.Commit() + Else + ObjGral.RollBack() + End If + + + ObjGral.Dispose() + + + If ChkEmitirTimbrado.Checked And Not ErrorProceso Then + 'CveMovimientoTimbrado = CveMovimientoSalida + EmitirTimbrado(CveTimbre) + End If + + Alert(MensajeAlert.ToString, TipoMensaje.MsgInformacion, "") + + + End Sub + + + +#End Region + +#Region " NUEVO - LIMPIA " + +#End Region + +#Region "DDL CLASIFICACION" + + Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange + ElProductoChange() + End Sub + Private Sub ElProductoChange() + TxtnSerie.Visible = False + TxtnLote.Visible = False + TxtnFechaCaducidad.Visible = False + + If DdlProducto2.SelectedValue.ToEntero > 0 Then + Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltroPrimero("", "PS") + If drP IsNot Nothing Then + + ThSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + TdSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + DdlSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + 'GvDatos.Columns(5).Visible = CBool(drP("AplicaSeccion")) + + + ThSerie.Visible = CBool(drP("AplicaSerie")) + TdSerie.Visible = CBool(drP("AplicaSerie")) + TxtnSerie.Visible = CBool(drP("AplicaSerie")) + 'GvDatos.Columns(6).Visible = CBool(drP("AplicaSerie")) + + + TxtnLote.Visible = CBool(drP("AplicaLote")) + ThLote.Visible = CBool(drP("AplicaLote")) + TdLote.Visible = CBool(drP("AplicaLote")) + 'GvDatos.Columns(7).Visible = CBool(drP("AplicaLote")) + + + TxtnFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + ThFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then ThFechaCaducidad.InnerText = UsuarioActual.Empresa.Funcionalidad(147) + 'ThFechaCaducidad.InnerText = If(UsuarioActual.Empresa.Funcionalidad(147) = "Fecha Elaboración", "Fecha Elaboración", "Fecha Caducidad") + TdFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + 'GvDatos.Columns(8).Visible = CBool(drP("AplicaCaducidad")) + + End If + + End If + + DdlUnidad.Items.Clear() + DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + DdlUnidad.DataBind() + UpDatos.Update() + End Sub + Private Function isWhitFamily() As Boolean + Return (UsuarioActual.CveEmpresa = 66) + End Function + Protected Sub DdlClasificacion_GV(sender As Object, e As System.EventArgs) + Dim pDdlClasificacion As DropDownList = CType(sender, DropDownList) + Dim pDdlProducto As DropDownList = CType(pDdlClasificacion.NamingContainer.FindControl("DdlProducto"), DropDownList) + + If pDdlClasificacion.SelectedValue = "-1" Then + pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + pDdlProducto.DataBind() + Else + pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=pDdlClasificacion.SelectedValue.ToEntero) + pDdlProducto.DataBind() + End If + + + pDdlProducto.DataBind() + pDdlProducto.Items.Insert(0, New ListItem("----", "-1")) + + End Sub +#End Region + +#Region "GV DATOS" + Private Sub CargaGvDatos() + EscondeColumnasGVM(DtMovimientos) + + GvDatos.DataSource = DtMovimientos + GvDatos.DataBind() + UpDatos.Update() + End Sub + + Private Sub EscondeColumnasGVM(DtTemp As DataTable) + + GvDatos.Columns(5).Visible = DtTemp.MAX("Serie").ToString <> "" + GvDatos.Columns(6).Visible = DtTemp.MAX("Lote").ToString <> "" + GvDatos.Columns(7).HeaderText = If(UsuarioActual.Empresa.Funcionalidad(147) = "Fecha Elaboración", "Fecha Elaboración", "Fecha Caducidad") + GvDatos.Columns(7).Visible = DtTemp.MAX("FechaCaducidad").ToString.ToDate > MinFecha + GvDatos.Columns(8).Visible = DtTemp.MAX("CveSeccionAlmacen").ToString.ToEntero > 0 + + + End Sub + + Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("EstatusExistencia").ToEntero < 0 Then + e.Row.Cells(0).BackColor = Drawing.Color.Red + End If + + End If + End Sub + Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting + Dim DbRow As DataRow = Nothing + DbRow = DtMovimientos.Rows(e.RowIndex) + + DtMovimientos.Rows.Remove(DbRow) + CargaGvDatos() + End Sub + + + + Protected Sub ChkSugiereFechaCaducidad_CheckedChanged(sender As Object, e As EventArgs) + + TxtnFechaCaducidad.Visible = Not ChkSugiereFechaCaducidad.Checked + TxtnLote.Visible = Not ChkSugiereFechaCaducidad.Checked + + End Sub + + +#End Region + +#Region " TRANSITORIO - RECEPCION " + + + Private Sub CargarUM(CvePS As Integer) + Dim ObjUM As New ClsProductosServicios() + If ObjUM.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then + DdlUnidad.Items.Clear() + DdlUnidad.DataSource = ObjUM.DtResultados + End If + ObjUM.Dispose() + DdlUnidad.DataBind() + End Sub + + + +#End Region + + + +#Region "TIMBRADO" + + + Private Sub EmitirTimbrado(CveTimbre As Integer) + + Dim ObjTimbres As New Timbres("Man", CveTimbre, UsuarioActual) + + If MensajeAlert Is Nothing Then + MensajeAlert = New StringBuilder + End If + + + MensajeAlert.Append("

    ") + + + If ObjTimbres.ObjFactura.Timbre Is Nothing Then + Alert(ObjTimbres.MsgError.ToString, TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If ObjTimbres.Timbrar() Then + + Try + PdfFactura(ObjTimbres.ObjFactura) + Catch ex As Exception + + End Try + + MensajeAlert.Append($"{ObjTimbres.ObjFactura.SerieFolio} Emitido con éxito.") + 'XML + Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjTimbres.ObjFactura.TipoDocto, ObjTimbres.ObjFactura.SerieFolio) + If File.Exists(ArchivoXML) Then + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", -1, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto))) + End If + 'PDF + 'Dim ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjTimbres.ObjFactura.TipoDocto, ObjTimbres.ObjFactura.SerieFolio) + 'If File.Exists(ArchivoPDF) Then + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto))) + 'End If + + ' If ChkEmitirCartaPorte.Checked Then + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", CveTimbre))) + 'Else + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimientoTimbrado))) + ' End If + + LimpiarDatos() + + Else + MensajeAlert.AppendFormat("
    • {0}
    ", ObjTimbres.MsgError.ToString) + End If + + + + + + + + End Sub + + Public Sub LimpiarDatos() + + + DT_Direcciones.Clear() + DtMovimientos.Clear() + + GvDatos.DataSource = Nothing + GvDireccionesEnvio.DataSource = Nothing + + GvDatos.DataBind() + GvDireccionesEnvio.DataBind() + + txtCantidad.Text = "" + DdlSubProyecto.SelectedValueExist(-1) + DdlChofer.SelectedValueExist(-1) + DdlUnidadCamion.SelectedValueExist(-1) + + LnkAgregarDireccion.Visible = True + + UpDatos.Update() + UpGvDireccionesEnvio.Update() + + + + + + + + End Sub + + + 'Private Sub Timbrar() + + ' CreaObjetosVenta() + ' Dim ObjTimbrado As New Timbrado + ' Dim FM As New Modelos.FemsaFactura + ' Dim TmpDT7Eleven As New DataTable + ' Dim TmpDTComplementosTimbrado As New DataTable + ' PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) + ' MensajeAlert.Append("

    ") + + + ' If ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) Then + ' MensajeAlert.Append("Emitido con exito.") + ' 'XML + ' Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + ' If File.Exists(ArchivoXML) Then + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) + ' End If + ' 'PDF + ' 'GeneraPDFFactura() + ' Dim ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + ' If File.Exists(ArchivoPDF) Then + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) + ' End If + + ' If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPOTIMBRE&CVEMOV={0}", CveMovimientoTimbrado))) + ' Else + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimientoTimbrado))) + ' End If + + ' Else + ' MensajeAlert.AppendFormat("
    • {0}
    ", ObjTimbrado.MensajeErrorCFDI) + ' End If + + 'End Sub + + Private Sub GeneraPDFFactura() + Try + PdfFactura(ObjFactura) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError) + End Try + End Sub + +#End Region + + Protected Sub DldChofer_SelectedIndexChanged(sender As Object, e As EventArgs) + ' Dim ObjAcar As New ClsAcarreos() + + ' If ObjAcar.GetChofer(DdlChofer.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 1, -1) Then + ' Dim dr As DataRow = ObjAcar.DtResultados.Rows(0) + ' If dr IsNot Nothing Then + ' TxtResponsableRecibio.Text = dr("Chofer").ToString + ' TxtIdentificacion.Text = dr("Identificacion").ToString + ' TxtDomicilio.Text = dr("Domicilio").ToString + ' TxtTelefono.Text = dr("Telefono").ToString + ' TxtCiudad.Text = dr("Ciudad").ToString + ' TxtLicencia.Text = dr("Licencia").ToString + ' End If + ' End If + ' ObjAcar.Dispose() + End Sub + + Protected Sub BtnDescargarFormatoExcelConceptos_Click(sender As Object, e As EventArgs) + Dim DtExcel As New DataTable + DtExcel.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) + DtExcel.Columns.Add(New DataColumn("Codigo", GetType(String))) + DtExcel.Columns.Add(New DataColumn("Producto", GetType(String))) + DtExcel.Columns.Add(New DataColumn("Serie", GetType(String))) + DtExcel.Columns.Add(New DataColumn("Lote", GetType(String))) + DtExcel.Columns.Add(New DataColumn("FechaCaducidad", GetType(Date))) + DtExcel.Columns.Add(New DataColumn("Observaciones", GetType(String))) + + DtExcel.TableName = "Traspaso" + + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + + Dim FileExcel As New ExcelFile() + + Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName) + worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With + { + .ColumnHeaders = True, + .StartRow = 0, + .StartColumn = 0 + }) + worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255) + + Dim columnCount = worksheet.CalculateMaxUsedColumns() + For i = 0 To columnCount + worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1)) + Next + + FileExcel.Save(Response, "Traspaso.xlsx", SaveOptions.XlsxDefault) + + End Sub + + + + Public Sub CargarCamiones() + DdlUnidadCamion.Items.Clear() + + DdlUnidadCamion.DataSource = GlobalDTInvCamiones(UsuarioActual.CveEmpresa) + DdlUnidadCamion.DataBind() + + + DdlUnidadCamion.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) + + + End Sub + + + + + Protected Sub ChkEmitirTimbrado_CheckedChanged(sender As Object, e As EventArgs) + + If ChkEmitirTimbrado.Checked Then + ChkEmitirCartaPorte.Checked = False + ChkEmitirCartaPorte.Visible = True + Else + ChkEmitirCartaPorte.Visible = False + ChkEmitirCartaPorte.Checked = False + End If + + + + End Sub + + + + Private Sub ResetModalDirecciones() + + End Sub + + +#Region "D I R E C C I O N E N V I O " + + Private Sub CargaCombosDirecionesClientesSAT() + CargaDirClientePais() + CargaDirClienteEstado() + CargaDirClienteMunicipio() + CargaDirClienteLocalidad() + CargaDirClienteColonia() + End Sub + + + + Private Sub CargaDirClientePais() + + DdlDirClientePais.DataSource = GlobalDTGralPaises() + DdlDirClientePais.DataBind() + DdlDirClientePais.SelectedValueExist("151") + End Sub + + Private Sub CargaDirClienteEstado() + DdlDirClienteEstado.Items.Clear() + If DdlDirClientePais.SelectedValue.ToEntero > 0 Then + DdlDirClienteEstado.DataSource = GlobalDTGralEstados("-1", DdlDirClientePais.SelectedValue.ToEntero) + End If + DdlDirClienteEstado.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlDirClienteEstado.DataBind() + End Sub + + Private Sub CargaDirClienteMunicipio() + DdlDirClienteMunicipio.Items.Clear() + If DdlDirClienteEstado.SelectedValue.ToEntero > 0 Then + DdlDirClienteMunicipio.DataSource = GlobalDTGralMunicipios("-1", DdlDirClienteEstado.SelectedValue.ToEntero) + End If + DdlDirClienteMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlDirClienteMunicipio.DataBind() + End Sub + + Private Sub CargaDirClienteColonia() + DdlDirClienteColonia.Items.Clear() + If DdlDirClienteMunicipio.SelectedValue.ToEntero > 0 Then + DdlDirClienteColonia.DataSource = GlobalDTGralColonias("-1", "-1", "-1", DdlDirClienteMunicipio.SelectedValue.ToEntero, CodigoPostal:=If(TxtEnvioCP.Text.Trim.Length > 0, TxtEnvioCP.Text.ToEntero, -1)) + End If + DdlDirClienteColonia.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlDirClienteColonia.DataBind() + End Sub + + + Protected Sub CargaDirClienteLocalidad() + + DdlDirClienteLocalidad.Items.Clear() + If DdlDirClienteEstado.SelectedValue.ToEntero > 0 Then + DdlDirClienteLocalidad.DataSource = GlobalDTLocalidad(DdlDirClienteEstado.SelectedValue.ToEntero, DdlDirClienteMunicipio.SelectedValue.ToEntero) + DdlDirClienteLocalidad.DataBind() + End If + + DdlDirClienteLocalidad.Items.Insert(0, New ListItem("Seleccione una", "-1")) + + End Sub + + + Protected Sub DdlDirClientePais_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaDirClienteEstado() + CargaDirClienteMunicipio() + CargaDirClienteColonia() + CargaDirClienteLocalidad() + End Sub + Protected Sub DdlDirClienteEstado_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaDirClienteMunicipio() + CargaDirClienteColonia() + CargaDirClienteLocalidad() + End Sub + + Protected Sub DdlDirClienteMunicipio_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaDirClienteColonia() + CargaDirClienteLocalidad() + End Sub + + + Protected Sub BtnDirClienteValidar_Click(sender As Object, e As EventArgs) + DirClientevalidaCodigoPostal() + End Sub + + + Protected Sub DdlDirClienteColonia_SelectedIndexChanged(sender As Object, e As EventArgs) + DirClientevalidaCodigoPostal() + End Sub + + Private Sub DirClientevalidaCodigoPostal() + + Dim CPTxt As Integer = TxtEnvioCP.Text.ToEntero() + + Dim CveColonia As Integer = DdlDirClienteColonia.SelectedValue.ToEntero + + If CPTxt > 0 And CveColonia > 0 Then + Dim CP As Integer = GlobalDTGralColonias("-1", "-1", "-1", CveColonia:=CveColonia).FiltroPrimeroValor("CP", "").ToEntero + If CPTxt <> CP Then + Alert("El código postal selecionado es diferente del codigo postal de la Colonia.", TipoMensaje.MsgAdvertencia) + End If + End If + + End Sub + + + Public Sub Edit_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + + 'CveDireccionEnvio = GvRow.DataKey("CveDireccionEnvio").ToEntero() + TxtEnvioDireccion.Text = GvRow.DataKey("EnvioDireccion") + TxtEnvioNoExt.Text = GvRow.DataKey("EnvioNoExt") + TxtEnvioNoInt.Text = GvRow.DataKey("EnvioNoInt") + 'TxtEnvioColonia.Text = GvRow.DataKey("EnvioColonia") + 'TxtEnvioCiudad.Text = GvRow.DataKey("EnvioCiudad") + 'TxtEnvioEstado.Text = GvRow.DataKey("EnvioEstado") + 'TxtEnvioContacto.Text = GvRow.DataKey("EnvioContacto") + 'TxtDepartamento.Text = GvRow.DataKey("EnvioDepartamento") + TxtEnvioCP.Text = GvRow.DataKey("EnvioCP") + ' TxtEnvioTel.Text = GvRow.DataKey("EnvioTel") + + DdlDirClientePais.SelectedValueExist(GvRow.DataKey("CvePais")) + CargaDirClienteEstado() + DdlDirClienteEstado.SelectedValueExist(GvRow.DataKey("CveEstado")) + CargaDirClienteMunicipio() + DdlDirClienteMunicipio.SelectedValueExist(GvRow.DataKey("CveMunicipio")) + CargaDirClienteColonia() + DdlDirClienteLocalidad.SelectedValueExist(GvRow.DataKey("CveLocalidad")) + CargaDirClienteLocalidad() + + DdlDirClienteColonia.SelectedValueExist(GvRow.DataKey("CveColonia")) + + 'ChkEstatus.Checked = If(GvRow.DataKey("Estatus").ToString() = "True", True, False) + 'If GvRow.DataKey("CveClienteSucursal").ToEntero() > 0 Then DdlClienteSucursalEnvio.SelectedValueExist(GvRow.DataKey("CveClienteSucursal")) Else DdlClienteSucursalEnvio.SelectedValueExist("-1") + + + CargaTiposDirecciones() + + + UpModalDVDireccionEnvio.Update() + RegistraScript("$('#divAddDireccionEnvio').modal('show');") + End Sub + + Private Sub CargaTiposDirecciones() + + DdlTipoDireccion.Items.Clear() + + + If DT_Direcciones.FiltraParametros(" Tipo = 1 ").Rows.Count = 0 Then + DdlTipoDireccion.Items.Add(New ListItem("Origen", "1")) + End If + + + If DT_Direcciones.FiltraParametros(" Tipo = 2 ").Rows.Count = 0 Then + DdlTipoDireccion.Items.Add(New ListItem("Destino", "2")) + End If + + DdlTipoDireccion.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + + + Private Sub BtnAgregarDireccion_Click(sender As Object, e As EventArgs) Handles BtnAgregarDireccion.Click + + + If DdlTipoDireccion.SelectedValue.ToEntero > 0 Then + + If DdlTipoDireccion.SelectedValue.ToEntero = 1 Then + FechaSalida = TxtFechaLlegada.Text.ToDate + Else + FechaLlegada = TxtFechaLlegada.Text.ToDate + End If + + Else + Alert("Debe seleccionar un tipo de dirección.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + + + DT_DireccionesAddRow(-1, TxtEnvioDireccion.Text, TxtEnvioCP.Text.ToEntero, UsuarioActual.CveUsuario, TxtEnvioNoExt.Text, TxtEnvioNoInt.Text, DdlDirClienteEstado.SelectedItem.Text, DdlDirClienteMunicipio.SelectedItem.Text, DdlDirClienteLocalidad.SelectedItem.Text, + DdlDirClienteColonia.SelectedItem.Text, DdlDirClientePais.SelectedValue.ToEntero, DdlDirClienteEstado.SelectedValue.ToEntero, DdlDirClienteMunicipio.SelectedValue.ToEntero, DdlDirClienteLocalidad.SelectedValue.ToEntero, DdlDirClienteColonia.SelectedValue.ToEntero, DdlTipoDireccion.SelectedValue.ToEntero, DdlTipoDireccion.SelectedItem.Text) + + + RegistraScript("$('#divAddDireccionEnvio').modal('hide');") + + + CargaDireccionesEnvio() + + End Sub + + Private Sub LnkAgregarDireccion_Click(sender As Object, e As EventArgs) Handles LnkAgregarDireccion.Click + + TxtEnvioDireccion.Text = "" + TxtEnvioNoExt.Text = "" + TxtEnvioNoInt.Text = "" + TxtEnvioCP.Text = "" + + CargaCombosDirecionesClientesSAT() + TxtFechaLlegada.Text = "" + + CargaTiposDirecciones() + + UpModalDVDireccionEnvio.Update() + RegistraScript("$('#divAddDireccionEnvio').modal('show');") + End Sub + Private Sub GvDireccionesEnvio_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDireccionesEnvio.RowDeleting + Dim ObjClientes As New ClsClientes + Dim TieneError = False + + Dim CveDireccionEnvio As Integer = GvDireccionesEnvio.Rows(e.RowIndex).DataKey("CveDireccionEnvio").ToEntero() + + If Not ObjClientes.DireccionEnvioRemove(CveDireccionEnvio) Then + TieneError = True + End If + + If Not TieneError Then + 'GvDireccionesEnvio.EditIndex = -1 + DT_Direcciones_Remove(e.RowIndex) + Alert("Se eliminó correctamente la dirección de envío.", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrió un error al eliminar la dirección de envío.", TipoMensaje.MsgAdvertencia) + End If + + CargaDireccionesEnvio() + End Sub + + + Public Sub CargaDireccionesEnvio() + + GvDireccionesEnvio.DataSource = DT_Direcciones + GvDireccionesEnvio.DataBind() + UpGvDireccionesEnvio.Update() + + + If DT_Direcciones.Rows.Count = 2 Then + LnkAgregarDireccion.Visible = False + Else + LnkAgregarDireccion.Visible = True + End If + + End Sub + + + + Property DT_Direcciones As DataTable + Get + + If ViewState("DT_Direcciones") Is Nothing Then + ViewState("DT_Direcciones") = Inicializa_DT_Direcciones() + End If + + Return DirectCast(ViewState("DT_Direcciones"), DataTable) + + End Get + Set(value As DataTable) + + End Set + End Property + + + Private Function Inicializa_DT_Direcciones() As DataTable + + Dim DT_Resultado As New DataTable + + DT_Resultado.Columns.Add("CveDireccionEnvio", GetType(Integer)) + DT_Resultado.Columns.Add("EnvioDireccion", GetType(String)) + + + DT_Resultado.Columns.Add("EnvioCP", GetType(Integer)) + DT_Resultado.Columns.Add("CveUsuario", GetType(Integer)) + DT_Resultado.Columns.Add("Estatus", GetType(Integer)) + DT_Resultado.Columns.Add("EnvioNoExt", GetType(String)) + DT_Resultado.Columns.Add("EnvioNoInt", GetType(String)) + + + DT_Resultado.Columns.Add("EnvioEstado", GetType(String)) + DT_Resultado.Columns.Add("EnvioMunicipio", GetType(String)) + DT_Resultado.Columns.Add("EnvioLocalidad", GetType(String)) + DT_Resultado.Columns.Add("EnvioColonia", GetType(String)) + + + DT_Resultado.Columns.Add("CvePais", GetType(Integer)) + DT_Resultado.Columns.Add("CveEstado", GetType(Integer)) + DT_Resultado.Columns.Add("CveMunicipio", GetType(Integer)) + DT_Resultado.Columns.Add("CveLocalidad", GetType(Integer)) + DT_Resultado.Columns.Add("CveColonia", GetType(Integer)) + DT_Resultado.Columns.Add("Tipo", GetType(Integer)) + DT_Resultado.Columns.Add("EnvioTipo", GetType(String)) + + + + Return DT_Resultado + + End Function + + + + Private Function DT_DireccionesAddRow(CveDireccionEnvio As Integer, EnvioDireccion As String, EnvioCP As Integer, CveUsuario As Integer, EnvioNoExt As String, EnvioNoInt As String, EnvioEstado As String, EnvioMunicipio As String, + EnvioLocalidad As String, EnvioColonia As String, CvePais As Integer, CveEstado As Integer, CveMunicipio As Integer, CveLocalidad As Integer, CveColonia As Integer, Tipo As Integer, EnvioTipo As String) As Boolean + + + + Dim Nrow As DataRow = DT_Direcciones.NewRow + + Nrow("CveDireccionEnvio") = CveDireccionEnvio + Nrow("EnvioDireccion") = EnvioDireccion + Nrow("EnvioCP") = EnvioCP + Nrow("CveUsuario") = CveUsuario + Nrow("EnvioNoExt") = EnvioNoExt + Nrow("EnvioNoInt") = EnvioNoInt + Nrow("EnvioEstado") = EnvioEstado + Nrow("EnvioMunicipio") = EnvioMunicipio + Nrow("EnvioLocalidad") = EnvioLocalidad + Nrow("EnvioColonia") = EnvioColonia + Nrow("CvePais") = CvePais + Nrow("CveEstado") = CveEstado + Nrow("CveMunicipio") = CveMunicipio + Nrow("CveLocalidad") = CveLocalidad + Nrow("CveColonia") = CveColonia + Nrow("Tipo") = Tipo + Nrow("EnvioTipo") = EnvioTipo + + DT_Direcciones.Rows.Add(Nrow) + + DT_Direcciones.AcceptChanges() + + Return True + + End Function + + + Private Sub DT_Direcciones_Remove(Index_Remove As Integer) + + DT_Direcciones.Rows(Index_Remove).Delete() + DT_Direcciones.AcceptChanges() + + End Sub + + +#End Region + + Protected Sub DdlTipoDireccion_SelectedIndexChanged(sender As Object, e As EventArgs) + + + If DdlTipoDireccion.SelectedValue.ToEntero = 2 Then + DvDistancia.Visible = True + Else + DvDistancia.Visible = False + End If + + UpBodyDireccion.Update() + UpModalDVDireccionEnvio.Update() + + End Sub +End Class + + + + diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index 3f7215698..5b16d58fe 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -1156,7 +1156,7 @@ Partial Class Inventarios_TraspasoAlmacen Dim CveSubProyectoTimbre As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}").Rows(0)("CveSubProyecto").ToString.ToEntero Dim Fechallegada As DateTime = (TxtFechaLlegada.Text & " 23:59:59").ToDateTime - Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(CveSubProyectoTimbre, -1, -1, CveMovimientoSalida, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, Fechallegada, "T", 1, 1, 1) + Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(CveSubProyectoTimbre, -1, -1, CveMovimientoSalida, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, Fechallegada, "T", "-1", "-1", Now, 1, 1, 1) If CveEntregaAlmacen > 0 Then CveTimbre = ObjGral.AddGralTimbre("Tra", CveSubProyectoTimbre, TxtFechaEntrega.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen:=CveEntregaAlmacen, AplicaCP:=ChkEmitirCartaPorte.Checked)