Carga de movs de almacen desde excel, para ajustes de secciones y fechas de caducidad
This commit is contained in:
@@ -1133,7 +1133,7 @@ Public Class ClsInventarios
|
|||||||
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
Public Function GetMovimientosDetalle(CveMovimiento As Integer, CveEmpresa As Integer, Optional CveCompra As Integer = -1) As Boolean
|
Public Function GetMovimientosDetalle(CveMovimiento As Integer, CveEmpresa As Integer, Optional CveCompra As Integer = -1, Optional CveMovimientoDetalle As Integer = -1) As Boolean
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
DataAdapter("PA_Inv_MovimientosDetalleGet")
|
DataAdapter("PA_Inv_MovimientosDetalleGet")
|
||||||
|
|
||||||
@@ -1141,6 +1141,7 @@ Public Class ClsInventarios
|
|||||||
.Add("@CveMovimiento", SqlDbType.Int).Value = CveMovimiento
|
.Add("@CveMovimiento", SqlDbType.Int).Value = CveMovimiento
|
||||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||||
.Add("@CveCompra", SqlDbType.Int).Value = CveCompra
|
.Add("@CveCompra", SqlDbType.Int).Value = CveCompra
|
||||||
|
.Add("@CveMovimientoDetalle", SqlDbType.Int).Value = CveMovimientoDetalle
|
||||||
End With
|
End With
|
||||||
Try
|
Try
|
||||||
SqlAdapter.Fill(Data)
|
SqlAdapter.Fill(Data)
|
||||||
|
|||||||
@@ -1181,11 +1181,11 @@ Public Class ClsPaginas
|
|||||||
' Application("GlobalDTProductosServicios") = value
|
' Application("GlobalDTProductosServicios") = value
|
||||||
' End Set
|
' End Set
|
||||||
'End Property
|
'End Property
|
||||||
ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1, Optional Estatus As Integer = -1) As DataTable
|
ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1, Optional Estatus As Integer = -1, Optional Codigo As String = "-1") As DataTable
|
||||||
Get
|
Get
|
||||||
Dim ObjPS As New ClsProductosServicios
|
Dim ObjPS As New ClsProductosServicios
|
||||||
|
|
||||||
If ObjPS.GetPS(CvePS, -1, CveEmpresa, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta, pEstado:=Estatus) Then
|
If ObjPS.GetPS(CvePS, -1, CveEmpresa, Codigo:=Codigo, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta, pEstado:=Estatus) Then
|
||||||
GlobalDTPS = ObjPS.DtResultados
|
GlobalDTPS = ObjPS.DtResultados
|
||||||
Else
|
Else
|
||||||
GlobalDTPS = Nothing
|
GlobalDTPS = Nothing
|
||||||
|
|||||||
@@ -1,70 +1,124 @@
|
|||||||
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="AjustesSeccionAlmacen.aspx.vb" Inherits="Inventarios_AjustesSeccionAlmacen" %>
|
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="AjustesSeccionAlmacen.aspx.vb" Inherits="Inventarios_AjustesSeccionAlmacen" %>
|
||||||
|
|
||||||
<asp:Content ID="Content1" ContentPlaceHolderID="CP" Runat="Server">
|
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content2" ContentPlaceHolderID="Css" Runat="Server">
|
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content3" ContentPlaceHolderID="E" Runat="Server">
|
<asp:Content ID="Content3" ContentPlaceHolderID="E" runat="Server">
|
||||||
Ajustes de Productos en Secciones de Almacen
|
Ajustes de Productos en Secciones de Almacen
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content4" ContentPlaceHolderID="HB" Runat="Server">
|
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content5" ContentPlaceHolderID="H" Runat="Server">
|
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
|
||||||
</asp:Content>
|
<asp:UpdatePanel runat="server" ID="UpAcciones" UpdateMode="Conditional">
|
||||||
<asp:Content ID="Content6" ContentPlaceHolderID="HA" Runat="Server">
|
<ContentTemplate>
|
||||||
</asp:Content>
|
<li>
|
||||||
<asp:Content ID="Content7" ContentPlaceHolderID="C" Runat="Server">
|
<asp:HyperLink ID="HlAgregarExcel" NavigateUrl="#" data-toggle="modal" data-target="#DivCargaExcel" runat="server"><i class='fa fa-server'></i> Importar Listado</asp:HyperLink>
|
||||||
<asp:UpdatePanel runat="server" ID="UpFiltraEntrega" UpdateMode="Conditional">
|
</li>
|
||||||
<ContentTemplate>
|
<li>
|
||||||
<div class="portlet solid grey-cascade portlet-filter">
|
<asp:LinkButton ID="LbDescargarExcel" runat="server"><i class='fa fa-file-excel-o'></i> Descargar Formato</asp:LinkButton>
|
||||||
<div class="portlet-title portlet-filterT smalltitle magindate">
|
</li>
|
||||||
<div class="tools">
|
</ContentTemplate>
|
||||||
<asp:Button ID="BtnConsultar" runat="server" Text="Consultar" class="btn btn-default" />
|
<Triggers>
|
||||||
</div>
|
<asp:PostBackTrigger ControlID="LbDescargarExcel" />
|
||||||
<div class="titlefiltros caption ">
|
</Triggers>
|
||||||
|
</asp:UpdatePanel>
|
||||||
<label class="col-md-1 truncate" style="text-align: right;">Almacen:</label>
|
</asp:Content>
|
||||||
<div class="col-md-3">
|
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
|
||||||
<asp:DropDownList ID="DdlAlmacen" runat="server" DataValueField="CveAlmacen" DataTextField="Almacen" class="select2me" Width="300px"></asp:DropDownList>
|
</asp:Content>
|
||||||
</div>
|
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
|
||||||
|
<asp:UpdatePanel runat="server" ID="UpFiltraEntrega" UpdateMode="Conditional">
|
||||||
<label class="col-md-1 truncate" style="text-align: right;">Clasificacion:</label>
|
<ContentTemplate>
|
||||||
<div class="col-md-3">
|
<div class="portlet solid grey-cascade portlet-filter">
|
||||||
<asp:DropDownList ID="DdlClasificaciones" runat="server" DataValueField="CveClasificacion" DataTextField="Clasificacion" class="select2me" Width="300px" ></asp:DropDownList>
|
<div class="portlet-title portlet-filterT smalltitle magindate">
|
||||||
</div>
|
<div class="tools">
|
||||||
|
<asp:Button ID="BtnConsultar" runat="server" Text="Consultar" class="btn btn-default" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="titlefiltros caption ">
|
||||||
</div>
|
|
||||||
</ContentTemplate>
|
<label class="col-md-1 truncate" style="text-align: right;">Almacen:</label>
|
||||||
</asp:UpdatePanel>
|
<div class="col-md-3">
|
||||||
<br />
|
<asp:DropDownList ID="DdlAlmacen" runat="server" DataValueField="CveAlmacen" DataTextField="Almacen" class="select2me" Width="300px"></asp:DropDownList>
|
||||||
<asp:UpdatePanel runat="server" ID="UppD" UpdateMode="Conditional">
|
</div>
|
||||||
<ContentTemplate>
|
|
||||||
<asp:GridView ID="GvD" DataKeyNames="CvePS,CveUM,CveAlmacen,PU,Existencia,Serie,CveSeccionAlmacen,FechaCaducidad,Lote" runat="server" AutoGenerateColumns="False" EmptyDataText="No hay movimientos pendientes" CssClass="table table-hover Widthall" GridLines="None">
|
<label class="col-md-1 truncate" style="text-align: right;">Clasificacion:</label>
|
||||||
<Columns>
|
<div class="col-md-3">
|
||||||
<asp:BoundField HeaderText="Producto" DataField="CodigoPS" />
|
<asp:DropDownList ID="DdlClasificaciones" runat="server" DataValueField="CveClasificacion" DataTextField="Clasificacion" class="select2me" Width="300px"></asp:DropDownList>
|
||||||
<asp:BoundField HeaderText="Serie" DataField="Serie" ItemStyle-Width="5%" />
|
</div>
|
||||||
<asp:BoundField HeaderText="Sección Actual" DataField="AlmacenSeccion" ItemStyle-Width="15%" />
|
|
||||||
<asp:BoundField HeaderText="Existencia" DataField="Existencia" DataFormatString="{0:#,###.##}" ItemStyle-Width="5%" />
|
</div>
|
||||||
<asp:TemplateField ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Center">
|
</div>
|
||||||
<ItemTemplate>
|
</div>
|
||||||
<asp:CheckBox ID="Chk" Checked="true" runat="server" ></asp:CheckBox>
|
</ContentTemplate>
|
||||||
</ItemTemplate>
|
</asp:UpdatePanel>
|
||||||
</asp:TemplateField>
|
<br />
|
||||||
<asp:TemplateField HeaderText="Nueva Seccion" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
|
<asp:UpdatePanel runat="server" ID="UppD" UpdateMode="Conditional">
|
||||||
<ItemTemplate>
|
<ContentTemplate>
|
||||||
<asp:DropDownList ID="DDlS" runat="server" Width="150px" DataValueField="CveAlmacenSeccion" DataTextField="AlmacenSeccion" class="select2me"></asp:DropDownList>
|
<asp:GridView ID="GvD" DataKeyNames="CvePS,CveUM,CveAlmacen,PU,Existencia,Serie,CveSeccionAlmacen,FechaCaducidad,Lote" runat="server" AutoGenerateColumns="False" EmptyDataText="No hay movimientos pendientes" CssClass="table table-hover Widthall" GridLines="None">
|
||||||
|
<Columns>
|
||||||
</ItemTemplate>
|
<asp:BoundField HeaderText="Producto" DataField="CodigoPS" />
|
||||||
</asp:TemplateField>
|
<asp:BoundField HeaderText="Serie" DataField="Serie" ItemStyle-Width="5%" />
|
||||||
</Columns>
|
<asp:BoundField HeaderText="Lote" DataField="Lote" ItemStyle-Width="5%" />
|
||||||
</asp:GridView>
|
<asp:BoundField HeaderText="FechaCaducidad" DataField="FechaCaducidad" ItemStyle-Width="5%" />
|
||||||
<asp:Button ID="BtnCambiarSeccion" runat="server" Text="Cambiar Sección" CssClass="btn btn-primary" />
|
<asp:BoundField HeaderText="Sección Actual" DataField="AlmacenSeccion" ItemStyle-Width="15%" />
|
||||||
|
<asp:BoundField HeaderText="Existencia" DataField="Existencia" DataFormatString="{0:#,###.##}" ItemStyle-Width="5%" />
|
||||||
</ContentTemplate>
|
<asp:TemplateField ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Center">
|
||||||
</asp:UpdatePanel>
|
<ItemTemplate>
|
||||||
</asp:Content>
|
<asp:CheckBox ID="Chk" Checked="true" runat="server"></asp:CheckBox>
|
||||||
<asp:Content ID="Content8" ContentPlaceHolderID="JS" Runat="Server">
|
</ItemTemplate>
|
||||||
</asp:Content>
|
</asp:TemplateField>
|
||||||
|
<asp:TemplateField HeaderText="Nueva Seccion" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
|
||||||
|
<ItemTemplate>
|
||||||
|
<asp:DropDownList ID="DDlS" runat="server" Width="150px" DataValueField="CveAlmacenSeccion" DataTextField="AlmacenSeccion" class="select2me"></asp:DropDownList>
|
||||||
|
|
||||||
|
</ItemTemplate>
|
||||||
|
</asp:TemplateField>
|
||||||
|
</Columns>
|
||||||
|
</asp:GridView>
|
||||||
|
<asp:Button ID="BtnCambiarSeccion" runat="server" Text="Cambiar Sección" CssClass="btn btn-primary" />
|
||||||
|
</ContentTemplate>
|
||||||
|
</asp:UpdatePanel>
|
||||||
|
<div id="DivCargaExcel" class="modal ADS fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header ">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title">Agregar Excel</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-md-2 truncate" style="text-align: right;">Almacen:</label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<asp:DropDownList ID="DdlAlmacenExcel" runat="server" DataValueField="CveAlmacen" DataTextField="Almacen" class="select2me" Width="100%"></asp:DropDownList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<h3>Arraste o haga click para subir el archivo Excel</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-11" style="margin-left: 30px; margin-right: 30px; margin-bottom: 200px;">
|
||||||
|
<asp:TextBox ID="TxtExcel" CssClass="ADSdropzone hidden" Text="" data-maxFile="1" runat="server"></asp:TextBox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-2" style="text-align: left">
|
||||||
|
<asp:Button ID="BtnDescargar" runat="server" CssClass="btn btn-warning" Text="Descargar Formato" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10" style="text-align: right">
|
||||||
|
<asp:Button ID="BtnCargaExcel" runat="server" CssClass="btn btn-success" Text="Aceptar"></asp:Button>
|
||||||
|
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</asp:Content>
|
||||||
|
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
|
||||||
|
</asp:Content>
|
||||||
|
|
||||||
|
|||||||
@@ -1,144 +1,340 @@
|
|||||||
|
|
||||||
Imports System.Data
|
Imports System.Data
|
||||||
Imports Extensiones
|
Imports Extensiones
|
||||||
|
|
||||||
Partial Class Inventarios_AjustesSeccionAlmacen
|
Partial Class Inventarios_AjustesSeccionAlmacen
|
||||||
Inherits ClsPaginas
|
Inherits ClsPaginas
|
||||||
|
|
||||||
Private Sub Inventarios_AjustesSeccionAlmacen_Load(sender As Object, e As EventArgs) Handles Me.Load
|
Private Sub Inventarios_AjustesSeccionAlmacen_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||||
If Not Page.IsPostBack Then
|
If Not Page.IsPostBack Then
|
||||||
CargaCombos()
|
CargaCombos()
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub CargaCombos()
|
Private Sub CargaCombos()
|
||||||
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||||
DdlAlmacen.DataBind()
|
DdlAlmacen.DataBind()
|
||||||
|
|
||||||
DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
|
DdlAlmacenExcel.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||||
DdlClasificaciones.DataBind()
|
DdlAlmacenExcel.DataBind()
|
||||||
DdlClasificaciones.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
||||||
End Sub
|
DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
|
||||||
|
DdlClasificaciones.DataBind()
|
||||||
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
DdlClasificaciones.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||||
CargaDatos()
|
End Sub
|
||||||
End Sub
|
|
||||||
|
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
||||||
Private Sub CargaDatos()
|
CargaDatos()
|
||||||
Dim ObjInv As New ClsInventarios
|
End Sub
|
||||||
|
|
||||||
If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlAlmacen.SelectedValue.ToEntero, DdlClasificaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
Private Sub CargaDatos()
|
||||||
GvD.DataSource = ObjInv.DtResultados
|
Dim ObjInv As New ClsInventarios
|
||||||
End If
|
|
||||||
|
If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlAlmacen.SelectedValue.ToEntero, DdlClasificaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||||
ObjInv.Dispose()
|
GvD.DataSource = ObjInv.DtResultados
|
||||||
GvD.DataBind()
|
End If
|
||||||
UppD.Update()
|
|
||||||
End Sub
|
ObjInv.Dispose()
|
||||||
|
GvD.DataBind()
|
||||||
Private Sub GvD_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvD.RowDataBound
|
UppD.Update()
|
||||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
End Sub
|
||||||
|
|
||||||
e.Row.FCDropDownList("DDlS").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero)
|
Private Sub GvD_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvD.RowDataBound
|
||||||
e.Row.FCDropDownList("DDlS").DataBind()
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||||
|
|
||||||
End If
|
e.Row.FCDropDownList("DDlS").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero)
|
||||||
End Sub
|
e.Row.FCDropDownList("DDlS").DataBind()
|
||||||
|
|
||||||
Private Sub BtnCambiarSeccion_Click(sender As Object, e As EventArgs) Handles BtnCambiarSeccion.Click
|
End If
|
||||||
Dim ObjInventario As New ClsInventarios
|
End Sub
|
||||||
Dim ObjPS As New ClsProductosServicios(ObjInventario.IniciaTransacSQL)
|
|
||||||
Dim Dtt As DataTable = Nothing
|
Private Sub BtnCambiarSeccion_Click(sender As Object, e As EventArgs) Handles BtnCambiarSeccion.Click
|
||||||
Dim CveMovimientoEntrada As Integer = 0
|
Dim ObjInventario As New ClsInventarios
|
||||||
Dim Folio = 0
|
Dim ObjPS As New ClsProductosServicios(ObjInventario.IniciaTransacSQL)
|
||||||
Dim ErrorMovInv As Boolean = False
|
Dim Dtt As DataTable = Nothing
|
||||||
Dim TextoError = ""
|
Dim CveMovimientoEntrada As Integer = 0
|
||||||
Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero
|
Dim Folio = 0
|
||||||
|
Dim ErrorMovInv As Boolean = False
|
||||||
|
Dim TextoError = ""
|
||||||
|
Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero
|
||||||
Dim Fecha As Date = DateTime.Now
|
|
||||||
'AGREGAMOS LA ENTRADA
|
|
||||||
Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
||||||
Observaciones:="", Modulo:="ASA/G1")
|
Dim Fecha As Date = DateTime.Now
|
||||||
Folio = ObjInventario.Folio
|
'AGREGAMOS LA ENTRADA
|
||||||
|
Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
||||||
If CveMovimientoSalida <= 0 Then
|
Observaciones:="", Modulo:="ASA/G1")
|
||||||
TextoError = "No se pudo generar el movimiento de salida correctamente"
|
Folio = ObjInventario.Folio
|
||||||
ErrorMovInv = True
|
|
||||||
Else
|
If CveMovimientoSalida <= 0 Then
|
||||||
|
TextoError = "No se pudo generar el movimiento de salida correctamente"
|
||||||
Dim CveMovimientoDetalleEntrada As Integer = 0
|
ErrorMovInv = True
|
||||||
Dim Cont As Integer = 0
|
Else
|
||||||
For Each gvr As GridViewRow In GvD.Rows
|
|
||||||
|
Dim CveMovimientoDetalleEntrada As Integer = 0
|
||||||
'que este seleccionado y que tenga diferente seccion
|
Dim Cont As Integer = 0
|
||||||
If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCDropDownList("DDlS").SelectedValue.ToEntero <> gvr.DataKey("CveSeccionAlmacen").ToEntero Then
|
For Each gvr As GridViewRow In GvD.Rows
|
||||||
|
|
||||||
If gvr.DataKey("CveSeccionAlmacen").ToEntero > 0 Then
|
'que este seleccionado y que tenga diferente seccion
|
||||||
ObjPS.UpdateAplicaSeccionAlmacen(gvr.DataKey("CvePS").ToEntero, UsuarioActual.CveEmpresa, True)
|
If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCDropDownList("DDlS").SelectedValue.ToEntero <> gvr.DataKey("CveSeccionAlmacen").ToEntero Then
|
||||||
End If
|
|
||||||
|
If gvr.DataKey("CveSeccionAlmacen").ToEntero > 0 Then
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.DataKey("Existencia").ToDecimal, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, 0, -1, CveSeccionAlmacen:=gvr.DataKey("CveSeccionAlmacen").ToEntero, Serie:=gvr.DataKey("Serie"), Lote:=gvr.DataKey("Lote"), FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate) Then
|
ObjPS.UpdateAplicaSeccionAlmacen(gvr.DataKey("CvePS").ToEntero, UsuarioActual.CveEmpresa, True)
|
||||||
ErrorMovInv = True
|
End If
|
||||||
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
||||||
Exit For
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.DataKey("Existencia").ToDecimal, gvr.DataKey("CveUM").ToEntero, gvr.DataKey("CvePS").ToEntero, 0, -1, CveSeccionAlmacen:=gvr.DataKey("CveSeccionAlmacen").ToEntero, Serie:=gvr.DataKey("Serie"), Lote:=gvr.DataKey("Lote"), FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate) Then
|
||||||
End If
|
ErrorMovInv = True
|
||||||
|
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
||||||
End If
|
Exit For
|
||||||
|
End If
|
||||||
Next
|
|
||||||
|
End If
|
||||||
If Not ErrorMovInv Then
|
|
||||||
|
Next
|
||||||
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
||||||
|
If Not ErrorMovInv Then
|
||||||
Dim resultado As DataTable = ObjInventario.DtResultados
|
|
||||||
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 2, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ASA/G1")
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
||||||
Dim ind As Integer = 0
|
|
||||||
|
Dim resultado As DataTable = ObjInventario.DtResultados
|
||||||
For Each Row As DataRow In resultado.Rows
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 2, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ASA/G1")
|
||||||
Dim CvePS = Row("CvePS").ToString().ToEntero()
|
Dim ind As Integer = 0
|
||||||
Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
|
|
||||||
Dim PU As Decimal = Row("PUOriginal").ToString().ToDecimal()
|
For Each Row As DataRow In resultado.Rows
|
||||||
Dim CveUM As Integer = Row("CveUM").ToString().ToEntero()
|
Dim CvePS = Row("CvePS").ToString().ToEntero()
|
||||||
Dim CveSeccionAlmacen As Integer = GvD.Rows(ind).FCDropDownList("DDlS").SelectedValue.ToEntero ' IfNull(Row("CveSeccionAlmacen"), "-1").ToString().ToEntero()
|
Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
|
||||||
Dim CostoIndirecto As Decimal = Row("CostoIndirecto").ToString().ToDecimal()
|
Dim PU As Decimal = Row("PUOriginal").ToString().ToDecimal()
|
||||||
Dim Serie As String = Row("Serie").ToString()
|
Dim CveUM As Integer = Row("CveUM").ToString().ToEntero()
|
||||||
Dim Lote As String = Row("Lote").ToString()
|
Dim CveSeccionAlmacen As Integer = GvD.Rows(ind).FCDropDownList("DDlS").SelectedValue.ToEntero ' IfNull(Row("CveSeccionAlmacen"), "-1").ToString().ToEntero()
|
||||||
Dim FechaCaducidad As Date = IfNull(Row("FechaCaducidad"), MinFecha).ToString.ToDate
|
Dim CostoIndirecto As Decimal = Row("CostoIndirecto").ToString().ToDecimal()
|
||||||
|
Dim Serie As String = Row("Serie").ToString()
|
||||||
'actualizamos el PS, para que tenga el aplica seccion
|
Dim Lote As String = Row("Lote").ToString()
|
||||||
|
Dim FechaCaducidad As Date = IfNull(Row("FechaCaducidad"), MinFecha).ToString.ToDate
|
||||||
ObjPS.UpdateAplicaSeccionAlmacen(Row("CvePS").ToString().ToEntero(), UsuarioActual.CveEmpresa, True)
|
|
||||||
|
'actualizamos el PS, para que tenga el aplica seccion
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, CveUM, CvePS, PU, -1, CostoIndirecto:=CostoIndirecto, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
||||||
ErrorMovInv = True
|
ObjPS.UpdateAplicaSeccionAlmacen(Row("CvePS").ToString().ToEntero(), UsuarioActual.CveEmpresa, True)
|
||||||
Exit For
|
|
||||||
End If
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, CveUM, CvePS, PU, -1, CostoIndirecto:=CostoIndirecto, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||||
ind += 1
|
ErrorMovInv = True
|
||||||
Next
|
Exit For
|
||||||
resultado.Dispose()
|
End If
|
||||||
|
ind += 1
|
||||||
Else
|
Next
|
||||||
TextoError = "No se pudo registrar el movimiento"
|
resultado.Dispose()
|
||||||
ErrorMovInv = True
|
|
||||||
End If
|
Else
|
||||||
|
TextoError = "No se pudo registrar el movimiento"
|
||||||
End If
|
ErrorMovInv = True
|
||||||
|
End If
|
||||||
End If
|
|
||||||
|
End If
|
||||||
|
|
||||||
If Not ErrorMovInv Then
|
End If
|
||||||
ObjInventario.Commit()
|
|
||||||
cargadatos
|
If Not ErrorMovInv Then
|
||||||
Alert("El Movimiento quede registrado correctamente", TipoMensaje.MsgInformacion)
|
ObjInventario.Commit()
|
||||||
Else
|
CargaDatos()
|
||||||
ObjInventario.RollBack()
|
Alert("El Movimiento quede registrado correctamente", TipoMensaje.MsgInformacion)
|
||||||
Alert("Ocurrio un error al registrar el movimiento", TipoMensaje.MsgError)
|
Else
|
||||||
End If
|
ObjInventario.RollBack()
|
||||||
|
Alert("Ocurrio un error al registrar el movimiento", TipoMensaje.MsgError)
|
||||||
ObjInventario.Dispose()
|
End If
|
||||||
End Sub
|
|
||||||
End Class
|
ObjInventario.Dispose()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles LbDescargarExcel.Click, BtnDescargar.Click
|
||||||
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoAjusteSecCad.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
|
||||||
|
|
||||||
|
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 = AppDomain.CurrentDomain.BaseDirectory & file.patch
|
||||||
|
Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "")
|
||||||
|
If Tipo = "EXCEL" Then
|
||||||
|
Dim CveAlmacen As Integer = DdlAlmacenExcel.SelectedValue.ToEntero()
|
||||||
|
Dim CveSubProyecto As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={CveAlmacen}")
|
||||||
|
|
||||||
|
CargarArchivo(Directorio, file.filename, CveAlmacen, CveSubProyecto)
|
||||||
|
Else
|
||||||
|
Alert("El archivo no es de tipo excel", TipoMensaje.MsgAdvertencia)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub CargarArchivo(Ruta As String, FileName As String, CveAlmacen As Integer, CveSubProyecto As Integer)
|
||||||
|
Dim DtExcel As DataTable = ReadExcelFile(Ruta + FileName, True)
|
||||||
|
|
||||||
|
Dim ErrorArchivo = False
|
||||||
|
If Not ErrorArchivo AndAlso DtExcel IsNot Nothing Then
|
||||||
|
If Not DtExcel.Columns(0).ColumnName = "Código" Then
|
||||||
|
Alert("El nombre de la segunda columna debe ser 'Código'.Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not DtExcel.Columns(1).ColumnName = "Producto/Servicio" Then
|
||||||
|
Alert("El nombre de la cuarta columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not DtExcel.Columns(2).ColumnName = "SeccionAlmacen" Then
|
||||||
|
Alert("El nombre de la quinta columna debe ser 'SeccionAlmacen'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not DtExcel.Columns(3).ColumnName = "Serie" Then
|
||||||
|
Alert("El nombre de la sexta columna debe ser 'Serie'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not DtExcel.Columns(4).ColumnName = "Lote" Then
|
||||||
|
Alert("El nombre de la séptima columna debe ser 'Lote'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If Not DtExcel.Columns(5).ColumnName = "FechaCaducidad" Then
|
||||||
|
Alert("El nombre de la octava columna debe ser 'FechaCaducidad'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
DtExcel.TableName = "Datos"
|
||||||
|
|
||||||
|
If Not ErrorArchivo Then
|
||||||
|
Dim ErrorMovInv As Boolean = False
|
||||||
|
|
||||||
|
Dim RowNoEncontrados As New StringBuilder()
|
||||||
|
Dim NumAgregados As Integer = 0
|
||||||
|
|
||||||
|
Dim ObjInventario As New ClsInventarios()
|
||||||
|
Dim ObjPS As New ClsProductosServicios(ObjInventario.IniciaTransacSQL())
|
||||||
|
|
||||||
|
Try
|
||||||
|
Dim DtExistenciasSecciones As DataTable = Nothing
|
||||||
|
If ObjInventario.GetMovimientosDetalleSeccionesAlmacen(DdlAlmacen.SelectedValue.ToEntero, DdlClasificaciones.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||||
|
DtExistenciasSecciones = ObjInventario.DtResultados.Copy()
|
||||||
|
End If
|
||||||
|
|
||||||
|
'SALIDA ALMACÉN
|
||||||
|
Dim CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", TipoCambio:=-1,
|
||||||
|
MovimientoFijo:=False, Modulo:="ASA/SA")
|
||||||
|
|
||||||
|
'ENTRADA ALMACÉN
|
||||||
|
Dim CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 2, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", TipoCambio:=-1,
|
||||||
|
MovimientoFijo:=False, Modulo:="ASA/EA")
|
||||||
|
|
||||||
|
Dim dtSecciones As DataTable = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, CveAlmacen)
|
||||||
|
dtSecciones.CaseSensitive = False
|
||||||
|
|
||||||
|
For Each RowExcel As DataRow In DtExcel.Rows
|
||||||
|
|
||||||
|
Dim Codigo As String = RowExcel("Código").ToString.Trim
|
||||||
|
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, Codigo:=Codigo).Rows(0)
|
||||||
|
|
||||||
|
If DrPS IsNot Nothing Then
|
||||||
|
If Not ErrorMovInv Then
|
||||||
|
Dim CvePS As Integer = DrPS("CvePS").ToString().ToEntero()
|
||||||
|
Dim CveUM As Integer = DrPS("CveUM").ToString().ToEntero()
|
||||||
|
Dim ProductoServicio As String = RowExcel("Producto/Servicio").ToString.Trim
|
||||||
|
|
||||||
|
Dim SeccionAlmacen As String = RowExcel("SeccionAlmacen").ToString.Trim
|
||||||
|
Dim CveSeccionAlmacen As Integer = dtSecciones.FiltroPrimeroValor("CveSeccion", $"AlmacenSeccion='{SeccionAlmacen}'")
|
||||||
|
|
||||||
|
Dim Serie As String = RowExcel("Serie").ToString()
|
||||||
|
Dim Lote As String = RowExcel("Lote").ToString()
|
||||||
|
Dim FechaCaducidad As Date = IfNull(RowExcel("FechaCaducidad"), MinFecha).ToString.ToDate
|
||||||
|
|
||||||
|
Dim RowExistencia As DataRow = DtExistenciasSecciones.FiltroPrimero($"CvePS={CvePS}")
|
||||||
|
|
||||||
|
Dim CveSeccionAlmacenSalida As Integer = RowExistencia("CveSeccionAlmacen").ToString().ToEntero()
|
||||||
|
Dim CantidadSalida As Decimal = RowExistencia("Existencia").ToString().ToDecimal()
|
||||||
|
Dim SerieSalida As String = RowExistencia("Serie").ToString()
|
||||||
|
Dim LoteSalida As String = RowExistencia("Lote").ToString()
|
||||||
|
Dim FechaCaducidadSalida As Date = IfNull(RowExistencia("FechaCaducidad"), MinFecha).ToString.ToDate
|
||||||
|
Dim PUSalida As Decimal = RowExistencia("PU").ToString()
|
||||||
|
|
||||||
|
'GENERA LA SALIDA DE LOS PRODUCTOS QUE VIENEN EN EL EXCEL
|
||||||
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadSalida, CveUM, CvePS, PUSalida, CveSeccionAlmacen:=CveSeccionAlmacenSalida, Serie:=SerieSalida, Lote:=LoteSalida, FechaCaducidad:=FechaCaducidadSalida, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||||
|
ErrorMovInv = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim CveMovimientoDetalleSalida As Integer = ObjInventario.CveMovimientoDetalle
|
||||||
|
|
||||||
|
ErrorMovInv = CveMovimientoDetalleSalida <= 0
|
||||||
|
|
||||||
|
'GENERA LA ENTRADA DE LOS PRODUCTOS QUE SE DIERON ENTRADA
|
||||||
|
If Not ErrorMovInv Then
|
||||||
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa, CveMovimientoDetalle:=CveMovimientoDetalleSalida) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
||||||
|
Dim RowEntrada As DataRow = ObjInventario.DtResultados.Rows(0)
|
||||||
|
|
||||||
|
Dim CvePSEntrada = RowEntrada("CvePS").ToString().ToEntero()
|
||||||
|
Dim CantidadEntrada As Decimal = RowEntrada("Cantidad").ToString().ToDecimal()
|
||||||
|
Dim PUEntrada As Decimal = RowEntrada("PUOriginal").ToString().ToDecimal()
|
||||||
|
Dim CveUMEntrada As Integer = RowEntrada("CveUM").ToString().ToEntero()
|
||||||
|
|
||||||
|
Dim CostoIndirecto As Decimal = RowEntrada("CostoIndirecto").ToString().ToDecimal()
|
||||||
|
|
||||||
|
'ACTUALIZAMOS EL PS, PARA QUE TENGA EL APLICA SECCION
|
||||||
|
ErrorMovInv = Not ObjPS.UpdateAplicaSeccionAlmacen(CvePS, UsuarioActual.CveEmpresa, True)
|
||||||
|
|
||||||
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, CantidadEntrada, CveUMEntrada, CvePSEntrada, PUEntrada, -1, CostoIndirecto:=CostoIndirecto, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||||
|
ErrorMovInv = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
ErrorMovInv = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
ErrorMovInv = True
|
||||||
|
RowNoEncontrados.AppendFormat("{0},", Codigo)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Next
|
||||||
|
dtSecciones.Dispose()
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
ErrorMovInv = True
|
||||||
|
OnError("Ocurrió un error al agregar el inventario", ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
If ErrorMovInv Then
|
||||||
|
ObjInventario.RollBack()
|
||||||
|
|
||||||
|
Dim SbError As New StringBuilder()
|
||||||
|
SbError.Append("Ocurrió un error al guardar")
|
||||||
|
If RowNoEncontrados.Length > 0 Then
|
||||||
|
SbError.Append("Los siguientes códigos no fueron encontrados en el sistema.<br/>")
|
||||||
|
SbError.Append(RowNoEncontrados.ToString())
|
||||||
|
End If
|
||||||
|
|
||||||
|
Alert(SbError.ToString(), TipoMensaje.MsgError)
|
||||||
|
Else
|
||||||
|
ObjInventario.Commit()
|
||||||
|
Alert("Se realizó el ajuste de los productos correctamente.")
|
||||||
|
End If
|
||||||
|
|
||||||
|
ObjInventario.Dispose()
|
||||||
|
ObjPS.Dispose()
|
||||||
|
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Alert("Ocurrió un error al cargar el excel.", TipoMensaje.MsgError)
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
End Class
|
||||||
Reference in New Issue
Block a user