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") = NowADS() 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") = NowADS() 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 = NowADS().ToShortDateString CEFecha.EndDate = NowADS().AddDays(-1) RVFecha.MaximumValue = NowADS().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.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") DdlSubProyecto.DataBind() 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 = NowADS().ToShortDateString TxtFechaLlegada.Text = NowADS().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 AndAlso ValidaPSSAT(DrPS, TxtPesoKg.Text.ToDecimal) 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, PesoKg:=TxtPesoKg.Text.ToDecimal) 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, Optional PesoKg As Decimal = 0D) 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") = 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() TxtPesoKg.Text = "" '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 String = GvRow.DataKey("EnvioCP") 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, CveConfigAutoTransporte:=DdlConfigAuto.SelectedValue.ToEntero, CveCamionRemolque1:=DdlRemolque1.SelectedValue.ToEntero, CveCamionRemolque2:=DdlRemolque2.SelectedValue.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, PesoKg:=GvRowPS.DataKey("PesoKg").ToDecimal) 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")) TxtPesoKg.Text = drP("PesoKg").ToString.ToDecimal.ToString("###,###,###.00") 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("", 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("", 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() DdlConfigAuto.Items.Clear() DdlUnidadCamion.Items.Clear() 'DdlUnidadCamion.DataSource = GlobalDTInvCamiones(UsuarioActual.CveEmpresa) 'DdlUnidadCamion.DataBind() Using ObjInv As New ClsInventarios If ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, Estatus:=1) Then DdlUnidadCamion.DataSource = ObjInv.DtResultados End If If ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, 2, Estatus:=1) Then DdlRemolque1.DataSource = ObjInv.DtResultados End If End Using DdlUnidadCamion.DataBind() DdlUnidadCamion.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) DdlRemolque1.DataBind() DdlRemolque1.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) Using ObjGrales As New ClsGenerales If ObjGrales.GetCartaPorteConfigAutoTransportes() Then DdlConfigAuto.DataSource = ObjGrales.DtResultados End If End Using DdlConfigAuto.DataBind() DdlConfigAuto.Items.Insert(0, New ListItem("Seleccione una", "-1")) 'Using ObjGral As New ClsGenerales ' If ObjGral.GetCartaPorteConfigAutoTransportes() Then ' DdlConfigAuto.DataSource = ObjGral.DtResultados ' End If 'End Using 'DdlConfigAuto.DataBind() 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 #Region "remolques" Protected Sub DdlUnidadCamionActivoFijo_SelectedIndexChanged(sender As Object, e As EventArgs) DvRemolque1.Visible = False DvRemolque2.Visible = False DdlRemolque1.SelectedValueExist(-1) DdlRemolque2.SelectedValueExist(-1) If DdlUnidadCamion.SelectedValue.ToEntero > 0 Then Using ObjInv As New ClsInventarios If ObjInv.GetCamiones(DdlUnidadCamion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 1) Then DdlConfigAuto.SelectedValueExist(ObjInv.DtResultados.FiltroPrimeroValor("CveConfigAutoTransporte")) DdlConfigAuto_SelectedIndexChanged(Nothing, Nothing) End If End Using End If UpEmitirTransitorio.Update() End Sub Property RequiereRemolque As Boolean Get If ViewState("RequiereRemolque") Is Nothing Then ViewState("RequiereRemolque") = False End If Return Boolean.Parse(ViewState("RequiereRemolque").ToString) End Get Set(value As Boolean) ViewState("RequiereRemolque") = value End Set End Property Property MostrarRemolques As Boolean Get If ViewState("MostrarRemolques") Is Nothing Then ViewState("MostrarRemolques") = False End If Return Boolean.Parse(ViewState("MostrarRemolques").ToString) End Get Set(value As Boolean) ViewState("MostrarRemolques") = value End Set End Property Protected Sub DdlConfigAuto_SelectedIndexChanged(sender As Object, e As EventArgs) ValidaConfiguracionVeiculo() End Sub Private Sub ValidaConfiguracionVeiculo() DvRemolque1.Visible = False DvRemolque2.Visible = False DdlRemolque1.SelectedValueExist(-1) DdlRemolque2.SelectedValueExist(-1) If DdlConfigAuto.SelectedValue.ToEntero > 0 Then Using ObjGrales As New ClsGenerales If ObjGrales.GetCartaPorteConfigAutoTransportes() Then Dim Remolque As String = ObjGrales.DtResultados.FiltroPrimeroValor("Remolque", $" CveConfigAutoTransporte ='{DdlConfigAuto.SelectedValue}'") If Remolque = "1" Then RequiereRemolque = True MostrarRemolques = True End If If Remolque = "0, 1" Then RequiereRemolque = False MostrarRemolques = True End If If Remolque = "0" Then RequiereRemolque = False MostrarRemolques = False End If End If End Using Else RequiereRemolque = False MostrarRemolques = False End If If RequiereRemolque Or MostrarRemolques Then DvRemolque1.Visible = True End If If Not RequiereRemolque Then DvConfiguracionVeiculo.Visible = False Else DvConfiguracionVeiculo.Visible = True End If UpEmitirTransitorio.Update() End Sub Protected Sub DdlRemolque1_SelectedIndexChanged(sender As Object, e As EventArgs) DdlRemolque2.Items.Clear() If DdlRemolque1.SelectedValue.ToEntero > 0 Then DvRemolque2.Visible = True Using ObjInv As New ClsInventarios If ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, 2, Estatus:=1) Then DdlRemolque2.DataSource = ObjInv.DtResultados.FiltraParametros($"CveCamion <> {DdlRemolque1.SelectedValue.ToEntero}") End If End Using DdlRemolque2.DataBind() Else DvRemolque2.Visible = False End If DdlRemolque2.Items.Insert(0, New ListItem("Seleccione uno", "-1")) UpEmitirTransitorio.Update() End Sub Private Function validarRemolques() As Boolean Dim Respuesta As Boolean = False If RequiereRemolque And DdlRemolque1.SelectedValue.ToEntero <= 0 Then Alert("La configuración de la carta porte requiere que seleccione un remolque", TipoMensaje.MsgAdvertencia) End If If RequiereRemolque And DdlRemolque1.SelectedValue.ToEntero > 0 Then Respuesta = True End If If Not RequiereRemolque Then Respuesta = True End If Return Respuesta End Function Function ValidaPSSAT(DrPS As DataRow, PesoKg As Decimal) As Boolean Dim Respuesta As Boolean = False Dim CveSATPS As Integer = DrPS("CveSATPS").ToString.ToEntero 'Dim PesoKg As Decimal = DrPS("PesoKg").ToString.ToDecimal Dim SATClaveUnidadMedida As String = DrPS("SATClaveUnidadMedida").ToString.Trim If CveSATPS > 0 And PesoKg > 0 And SATClaveUnidadMedida.Length > 0 Then Respuesta = True Else Respuesta = False Dim SBMensaje As New StringBuilder SBMensaje.AppendLine("El producto seleccionado presenta la siguiente situación:
") If CveSATPS <= 0 Then SBMensaje.AppendLine("-Producto SAT no asignado.
") End If If PesoKg = 0 Then SBMensaje.AppendLine("-Producto sin peso definido.
") End If If SATClaveUnidadMedida.Length = 0 Then SBMensaje.AppendLine("-Producto sin unidad de medida SAT asignada. ") End If SBMensaje.AppendLine($"

Corregir Producto ") Alert(SBMensaje.ToString, TipoMensaje.MsgAdvertencia) End If Return Respuesta End Function #End Region End Class