-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%----%>
+
+
+
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+
diff --git a/Inventarios/TrasladoSolicitud.aspx.vb b/Inventarios/TrasladoSolicitud.aspx.vb
index 1ed0fefa3..ff86d81a5 100644
--- a/Inventarios/TrasladoSolicitud.aspx.vb
+++ b/Inventarios/TrasladoSolicitud.aspx.vb
@@ -1,396 +1,182 @@
-Option Strict On
-Option Explicit On
-
-Imports System.Data
-Imports Extensiones
-Imports Microsoft.Reporting.WebForms
+Imports System.Data
+Imports ClosedXML.Excel.XLPredefinedFormat
+Imports Extensiones
+Imports Telerik.Web.UI.ComboBox.ComboBoxStyles
-Partial Class Inventarios_TrasladoSolicitud
+Partial Class Inventarios_TrasladoSolicitud
Inherits ClsPaginas
-#Region "Propiedades"
- Private Property TempDT As DataTable
- Get
- Return CType(ViewState("TempDT"), DataTable)
- End Get
- Set(value As DataTable)
- ViewState("TempDT") = value
- End Set
- End Property
-
- Private Property CveTraspasoSolicitud As Integer
- Get
- Return CType(ViewState("CveTraspasoSolicitud"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveTraspasoSolicitud") = value
- End Set
- End Property
-
- 'CveDireccionEnvio del Traslado
- Private Property CveDireccionEnvio As Integer
- Get
- Return CType(ViewState("CveDireccionEnvio"), Integer)
- End Get
- Set(value As Integer)
- ViewState("CveDireccionEnvio") = value
- End Set
- End Property
- Private Property CveUsuarioSolicita As Integer
- Get
- If ViewState("CveUsuarioSolicita") Is Nothing Then
- Return -1
- Else
- Return CType(ViewState("CveUsuarioSolicita"), Integer)
- End If
+ Private Property TempDT As DataTable
+ Get
+ Return CType(ViewState("TempDT"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("TempDT") = value
+ End Set
+ End Property
+
+ Private Property CveTraspasoSolicitud As Integer
+ Get
+ If ViewState("CveTraspasoSolicitud") Is Nothing Then
+ ViewState("CveTraspasoSolicitud") = -1
+ End If
+ Return ViewState("CveTraspasoSolicitud").ToString.ToEntero
End Get
Set(value As Integer)
- ViewState("CveUsuarioSolicita") = value
+ ViewState("CveTraspasoSolicitud") = value
End Set
End Property
- Private Property AplicaSerie As Boolean
+
+ Private Property CveAlmacenOrigen As Integer
Get
- If ViewState("AplicaSerie") Is Nothing Then
- Return False
- Else
- Return CType(ViewState("AplicaSerie"), Boolean)
+ If ViewState("CveAlmacenOrigen") Is Nothing Then
+ ViewState("CveAlmacenOrigen") = -1
End If
-
+ Return ViewState("CveAlmacenOrigen").ToString.ToEntero
End Get
- Set(value As Boolean)
- ViewState("AplicaSerie") = value
+ Set(value As Integer)
+ ViewState("CveAlmacenOrigen") = value
End Set
End Property
- Private Property AplicaLote As Boolean
+
+ Private Property CveAlmacenDestino As Integer
Get
- If ViewState("AplicaLote") Is Nothing Then
- Return False
- Else
- Return CType(ViewState("AplicaLote"), Boolean)
+ If ViewState("CveAlmacenDestino") Is Nothing Then
+ ViewState("CveAlmacenDestino") = -1
End If
-
+ Return ViewState("CveAlmacenDestino").ToString.ToEntero
End Get
- Set(value As Boolean)
- ViewState("AplicaLote") = value
+ Set(value As Integer)
+ ViewState("CveAlmacenDestino") = value
End Set
End Property
- Private Property AplicaCaducidad As Boolean
- Get
- If ViewState("AplicaCaducidad") Is Nothing Then
- Return False
- Else
- Return CType(ViewState("AplicaCaducidad"), Boolean)
- End If
- End Get
- Set(value As Boolean)
- ViewState("AplicaCaducidad") = value
- End Set
- End Property
+ Private Sub Inventarios_RepTrasladoSolicitud_Load(sender As Object, e As EventArgs) Handles Me.Load
+ If Not Page.IsPostBack Then
+ CargaCombos()
+ InicializaValores()
-#End Region
+ TxtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString
+ TxtFechaF.Text = NowADS().ToShortDateString
+ End If
+ End Sub
- Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
- If Not IsPostBack Then
-
- InicializaValores()
-
- 'CARGAMOS SOLICITUD YA EXISTENTE.
- If Request("CveTraspasoSolicitud").ToEntero > 0 Then
- CveTraspasoSolicitud = Request("CveTraspasoSolicitud").ToEntero
- CargaDatos()
- End If
-
- End If
+ Private Sub InicializaValores()
+ CreaDTTemporal()
+ CargaAlmacenes()
+ CargaPS()
+ 'CargaClientes()
+
+ ' CargaUnidadMedida()
+
+ End Sub
+
+
+ 'Private Sub CargaUnidadMedida()
+ ' DdlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
+ ' DdlUM.DataBind()
+ 'End Sub
+
+ Private Sub CargaAlmacenes()
+ 'Cargo los almacenes
+ DdlAlmacenOrigen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen <> 9") 'Excluir almacenes de Apartado
+ DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen <> 9") 'Excluir almacenes de Apartado
+ DdlAlmacenOrigen.DataBind()
+ DdlAlmacenDestino.DataBind()
End Sub
-#Region " INICIALIZA VALORES "
- Private Sub InicializaValores()
- CveTraspasoSolicitud = -1
- CveDireccionEnvio = -1
- DivFolio.Visible = False
-
- TxtFecha.Text = NowADS().ToShortDateString
- CreaDTTemporal()
- CargaAlmacenes()
- CargaPS()
- CargaClientes()
- DdlContratos.Items.Insert(0, New ListItem("Seleccione", "-1"))
- CargaUnidadMedida()
- CargaPaqueterias()
- End Sub
- Public Sub CreaDTTemporal()
- TempDT = New DataTable
- TempDT.Columns.Add("Cantidad", Type.GetType("System.Double"))
- TempDT.Columns.Add("CvePS", Type.GetType("System.Int32"))
- TempDT.Columns.Add("CodigoPS", Type.GetType("System.String"))
- TempDT.Columns.Add("CveUM", Type.GetType("System.Int32"))
- TempDT.Columns.Add("UnidadMedida", Type.GetType("System.String"))
- TempDT.Columns.Add("Precio", Type.GetType("System.Double"))
- TempDT.Columns.Add("Observaciones", Type.GetType("System.String"))
- TempDT.Columns.Add("CveContratoDetalle", Type.GetType("System.Int32"))
- 'TempDT.Columns.Add("CveContratoDetalle", Type.GetType("System.Int32"))
- 'TempDT.Columns.Add("CveDireccionEnvio", Type.GetType("System.Int32"))
+ Private Sub CargaPS()
+ DdlProductoServicio.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
+
+ If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
+ DdlProductoServicio.ddlWS.Attributes.Add("data-cveclasificacion", "-1")
+ DdlProductoServicio.SelectedText = ""
+ DdlProductoServicio.SelectedValue = "-1"
+ Else
+ DdlProductoServicio.ddl.Items.Clear()
+ DdlProductoServicio.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=-1)
+ DdlProductoServicio.ddl.DataBind()
+ DdlProductoServicio.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
+ End If
+ 'DdlProductoServicio.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
+ 'DdlProductoServicio.DataBind()
+ 'DdlProductoServicio.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End Sub
+
+ Private Sub CargaCombos()
+ DdlAlmacenOrigenFiltro.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen <> 9")
+ DdlAlmacenOrigenFiltro.DataBind()
+ DdlAlmacenOrigenFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
+
+ DdlAlmacenDestinoFiltro.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen <> 9")
+ DdlAlmacenDestinoFiltro.DataBind()
+ DdlAlmacenDestinoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
+
+ 'DdlContrato.DataSource = GlobalDTContratos(UsuarioActual.CveEmpresa)
+ 'DdlContrato.DataBind()
+ 'DdlContrato.Items.Insert(0, New ListItem("Todos", "-1"))
+
+ 'DdlSolicitante.DataSource = GlobalDTUsuarios(CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "Nombre")
+ 'DdlSolicitante.DataBind()
+ 'DdlSolicitante.Items.Insert(0, New ListItem("Todos", "-1"))
+ End Sub
+
+
+ Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
+ CargaDatos()
+ End Sub
+
+ Private Sub CargaDatos()
+ Dim ObjInv As New ClsInventarios
+
+ If ObjInv.RepTrasladoSolicitud(DdlAlmacenOrigenFiltro.SelectedValue.ToEntero, DdlAlmacenDestinoFiltro.SelectedValue.ToEntero, -1, TxtFechaI.Text.ToDate, TxtFechaF.Text.ToDate, -1, -1,
+ -1, UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
+
+ GvT.DataSource = ObjInv.DtResultados
+ End If
+
+ ObjInv.Dispose()
+ GvT.DataBind()
+
+ UPPMov.Update()
+ End Sub
+
+
+
+ Public Sub CreaDTTemporal()
+ TempDT = New DataTable
+ TempDT.Columns.Add("Cantidad", Type.GetType("System.Double"))
+ TempDT.Columns.Add("CvePS", Type.GetType("System.Int32"))
+ TempDT.Columns.Add("CodigoPS", Type.GetType("System.String"))
+ TempDT.Columns.Add("CveUM", Type.GetType("System.Int32"))
+ TempDT.Columns.Add("UnidadMedida", Type.GetType("System.String"))
+ TempDT.Columns.Add("Precio", Type.GetType("System.Double"))
+ TempDT.Columns.Add("Observaciones", Type.GetType("System.String"))
+ TempDT.Columns.Add("CveContratoDetalle", Type.GetType("System.Int32"))
+ 'TempDT.Columns.Add("CveContratoDetalle", Type.GetType("System.Int32"))
+ 'TempDT.Columns.Add("CveDireccionEnvio", Type.GetType("System.Int32"))
TempDT.Columns.Add("Serie", Type.GetType("System.String"))
- TempDT.Columns.Add("Lote", Type.GetType("System.String"))
- TempDT.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime"))
-
- TempDT.Columns.Add()
- End Sub
- Private Sub CargaPaqueterias()
- DdlPaqueteria.DataSource = GlobalDTPaqueterias(UsuarioActual.CveEmpresa)
- DdlPaqueteria.DataBind()
- DdlPaqueteria.Items.Insert(0, New ListItem("-", "-1"))
- End Sub
-
- Private Sub CargaUnidadMedida()
- DdlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
- DdlUM.DataBind()
- End Sub
-
- Private Sub CargaAlmacenes()
- 'Cargo los almacenes
- DdlAlmacenOrigen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen <> 9") 'Excluir almacenes de Apartado
- DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen <> 9") 'Excluir almacenes de Apartado
- DdlAlmacenOrigen.DataBind()
- DdlAlmacenDestino.DataBind()
- End Sub
-
- Private Sub CargaClientes()
- DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
- DdlClientes.DataBind()
- DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1"))
- End Sub
-
- Private Sub CargaPS()
- DdlProductoServicio.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
-
- If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
- DdlProductoServicio.ddlWS.Attributes.Add("data-cveclasificacion", "-1")
- DdlProductoServicio.SelectedText = ""
- DdlProductoServicio.SelectedValue = "-1"
- Else
- DdlProductoServicio.ddl.Items.Clear()
- DdlProductoServicio.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=-1)
- DdlProductoServicio.ddl.DataBind()
- DdlProductoServicio.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
- End If
- 'DdlProductoServicio.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
- 'DdlProductoServicio.DataBind()
- 'DdlProductoServicio.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ TempDT.Columns.Add("Lote", Type.GetType("System.String"))
+ TempDT.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime"))
+
+ TempDT.Columns.Add()
End Sub
-#End Region
-
-#Region " CARGA DATOS "
- Private Sub CargaDatos()
- Dim ObjInventarios As New ClsInventarios
- Dim ObjClientes As New ClsClientes
-
- If ObjInventarios.AddTrasladoSolicitudGet(CveTraspasoSolicitud, UsuarioActual.CveEmpresa) Then
- If ObjInventarios.DtResultados.Rows.Count > 0 Then
- For Each rowtp As DataRow In ObjInventarios.DtResultados.Rows
- If Not AplicaSerie Then
- AplicaSerie = rowtp("Serie").ToString <> ""
- End If
- If Not AplicaLote Then
- AplicaLote = rowtp("Lote").ToString <> ""
- End If
- If Not AplicaCaducidad Then
- AplicaCaducidad = rowtp("FechaCaducidad").ToString <> ""
- End If
- Next
-
- Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProductoServicio.SelectedValue.ToEntero).FiltroPrimero("")
-
-
- GvDatos.Columns(4).Visible = False
- GvDatos.Columns(5).Visible = AplicaSerie
- GvDatos.Columns(6).Visible = AplicaLote
- GvDatos.Columns(7).Visible = AplicaCaducidad
-
- DivFolio.Visible = True
- LbFolio.Text = ObjInventarios.DtResultados.Rows(0)("FolioTraspaso").ToString
- TxtObservaciones.Text = ObjInventarios.DtResultados.Rows(0)("ObservacionesTraspaso").ToString
-
- TempDT = ObjInventarios.DtResultados
- GvDatos.DataSource = ObjInventarios.DtResultados
- GvDatos.DataBind()
-
- If ObjInventarios.DtResultados.Rows(0)("CveContrato").ToString.ToEntero > 0 Then
- RowContrato.Visible = True
- ChkDesdeContrato.Checked = True
- GvDatos.Columns(3).Visible = True
- Else
- GvDatos.Columns(3).Visible = False
- End If
-
- DdlAlmacenOrigen.SelectedValue = ObjInventarios.DtResultados.Rows(0)("CveAlmacenOrigen").ToString
- DdlAlmacenDestino.SelectedValue = ObjInventarios.DtResultados.Rows(0)("CveAlmacenDestino").ToString
- DdlPaqueteria.SelectedValue = ObjInventarios.DtResultados.Rows(0)("CvePaqueteria").ToString
- TxtFecha.Text = ObjInventarios.DtResultados.Rows(0)("Fecha").ToString
- LblUsuario.Text = ObjInventarios.DtResultados.Rows(0)("Usuario").ToString
- HplContrato.Text = ObjInventarios.DtResultados.Rows(0)("DescripcionContrato").ToString
- HplContrato.NavigateUrl = $"/Contratos/Contrato.aspx?CveContrato={ObjInventarios.DtResultados.Rows(0)("CveContrato").ToString.ToEntero}"
-
- CveUsuarioSolicita = ObjInventarios.DtResultados.Rows(0)("CveUsuario").ToString.ToEntero
-
- '25/04/2018
- CveDireccionEnvio = ObjInventarios.DtResultados.Rows(0)("CveDireccionEnvio").ToString.ToEntero
- If CveDireccionEnvio > 0 And ObjClientes.DireccionEnvioGet(CveDireccionEnvio, -1, -1) Then
- LblDireccionEnvio.Text = ObjClientes.DtResultados.FiltraParametros(String.Format("Estatus = 1")).Rows(0)("SucursalClienteVentaDireccion").ToString
- Else
- Dim CveCliente As Integer = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCliente", $"CveContrato = {ObjInventarios.DtResultados.Rows(0)("CveContrato").ToString.ToEntero}").ToEntero
- Dim DtCliente As DataTable = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros($"CveCliente = {CveCliente}")
- If DtCliente.Rows.Count > 0 Then
- LblDireccionEnvio.Text = String.Format("{0},{1}, {2}", DtCliente.FiltroPrimeroValor("Direccion"), DtCliente.FiltroPrimeroValor("Colonia"), DtCliente.FiltroPrimeroValor("Ciudad"), DtCliente.FiltroPrimeroValor("Contacto"))
- End If
- End If
-
- If ObjInventarios.DtResultados.Rows(0)("CveTrasladoEstatus").ToString.Contiene("1", "3") And Not ObjInventarios.DtResultados.Rows(0)("CveMovimientoAlmacen").ToString.ToEntero > 0 Then
- LBCancelarTraslado.Visible = True
- End If
-
- If ObjInventarios.DtResultados.Rows(0)("CveTrasladoEstatus").ToString = "2" Then
- DivCancelado.Visible = True
- End If
-
- If ObjInventarios.DtResultados.Rows(0)("CveMovimientoAlmacen").ToString.ToEntero > 0 Then
- RowMovimiento.Visible = True
- HLMovimiento.Text = ObjInventarios.DtResultados.Rows(0)("FolioAlmacen").ToString
- HLMovimiento.NavigateUrl = $"/Inventarios/EntradasSalidas.aspx?CveMovimiento={ObjInventarios.DtResultados.Rows(0)("CveMovimientoAlmacen").ToString.ToEntero}"
- Else
- RowMovimiento.Visible = False
- End If
-
- If ObjInventarios.DtResultados.Rows(0)("Guia").ToString <> "" Then
- TrGuia.Visible = True
- TxtGuia.Text = ObjInventarios.DtResultados.Rows(0)("Guia").ToString
- Else
- TrGuia.Visible = False
- End If
-
- If UsuarioActual.TienePermisoProceso(313) Then
- BtnEliminar.Visible = True
- End If
-
- BtnGuardar.Enabled = False
- TxtObservaciones.Enabled = False
- TxtFecha.Enabled = False
- DdlPaqueteria.Enabled = False
- ChkDesdeContrato.Enabled = False
- DdlAlmacenDestino.Enabled = False
- DdlAlmacenOrigen.Enabled = False
- TxtGuia.Enabled = False
- HLDesdeContrato.Enabled = False
- LbAgregarPS.Enabled = False
- DivInfo.Visible = True
- LbImprimir.Visible = True
- ImgExcel.Visible = True
-
- LbAgregarPS.Visible = False
- HLDesdeContrato.Visible = False
-
-
- Dim EstatusAlmacen As Integer = ObjInventarios.DtResultados.Rows(0)("EstatusAlmacen").ToString().ToEntero
- Dim CveUsuarioAutoriza As Integer = ObjInventarios.DtResultados.Rows(0)("CveUsuarioAutorizaDestino").ToString().ToEntero
-
- If EstatusAlmacen > 0 Then
-
-
- If UsuarioActual.CveUsuario = CveUsuarioAutoriza Then
-
- If EstatusAlmacen = 1 Then
-
-
- DivAutoriza.Visible = True
- DVAutorizarBotones.Visible = True
- DVAutorizaInformacion.Visible = False
-
- ElseIf EstatusAlmacen.Contiene(2, 3) Then
- DivAutoriza.Visible = True
-
- DVAutorizarBotones.Visible = False
- DVAutorizaInformacion.Visible = True
-
- LblEstatusAutorizo.Text = If(EstatusAlmacen = 2, "Aceptado", "Rechazado")
- LblUsaurioAutorizo.Text = ObjInventarios.DtResultados.Rows(0)("NombreAutoriza").ToString()
- LblFechaAutoriza.Text = ObjInventarios.DtResultados.Rows(0)("FechaAutorizacion").ToString().ToDate().ToString("dd/MM/yyyy")
- Else
-
- End If
-
- ElseIf EstatusAlmacen.Contiene(2, 3) Then
-
- DivAutoriza.Visible = True
-
- DVAutorizarBotones.Visible = False
- DVAutorizaInformacion.Visible = True
-
- LblEstatusAutorizo.Text = If(EstatusAlmacen = 2, "Aceptado", "Rechazado")
- LblUsaurioAutorizo.Text = ObjInventarios.DtResultados.Rows(0)("NombreAutoriza").ToString()
- LblFechaAutoriza.Text = ObjInventarios.DtResultados.Rows(0)("FechaAutorizacion").ToString().ToDate().ToString("dd/MM/yyyy")
- GvDatos.Columns(6).Visible = False ' se oculta la columna de eliminar
-
- End If
-
-
- Else
- DivAutoriza.Visible = False
- End If
-
-
-
- Else
- Alert("Ocurrió un error al obtener los datos del traspaso.", TipoMensaje.MsgError)
- End If
-
- UpAutorizaciones.Update()
-
- End If
- ObjInventarios.Dispose()
- ObjClientes.Dispose()
- MostarSerieColumn()
- End Sub
-#End Region
-
-
-#Region " AGREGAR "
- Private Sub BtnAgregarModal_Click(sender As Object, e As EventArgs) Handles LbAgregarPS.Click
-
- If ChkDesdeContrato.Checked Then
- GvDatos.Columns(3).Visible = False
- ChkDesdeContrato.Checked = False
- TempDT.Rows.Clear()
- GvDatos.DataSource = TempDT
- GvDatos.DataBind()
- UpDatos.Update()
- End If
-
- TxtCantidad.Text = ""
- DdlUM.SelectedIndex = 0
- LbContratos.Text = ""
- DdlProductoServicio.SelectedText = ""
- DdlProductoServicio.SelectedValue = "-1"
- UpPS.Update()
- UpDatos.Update()
- RegistraScript(String.Format("$('#{0}').modal();", "ModalPS"))
- End Sub
Private Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) Handles BtnAgregarPS.Click
- If Not DdlProductoServicio.SelectedValue.ToEntero > 0 Then
- Alert("Tiene que seleccionar un producto.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- If Not AddPSTemporal() Then
- Exit Sub
+ If Not DdlProductoServicio.SelectedValue.ToEntero > 0 Then
+ Alert("Tiene que seleccionar un producto.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If Not AddPSTemporal() Then
+ Exit Sub
End If
'If ObjInventario.GetExistenciasPS(DdlProductoServicio.SelectedValue.ToEntero, DdlUM.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, PendientePorSurtir:=1, Lote:=TxtLote.Text.ToString, FechaCaducidad:=TxtCaducidad.Text.ToString) >= TxtCantidad.Text.ToDouble Then
@@ -398,865 +184,506 @@ Partial Class Inventarios_TrasladoSolicitud
TxtCantidad.Text = ""
DdlProductoServicio.SelectedText = ""
DdlProductoServicio.SelectedValue = "-1"
- DdlUM.SelectedIndex = 0
- TxtCaducidad.Text = ""
- TxtSerie.Text = ""
- TxtLote.Text = ""
+ 'DdlUM.SelectedIndex = 0
+ 'TxtCaducidad.Text = ""
+ 'TxtSerie.Text = ""
+ 'TxtLote.Text = ""
GvDatos.DataSource = TempDT
GvDatos.DataBind()
-
- If ChkSeguirAgregando.Checked Then
- TxtCantidad.Focus()
- Else
- RegistraScript("$('#ModalPS').hide();", "EscondeAgregar")
- End If
-
UpPS.Update()
- UpDatos.Update()
- End Sub
- Private Function AddPSTemporal() As Boolean
- Dim Row As DataRow = TempDT.NewRow()
- Dim Lote As String = "-1"
- Dim FechaCaducidad As Date = MinFecha
- Row("Cantidad") = TxtCantidad.Text.Trim.ToDouble
- Row("CvePS") = DdlProductoServicio.SelectedValue.ToEntero
- Row("CodigoPS") = DdlProductoServicio.SelectedText
- Row("Precio") = 0
- Row("CveUM") = DdlUM.SelectedValue.ToEntero
- Row("UnidadMedida") = DdlUM.SelectedItem.Text
+
+ End Sub
+
+
+ Private Function AddPSTemporal() As Boolean
+ Dim Row As DataRow = TempDT.NewRow()
+ Dim Lote As String = "-1"
+ Dim FechaCaducidad As Date = MinFecha
+ Row("Cantidad") = TxtCantidad.Text.Trim.ToDouble
+ Row("CvePS") = DdlProductoServicio.SelectedValue.ToEntero
+ Row("CodigoPS") = DdlProductoServicio.SelectedText
+ Row("Precio") = 0
+ 'Row("CveUM") = DdlUM.SelectedValue.ToEntero
+ 'Row("UnidadMedida") = DdlUM.SelectedItem.Text
Row("Observaciones") = ""
Row("Lote") = "-1"
Row("Serie") = "-1"
Row("FechaCaducidad") = MinFecha
- If divLote.Visible Then
- Row("Lote") = TxtLote.Text
- GvDatos.Columns(6).Visible = True
- Lote = TxtLote.Text.ToString
+
+
+ TempDT.Rows.Add(Row)
+
+
+ Return True
+ End Function
+
+
+#Region " GUARDAR "
+ Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
+
+ Dim CveTraspasoSolicitud As Integer = -1
+
+ If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then
+ Alert("Los almacenes de origen y destino no pueden ser el mismo. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
End If
-
- If divCaducidad.Visible Then
- Row("FechaCaducidad") = TxtCaducidad.Text
- GvDatos.Columns(7).Visible = True
- FechaCaducidad = TxtCaducidad.Text.ToDate
- RFVFechaCad.Enabled = True
-
- Else
- FechaCaducidad = MinFecha
- End If
-
-
- If Div4.Visible Then
- Row("Serie") = TxtSerie.Text
- GvDatos.Columns(5).Visible = True
- End If
-
-
-
- Dim ObjInventarios As New ClsInventarios
- Dim Existencia As Double = ObjInventarios.GetExistenciasPS(DdlProductoServicio.SelectedValue.ToEntero, DdlUM.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), Lote:=Lote, FechaCaducidad:=FechaCaducidad)
- ObjInventarios.Dispose()
-
- If Existencia - TxtCantidad.Text.Trim.ToDouble - TempDT.SUM("Cantidad", $"CvePS = {DdlProductoServicio.SelectedValue.ToEntero} AND CveUM = {DdlUM.SelectedValue.ToEntero}") < 0 Then
- If Existencia = 0 Then
- Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia)
- Else
- Alert($"No hay existencia suficiente del producto. Solo hay en existencia: {Existencia - TempDT.SUM("Cantidad", $"CvePS = {DdlProductoServicio.SelectedValue.ToEntero} AND CveUM = {DdlUM.SelectedValue.ToEntero}")}", TipoMensaje.MsgAdvertencia)
- End If
- Return False
- End If
-
- TempDT.Rows.Add(Row)
-
-
- Return True
- End Function
-#End Region
-
-#Region " AGREGAR DESDE CONTRATO "
- Private Sub ChkDesdeContrato_CheckedChanged(sender As Object, e As EventArgs) Handles ChkDesdeContrato.CheckedChanged
-
- If ChkDesdeContrato.Checked Then
- GvDatos.Columns(3).Visible = True
- DdlContratos.SelectedIndex = 0
- DdlClientes.SelectedIndex = 0
-
- DdlDireccionEnvio.Items.Clear()
- DivContratoDireccionEnvio.Visible = False
-
- CargaExcel.Visible = False
- GvContratos.DataBind()
- UpContrato.Update()
- RegistraScript(String.Format("$('#{0}').modal().show();", "ModalContrato"))
- Else
- LbContratos.Text = ""
- End If
-
- TempDT.Rows.Clear()
- GvDatos.DataSource = TempDT
- GvDatos.DataBind()
- UpDatos.Update()
-
- End Sub
- Private Sub HLDesdeContrato_Click(sender As Object, e As EventArgs) Handles HLDesdeContrato.Click
- DdlContratos.SelectedIndex = 0
- DdlClientes.SelectedIndex = 0
- DdlDireccionEnvio.Items.Clear()
- DivContratoDireccionEnvio.Visible = False
- UpContrato.Update()
- RegistraScript(String.Format("$('#{0}').modal();", "ModalContrato"))
- End Sub
- Private Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientes.SelectedIndexChanged
- DdlContratos.Items.Clear()
-
- Dim ObjContratos As New ClsContratos
- If ObjContratos.GetContratosEstatus(UsuarioActual.CveEmpresa) Then
- Dim CveEstatusVigente = ObjContratos.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus = 1", Orderby:="CveContratoEstatus").ToEntero
-
- DdlContratos.DataSource = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltraParametros($" CveCliente = {DdlClientes.SelectedValue.ToEntero} AND CveContratosEstatus = {CveEstatusVigente}")
-
- 'If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, DdlClientes.SelectedValue.ToEntero, CveEstatusVigente) Then
- ' DdlContratos.DataSource = ObjContratos.DtResultados
- 'End If
-
- End If
- ObjContratos.Dispose()
-
- DdlContratos.DataBind()
- DdlContratos.Items.Insert(0, New ListItem("Seleccione", "-1"))
- GvContratos.DataBind()
-
- Dim ObjClientes As New ClsClientes
-
- DdlDireccionEnvio.Items.Clear()
- If DdlClientes.SelectedValue <> "-1" And ObjClientes.DireccionEnvioGet(-1, DdlClientes.SelectedValue.ToEntero, -1) And ObjClientes.DtResultados.Rows.Count > 0 Then
- DivContratoDireccionEnvio.Visible = True
- DdlDireccionEnvio.DataSource = ObjClientes.DtResultados.FiltraParametros(String.Format("Estatus = 1"))
- DdlDireccionEnvio.Items.Insert(0, New ListItem("Seleccione", "-1"))
- DdlDireccionEnvio.DataBind()
- Else
- DivContratoDireccionEnvio.Visible = False
- End If
- ObjClientes.Dispose()
-
- UpContrato.Update()
- End Sub
- Private Sub DdlContratos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlContratos.SelectedIndexChanged
- Dim ObjContratos As New ClsContratos
- If ObjContratos.GetContratosDetalle(DdlContratos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
- GvContratos.DataSource = ObjContratos.DtResultados
- GvContratos.DataBind()
- If ObjContratos.DtResultados.Rows.Count > 0 Then
- CargaExcel.Visible = True
- Else
- CargaExcel.Visible = False
- End If
- End If
- ObjContratos.Dispose()
- UpContrato.Update()
- End Sub
- Private Sub BtnAgregarContrato_Click(sender As Object, e As EventArgs) Handles BtnAgregarContrato.Click
-
- TempDT.Rows.Clear()
-
- Dim ObjInventarios As New ClsInventarios
- Dim Existencia = 0.0
- Dim TieneErrorExistencia = False
- Dim MensajeExistencia As New StringBuilder
- MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:
")
- Dim CodigoPS As String = ""
-
- For Each row As GridViewRow In GvContratos.Rows
- If row.FCTextBox("TxtCantContrato").Text.Trim.ToDouble > 0 Then
- Dim RowTemp As DataRow = TempDT.NewRow()
- RowTemp("Cantidad") = row.FCTextBox("TxtCantContrato").Text.Trim.ToDouble
- RowTemp("CvePS") = row.DataKey("CvePS").ToEntero
- RowTemp("CodigoPS") = row.DataKey("CodigoPS")
- RowTemp("Precio") = row.DataKey("PU")
- RowTemp("CveUM") = row.DataKey("CveUM").ToEntero
- RowTemp("UnidadMedida") = row.DataKey("UM")
- RowTemp("Observaciones") = ""
- RowTemp("Lote") = "-1"
- RowTemp("FechaCaducidad") = MinFecha
- 'RowTemp("CveDireccionEnvio") = DdlDireccionEnvio.SelectedValue
- 'RowTemp("DireccionEnvio") = IIf(DdlDireccionEnvio.SelectedValue = "-1", "", DdlDireccionEnvio.SelectedItem)
- RowTemp("CveContratoDetalle") = row.DataKey("CveContratoDetalle")
- CodigoPS = RowTemp("CodigoPS").ToString
-
-
- Existencia = ObjInventarios.GetExistenciasPS(row.DataKey("CvePS").ToEntero, row.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"))
- If Existencia - row.FCTextBox("TxtCantContrato").Text.Trim.ToDouble - TempDT.SUM("Cantidad", $"CvePS = {row.DataKey("CvePS").ToEntero} AND CveUM = {row.DataKey("CveUM").ToEntero}") < 0 Then
- MensajeExistencia.AppendFormat("
-
{0}. Existencia: {1}", CodigoPS, Existencia)
- TieneErrorExistencia = True
- Continue For
- End If
-
- TempDT.Rows.Add(RowTemp)
- End If
- Next
-
- If TieneErrorExistencia Then
- Alert(MensajeExistencia.ToString, TipoMensaje.MsgAdvertencia)
- ObjInventarios.Dispose()
- Exit Sub
- Else
- CveDireccionEnvio = DdlDireccionEnvio.SelectedValue.ToEntero
- End If
-
- ObjInventarios.Dispose()
- GvDatos.DataSource = TempDT
- GvDatos.DataBind()
- CargaTextoContrato()
- RegistraScript(String.Format("$('#{0}').modal().hide();", "ModalContrato"))
-
- UpDatos.Update()
-
- End Sub
-#End Region
-
-
-#Region " GV DATOS "
- Private Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
- EliminarRow(e.RowIndex)
- End Sub
- Private Sub EliminarRow(RowIndex As Integer)
- TempDT.Rows(RowIndex).Delete()
- TempDT.AcceptChanges()
- GvDatos.DataSource = TempDT
- GvDatos.DataBind()
- UpDatos.Update()
- End Sub
-
-
-#End Region
-
-
-#Region " GUARDAR "
- Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
-
- If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then
- Alert("Los almacenes de origen y destino no pueden ser el mismo. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
- If Not GvDatos.Rows.Count > 0 Then
- Alert("No se ha seleccionado ningún Producto para trasladar.", TipoMensaje.MsgAdvertencia)
- Exit Sub
+ If Not GvDatos.Rows.Count > 0 Then
+ Alert("No se ha seleccionado ningún Producto para trasladar.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
End If
-
- Dim CveUsuarioAutoriza As Integer = -1
+ 'Dim CveUsuarioAutoriza As Integer = -1
Dim EstatusAlmacen As Integer = 2
'VERIFICA EXISTENCIAS
- Dim ObjInventarios As New ClsInventarios
+ Dim ObjInventarios As New ClsInventarios
Dim Existencia As Decimal = 0
- Dim TieneErrorExistencia As Boolean = False
- Dim MensajeExistencia As New StringBuilder
- MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:
")
+ Dim TieneErrorExistencia As Boolean = False
+ Dim MensajeExistencia As New StringBuilder
+ MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:
")
Dim CodigoPS As String = ""
+ ''Aqui poner permiso para poder evitar permiso de traslado
+ 'If ObjInventarios.GetAlmacenes(-1, -1, UsuarioActual.CveEmpresa, -1) Then
- 'Aqui poner permiso para poder evitar permiso de traslado
- If ObjInventarios.GetAlmacenes(-1, -1, UsuarioActual.CveEmpresa, -1) Then
+ ' If ObjInventarios.DtResultados.Rows.Count > 0 Then
- If ObjInventarios.DtResultados.Rows.Count > 0 Then
+ ' CveUsuarioAutoriza = If(ObjInventarios.DtResultados.FiltraParametros($"CveAlmacen = {DdlAlmacenDestino.SelectedValue}")(0)("CveUsuarioAutoriza").ToString.ToEntero > 0, ObjInventarios.DtResultados.FiltraParametros($"CveAlmacen = {DdlAlmacenDestino.SelectedValue}")(0)("CveUsuarioAutoriza").ToString.ToEntero, -1)
+ ' If CveUsuarioAutoriza > 0 Then
+ ' EstatusAlmacen = 1
+ ' End If
- CveUsuarioAutoriza = If(ObjInventarios.DtResultados.FiltraParametros($"CveAlmacen = {DdlAlmacenDestino.SelectedValue}")(0)("CveUsuarioAutoriza").ToString.ToEntero > 0, ObjInventarios.DtResultados.FiltraParametros($"CveAlmacen = {DdlAlmacenDestino.SelectedValue}")(0)("CveUsuarioAutoriza").ToString.ToEntero, -1)
- If CveUsuarioAutoriza > 0 Then
- EstatusAlmacen = 1
- End If
+ ' Else
+ ' CveUsuarioAutoriza = -1
+ ' End If
+ 'End If
- Else
- CveUsuarioAutoriza = -1
- End If
- End If
-
-
- For Each row As GridViewRow In GvDatos.Rows
- CodigoPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=row.DataKey("CvePS").ToEntero).FiltroPrimeroValor("PSCodigo", "")
- Existencia = ObjInventarios.GetExistenciasPS(row.DataKey("CvePS").ToEntero, row.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), Lote:=row.DataKey("Lote").ToString, FechaCaducidad:=row.DataKey("FechaCaducidad").ToString.ToDate)
- If Existencia - TempDT.SUM("Cantidad", $"CvePS = {row.DataKey("CvePS").ToEntero} AND CveUM = {row.DataKey("CveUM").ToEntero}") < 0 Then
- MensajeExistencia.AppendFormat("
-
{0}. Existencia: {1}", CodigoPS, Existencia)
- TieneErrorExistencia = True
- End If
- Next
-
- If TieneErrorExistencia Then
- Alert(MensajeExistencia.ToString, TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
-
-
- ObjInventarios.IniciaTransacSQL()
- Dim TieneError As Boolean = False
-
- Dim CveContrato As Integer = 0
- Dim Guia As String = ""
- If TxtGuia.Text <> "" Then Guia = TxtGuia.Text Else Guia = ""
- If DdlContratos.SelectedValue.ToEntero > 0 Then CveContrato = DdlContratos.SelectedValue.ToEntero Else CveContrato = -1
-
- Dim Estatus As Integer = -1
-
- If UsuarioActual.Empresa.Funcionalidad(105) <> "" Then
- Estatus = 1
- Else
- Estatus = 3
- End If
-
- Dim Folio As Integer = ObjInventarios.AddTrasladoSolicitud(TxtObservaciones.Text.Trim, DdlAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero, Estatus, -1, TxtFecha.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato, Guia:=Guia, CvePaqueteria:=DdlPaqueteria.SelectedValue.ToEntero, CveDireccionEnvio:=CveDireccionEnvio, EstatusAlmacen:=EstatusAlmacen)
-
- If Folio > 0 Then
- CveTraspasoSolicitud = ObjInventarios.CveTraspasoSolicitud
- Else
- TieneError = True
- End If
-
- If Not TieneError Then
- For Each Row As GridViewRow In GvDatos.Rows
- Dim CveUM As Integer = Row.DataKey("CveUM").ToEntero
- Dim CvePS As Integer = Row.DataKey("CvePS").ToEntero
- Dim Cantidad As Integer = Row.DataKey("Cantidad").ToEntero
- Dim Precio As Decimal = Row.DataKey("Precio").ToDecimal
- Dim Observaciones As String = Row.DataKey("Observaciones")
- Dim CveContratoDetalle As Integer = Row.DataKey("CveContratoDetalle").ToEntero
- Dim Serie As String = Row.DataKey("Serie")
- Dim Lote As String = Row.DataKey("Lote")
- Dim FechaCaducidad As Date = Row.DataKey("FechaCaducidad").ToDate
-
- If Not ObjInventarios.AddTrasladoSolicitudDetalle(CveTraspasoSolicitud, Cantidad, CveUM, CvePS, Precio, Observaciones, CveContratoDetalle, Serie, Lote, FechaCaducidad) Then
- TieneError = True
- Exit For
- End If
- Next
- End If
-
-
- If TieneError = False Then
- ObjInventarios.Commit()
- Alert($"El Traspaso se guardó correctamente con el folio #:
{Folio}.", TipoMensaje.MsgInformacion, $"document.location.href=""/Inventarios/TrasladoSolicitud.aspx?CveTraspasoSolicitud={CveTraspasoSolicitud}""")
-
- If CveUsuarioAutoriza > 0 Then
- MandaCorreoAutorizacion(Folio, CveTraspasoSolicitud, CveUsuarioAutoriza)
- End If
-
- Else
- ObjInventarios.RollBack()
- Alert("Ocurrió un Error al guardar el traspaso.", TipoMensaje.MsgError)
- End If
- ObjInventarios.Dispose()
-
- End Sub
-#End Region
-
-
-#Region " ELIMINAR - CANCELAR "
- Private Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
- Dim ObjInventarios As New ClsInventarios
- If ObjInventarios.RemoveTrasladoSolicitud(CveTraspasoSolicitud, UsuarioActual.CveEmpresa) Then
- Alert("Se eliminó correctamente el Traspaso.", TipoMensaje.MsgInformacion, "document.location.href=""/Inventarios/TrasladoSolicitud.aspx""")
- End If
- ObjInventarios.Dispose()
- End Sub
- Protected Sub LBCancelarTraslado_Click(sender As Object, e As EventArgs)
- Dim ObjInventarios As New ClsInventarios
-
- If ObjInventarios.UpdateTraspasoSolicitudEstatus(CveTraspasoSolicitud, 2) Then
- LBCancelarTraslado.Visible = False
- Alert("Se canceló correctamente la solicitud de traslado.", TipoMensaje.MsgInformacion)
- End If
-
- ObjInventarios.Dispose()
- End Sub
-#End Region
-
-
-#Region " IMPRESION "
- Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles LbImprimir.Click
- GenerarPDF()
- End Sub
- Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
- GenerarPDF("Excel")
- End Sub
- Private Sub GenerarPDF(Optional Formato As String = "PDF")
-
-
- Dim ObjInventarios As New ClsInventarios
- Dim ObjClientes As New ClsClientes
-
-
- Dim CveTraspasoSolicitud As Integer = Request("CveTraspasoSolicitud").ToEntero
- If ObjInventarios.AddTrasladoSolicitudGet(CveTraspasoSolicitud, UsuarioActual.CveEmpresa) Then
- If ObjInventarios.DtResultados.Rows.Count > 0 Then
- Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
- Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
- Dim dt As DataTable = ObjInventarios.DtResultados
-
- Dim DTCliente As New DataTable
- Dim CveCliente As Integer = 0
- Dim CveDireccionEnvio As Integer = 0
- Dim ClienteNombre = "", EnvioContacto = "", EnvioDireccion = "", EnvioColonia = "", EnvioCiudad = "", EnvioEstado = "", ClientePais = "", EnvioCP = "", Contrato = "",
- Paqueteria = "", NumContrato = ""
-
-
-
- Dim CveContrato As Integer = ObjInventarios.DtResultados.FiltroPrimeroValor("CveContrato").ToString.ToEntero
- If CveContrato > 0 Then
- Contrato = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("DescripcionContrato", $"CveContrato={CveContrato}")
- NumContrato = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("NumeroContrato", $"CveContrato={CveContrato} ")
- CveCliente = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCliente", $"CveContrato = {CveContrato}").ToEntero
- CveDireccionEnvio = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveDireccionEnvio", $"CveContrato = {CveContrato}").ToEntero
-
-
- If CveCliente > 0 Then
-
- DTCliente = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros($"CveCliente = {CveCliente}")
-
- 'Si el traslado tiene cvedireccionenvio trae sus datos
- If Me.CveDireccionEnvio > 0 And ObjClientes.DireccionEnvioGet(Me.CveDireccionEnvio, DdlClientes.SelectedValue.ToEntero, -1) And ObjClientes.DtResultados.Rows.Count > 0 Then
-
- ClienteNombre = DTCliente.FiltroPrimeroValor("Nombre")
- 'ClientePais = DTCliente.FiltroPrimeroValor("PAIS")
- EnvioContacto = ObjClientes.DtResultados.Rows(0)("EnvioContacto").ToString '??
-
- EnvioDireccion = ObjClientes.DtResultados.Rows(0)("EnvioDireccion").ToString
- EnvioColonia = ObjClientes.DtResultados.Rows(0)("EnvioColonia").ToString
- EnvioCiudad = ObjClientes.DtResultados.Rows(0)("EnvioCiudad").ToString
- EnvioCP = ObjClientes.DtResultados.Rows(0)("EnvioCP").ToString
- EnvioEstado = ObjClientes.DtResultados.Rows(0)("EnvioEstado").ToString
- Else
- '25/04/2018 - Si el trasladosolicitud no tiene cvedireccion envio asignada, va por la el cliente
- Dim ObjVentas As New ClsClientes
- If ObjVentas.DireccionEnvioGet(CveDireccionEnvio, -1, -1) Then
- If ObjVentas.DtResultados.Rows.Count > 0 Then
- ClienteNombre = DTCliente.FiltroPrimeroValor("Nombre")
- ClientePais = DTCliente.FiltroPrimeroValor("PAIS")
- EnvioContacto = ObjVentas.DtResultados.Rows(0)("EnvioContacto").ToString
- EnvioDireccion = ObjVentas.DtResultados.Rows(0)("EnvioDireccion").ToString
- EnvioColonia = ObjVentas.DtResultados.Rows(0)("EnvioColonia").ToString
- EnvioCiudad = ObjVentas.DtResultados.Rows(0)("EnvioCiudad").ToString
- EnvioCP = ObjVentas.DtResultados.Rows(0)("EnvioCP").ToString
- EnvioEstado = ObjVentas.DtResultados.Rows(0)("EnvioEstado").ToString
- Else
- ClienteNombre = DTCliente.FiltroPrimeroValor("Nombre")
- EnvioContacto = DTCliente.FiltroPrimeroValor("Contacto")
- EnvioDireccion = DTCliente.FiltroPrimeroValor("Direccion")
- EnvioColonia = DTCliente.FiltroPrimeroValor("Colonia")
- EnvioCiudad = DTCliente.FiltroPrimeroValor("Ciudad")
- EnvioEstado = DTCliente.FiltroPrimeroValor("Estado")
- ClientePais = DTCliente.FiltroPrimeroValor("PAIS")
- EnvioCP = DTCliente.FiltroPrimeroValor("CP")
- End If
- End If
- ObjVentas.Dispose()
- End If
- End If
- End If
-
-
- Dim params As New List(Of ReportParameter)
- params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
- params.Add(New ReportParameter("FechaImpresion", NowADS().ToShortDateString))
- params.Add(New ReportParameter("Fecha", TxtFecha.Text.Substring(0, 10)))
- params.Add(New ReportParameter("AlmacenOrigen", DdlAlmacenOrigen.SelectedItem.Text))
- params.Add(New ReportParameter("AlmacenDestino", DdlAlmacenDestino.SelectedItem.Text))
- params.Add(New ReportParameter("Guia", TxtGuia.Text))
- params.Add(New ReportParameter("UsuarioSolicito", LblUsuario.Text))
- params.Add(New ReportParameter("Folio", LbFolio.Text))
- params.Add(New ReportParameter("Observaciones", TxtObservaciones.Text))
- params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario))
- 'NUEVOS
- params.Add(New ReportParameter("ClienteNombre", ClienteNombre))
- params.Add(New ReportParameter("EnvioContacto", EnvioContacto))
- params.Add(New ReportParameter("EnvioDireccion", EnvioDireccion))
- params.Add(New ReportParameter("EnvioColonia", EnvioColonia))
- params.Add(New ReportParameter("EnvioCiudad", EnvioCiudad))
- params.Add(New ReportParameter("EnvioEstado", EnvioEstado))
- params.Add(New ReportParameter("ClientePais", ClientePais))
- params.Add(New ReportParameter("EnvioCP", EnvioCP))
- params.Add(New ReportParameter("Contrato", Contrato))
- params.Add(New ReportParameter("Paqueteria", DdlPaqueteria.SelectedItem.Text))
- params.Add(New ReportParameter("NumeroContrato", NumContrato))
- params.Add(New ReportParameter("FechaEnvio", TxtFecha.Text.Substring(0, 10)))
- params.Add(New ReportParameter("TieneSerie", GvDatos.Columns(5).Visible.ToString()))
-
- Dim RutaFormato As String = String.Format("Empresas\{0}\Formatos\RepTrasladoSolicitud.rdlc", UsuarioActual.CveEmpresa)
- Dim RutaFormatoDefault As String = String.Format("Empresas\Grales\Formatos\RepTrasladoSolicitud.rdlc")
-
- Dim Archivo As New System.IO.FileInfo(RutaFormato)
-
-
- params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
-
- If UsuarioActual.CveEmpresa = 72 Or UsuarioActual.CveEmpresa = 1 Then
- ImprimirPDF(String.Format("{0}Formatos\RepTrasladoSolicitud.rdlc", UsuarioActual.Empresa.Ruta), dt, params, String.Format("Solicitud de Traslado - {0}", NowADS().ToDateTime.ToShortDateString), Formato:=Formato)
- Else
- ImprimirPDF(RutaFormatoDefault, dt, params, String.Format("Solicitud de Traslado - {0}", NowADS().ToDateTime.ToShortDateString), Formato:=Formato)
- End If
-
- Else
- Alert("Ocurrió un error al obtener los datos del traspaso.", TipoMensaje.MsgError)
- End If
-
- End If
- ObjInventarios.Dispose()
- ObjClientes.Dispose()
-
- End Sub
-
-#End Region
-
-
-#Region "Carga Excel"
- Protected Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
- If TxtExcel.getfiles().Archivos.Count > 0 Then
- Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
- Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.path
- Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
- CargarArchivo(Directorio, file.filename, Tipo)
- Else
- Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
- End If
- End Sub
-
-
- Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
- Dim dt As New DataTable
- Dim Conexion As Odbc.OdbcConnection = Nothing
- Dim ErrorArchivo = False
- Dim ErrorExcel = False
- Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
- Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
- Dim objDbAdapter As Common.DbDataAdapter = objDbFactory.CreateDataAdapter()
- Dim objDbConnection As Common.DbConnection = objDbFactory.CreateConnection()
- objDbConnection.ConnectionString = strConnString
- objDbConnection.Open()
- Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
- Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
- Try
- Select Case Tipo
- Case "CSV"
- Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;")
- Conexion.Open()
- Dim cmd = Conexion.CreateCommand()
- cmd.CommandType = CommandType.Text
- cmd.CommandText = $"SELECT * FROM [{FileName}]"
- Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
- DataAdapter.Fill(dt)
- Case "EXCEL"
- Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
- Conexion.Open()
- Dim cmd = Conexion.CreateCommand()
- cmd.CommandType = CommandType.Text
- cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
- Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
- DataAdapter.Fill(dt)
- Case Else
- Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
- Exit Sub
- End Select
- Catch ex As Exception
- ErrorArchivo = True
- OnError("Ocurrio un error al leer el archivo
" & ex.Message, ex)
- End Try
- Conexion.Close()
-
-
- Dim DTContratosTemporal As New DataTable
- Dim ObjContratos As New ClsContratos
- If ObjContratos.GetContratosDetalle(DdlContratos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
- DTContratosTemporal = ObjContratos.DtResultados
- End If
- ObjContratos.Dispose()
-
- If DTContratosTemporal IsNot Nothing Then
- If Not ErrorArchivo Then
- For Each Row As DataRow In dt.FiltraParametros("Cantidad > 0").Rows
- Dim Cantidad As String = Row("Cantidad").ToString
- Dim Codigo As String = Row("Codigo").ToString.Trim
- Dim Observaciones As String = Row("Observaciones").ToString
- Dim CodigoPS As String = ""
- Dim CodigoContrato As String = ""
-
- CodigoPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("PSCodigo", $"Codigo = '{Codigo}'")
-
- CodigoContrato = DTContratosTemporal.FiltroPrimeroValor("Codigo", $"Codigo = '{Codigo}'").ToString
-
- If CodigoContrato <> "" Then
- Dim RowTemp As DataRow = TempDT.NewRow()
- RowTemp("Cantidad") = Cantidad
- RowTemp("CvePS") = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", $"Codigo = '{Codigo}'").ToString.ToEntero
- RowTemp("CodigoPS") = CodigoPS
- RowTemp("Observaciones") = Observaciones
-
- Dim ObjInventarios As New ClsInventarios
- Dim Existencia As Double = ObjInventarios.GetExistenciasPS(RowTemp("CvePS").ToString.ToEntero, RowTemp("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"))
- ObjInventarios.Dispose()
-
- If Existencia - RowTemp("Cantidad").ToString.ToDouble - TempDT.SUM("Cantidad", $"CvePS = {RowTemp("CvePS").ToString.ToEntero} AND CveUM = {RowTemp("CveUM").ToString.ToEntero}") < 0 Then
- If Existencia = 0 Then
- Alert($"No hay existencia del producto: {CodigoPS}", TipoMensaje.MsgAdvertencia)
- Else
- Alert($"No hay existencia suficiente del producto: {CodigoPS}, Solo hay en existencia: {Existencia - TempDT.SUM("Cantidad", $"CvePS = {RowTemp("CvePS").ToString.ToEntero} AND CveUM = {RowTemp("CveUM").ToString.ToEntero}")}", TipoMensaje.MsgAdvertencia)
- End If
- End If
- TempDT.Rows.Add(RowTemp)
- Else
- Alert($"El Código: ""
{CodigoPS}"", no se encuentra en el contrato.", TipoMensaje.MsgAdvertencia)
- Exit For
- End If
-
- Next
-
- GvDatos.DataSource = TempDT
- GvDatos.DataBind()
- CargaTextoContrato()
- UpDatos.Update()
- RegistraScript(String.Format("$('#{0}').modal().hide();", "ModalContrato"))
-
- End If
- Else
- Alert($"Ha ocurrido un error al cargar el contrato.", TipoMensaje.MsgError)
-
- End If
-
-
- End Sub
-
-
- Public Sub CargaTextoContrato()
- If DdlContratos.SelectedValue.ToEntero > 0 Then
- LbContratos.Text = DdlContratos.SelectedItem.Text
- Else
- LbContratos.Text = ""
- End If
- UpDatos.Update()
- End Sub
-
- Private Sub LbContratos_Click(sender As Object, e As EventArgs) Handles LbContratos.Click
- RegistraScript(String.Format("$('#{0}').modal().show();", "ModalContrato"))
- End Sub
-
- Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
- Dim Directorio As String = ""
- Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SolicitudTraslado.xlsx"
- Dim Archivo As New IO.FileInfo(Directorio)
- If Archivo.Exists Then
- Response.Clear()
- Response.ClearHeaders()
- Response.ClearContent()
- Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
- Response.AddHeader("Content-Length", Archivo.Length.ToString())
- Response.ContentType = "text/plain"
- Response.Flush()
- Response.TransmitFile(Archivo.FullName)
- Response.End()
- End If
- End Sub
-
-
-#End Region
-
-
- Protected Sub DdlProductoServicio_selectedindexchange(sender As Object, e As EventArgs)
- If DdlProductoServicio.SelectedValue.ToEntero > 0 Then
- Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProductoServicio.SelectedValue.ToEntero).FiltroPrimero("")
- DdlUM.Items.Clear()
- If UsuarioActual.Empresa.UsaInventarios Then
- DdlUM.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductoServicio.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
- Else
- DdlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
- End If
- DdlUM.Items.Insert(0, New ListItem("Seleccione", "-1"))
- DdlUM.SelectedValue = "-1"
- DdlUM.DataBind()
- DdlUM.SelectedValueExist(drPS("CveUnidadMedida").ToString)
- AplicaSerie = drPS("AplicaSerie").ToString = "True"
- Div4.Visible = AplicaSerie
-
- AplicaLote = drPS("AplicaLote").ToString = "True"
- divLote.Visible = AplicaLote
- RFVLote.Enabled = AplicaLote
-
- AplicaCaducidad = drPS("AplicaCaducidad").ToString = "True"
- divCaducidad.Visible = AplicaCaducidad
- divCaducidad2.Visible = AplicaCaducidad
- RFVFechaCad.Enabled = AplicaCaducidad
-
- End If
- UpPS.Update()
- UpDatos.Update()
- End Sub
-
-
- Protected Sub LnkAceptarTraslado_Click(sender As Object, e As EventArgs)
-
- Dim ObjInven As New ClsInventarios
- If ObjInven.UpdateTrasladoAutorizar(CveTraspasoSolicitud, UsuarioActual.CveEmpresa, 2, UsuarioActual.CveUsuario, NowADS()) Then
- Alert("Autorizado correctamente.")
- End If
- ObjInven.Dispose()
-
- CargaDatos()
-
- End Sub
-
- Protected Sub LnkRechazarTraslado_Click(sender As Object, e As EventArgs)
-
- TxtMotivoRechazo.Text = ""
- UpModalRechazo.Update()
- RegistraScript("$('#ModalRechazarTraslado').modal();")
-
- End Sub
-
-
- Protected Sub BtnModalRechazo_Click(sender As Object, e As EventArgs)
- RechazarTraslado()
- End Sub
-
- Private Sub RechazarTraslado()
-
- Dim ErrorProceso As Boolean = False
-
- If TxtMotivoRechazo.Text.Trim.Length.ToEntero = 0 Then
- Alert("El motivo de rechazo es necesario", TipoMensaje.MsgAdvertencia)
- End If
-
-
- Dim ObjInven As New ClsInventarios
-
- If ObjInven.UpdateTrasladoAutorizar(CveTraspasoSolicitud, UsuarioActual.CveEmpresa, 3, UsuarioActual.CveUsuario, NowADS()) Then
- Alert("Rechazado correctamente.")
- ErrorProceso = False
- Else
- ErrorProceso = True
- End If
-
- ObjInven.Dispose()
-
- If Not ErrorProceso Then
- MandaCorreoRechazo(LbFolio.Text.ToEntero, CveTraspasoSolicitud, CveUsuarioSolicita, TxtMotivoRechazo.Text)
- CargaDatos()
- RegistraScript("$('#ModalRechazarTraslado').modal('hide');")
- End If
-
- End Sub
-
-
- Private Sub MandaCorreoRechazo(Folio As Integer, CveTraspasoSolicitud As Integer, CveUsuarioSolicita As Integer, MotivoRechazo As String)
-
- Dim SB As New StringBuilder
-
- Dim CorreoDestino As String = GlobalDTUsuarios(CveUsuarioSolicita)(0)("Correo").ToString.Trim
-
-
- If CorreoDestino.Length > 0 Then
-
-
- SB.AppendLine($"
Se ha rechazado la solicitud de traspaso con folio {Folio}, el traspaso fue rechazado por el usuario {UsuarioActual.Nombre }, el traspaso fue rechazado por el motivo: {MotivoRechazo}
")
-
-
-
- SB.AppendLine("
")
- SB.AppendLine("
")
- SB.AppendLine("| Cantidad | U.M. | Producto | Observaciones |
")
-
- For Each GvRow As GridViewRow In GvDatos.Rows
-
- If GvRow.RowType = DataControlRowType.DataRow Then
- SB.AppendLine($" | {GvRow.DataKey("Cantidad")} | {GvRow.DataKey("UnidadMedida")} | {GvRow.DataKey("CodigoPS")} | {GvRow.DataKey("Observaciones")} |
")
- End If
-
- Next
- SB.AppendLine("
")
- SB.AppendLine("
")
-
- SB.AppendLine($"
Ir a solicitud de traspaso folio {Folio}")
-
-
-
- Dim MandaCorre As New ClsSisMail
- MandaCorre.SendMail(ClsPaginas.EmpresaNotificaciones, CorreoDestino, $"Rechazo de Autorización de traspaso #{Folio}", SB.ToString, Displayname:="SIG Notificaciones: Rechazo de Traspaso")
-
- End If
-
- End Sub
-
-
- Private Sub MandaCorreoAutorizacion(Folio As Integer, CveTraspasoSolicitud As Integer, CveUsuarioAutoriza As Integer)
-
- Dim SB As New StringBuilder
-
- Dim CorreoDestino As String = GlobalDTUsuarios(CveUsuarioAutoriza)(0)("Correo").ToString.Trim
-
-
- If CorreoDestino.Length > 0 Then
-
-
-
- SB.AppendLine($"
Se ha registrado una solicitud de traspaso de {DdlAlmacenOrigen.SelectedItem.Text} a {DdlAlmacenDestino.SelectedItem.Text}, con los siguientes productos.
")
-
-
-
- SB.AppendLine("
")
- SB.AppendLine("
")
- SB.AppendLine("| Cantidad | U.M. | Producto | Observaciones |
")
-
- For Each GvRow As GridViewRow In GvDatos.Rows
-
- If GvRow.RowType = DataControlRowType.DataRow Then
- SB.AppendLine($" | {GvRow.DataKey("Cantidad")} | {GvRow.DataKey("UnidadMedida")} | {GvRow.DataKey("CodigoPS")} | {GvRow.DataKey("Observaciones")} |
")
- End If
-
- Next
- SB.AppendLine("
")
- SB.AppendLine("
")
- SB.AppendLine($"
Ir a solicitud de traspaso para autorización")
-
-
-
- Dim MandaCorre As New ClsSisMail
- MandaCorre.SendMail(ClsPaginas.EmpresaNotificaciones, CorreoDestino, $"Solicitud de Autorización de traspaso #{Folio}", SB.ToString, Displayname:="SIG Notificaciones: Solicitud de Traspaso")
-
- End If
-
- End Sub
-
- Public Sub MostarSerieColumn()
- Dim Mostrar As Boolean = False
For Each row As GridViewRow In GvDatos.Rows
- Dim Serie As String = row.DataKey("Serie").ToString
- If Serie IsNot "-1" And Serie IsNot "" Then
- Mostrar = True
- Exit For
+ CodigoPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=row.DataKey("CvePS").ToEntero).FiltroPrimeroValor("PSCodigo", "")
+ Existencia = ObjInventarios.GetExistenciasPS(row.DataKey("CvePS").ToEntero, row.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=NowADS.ToString("yyyy/MM/dd 23:59"), Lote:=row.DataKey("Lote").ToString, FechaCaducidad:=row.DataKey("FechaCaducidad").ToString.ToDate)
+ If Existencia - TempDT.SUM("Cantidad", $"CvePS = {row.DataKey("CvePS").ToEntero} AND CveUM = {row.DataKey("CveUM").ToEntero}") < 0 Then
+ MensajeExistencia.AppendFormat("
-
{0}. Existencia: {1}", CodigoPS, Existencia)
+ TieneErrorExistencia = True
End If
Next
- GvDatos.Columns(5).Visible = Mostrar
+
+ If TieneErrorExistencia Then
+ Alert(MensajeExistencia.ToString, TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+
+ ObjInventarios.IniciaTransacSQL()
+ Dim TieneError As Boolean = False
+
+ 'Dim CveContrato As Integer = 0
+ 'Dim Guia As String = ""
+ 'If TxtGuia.Text <> "" Then Guia = TxtGuia.Text Else Guia = ""
+ 'If DdlContratos.SelectedValue.ToEntero > 0 Then CveContrato = DdlContratos.SelectedValue.ToEntero Else CveContrato = -1
+
+ Dim Estatus As Integer = -1
+
+ If UsuarioActual.Empresa.Funcionalidad(105) <> "" Then
+ Estatus = 1
+ Else
+ Estatus = 3
+ End If
+
+ Dim Folio As Integer = ObjInventarios.AddTrasladoSolicitud("", DdlAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero, Estatus, -1, NowADS, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, EstatusAlmacen:=EstatusAlmacen)
+
+ If Folio > 0 Then
+ CveTraspasoSolicitud = ObjInventarios.CveTraspasoSolicitud
+ Else
+ TieneError = True
+ End If
+
+ If Not TieneError Then
+ For Each Row As GridViewRow In GvDatos.Rows
+ 'Dim CveUM As Integer = Row.DataKey("CveUM").ToEntero
+ Dim CvePS As Integer = Row.DataKey("CvePS").ToEntero
+ Dim Cantidad As Integer = Row.DataKey("Cantidad").ToEntero
+ 'Dim Precio As Decimal = Row.DataKey("Precio").ToDecimal
+ 'Dim Observaciones As String = Row.DataKey("Observaciones")
+ 'Dim CveContratoDetalle As Integer = Row.DataKey("CveContratoDetalle").ToEntero
+ 'Dim Serie As String = Row.DataKey("Serie")
+ 'Dim Lote As String = Row.DataKey("Lote")
+ 'Dim FechaCaducidad As Date = Row.DataKey("FechaCaducidad").ToDate
+
+ If Not ObjInventarios.AddTrasladoSolicitudDetalle(CveTraspasoSolicitud, Cantidad, -1, CvePS, 0, "", -1, "-1", "-1", MinFecha) Then
+ TieneError = True
+ Exit For
+ End If
+ Next
+ End If
+
+
+ If TieneError = False Then
+ ObjInventarios.Commit()
+ Alert($"El Traspaso se guardó correctamente con el folio #:
{Folio}.", TipoMensaje.MsgInformacion)
+ RegistraScript(String.Format("$('#{0}').modal('hide');", "DVModalSolicitudAdd"))
+ CargaDatos()
+ Else
+ ObjInventarios.RollBack()
+ Alert("Ocurrió un Error al guardar el traspaso.", TipoMensaje.MsgError)
+ End If
+ ObjInventarios.Dispose()
+
+ End Sub
+#End Region
+
+
+#Region " GV DATOS "
+ Private Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
+ EliminarRow(e.RowIndex)
+ End Sub
+ Private Sub EliminarRow(RowIndex As Integer)
+ TempDT.Rows(RowIndex).Delete()
+ TempDT.AcceptChanges()
+ GvDatos.DataSource = TempDT
+ GvDatos.DataBind()
+ UpPS.Update()
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.FCLiteral("LtlSerie").ToString = "-1" Then
- e.Row.FCLiteral("LtlSerie").Text = ""
- End If
- If e.Row.FCLiteral("LtlLote").ToString = "-1" Then
- e.Row.FCLiteral("LtlLote").Text = ""
- End If
+#End Region
+
+
+ Protected Sub LnkAgregarSolicitud_Click(sender As Object, e As EventArgs)
+ RegistraScript(String.Format("$('#{0}').modal();", "DVModalSolicitudAdd"))
+ End Sub
+
+ Protected Sub LnkMostrarTraspaso_Click(sender As Object, e As EventArgs)
+
+ Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
+ CveTraspasoSolicitud = GvRow.DataKey("CveTraspasoSolicitud").ToEntero
+ CveAlmacenOrigen = GvRow.DataKey("CveAlmacenOrigen").ToEntero
+ CveAlmacenDestino = GvRow.DataKey("CveAlmacenDestino").ToEntero
+ Dim CveTrasladoEstatus As Integer = GvRow.DataKey("CveTrasladoEstatus").ToEntero
+
+ LblModalSolicitudFolio.Text = GvRow.DataKey("Folio")
+ LblModalSolicitudSolicitante.Text = GvRow.DataKey("Nombre")
+ LblModalSolicitudOrigen.Text = GvRow.DataKey("AlmacenOrigen")
+ LblModalSolicitudDestino.Text = GvRow.DataKey("AlmacenDestino")
+
+ ' TraspasoEstatus,AlmacenOrigen,AlmacenDestino,Nombre
+
+ Dim ObjInventarios As New ClsInventarios
+ If ObjInventarios.AddTrasladoSolicitudGet(CveTraspasoSolicitud, UsuarioActual.CveEmpresa) Then
+ GvSolicitudes.DataSource = ObjInventarios.DtResultados
+ End If
+ ObjInventarios.Dispose()
+ GvSolicitudes.DataBind()
+
+ GvSolicitudes.Columns(0).Visible = If(CveTrasladoEstatus = 1, True, False)
+ GvSolicitudes.Columns(2).Visible = If(CveTrasladoEstatus = 1, True, False)
+ BtnAceptarSolicitud.Visible = If(CveTrasladoEstatus = 1, True, False)
+ BtnRechazarSolicitud.Visible = If(CveTrasladoEstatus = 1, True, False)
+
+
+
+ UpModalSolicitudes.Update()
+ RegistraScript(String.Format("$('#{0}').modal();", "DVModalSolicitud"))
+
+ End Sub
+
+ Protected Sub BtnAceptarSolicitud_Click(sender As Object, e As EventArgs)
+
+
+ Dim CveAlmacenTransictorio As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3).FiltroPrimeroValor("CveAlmacen").ToEntero
+
+ If Not CveAlmacenTransictorio > 0 Then
+ Alert("No se encontro un almacen transitorio", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ Dim ErrorMovInv As Boolean = False
+ Dim ErrorExistencia As Boolean = False
+
+ Dim ObjInventario As New ClsInventarios
+ Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
+
+ Dim TextoExistencia As StringBuilder = New StringBuilder
+ TextoExistencia.Append("Los siguiente productos no tienen existencia:
")
+
+ For Each gvr As GridViewRow In GvSolicitudes.Rows
+ Dim Existencia As Decimal = 0
+
+ Dim MsgAdicional As String = ""
+
+ If ObjInventario.GetExistenciasProducto(gvr.DataKey("CvePS").ToEntero, gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, CveAlmacenOrigen, FechaMovto:=NowADS.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=-1, Serie:="-1", Lote:="-1", Caducidad:=MinFecha) Then
+ 'si hay existencia en almacen costeado, lo tengo que sacar
+ ' si tiene serie el producto, debe de
+ Existencia = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", CveAlmacenOrigen)).ToDecimal
+ Dim ExistenciaSinPendiente As Decimal = ObjInventario.DtResultados.FiltroPrimeroValor("Existencia", String.Format("CveAlmacen = {0}", CveAlmacenOrigen)).ToDecimal
+ Dim PendienteporSurtir As Decimal = ObjInventario.DtResultados.FiltroPrimeroValor("PendientePorSurtir", String.Format("CveAlmacen = {0}", CveAlmacenOrigen)).ToDecimal
+
+ ' si la existencia es negativa y tiene serie ó lote, quiere decir que la consulta es específica, y si hay pendientes por surtir. puede generar negativos
+ ' para asegurarnos que lo pendiente por surtir se pueda surtir con otras series, consultamos de nuevo, pero a nivel producto, para checar existencia
+
+ If ExistenciaSinPendiente > 0 AndAlso Existencia <= 0 AndAlso PendienteporSurtir > 0 Then
+ MsgAdicional = " Pendiente por surtir: " & PendienteporSurtir.FormatoNumero(0)
+ If ObjInventario.GetExistenciasProducto(gvr.DataKey("CvePS").ToEntero, gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, CveAlmacenOrigen, FechaMovto:=NowADS.ToString("yyyy/MM/dd 23:59")) Then
+ 'si hay existencia en almacen costeado, lo tengo que sacar
+ Existencia = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", CveAlmacenOrigen)).ToDecimal
+ 'si la existencia del producto en general, supera a lo pendiente, entonces la serie si se puede sacar.
+
+ End If
+ End If
- If e.Row.FCLiteral("LtlFechaCaducidad").ToString.ToDate = MinFecha Then
- e.Row.FCLiteral("LtlFechaCaducidad").Text = ""
End If
+ Existencia -= gvr.FCTextBox("TxtCantidad").Text.ToDecimal()
+
+ If Existencia < 0 Then
+ ErrorExistencia = True
+ TextoExistencia.AppendFormat("-
#{0} {1} {2} Existencia:
{3}{4}
", "", gvr.DataKey("CodigoPS"), "", (Existencia + gvr.FCTextBox("TxtCantidad").Text.ToDecimal()), MsgAdicional)
+ End If
+ Next
+
+ If ErrorExistencia Then
+ ObjInventario.Dispose()
+ Alert(TextoExistencia.ToString, TipoMensaje.MsgError)
+ RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
+
+ Exit Sub
+ End If
+
+
+
+ Dim DrAlmO, DrAlmD As DataRow
+ Dim CveSucursalOrigen, CveSucursalDestino As Integer
+ Dim TipoAlmacenOrigen, TipoAlmacenDestino As Integer
+ Dim CveSubProyectoOrigen, CveSubProyectoDestino As Integer
+
+ Dim CveAlmacenVirtualSalida As Integer = -1
+ Dim CveAlmacenVirtualEntrada As Integer = -1
+
+ DrAlmO = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenOrigen).FiltroPrimero("")
+ DrAlmD = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenDestino).FiltroPrimero("")
+
+ If DrAlmO IsNot Nothing AndAlso DrAlmD IsNot Nothing Then
+ CveSucursalOrigen = DrAlmO("CveSubProyecto").ToString.ToEntero
+ TipoAlmacenOrigen = DrAlmO("CveTipoAlmacen").ToString.ToEntero
+ CveSubProyectoOrigen = DrAlmO("CveSubProyecto").ToString.ToEntero
+ CveAlmacenVirtualSalida = DrAlmO("CveAlmacenVirtual").ToString.ToEntero
+
+
+ CveSucursalDestino = DrAlmD("CveSubProyecto").ToString.ToEntero
+ TipoAlmacenDestino = DrAlmD("CveTipoAlmacen").ToString.ToEntero
+ CveSubProyectoDestino = DrAlmD("CveSubProyecto").ToString.ToEntero
+ CveAlmacenVirtualEntrada = DrAlmD("CveAlmacenVirtual").ToString.ToEntero
End If
+
+ ' val Existencia
+
+ Dim CveMovimientoSalida As Integer = -1
+ Dim CveMovimientoEntrada As Integer = -1
+ Dim TipoMovimientoSalida As Integer = 26
+
+ Dim FolioSalida As Integer = 0
+ Dim FolioEntrada As Integer = 0
+
+ Dim TextoError As String = ""
+ Dim CveConceptoEntrada As Integer = 27
+
+
+ 'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN
+ CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenOrigen, TipoMovimientoSalida, 1, NowADS, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
+ Observaciones:="", Recibio:="-1",
+ CveAlmacenDestino:=CveAlmacenDestino, GastoIndirecto:=-1,
+ ResponsableCarga:="", ResponsableRecibio:="",
+ Modulo:="STA/G1", CveFolioGarantia:=-1)
+
+
+
+ FolioSalida = ObjInventario.Folio
+ 'Folio = ObjInventario.Folio
+ If CveMovimientoSalida <= 0 Then
+ TextoError = "Ocurrió un error al generar el movimiento de salida"
+ ErrorMovInv = True
+ Else
+ Dim Cont As Integer = 0
+
+
+ For Each gvr As GridViewRow In GvSolicitudes.Rows
+
+ Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal
+ If gvr.FCCheckBox("Chk").Checked AndAlso Cantidad > 0 Then
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, 0, CveAF:=-1, CveSeccionAlmacen:=-1, Serie:="-1", Lote:="-1", FechaCaducidad:=MinFecha, Observaciones:="") Then
+ ErrorMovInv = True
+ TextoError = "Ocurrió un error al guardar los movimientos de salida"
+ Exit For
+ End If
+ Cont += 1
+ End If
+ Next
+
+ 'For Each Dr As DataRow In DtMovimientos.Rows
+
+ 'Next
+ End If
+
+ 'ENTRADA
+ CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenTransictorio, CveConceptoEntrada, 1, NowADS, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, -1, -1,
+ Observaciones:="", Recibio:="",
+ CveAlmacenDestino:=CveAlmacenDestino, CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="STA/G2", CveFolioGarantia:=-1)
+ FolioEntrada = ObjInventario.Folio
+ If CveMovimientoEntrada <= 0 Then
+ TextoError = "Ocurrió un error al generar el movimiento de entrada"
+ ErrorMovInv = True
+ Else
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+ Dim Cont As Integer = 0
+ Dim dttSalida As DataTable = ObjInventario.DtResultados
+
+ Dim tCveClasificacion As Integer = ObjInventario.DtResultados.MAX("CveClasificacion").ToEntero
+
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ Dim CostoEntrada As Decimal = If(TipoAlmacenDestino = 26, 0, Dr("PU").ToString.ToDecimal())
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, CostoEntrada, CveAF:=-1,
+ CveSeccionAlmacen:=-1, Serie:="-1", Lote:="-1", FechaCaducidad:=MinFecha, CveMovimientoDetalleEntrada:=-1, Observaciones:="") Then
+ ErrorMovInv = True
+ TextoError = "Ocurrió un error al guardar los movimientos de entrada"
+ Exit For
+ End If
+ Cont += 1
+ Next
+
+ Dim Concepto As String = ""
+ If Concepto = "" Then Concepto = "Traspaso"
+
+ 'AGREGAMOS PREPOLIZAS TRASPASO DIRECTO:
+ If Not ErrorMovInv Then
+ Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, NowADS, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+
+ Dim importe As Decimal = dttSalida.SUMD("Total").RoundSQL
+ Dim Contabilizable As Boolean = False
+ If UsuarioActual.Empresa.Funcionalidad(267) = "1" Then Contabilizable = True 'cuando es citrícola
+ If TipoAlmacenOrigen = 26 AndAlso TipoAlmacenDestino <> 26 Then Contabilizable = True
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, importe, 68, "", "", CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable) Then
+ ErrorMovInv = True
+ End If
+
+ 'si el tipo de almacen de entrada es Almacen sin costo, se registra al costo, la salida.
+ If TipoAlmacenOrigen <> 26 AndAlso TipoAlmacenDestino = 26 Then
+
+
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, importe, 69, "", "", CveClasificacion:=tCveClasificacion, CveSubProyecto:=CveSubProyectoOrigen, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable) Then
+ ErrorMovInv = True
+ End If
+ Contabilizable = False
+ importe = 0
+ End If
+
+ If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, importe, 68, "", "", CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable) Then
+ ErrorMovInv = True
+ End If
+
+ If Not ErrorMovInv Then
+ If ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then
+ If ObjConta.ValorPolizaDescuadre > 0 Then
+ 'MsgError = ObjMov.MensajePolizaDescuadre
+ ErrorMovInv = True
+ 'GuardaLogAD($"Bancos/Transferencias | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
+ End If
+ Else
+ ErrorMovInv = True
+ End If
+ End If
+ End If
+ End If
+ End If
+
+
+ If Not ErrorMovInv Then
+ If ObjInventario.UpdateTraspasoSolicitudMovimiento(CveTraspasoSolicitud, CveMovimientoSalida) Then
+ If Not ObjInventario.UpdateTraspasoSolicitudEstatus(CveTraspasoSolicitud, 2) Then
+ ErrorMovInv = True
+ End If
+ Else
+ ErrorMovInv = True
+ End If
+ End If
+
+ Dim MensajeAlert As New StringBuilder
+ If Not ErrorMovInv Then
+ ObjInventario.Commit()
+ MensajeAlert.Append("Se realizó con éxito el traspaso.")
+ MensajeAlert.AppendFormat("
Folio de Salida:
{0}", FolioSalida, CveMovimientoSalida)
+ MensajeAlert.AppendFormat("
Imprimir ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
+ Alert(MensajeAlert.ToString, TipoMensaje.MsgInformacion, "")
+ RegistraScript(String.Format("$('#{0}').modal('hide');", "DVModalSolicitud"))
+ Else
+ ObjInventario.RollBack()
+ Alert(TextoError, TipoMensaje.MsgError)
+ End If
+
+ ObjInventario.Dispose()
+
+ If Not ErrorMovInv Then
+ CargaDatos()
+ End If
+
End Sub
-End Class
-
+
+ Protected Sub BtnRechazarSolicitud_Click(sender As Object, e As EventArgs)
+ Dim ErrorMovInv As Boolean = False
+
+ Dim ObjInventarios As New ClsInventarios
+ If Not ObjInventarios.UpdateTraspasoSolicitudEstatus(CveTraspasoSolicitud, 3) Then
+ ErrorMovInv = True
+ End If
+ ObjInventarios.Dispose()
+
+ If Not ErrorMovInv Then
+ RegistraScript(String.Format("$('#{0}').modal('hide');", "DVModalSolicitud"))
+ Alert("Se rechazo correctamente la solicitud de traspaso.", TipoMensaje.MsgInformacion)
+ CargaDatos()
+ End If
+
+ End Sub
+
+ Protected Sub GvSolicitudes_RowDataBound(sender As Object, e As GridViewRowEventArgs)
+
+ If e.Row.RowType = DataControlRowType.DataRow Then
+ Dim Cantidad As Decimal = e.Row.DataKey("Cantidad").ToDecimal
+ e.Row.FCCheckBox("chk").Attributes.Add("onclick", $"validaCantidadSolicitud({Cantidad},'{e.Row.FCTextBox("TxtCantidad").ClientID}','{e.Row.FCCheckBox("Chk").ClientID}',1);")
+ e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", $"validaCantidadSolicitud({Cantidad},'{e.Row.FCTextBox("TxtCantidad").ClientID}','{e.Row.FCCheckBox("Chk").ClientID}',2);")
+ End If
+
+ End Sub
+
+ Protected Sub GvT_RowDataBound(sender As Object, e As GridViewRowEventArgs)
+
+ If e.Row.RowType = DataControlRowType.DataRow Then
+
+ e.Row.FCLinkButton("LnkMostrarTraspaso").Visible = If(e.Row.DataKey("PermisoOrigen").ToEntero = 1, True, False)
+
+ If e.Row.DataKey("CveTrasladoEstatus").ToEntero = 1 Then
+ e.Row.FCLinkButton("LnkMostrarTraspaso").CssClass = "btn btn-circle btn-sm blue"
+ Else
+ If e.Row.DataKey("CveTrasladoEstatus").ToEntero = 2 Then
+ e.Row.FCLinkButton("LnkMostrarTraspaso").CssClass = "btn btn-circle btn-sm green"
+ Else
+ e.Row.FCLinkButton("LnkMostrarTraspaso").CssClass = "btn btn-circle btn-sm red"
+ End If
+
+
+ End If
+
+
+ End If
+
+ End Sub
+End Class
diff --git a/Inventarios/TrasladoSolicitudOld.aspx b/Inventarios/TrasladoSolicitudOld.aspx
new file mode 100644
index 000000000..fef1a621d
--- /dev/null
+++ b/Inventarios/TrasladoSolicitudOld.aspx
@@ -0,0 +1,593 @@
+<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="TrasladoSolicitudOld.aspx.vb" Inherits="Inventarios_TrasladoSolicitudOld" %>
+
+
+
+
+
+
+
+
+ Solicitud de Traslados
+
+
+
+
+
+ Agregar Producto
+
+
+
+ Ayuda
+
+
+
+
+ Vincular desde Contrato
+
+
+
+ Generar PDF
+
+
+
+ Generar Excel
+
+
+ Cancelar Solicitud
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INFORMACIÓN DEL TRASLADO
+
+
+
+
+
+
+
+
+ |
+ Folio:
+ |
+
+
+
+
+ |
+
+
+ | Fecha: |
+
+
+ |
+
+
+
+ | Almacén Origen: |
+
+
+ |
+
+
+ | Almacén Destino: |
+
+
+ |
+
+
+
+
+
+ | Paquetería: |
+
+
+ |
+
+
+
+
+
+ | Número Guía: |
+
+ |
+
+
+
+
+ | Observaciones: |
+
+
+ |
+
+
+
+
+ | Vincular desde Contrato: |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INFORMACIÓN DE LA SOLICITUD
+
+
+
+
+
+
+
+
+
+
+
+ | Usuario Solicitó: |
+
+
+ |
+
+
+
+ | Contrato: |
+
+
+
+ |
+
+
+
+ | Dirección de Envio: |
+
+
+ |
+
+
+
+
+ | Movimiento: |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AUTORIZACIÓN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PRODUCTOS
+
+
+
+
+
+
+
+
+
+
+
+
+ <%----%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Inventarios/TrasladoSolicitudOld.aspx.vb b/Inventarios/TrasladoSolicitudOld.aspx.vb
new file mode 100644
index 000000000..f3870501b
--- /dev/null
+++ b/Inventarios/TrasladoSolicitudOld.aspx.vb
@@ -0,0 +1,1262 @@
+Option Strict On
+Option Explicit On
+
+Imports System.Data
+Imports Extensiones
+Imports Microsoft.Reporting.WebForms
+
+Partial Class Inventarios_TrasladoSolicitudOld
+ Inherits ClsPaginas
+
+#Region "Propiedades"
+ Private Property TempDT As DataTable
+ Get
+ Return CType(ViewState("TempDT"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("TempDT") = value
+ End Set
+ End Property
+
+ Private Property CveTraspasoSolicitud As Integer
+ Get
+ Return CType(ViewState("CveTraspasoSolicitud"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveTraspasoSolicitud") = value
+ End Set
+ End Property
+
+ 'CveDireccionEnvio del Traslado
+ Private Property CveDireccionEnvio As Integer
+ Get
+ Return CType(ViewState("CveDireccionEnvio"), Integer)
+ End Get
+ Set(value As Integer)
+ ViewState("CveDireccionEnvio") = value
+ End Set
+ End Property
+ Private Property CveUsuarioSolicita As Integer
+ Get
+ If ViewState("CveUsuarioSolicita") Is Nothing Then
+ Return -1
+ Else
+ Return CType(ViewState("CveUsuarioSolicita"), Integer)
+ End If
+
+ End Get
+ Set(value As Integer)
+ ViewState("CveUsuarioSolicita") = value
+ End Set
+ End Property
+
+ Private Property AplicaSerie As Boolean
+ Get
+ If ViewState("AplicaSerie") Is Nothing Then
+ Return False
+ Else
+ Return CType(ViewState("AplicaSerie"), Boolean)
+ End If
+
+ End Get
+ Set(value As Boolean)
+ ViewState("AplicaSerie") = value
+ End Set
+ End Property
+
+ Private Property AplicaLote As Boolean
+ Get
+ If ViewState("AplicaLote") Is Nothing Then
+ Return False
+ Else
+ Return CType(ViewState("AplicaLote"), Boolean)
+ End If
+
+ End Get
+ Set(value As Boolean)
+ ViewState("AplicaLote") = value
+ End Set
+ End Property
+
+ Private Property AplicaCaducidad As Boolean
+ Get
+ If ViewState("AplicaCaducidad") Is Nothing Then
+ Return False
+ Else
+ Return CType(ViewState("AplicaCaducidad"), Boolean)
+ End If
+
+ End Get
+ Set(value As Boolean)
+ ViewState("AplicaCaducidad") = value
+ End Set
+ End Property
+
+#End Region
+
+ Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
+ If Not IsPostBack Then
+
+ InicializaValores()
+
+ 'CARGAMOS SOLICITUD YA EXISTENTE.
+ If Request("CveTraspasoSolicitud").ToEntero > 0 Then
+ CveTraspasoSolicitud = Request("CveTraspasoSolicitud").ToEntero
+ CargaDatos()
+ End If
+
+ End If
+ End Sub
+
+
+
+#Region " INICIALIZA VALORES "
+ Private Sub InicializaValores()
+ CveTraspasoSolicitud = -1
+ CveDireccionEnvio = -1
+ DivFolio.Visible = False
+
+ TxtFecha.Text = NowADS().ToShortDateString
+ CreaDTTemporal()
+ CargaAlmacenes()
+ CargaPS()
+ CargaClientes()
+ DdlContratos.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ CargaUnidadMedida()
+ CargaPaqueterias()
+ End Sub
+ Public Sub CreaDTTemporal()
+ TempDT = New DataTable
+ TempDT.Columns.Add("Cantidad", Type.GetType("System.Double"))
+ TempDT.Columns.Add("CvePS", Type.GetType("System.Int32"))
+ TempDT.Columns.Add("CodigoPS", Type.GetType("System.String"))
+ TempDT.Columns.Add("CveUM", Type.GetType("System.Int32"))
+ TempDT.Columns.Add("UnidadMedida", Type.GetType("System.String"))
+ TempDT.Columns.Add("Precio", Type.GetType("System.Double"))
+ TempDT.Columns.Add("Observaciones", Type.GetType("System.String"))
+ TempDT.Columns.Add("CveContratoDetalle", Type.GetType("System.Int32"))
+ 'TempDT.Columns.Add("CveContratoDetalle", Type.GetType("System.Int32"))
+ 'TempDT.Columns.Add("CveDireccionEnvio", Type.GetType("System.Int32"))
+ TempDT.Columns.Add("Serie", Type.GetType("System.String"))
+ TempDT.Columns.Add("Lote", Type.GetType("System.String"))
+ TempDT.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime"))
+
+ TempDT.Columns.Add()
+ End Sub
+ Private Sub CargaPaqueterias()
+ DdlPaqueteria.DataSource = GlobalDTPaqueterias(UsuarioActual.CveEmpresa)
+ DdlPaqueteria.DataBind()
+ DdlPaqueteria.Items.Insert(0, New ListItem("-", "-1"))
+ End Sub
+
+ Private Sub CargaUnidadMedida()
+ DdlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
+ DdlUM.DataBind()
+ End Sub
+
+ Private Sub CargaAlmacenes()
+ 'Cargo los almacenes
+ DdlAlmacenOrigen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen <> 9") 'Excluir almacenes de Apartado
+ DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen <> 9") 'Excluir almacenes de Apartado
+ DdlAlmacenOrigen.DataBind()
+ DdlAlmacenDestino.DataBind()
+ End Sub
+
+ Private Sub CargaClientes()
+ DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
+ DdlClientes.DataBind()
+ DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End Sub
+
+ Private Sub CargaPS()
+ DdlProductoServicio.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
+
+ If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
+ DdlProductoServicio.ddlWS.Attributes.Add("data-cveclasificacion", "-1")
+ DdlProductoServicio.SelectedText = ""
+ DdlProductoServicio.SelectedValue = "-1"
+ Else
+ DdlProductoServicio.ddl.Items.Clear()
+ DdlProductoServicio.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=-1)
+ DdlProductoServicio.ddl.DataBind()
+ DdlProductoServicio.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
+ End If
+ 'DdlProductoServicio.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
+ 'DdlProductoServicio.DataBind()
+ 'DdlProductoServicio.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End Sub
+#End Region
+
+
+#Region " CARGA DATOS "
+ Private Sub CargaDatos()
+ Dim ObjInventarios As New ClsInventarios
+ Dim ObjClientes As New ClsClientes
+
+ If ObjInventarios.AddTrasladoSolicitudGet(CveTraspasoSolicitud, UsuarioActual.CveEmpresa) Then
+ If ObjInventarios.DtResultados.Rows.Count > 0 Then
+ For Each rowtp As DataRow In ObjInventarios.DtResultados.Rows
+ If Not AplicaSerie Then
+ AplicaSerie = rowtp("Serie").ToString <> ""
+ End If
+ If Not AplicaLote Then
+ AplicaLote = rowtp("Lote").ToString <> ""
+ End If
+ If Not AplicaCaducidad Then
+ AplicaCaducidad = rowtp("FechaCaducidad").ToString <> ""
+ End If
+ Next
+
+ Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProductoServicio.SelectedValue.ToEntero).FiltroPrimero("")
+
+
+ GvDatos.Columns(4).Visible = False
+ GvDatos.Columns(5).Visible = AplicaSerie
+ GvDatos.Columns(6).Visible = AplicaLote
+ GvDatos.Columns(7).Visible = AplicaCaducidad
+
+ DivFolio.Visible = True
+ LbFolio.Text = ObjInventarios.DtResultados.Rows(0)("FolioTraspaso").ToString
+ TxtObservaciones.Text = ObjInventarios.DtResultados.Rows(0)("ObservacionesTraspaso").ToString
+
+ TempDT = ObjInventarios.DtResultados
+ GvDatos.DataSource = ObjInventarios.DtResultados
+ GvDatos.DataBind()
+
+ If ObjInventarios.DtResultados.Rows(0)("CveContrato").ToString.ToEntero > 0 Then
+ RowContrato.Visible = True
+ ChkDesdeContrato.Checked = True
+ GvDatos.Columns(3).Visible = True
+ Else
+ GvDatos.Columns(3).Visible = False
+ End If
+
+ DdlAlmacenOrigen.SelectedValue = ObjInventarios.DtResultados.Rows(0)("CveAlmacenOrigen").ToString
+ DdlAlmacenDestino.SelectedValue = ObjInventarios.DtResultados.Rows(0)("CveAlmacenDestino").ToString
+ DdlPaqueteria.SelectedValue = ObjInventarios.DtResultados.Rows(0)("CvePaqueteria").ToString
+ TxtFecha.Text = ObjInventarios.DtResultados.Rows(0)("Fecha").ToString
+ LblUsuario.Text = ObjInventarios.DtResultados.Rows(0)("Usuario").ToString
+ HplContrato.Text = ObjInventarios.DtResultados.Rows(0)("DescripcionContrato").ToString
+ HplContrato.NavigateUrl = $"/Contratos/Contrato.aspx?CveContrato={ObjInventarios.DtResultados.Rows(0)("CveContrato").ToString.ToEntero}"
+
+ CveUsuarioSolicita = ObjInventarios.DtResultados.Rows(0)("CveUsuario").ToString.ToEntero
+
+ '25/04/2018
+ CveDireccionEnvio = ObjInventarios.DtResultados.Rows(0)("CveDireccionEnvio").ToString.ToEntero
+ If CveDireccionEnvio > 0 And ObjClientes.DireccionEnvioGet(CveDireccionEnvio, -1, -1) Then
+ LblDireccionEnvio.Text = ObjClientes.DtResultados.FiltraParametros(String.Format("Estatus = 1")).Rows(0)("SucursalClienteVentaDireccion").ToString
+ Else
+ Dim CveCliente As Integer = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCliente", $"CveContrato = {ObjInventarios.DtResultados.Rows(0)("CveContrato").ToString.ToEntero}").ToEntero
+ Dim DtCliente As DataTable = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros($"CveCliente = {CveCliente}")
+ If DtCliente.Rows.Count > 0 Then
+ LblDireccionEnvio.Text = String.Format("{0},{1}, {2}", DtCliente.FiltroPrimeroValor("Direccion"), DtCliente.FiltroPrimeroValor("Colonia"), DtCliente.FiltroPrimeroValor("Ciudad"), DtCliente.FiltroPrimeroValor("Contacto"))
+ End If
+ End If
+
+ If ObjInventarios.DtResultados.Rows(0)("CveTrasladoEstatus").ToString.Contiene("1", "3") And Not ObjInventarios.DtResultados.Rows(0)("CveMovimientoAlmacen").ToString.ToEntero > 0 Then
+ LBCancelarTraslado.Visible = True
+ End If
+
+ If ObjInventarios.DtResultados.Rows(0)("CveTrasladoEstatus").ToString = "2" Then
+ DivCancelado.Visible = True
+ End If
+
+ If ObjInventarios.DtResultados.Rows(0)("CveMovimientoAlmacen").ToString.ToEntero > 0 Then
+ RowMovimiento.Visible = True
+ HLMovimiento.Text = ObjInventarios.DtResultados.Rows(0)("FolioAlmacen").ToString
+ HLMovimiento.NavigateUrl = $"/Inventarios/EntradasSalidas.aspx?CveMovimiento={ObjInventarios.DtResultados.Rows(0)("CveMovimientoAlmacen").ToString.ToEntero}"
+ Else
+ RowMovimiento.Visible = False
+ End If
+
+ If ObjInventarios.DtResultados.Rows(0)("Guia").ToString <> "" Then
+ TrGuia.Visible = True
+ TxtGuia.Text = ObjInventarios.DtResultados.Rows(0)("Guia").ToString
+ Else
+ TrGuia.Visible = False
+ End If
+
+ If UsuarioActual.TienePermisoProceso(313) Then
+ BtnEliminar.Visible = True
+ End If
+
+ BtnGuardar.Enabled = False
+ TxtObservaciones.Enabled = False
+ TxtFecha.Enabled = False
+ DdlPaqueteria.Enabled = False
+ ChkDesdeContrato.Enabled = False
+ DdlAlmacenDestino.Enabled = False
+ DdlAlmacenOrigen.Enabled = False
+ TxtGuia.Enabled = False
+ HLDesdeContrato.Enabled = False
+ LbAgregarPS.Enabled = False
+ DivInfo.Visible = True
+ LbImprimir.Visible = True
+ ImgExcel.Visible = True
+
+ LbAgregarPS.Visible = False
+ HLDesdeContrato.Visible = False
+
+
+ Dim EstatusAlmacen As Integer = ObjInventarios.DtResultados.Rows(0)("EstatusAlmacen").ToString().ToEntero
+ Dim CveUsuarioAutoriza As Integer = ObjInventarios.DtResultados.Rows(0)("CveUsuarioAutorizaDestino").ToString().ToEntero
+
+ If EstatusAlmacen > 0 Then
+
+
+ If UsuarioActual.CveUsuario = CveUsuarioAutoriza Then
+
+ If EstatusAlmacen = 1 Then
+
+
+ DivAutoriza.Visible = True
+ DVAutorizarBotones.Visible = True
+ DVAutorizaInformacion.Visible = False
+
+ ElseIf EstatusAlmacen.Contiene(2, 3) Then
+ DivAutoriza.Visible = True
+
+ DVAutorizarBotones.Visible = False
+ DVAutorizaInformacion.Visible = True
+
+ LblEstatusAutorizo.Text = If(EstatusAlmacen = 2, "Aceptado", "Rechazado")
+ LblUsaurioAutorizo.Text = ObjInventarios.DtResultados.Rows(0)("NombreAutoriza").ToString()
+ LblFechaAutoriza.Text = ObjInventarios.DtResultados.Rows(0)("FechaAutorizacion").ToString().ToDate().ToString("dd/MM/yyyy")
+ Else
+
+ End If
+
+ ElseIf EstatusAlmacen.Contiene(2, 3) Then
+
+ DivAutoriza.Visible = True
+
+ DVAutorizarBotones.Visible = False
+ DVAutorizaInformacion.Visible = True
+
+ LblEstatusAutorizo.Text = If(EstatusAlmacen = 2, "Aceptado", "Rechazado")
+ LblUsaurioAutorizo.Text = ObjInventarios.DtResultados.Rows(0)("NombreAutoriza").ToString()
+ LblFechaAutoriza.Text = ObjInventarios.DtResultados.Rows(0)("FechaAutorizacion").ToString().ToDate().ToString("dd/MM/yyyy")
+ GvDatos.Columns(6).Visible = False ' se oculta la columna de eliminar
+
+ End If
+
+
+ Else
+ DivAutoriza.Visible = False
+ End If
+
+
+
+ Else
+ Alert("Ocurrió un error al obtener los datos del traspaso.", TipoMensaje.MsgError)
+ End If
+
+ UpAutorizaciones.Update()
+
+ End If
+ ObjInventarios.Dispose()
+ ObjClientes.Dispose()
+ MostarSerieColumn()
+ End Sub
+#End Region
+
+
+#Region " AGREGAR "
+ Private Sub BtnAgregarModal_Click(sender As Object, e As EventArgs) Handles LbAgregarPS.Click
+
+ If ChkDesdeContrato.Checked Then
+ GvDatos.Columns(3).Visible = False
+ ChkDesdeContrato.Checked = False
+ TempDT.Rows.Clear()
+ GvDatos.DataSource = TempDT
+ GvDatos.DataBind()
+ UpDatos.Update()
+ End If
+
+ TxtCantidad.Text = ""
+ DdlUM.SelectedIndex = 0
+ LbContratos.Text = ""
+ DdlProductoServicio.SelectedText = ""
+ DdlProductoServicio.SelectedValue = "-1"
+ UpPS.Update()
+ UpDatos.Update()
+ RegistraScript(String.Format("$('#{0}').modal();", "ModalPS"))
+ End Sub
+ Private Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) Handles BtnAgregarPS.Click
+
+ If Not DdlProductoServicio.SelectedValue.ToEntero > 0 Then
+ Alert("Tiene que seleccionar un producto.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If Not AddPSTemporal() Then
+ Exit Sub
+ End If
+
+ 'If ObjInventario.GetExistenciasPS(DdlProductoServicio.SelectedValue.ToEntero, DdlUM.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, PendientePorSurtir:=1, Lote:=TxtLote.Text.ToString, FechaCaducidad:=TxtCaducidad.Text.ToString) >= TxtCantidad.Text.ToDouble Then
+
+ TxtCantidad.Text = ""
+ DdlProductoServicio.SelectedText = ""
+ DdlProductoServicio.SelectedValue = "-1"
+ DdlUM.SelectedIndex = 0
+ TxtCaducidad.Text = ""
+ TxtSerie.Text = ""
+ TxtLote.Text = ""
+
+ GvDatos.DataSource = TempDT
+ GvDatos.DataBind()
+
+
+ If ChkSeguirAgregando.Checked Then
+ TxtCantidad.Focus()
+ Else
+ RegistraScript("$('#ModalPS').hide();", "EscondeAgregar")
+ End If
+
+ UpPS.Update()
+ UpDatos.Update()
+
+ End Sub
+ Private Function AddPSTemporal() As Boolean
+ Dim Row As DataRow = TempDT.NewRow()
+ Dim Lote As String = "-1"
+ Dim FechaCaducidad As Date = MinFecha
+ Row("Cantidad") = TxtCantidad.Text.Trim.ToDouble
+ Row("CvePS") = DdlProductoServicio.SelectedValue.ToEntero
+ Row("CodigoPS") = DdlProductoServicio.SelectedText
+ Row("Precio") = 0
+ Row("CveUM") = DdlUM.SelectedValue.ToEntero
+ Row("UnidadMedida") = DdlUM.SelectedItem.Text
+ Row("Observaciones") = ""
+ Row("Lote") = "-1"
+ Row("Serie") = "-1"
+ Row("FechaCaducidad") = MinFecha
+
+ If divLote.Visible Then
+ Row("Lote") = TxtLote.Text
+ GvDatos.Columns(6).Visible = True
+ Lote = TxtLote.Text.ToString
+ End If
+
+
+ If divCaducidad.Visible Then
+ Row("FechaCaducidad") = TxtCaducidad.Text
+ GvDatos.Columns(7).Visible = True
+ FechaCaducidad = TxtCaducidad.Text.ToDate
+ RFVFechaCad.Enabled = True
+
+ Else
+ FechaCaducidad = MinFecha
+ End If
+
+
+ If Div4.Visible Then
+ Row("Serie") = TxtSerie.Text
+ GvDatos.Columns(5).Visible = True
+ End If
+
+
+
+ Dim ObjInventarios As New ClsInventarios
+ Dim Existencia As Double = ObjInventarios.GetExistenciasPS(DdlProductoServicio.SelectedValue.ToEntero, DdlUM.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), Lote:=Lote, FechaCaducidad:=FechaCaducidad)
+ ObjInventarios.Dispose()
+
+ If Existencia - TxtCantidad.Text.Trim.ToDouble - TempDT.SUM("Cantidad", $"CvePS = {DdlProductoServicio.SelectedValue.ToEntero} AND CveUM = {DdlUM.SelectedValue.ToEntero}") < 0 Then
+ If Existencia = 0 Then
+ Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia)
+ Else
+ Alert($"No hay existencia suficiente del producto. Solo hay en existencia: {Existencia - TempDT.SUM("Cantidad", $"CvePS = {DdlProductoServicio.SelectedValue.ToEntero} AND CveUM = {DdlUM.SelectedValue.ToEntero}")}", TipoMensaje.MsgAdvertencia)
+ End If
+ Return False
+ End If
+
+ TempDT.Rows.Add(Row)
+
+
+ Return True
+ End Function
+#End Region
+
+#Region " AGREGAR DESDE CONTRATO "
+ Private Sub ChkDesdeContrato_CheckedChanged(sender As Object, e As EventArgs) Handles ChkDesdeContrato.CheckedChanged
+
+ If ChkDesdeContrato.Checked Then
+ GvDatos.Columns(3).Visible = True
+ DdlContratos.SelectedIndex = 0
+ DdlClientes.SelectedIndex = 0
+
+ DdlDireccionEnvio.Items.Clear()
+ DivContratoDireccionEnvio.Visible = False
+
+ CargaExcel.Visible = False
+ GvContratos.DataBind()
+ UpContrato.Update()
+ RegistraScript(String.Format("$('#{0}').modal().show();", "ModalContrato"))
+ Else
+ LbContratos.Text = ""
+ End If
+
+ TempDT.Rows.Clear()
+ GvDatos.DataSource = TempDT
+ GvDatos.DataBind()
+ UpDatos.Update()
+
+ End Sub
+ Private Sub HLDesdeContrato_Click(sender As Object, e As EventArgs) Handles HLDesdeContrato.Click
+ DdlContratos.SelectedIndex = 0
+ DdlClientes.SelectedIndex = 0
+ DdlDireccionEnvio.Items.Clear()
+ DivContratoDireccionEnvio.Visible = False
+ UpContrato.Update()
+ RegistraScript(String.Format("$('#{0}').modal();", "ModalContrato"))
+ End Sub
+ Private Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientes.SelectedIndexChanged
+ DdlContratos.Items.Clear()
+
+ Dim ObjContratos As New ClsContratos
+ If ObjContratos.GetContratosEstatus(UsuarioActual.CveEmpresa) Then
+ Dim CveEstatusVigente = ObjContratos.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus = 1", Orderby:="CveContratoEstatus").ToEntero
+
+ DdlContratos.DataSource = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltraParametros($" CveCliente = {DdlClientes.SelectedValue.ToEntero} AND CveContratosEstatus = {CveEstatusVigente}")
+
+ 'If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, DdlClientes.SelectedValue.ToEntero, CveEstatusVigente) Then
+ ' DdlContratos.DataSource = ObjContratos.DtResultados
+ 'End If
+
+ End If
+ ObjContratos.Dispose()
+
+ DdlContratos.DataBind()
+ DdlContratos.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ GvContratos.DataBind()
+
+ Dim ObjClientes As New ClsClientes
+
+ DdlDireccionEnvio.Items.Clear()
+ If DdlClientes.SelectedValue <> "-1" And ObjClientes.DireccionEnvioGet(-1, DdlClientes.SelectedValue.ToEntero, -1) And ObjClientes.DtResultados.Rows.Count > 0 Then
+ DivContratoDireccionEnvio.Visible = True
+ DdlDireccionEnvio.DataSource = ObjClientes.DtResultados.FiltraParametros(String.Format("Estatus = 1"))
+ DdlDireccionEnvio.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ DdlDireccionEnvio.DataBind()
+ Else
+ DivContratoDireccionEnvio.Visible = False
+ End If
+ ObjClientes.Dispose()
+
+ UpContrato.Update()
+ End Sub
+ Private Sub DdlContratos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlContratos.SelectedIndexChanged
+ Dim ObjContratos As New ClsContratos
+ If ObjContratos.GetContratosDetalle(DdlContratos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
+ GvContratos.DataSource = ObjContratos.DtResultados
+ GvContratos.DataBind()
+ If ObjContratos.DtResultados.Rows.Count > 0 Then
+ CargaExcel.Visible = True
+ Else
+ CargaExcel.Visible = False
+ End If
+ End If
+ ObjContratos.Dispose()
+ UpContrato.Update()
+ End Sub
+ Private Sub BtnAgregarContrato_Click(sender As Object, e As EventArgs) Handles BtnAgregarContrato.Click
+
+ TempDT.Rows.Clear()
+
+ Dim ObjInventarios As New ClsInventarios
+ Dim Existencia = 0.0
+ Dim TieneErrorExistencia = False
+ Dim MensajeExistencia As New StringBuilder
+ MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:
")
+ Dim CodigoPS As String = ""
+
+ For Each row As GridViewRow In GvContratos.Rows
+ If row.FCTextBox("TxtCantContrato").Text.Trim.ToDouble > 0 Then
+ Dim RowTemp As DataRow = TempDT.NewRow()
+ RowTemp("Cantidad") = row.FCTextBox("TxtCantContrato").Text.Trim.ToDouble
+ RowTemp("CvePS") = row.DataKey("CvePS").ToEntero
+ RowTemp("CodigoPS") = row.DataKey("CodigoPS")
+ RowTemp("Precio") = row.DataKey("PU")
+ RowTemp("CveUM") = row.DataKey("CveUM").ToEntero
+ RowTemp("UnidadMedida") = row.DataKey("UM")
+ RowTemp("Observaciones") = ""
+ RowTemp("Lote") = "-1"
+ RowTemp("FechaCaducidad") = MinFecha
+ 'RowTemp("CveDireccionEnvio") = DdlDireccionEnvio.SelectedValue
+ 'RowTemp("DireccionEnvio") = IIf(DdlDireccionEnvio.SelectedValue = "-1", "", DdlDireccionEnvio.SelectedItem)
+ RowTemp("CveContratoDetalle") = row.DataKey("CveContratoDetalle")
+ CodigoPS = RowTemp("CodigoPS").ToString
+
+
+ Existencia = ObjInventarios.GetExistenciasPS(row.DataKey("CvePS").ToEntero, row.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"))
+ If Existencia - row.FCTextBox("TxtCantContrato").Text.Trim.ToDouble - TempDT.SUM("Cantidad", $"CvePS = {row.DataKey("CvePS").ToEntero} AND CveUM = {row.DataKey("CveUM").ToEntero}") < 0 Then
+ MensajeExistencia.AppendFormat("
-
{0}. Existencia: {1}", CodigoPS, Existencia)
+ TieneErrorExistencia = True
+ Continue For
+ End If
+
+ TempDT.Rows.Add(RowTemp)
+ End If
+ Next
+
+ If TieneErrorExistencia Then
+ Alert(MensajeExistencia.ToString, TipoMensaje.MsgAdvertencia)
+ ObjInventarios.Dispose()
+ Exit Sub
+ Else
+ CveDireccionEnvio = DdlDireccionEnvio.SelectedValue.ToEntero
+ End If
+
+ ObjInventarios.Dispose()
+ GvDatos.DataSource = TempDT
+ GvDatos.DataBind()
+ CargaTextoContrato()
+ RegistraScript(String.Format("$('#{0}').modal().hide();", "ModalContrato"))
+
+ UpDatos.Update()
+
+ End Sub
+#End Region
+
+
+#Region " GV DATOS "
+ Private Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
+ EliminarRow(e.RowIndex)
+ End Sub
+ Private Sub EliminarRow(RowIndex As Integer)
+ TempDT.Rows(RowIndex).Delete()
+ TempDT.AcceptChanges()
+ GvDatos.DataSource = TempDT
+ GvDatos.DataBind()
+ UpDatos.Update()
+ End Sub
+
+
+#End Region
+
+
+#Region " GUARDAR "
+ Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
+
+ If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then
+ Alert("Los almacenes de origen y destino no pueden ser el mismo. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ If Not GvDatos.Rows.Count > 0 Then
+ Alert("No se ha seleccionado ningún Producto para trasladar.", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+
+ Dim CveUsuarioAutoriza As Integer = -1
+ Dim EstatusAlmacen As Integer = 2
+ 'VERIFICA EXISTENCIAS
+ Dim ObjInventarios As New ClsInventarios
+ Dim Existencia As Decimal = 0
+ Dim TieneErrorExistencia As Boolean = False
+ Dim MensajeExistencia As New StringBuilder
+ MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:
")
+ Dim CodigoPS As String = ""
+
+
+
+ 'Aqui poner permiso para poder evitar permiso de traslado
+ If ObjInventarios.GetAlmacenes(-1, -1, UsuarioActual.CveEmpresa, -1) Then
+
+ If ObjInventarios.DtResultados.Rows.Count > 0 Then
+
+ CveUsuarioAutoriza = If(ObjInventarios.DtResultados.FiltraParametros($"CveAlmacen = {DdlAlmacenDestino.SelectedValue}")(0)("CveUsuarioAutoriza").ToString.ToEntero > 0, ObjInventarios.DtResultados.FiltraParametros($"CveAlmacen = {DdlAlmacenDestino.SelectedValue}")(0)("CveUsuarioAutoriza").ToString.ToEntero, -1)
+ If CveUsuarioAutoriza > 0 Then
+ EstatusAlmacen = 1
+ End If
+
+ Else
+ CveUsuarioAutoriza = -1
+ End If
+ End If
+
+
+
+
+ For Each row As GridViewRow In GvDatos.Rows
+ CodigoPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=row.DataKey("CvePS").ToEntero).FiltroPrimeroValor("PSCodigo", "")
+ Existencia = ObjInventarios.GetExistenciasPS(row.DataKey("CvePS").ToEntero, row.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), Lote:=row.DataKey("Lote").ToString, FechaCaducidad:=row.DataKey("FechaCaducidad").ToString.ToDate)
+ If Existencia - TempDT.SUM("Cantidad", $"CvePS = {row.DataKey("CvePS").ToEntero} AND CveUM = {row.DataKey("CveUM").ToEntero}") < 0 Then
+ MensajeExistencia.AppendFormat("
-
{0}. Existencia: {1}", CodigoPS, Existencia)
+ TieneErrorExistencia = True
+ End If
+ Next
+
+ If TieneErrorExistencia Then
+ Alert(MensajeExistencia.ToString, TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+
+ ObjInventarios.IniciaTransacSQL()
+ Dim TieneError As Boolean = False
+
+ Dim CveContrato As Integer = 0
+ Dim Guia As String = ""
+ If TxtGuia.Text <> "" Then Guia = TxtGuia.Text Else Guia = ""
+ If DdlContratos.SelectedValue.ToEntero > 0 Then CveContrato = DdlContratos.SelectedValue.ToEntero Else CveContrato = -1
+
+ Dim Estatus As Integer = -1
+
+ If UsuarioActual.Empresa.Funcionalidad(105) <> "" Then
+ Estatus = 1
+ Else
+ Estatus = 3
+ End If
+
+ Dim Folio As Integer = ObjInventarios.AddTrasladoSolicitud(TxtObservaciones.Text.Trim, DdlAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero, Estatus, -1, TxtFecha.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato, Guia:=Guia, CvePaqueteria:=DdlPaqueteria.SelectedValue.ToEntero, CveDireccionEnvio:=CveDireccionEnvio, EstatusAlmacen:=EstatusAlmacen)
+
+ If Folio > 0 Then
+ CveTraspasoSolicitud = ObjInventarios.CveTraspasoSolicitud
+ Else
+ TieneError = True
+ End If
+
+ If Not TieneError Then
+ For Each Row As GridViewRow In GvDatos.Rows
+ Dim CveUM As Integer = Row.DataKey("CveUM").ToEntero
+ Dim CvePS As Integer = Row.DataKey("CvePS").ToEntero
+ Dim Cantidad As Integer = Row.DataKey("Cantidad").ToEntero
+ Dim Precio As Decimal = Row.DataKey("Precio").ToDecimal
+ Dim Observaciones As String = Row.DataKey("Observaciones")
+ Dim CveContratoDetalle As Integer = Row.DataKey("CveContratoDetalle").ToEntero
+ Dim Serie As String = Row.DataKey("Serie")
+ Dim Lote As String = Row.DataKey("Lote")
+ Dim FechaCaducidad As Date = Row.DataKey("FechaCaducidad").ToDate
+
+ If Not ObjInventarios.AddTrasladoSolicitudDetalle(CveTraspasoSolicitud, Cantidad, CveUM, CvePS, Precio, Observaciones, CveContratoDetalle, Serie, Lote, FechaCaducidad) Then
+ TieneError = True
+ Exit For
+ End If
+ Next
+ End If
+
+
+ If TieneError = False Then
+ ObjInventarios.Commit()
+ Alert($"El Traspaso se guardó correctamente con el folio #:
{Folio}.", TipoMensaje.MsgInformacion, $"document.location.href=""/Inventarios/TrasladoSolicitud.aspx?CveTraspasoSolicitud={CveTraspasoSolicitud}""")
+
+ If CveUsuarioAutoriza > 0 Then
+ MandaCorreoAutorizacion(Folio, CveTraspasoSolicitud, CveUsuarioAutoriza)
+ End If
+
+ Else
+ ObjInventarios.RollBack()
+ Alert("Ocurrió un Error al guardar el traspaso.", TipoMensaje.MsgError)
+ End If
+ ObjInventarios.Dispose()
+
+ End Sub
+#End Region
+
+
+#Region " ELIMINAR - CANCELAR "
+ Private Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
+ Dim ObjInventarios As New ClsInventarios
+ If ObjInventarios.RemoveTrasladoSolicitud(CveTraspasoSolicitud, UsuarioActual.CveEmpresa) Then
+ Alert("Se eliminó correctamente el Traspaso.", TipoMensaje.MsgInformacion, "document.location.href=""/Inventarios/TrasladoSolicitud.aspx""")
+ End If
+ ObjInventarios.Dispose()
+ End Sub
+ Protected Sub LBCancelarTraslado_Click(sender As Object, e As EventArgs)
+ Dim ObjInventarios As New ClsInventarios
+
+ If ObjInventarios.UpdateTraspasoSolicitudEstatus(CveTraspasoSolicitud, 2) Then
+ LBCancelarTraslado.Visible = False
+ Alert("Se canceló correctamente la solicitud de traslado.", TipoMensaje.MsgInformacion)
+ End If
+
+ ObjInventarios.Dispose()
+ End Sub
+#End Region
+
+
+#Region " IMPRESION "
+ Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles LbImprimir.Click
+ GenerarPDF()
+ End Sub
+ Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
+ GenerarPDF("Excel")
+ End Sub
+ Private Sub GenerarPDF(Optional Formato As String = "PDF")
+
+
+ Dim ObjInventarios As New ClsInventarios
+ Dim ObjClientes As New ClsClientes
+
+
+ Dim CveTraspasoSolicitud As Integer = Request("CveTraspasoSolicitud").ToEntero
+ If ObjInventarios.AddTrasladoSolicitudGet(CveTraspasoSolicitud, UsuarioActual.CveEmpresa) Then
+ If ObjInventarios.DtResultados.Rows.Count > 0 Then
+ Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
+ Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
+ Dim dt As DataTable = ObjInventarios.DtResultados
+
+ Dim DTCliente As New DataTable
+ Dim CveCliente As Integer = 0
+ Dim CveDireccionEnvio As Integer = 0
+ Dim ClienteNombre = "", EnvioContacto = "", EnvioDireccion = "", EnvioColonia = "", EnvioCiudad = "", EnvioEstado = "", ClientePais = "", EnvioCP = "", Contrato = "",
+ Paqueteria = "", NumContrato = ""
+
+
+
+ Dim CveContrato As Integer = ObjInventarios.DtResultados.FiltroPrimeroValor("CveContrato").ToString.ToEntero
+ If CveContrato > 0 Then
+ Contrato = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("DescripcionContrato", $"CveContrato={CveContrato}")
+ NumContrato = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("NumeroContrato", $"CveContrato={CveContrato} ")
+ CveCliente = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCliente", $"CveContrato = {CveContrato}").ToEntero
+ CveDireccionEnvio = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveDireccionEnvio", $"CveContrato = {CveContrato}").ToEntero
+
+
+ If CveCliente > 0 Then
+
+ DTCliente = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros($"CveCliente = {CveCliente}")
+
+ 'Si el traslado tiene cvedireccionenvio trae sus datos
+ If Me.CveDireccionEnvio > 0 And ObjClientes.DireccionEnvioGet(Me.CveDireccionEnvio, DdlClientes.SelectedValue.ToEntero, -1) And ObjClientes.DtResultados.Rows.Count > 0 Then
+
+ ClienteNombre = DTCliente.FiltroPrimeroValor("Nombre")
+ 'ClientePais = DTCliente.FiltroPrimeroValor("PAIS")
+ EnvioContacto = ObjClientes.DtResultados.Rows(0)("EnvioContacto").ToString '??
+
+ EnvioDireccion = ObjClientes.DtResultados.Rows(0)("EnvioDireccion").ToString
+ EnvioColonia = ObjClientes.DtResultados.Rows(0)("EnvioColonia").ToString
+ EnvioCiudad = ObjClientes.DtResultados.Rows(0)("EnvioCiudad").ToString
+ EnvioCP = ObjClientes.DtResultados.Rows(0)("EnvioCP").ToString
+ EnvioEstado = ObjClientes.DtResultados.Rows(0)("EnvioEstado").ToString
+ Else
+ '25/04/2018 - Si el trasladosolicitud no tiene cvedireccion envio asignada, va por la el cliente
+ Dim ObjVentas As New ClsClientes
+ If ObjVentas.DireccionEnvioGet(CveDireccionEnvio, -1, -1) Then
+ If ObjVentas.DtResultados.Rows.Count > 0 Then
+ ClienteNombre = DTCliente.FiltroPrimeroValor("Nombre")
+ ClientePais = DTCliente.FiltroPrimeroValor("PAIS")
+ EnvioContacto = ObjVentas.DtResultados.Rows(0)("EnvioContacto").ToString
+ EnvioDireccion = ObjVentas.DtResultados.Rows(0)("EnvioDireccion").ToString
+ EnvioColonia = ObjVentas.DtResultados.Rows(0)("EnvioColonia").ToString
+ EnvioCiudad = ObjVentas.DtResultados.Rows(0)("EnvioCiudad").ToString
+ EnvioCP = ObjVentas.DtResultados.Rows(0)("EnvioCP").ToString
+ EnvioEstado = ObjVentas.DtResultados.Rows(0)("EnvioEstado").ToString
+ Else
+ ClienteNombre = DTCliente.FiltroPrimeroValor("Nombre")
+ EnvioContacto = DTCliente.FiltroPrimeroValor("Contacto")
+ EnvioDireccion = DTCliente.FiltroPrimeroValor("Direccion")
+ EnvioColonia = DTCliente.FiltroPrimeroValor("Colonia")
+ EnvioCiudad = DTCliente.FiltroPrimeroValor("Ciudad")
+ EnvioEstado = DTCliente.FiltroPrimeroValor("Estado")
+ ClientePais = DTCliente.FiltroPrimeroValor("PAIS")
+ EnvioCP = DTCliente.FiltroPrimeroValor("CP")
+ End If
+ End If
+ ObjVentas.Dispose()
+ End If
+ End If
+ End If
+
+
+ Dim params As New List(Of ReportParameter)
+ params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
+ params.Add(New ReportParameter("FechaImpresion", NowADS().ToShortDateString))
+ params.Add(New ReportParameter("Fecha", TxtFecha.Text.Substring(0, 10)))
+ params.Add(New ReportParameter("AlmacenOrigen", DdlAlmacenOrigen.SelectedItem.Text))
+ params.Add(New ReportParameter("AlmacenDestino", DdlAlmacenDestino.SelectedItem.Text))
+ params.Add(New ReportParameter("Guia", TxtGuia.Text))
+ params.Add(New ReportParameter("UsuarioSolicito", LblUsuario.Text))
+ params.Add(New ReportParameter("Folio", LbFolio.Text))
+ params.Add(New ReportParameter("Observaciones", TxtObservaciones.Text))
+ params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario))
+ 'NUEVOS
+ params.Add(New ReportParameter("ClienteNombre", ClienteNombre))
+ params.Add(New ReportParameter("EnvioContacto", EnvioContacto))
+ params.Add(New ReportParameter("EnvioDireccion", EnvioDireccion))
+ params.Add(New ReportParameter("EnvioColonia", EnvioColonia))
+ params.Add(New ReportParameter("EnvioCiudad", EnvioCiudad))
+ params.Add(New ReportParameter("EnvioEstado", EnvioEstado))
+ params.Add(New ReportParameter("ClientePais", ClientePais))
+ params.Add(New ReportParameter("EnvioCP", EnvioCP))
+ params.Add(New ReportParameter("Contrato", Contrato))
+ params.Add(New ReportParameter("Paqueteria", DdlPaqueteria.SelectedItem.Text))
+ params.Add(New ReportParameter("NumeroContrato", NumContrato))
+ params.Add(New ReportParameter("FechaEnvio", TxtFecha.Text.Substring(0, 10)))
+ params.Add(New ReportParameter("TieneSerie", GvDatos.Columns(5).Visible.ToString()))
+
+ Dim RutaFormato As String = String.Format("Empresas\{0}\Formatos\RepTrasladoSolicitud.rdlc", UsuarioActual.CveEmpresa)
+ Dim RutaFormatoDefault As String = String.Format("Empresas\Grales\Formatos\RepTrasladoSolicitud.rdlc")
+
+ Dim Archivo As New System.IO.FileInfo(RutaFormato)
+
+
+ params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
+
+ If UsuarioActual.CveEmpresa = 72 Or UsuarioActual.CveEmpresa = 1 Then
+ ImprimirPDF(String.Format("{0}Formatos\RepTrasladoSolicitud.rdlc", UsuarioActual.Empresa.Ruta), dt, params, String.Format("Solicitud de Traslado - {0}", NowADS().ToDateTime.ToShortDateString), Formato:=Formato)
+ Else
+ ImprimirPDF(RutaFormatoDefault, dt, params, String.Format("Solicitud de Traslado - {0}", NowADS().ToDateTime.ToShortDateString), Formato:=Formato)
+ End If
+
+ Else
+ Alert("Ocurrió un error al obtener los datos del traspaso.", TipoMensaje.MsgError)
+ End If
+
+ End If
+ ObjInventarios.Dispose()
+ ObjClientes.Dispose()
+
+ End Sub
+
+#End Region
+
+
+#Region "Carga Excel"
+ Protected Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
+ If TxtExcel.getfiles().Archivos.Count > 0 Then
+ Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
+ Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.path
+ Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
+ CargarArchivo(Directorio, file.filename, Tipo)
+ Else
+ Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
+ End If
+ End Sub
+
+
+ Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
+ Dim dt As New DataTable
+ Dim Conexion As Odbc.OdbcConnection = Nothing
+ Dim ErrorArchivo = False
+ Dim ErrorExcel = False
+ Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
+ Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
+ Dim objDbAdapter As Common.DbDataAdapter = objDbFactory.CreateDataAdapter()
+ Dim objDbConnection As Common.DbConnection = objDbFactory.CreateConnection()
+ objDbConnection.ConnectionString = strConnString
+ objDbConnection.Open()
+ Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
+ Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
+ Try
+ Select Case Tipo
+ Case "CSV"
+ Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;")
+ Conexion.Open()
+ Dim cmd = Conexion.CreateCommand()
+ cmd.CommandType = CommandType.Text
+ cmd.CommandText = $"SELECT * FROM [{FileName}]"
+ Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
+ DataAdapter.Fill(dt)
+ Case "EXCEL"
+ Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
+ Conexion.Open()
+ Dim cmd = Conexion.CreateCommand()
+ cmd.CommandType = CommandType.Text
+ cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
+ Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
+ DataAdapter.Fill(dt)
+ Case Else
+ Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
+ Exit Sub
+ End Select
+ Catch ex As Exception
+ ErrorArchivo = True
+ OnError("Ocurrio un error al leer el archivo
" & ex.Message, ex)
+ End Try
+ Conexion.Close()
+
+
+ Dim DTContratosTemporal As New DataTable
+ Dim ObjContratos As New ClsContratos
+ If ObjContratos.GetContratosDetalle(DdlContratos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
+ DTContratosTemporal = ObjContratos.DtResultados
+ End If
+ ObjContratos.Dispose()
+
+ If DTContratosTemporal IsNot Nothing Then
+ If Not ErrorArchivo Then
+ For Each Row As DataRow In dt.FiltraParametros("Cantidad > 0").Rows
+ Dim Cantidad As String = Row("Cantidad").ToString
+ Dim Codigo As String = Row("Codigo").ToString.Trim
+ Dim Observaciones As String = Row("Observaciones").ToString
+ Dim CodigoPS As String = ""
+ Dim CodigoContrato As String = ""
+
+ CodigoPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("PSCodigo", $"Codigo = '{Codigo}'")
+
+ CodigoContrato = DTContratosTemporal.FiltroPrimeroValor("Codigo", $"Codigo = '{Codigo}'").ToString
+
+ If CodigoContrato <> "" Then
+ Dim RowTemp As DataRow = TempDT.NewRow()
+ RowTemp("Cantidad") = Cantidad
+ RowTemp("CvePS") = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", $"Codigo = '{Codigo}'").ToString.ToEntero
+ RowTemp("CodigoPS") = CodigoPS
+ RowTemp("Observaciones") = Observaciones
+
+ Dim ObjInventarios As New ClsInventarios
+ Dim Existencia As Double = ObjInventarios.GetExistenciasPS(RowTemp("CvePS").ToString.ToEntero, RowTemp("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"))
+ ObjInventarios.Dispose()
+
+ If Existencia - RowTemp("Cantidad").ToString.ToDouble - TempDT.SUM("Cantidad", $"CvePS = {RowTemp("CvePS").ToString.ToEntero} AND CveUM = {RowTemp("CveUM").ToString.ToEntero}") < 0 Then
+ If Existencia = 0 Then
+ Alert($"No hay existencia del producto: {CodigoPS}", TipoMensaje.MsgAdvertencia)
+ Else
+ Alert($"No hay existencia suficiente del producto: {CodigoPS}, Solo hay en existencia: {Existencia - TempDT.SUM("Cantidad", $"CvePS = {RowTemp("CvePS").ToString.ToEntero} AND CveUM = {RowTemp("CveUM").ToString.ToEntero}")}", TipoMensaje.MsgAdvertencia)
+ End If
+ End If
+ TempDT.Rows.Add(RowTemp)
+ Else
+ Alert($"El Código: ""
{CodigoPS}"", no se encuentra en el contrato.", TipoMensaje.MsgAdvertencia)
+ Exit For
+ End If
+
+ Next
+
+ GvDatos.DataSource = TempDT
+ GvDatos.DataBind()
+ CargaTextoContrato()
+ UpDatos.Update()
+ RegistraScript(String.Format("$('#{0}').modal().hide();", "ModalContrato"))
+
+ End If
+ Else
+ Alert($"Ha ocurrido un error al cargar el contrato.", TipoMensaje.MsgError)
+
+ End If
+
+
+ End Sub
+
+
+ Public Sub CargaTextoContrato()
+ If DdlContratos.SelectedValue.ToEntero > 0 Then
+ LbContratos.Text = DdlContratos.SelectedItem.Text
+ Else
+ LbContratos.Text = ""
+ End If
+ UpDatos.Update()
+ End Sub
+
+ Private Sub LbContratos_Click(sender As Object, e As EventArgs) Handles LbContratos.Click
+ RegistraScript(String.Format("$('#{0}').modal().show();", "ModalContrato"))
+ End Sub
+
+ Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
+ Dim Directorio As String = ""
+ Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SolicitudTraslado.xlsx"
+ Dim Archivo As New IO.FileInfo(Directorio)
+ If Archivo.Exists Then
+ Response.Clear()
+ Response.ClearHeaders()
+ Response.ClearContent()
+ Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
+ Response.AddHeader("Content-Length", Archivo.Length.ToString())
+ Response.ContentType = "text/plain"
+ Response.Flush()
+ Response.TransmitFile(Archivo.FullName)
+ Response.End()
+ End If
+ End Sub
+
+
+#End Region
+
+
+ Protected Sub DdlProductoServicio_selectedindexchange(sender As Object, e As EventArgs)
+ If DdlProductoServicio.SelectedValue.ToEntero > 0 Then
+ Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProductoServicio.SelectedValue.ToEntero).FiltroPrimero("")
+ DdlUM.Items.Clear()
+ If UsuarioActual.Empresa.UsaInventarios Then
+ DdlUM.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductoServicio.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
+ Else
+ DdlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
+ End If
+ DdlUM.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ DdlUM.SelectedValue = "-1"
+ DdlUM.DataBind()
+ DdlUM.SelectedValueExist(drPS("CveUnidadMedida").ToString)
+ AplicaSerie = drPS("AplicaSerie").ToString = "True"
+ Div4.Visible = AplicaSerie
+
+ AplicaLote = drPS("AplicaLote").ToString = "True"
+ divLote.Visible = AplicaLote
+ RFVLote.Enabled = AplicaLote
+
+ AplicaCaducidad = drPS("AplicaCaducidad").ToString = "True"
+ divCaducidad.Visible = AplicaCaducidad
+ divCaducidad2.Visible = AplicaCaducidad
+ RFVFechaCad.Enabled = AplicaCaducidad
+
+ End If
+ UpPS.Update()
+ UpDatos.Update()
+ End Sub
+
+
+ Protected Sub LnkAceptarTraslado_Click(sender As Object, e As EventArgs)
+
+ Dim ObjInven As New ClsInventarios
+ If ObjInven.UpdateTrasladoAutorizar(CveTraspasoSolicitud, UsuarioActual.CveEmpresa, 2, UsuarioActual.CveUsuario, NowADS()) Then
+ Alert("Autorizado correctamente.")
+ End If
+ ObjInven.Dispose()
+
+ CargaDatos()
+
+ End Sub
+
+ Protected Sub LnkRechazarTraslado_Click(sender As Object, e As EventArgs)
+
+ TxtMotivoRechazo.Text = ""
+ UpModalRechazo.Update()
+ RegistraScript("$('#ModalRechazarTraslado').modal();")
+
+ End Sub
+
+
+ Protected Sub BtnModalRechazo_Click(sender As Object, e As EventArgs)
+ RechazarTraslado()
+ End Sub
+
+ Private Sub RechazarTraslado()
+
+ Dim ErrorProceso As Boolean = False
+
+ If TxtMotivoRechazo.Text.Trim.Length.ToEntero = 0 Then
+ Alert("El motivo de rechazo es necesario", TipoMensaje.MsgAdvertencia)
+ End If
+
+
+ Dim ObjInven As New ClsInventarios
+
+ If ObjInven.UpdateTrasladoAutorizar(CveTraspasoSolicitud, UsuarioActual.CveEmpresa, 3, UsuarioActual.CveUsuario, NowADS()) Then
+ Alert("Rechazado correctamente.")
+ ErrorProceso = False
+ Else
+ ErrorProceso = True
+ End If
+
+ ObjInven.Dispose()
+
+ If Not ErrorProceso Then
+ MandaCorreoRechazo(LbFolio.Text.ToEntero, CveTraspasoSolicitud, CveUsuarioSolicita, TxtMotivoRechazo.Text)
+ CargaDatos()
+ RegistraScript("$('#ModalRechazarTraslado').modal('hide');")
+ End If
+
+ End Sub
+
+
+ Private Sub MandaCorreoRechazo(Folio As Integer, CveTraspasoSolicitud As Integer, CveUsuarioSolicita As Integer, MotivoRechazo As String)
+
+ Dim SB As New StringBuilder
+
+ Dim CorreoDestino As String = GlobalDTUsuarios(CveUsuarioSolicita)(0)("Correo").ToString.Trim
+
+
+ If CorreoDestino.Length > 0 Then
+
+
+ SB.AppendLine($"
Se ha rechazado la solicitud de traspaso con folio {Folio}, el traspaso fue rechazado por el usuario {UsuarioActual.Nombre }, el traspaso fue rechazado por el motivo: {MotivoRechazo}
")
+
+
+
+ SB.AppendLine("
")
+ SB.AppendLine("
")
+ SB.AppendLine("| Cantidad | U.M. | Producto | Observaciones |
")
+
+ For Each GvRow As GridViewRow In GvDatos.Rows
+
+ If GvRow.RowType = DataControlRowType.DataRow Then
+ SB.AppendLine($" | {GvRow.DataKey("Cantidad")} | {GvRow.DataKey("UnidadMedida")} | {GvRow.DataKey("CodigoPS")} | {GvRow.DataKey("Observaciones")} |
")
+ End If
+
+ Next
+ SB.AppendLine("
")
+ SB.AppendLine("
")
+
+ SB.AppendLine($"
Ir a solicitud de traspaso folio {Folio}")
+
+
+
+ Dim MandaCorre As New ClsSisMail
+ MandaCorre.SendMail(ClsPaginas.EmpresaNotificaciones, CorreoDestino, $"Rechazo de Autorización de traspaso #{Folio}", SB.ToString, Displayname:="SIG Notificaciones: Rechazo de Traspaso")
+
+ End If
+
+ End Sub
+
+
+ Private Sub MandaCorreoAutorizacion(Folio As Integer, CveTraspasoSolicitud As Integer, CveUsuarioAutoriza As Integer)
+
+ Dim SB As New StringBuilder
+
+ Dim CorreoDestino As String = GlobalDTUsuarios(CveUsuarioAutoriza)(0)("Correo").ToString.Trim
+
+
+ If CorreoDestino.Length > 0 Then
+
+
+
+ SB.AppendLine($"
Se ha registrado una solicitud de traspaso de {DdlAlmacenOrigen.SelectedItem.Text} a {DdlAlmacenDestino.SelectedItem.Text}, con los siguientes productos.
")
+
+
+
+ SB.AppendLine("
")
+ SB.AppendLine("
")
+ SB.AppendLine("| Cantidad | U.M. | Producto | Observaciones |
")
+
+ For Each GvRow As GridViewRow In GvDatos.Rows
+
+ If GvRow.RowType = DataControlRowType.DataRow Then
+ SB.AppendLine($" | {GvRow.DataKey("Cantidad")} | {GvRow.DataKey("UnidadMedida")} | {GvRow.DataKey("CodigoPS")} | {GvRow.DataKey("Observaciones")} |
")
+ End If
+
+ Next
+ SB.AppendLine("
")
+ SB.AppendLine("
")
+ SB.AppendLine($"
Ir a solicitud de traspaso para autorización")
+
+
+
+ Dim MandaCorre As New ClsSisMail
+ MandaCorre.SendMail(ClsPaginas.EmpresaNotificaciones, CorreoDestino, $"Solicitud de Autorización de traspaso #{Folio}", SB.ToString, Displayname:="SIG Notificaciones: Solicitud de Traspaso")
+
+ End If
+
+ End Sub
+
+ Public Sub MostarSerieColumn()
+ Dim Mostrar As Boolean = False
+ For Each row As GridViewRow In GvDatos.Rows
+ Dim Serie As String = row.DataKey("Serie").ToString
+ If Serie IsNot "-1" And Serie IsNot "" Then
+ Mostrar = True
+ Exit For
+ End If
+ Next
+ GvDatos.Columns(5).Visible = Mostrar
+ 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.FCLiteral("LtlSerie").ToString = "-1" Then
+ e.Row.FCLiteral("LtlSerie").Text = ""
+ End If
+
+ If e.Row.FCLiteral("LtlLote").ToString = "-1" Then
+ e.Row.FCLiteral("LtlLote").Text = ""
+ End If
+
+ If e.Row.FCLiteral("LtlFechaCaducidad").ToString.ToDate = MinFecha Then
+ e.Row.FCLiteral("LtlFechaCaducidad").Text = ""
+ End If
+
+ End If
+
+
+ End Sub
+End Class
+