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 AndAlso ValidaPSSAT(DrPS) 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 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,
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("