Cargar productos desde un excel
This commit is contained in:
@@ -60,9 +60,9 @@
|
||||
Traspaso de Almacén
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
|
||||
<%-- <li>
|
||||
<asp:HyperLink ID="LnkEnviarMail" runat="server" Style="color: #686868;" Visible="false"><i class="fa fa-envelope" style="color: #686868;"></i> Enviar Mail</asp:HyperLink>
|
||||
</li>--%>
|
||||
<li>
|
||||
<asp:HyperLink ID="LnkCargarExcel" runat="server" NavigateUrl="#" data-toggle="modal" data-target="#DivCargaExcelConceptos" Style="color: #686868;" ><i class="fa fa-file-excel-o" style="color: #686868;"></i> Cargar Conceptos</asp:HyperLink>
|
||||
</li>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content6" ContentPlaceHolderID="C" runat="Server">
|
||||
|
||||
@@ -780,7 +780,52 @@
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
|
||||
<%--CARGA EXCEL--%>
|
||||
<div id="DivCargaExcelConceptos" 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">Cargar Conceptos</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<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;">
|
||||
<asp:TextBox ID="TxtExcelConceptos" 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:UpdatePanel ID="UpDescargar" runat="server" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<asp:Button ID="BtnDescargarFormatoExcelConceptos" OnClick="BtnDescargarFormatoExcelConceptos_Click" runat="server" CssClass="btn btn-warning" Text="Descargar Formato" />
|
||||
</ContentTemplate>
|
||||
<Triggers>
|
||||
<asp:PostBackTrigger ControlID="BtnDescargarFormatoExcelConceptos" />
|
||||
</Triggers>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
<div class="col-md-10" style="text-align: right">
|
||||
<asp:UpdatePanel runat="server">
|
||||
<ContentTemplate>
|
||||
<asp:Button ID="BtnCargaExcelConceptos" runat="server" OnClick="BtnCargaExcelConceptos_Click" CssClass="btn btn-success" Text="Aceptar" ValidationGroup="GrpCargarExcel"></asp:Button>
|
||||
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ Option Strict On
|
||||
Imports System.Data
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports GemBox.Spreadsheet
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class Inventarios_TraspasoAlmacen
|
||||
Inherits ClsPaginas
|
||||
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "PROPIEDADES"
|
||||
Public Property DtMovimientos() As DataTable
|
||||
Get
|
||||
@@ -166,9 +167,9 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
Set(value As Integer)
|
||||
ViewState("TipoSeccionAlmacen") = value
|
||||
End Set
|
||||
End Property
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
|
||||
@@ -214,8 +215,8 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
Else
|
||||
If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(0);$('#DivGastoIndirecto').show(0);$('#DivDocChofer').show(0);")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Sub
|
||||
|
||||
#Region "CARGA DATOS"
|
||||
Protected Sub CreaDT()
|
||||
Dim dt As New DataTable
|
||||
@@ -472,9 +473,9 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
'Inv.Dispose()
|
||||
|
||||
'TxtFolio.Text = Folio.ToString
|
||||
End Sub
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " AGREGAR "
|
||||
Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
||||
BtnAgregarPS(txtCantidad.Text.ToDecimal)
|
||||
@@ -605,11 +606,11 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
If TxtCodigoPS.Visible Then
|
||||
TxtCodigoPS.Focus()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " GUARDAR "
|
||||
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
||||
|
||||
@@ -971,11 +972,11 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
|
||||
Return Retorno
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " NUEVO - LIMPIA "
|
||||
Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs)
|
||||
LimpiaMovimiento()
|
||||
@@ -1009,9 +1010,9 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
|
||||
DtMovimientos.Rows.Clear()
|
||||
CargaGvDatos()
|
||||
End Sub
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "DDL CLASIFICACION"
|
||||
Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged
|
||||
ChangeDdlProducto()
|
||||
@@ -1042,18 +1043,18 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
ThSerieLote.Visible = True
|
||||
TdSerieLote.Visible = True
|
||||
TxtnSerieLote.Visible = True
|
||||
GvDatos.Columns(4).Visible = True
|
||||
GvDatos.Columns(5).Visible = True
|
||||
End If
|
||||
If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 6", "PS").Rows.Count > 0 Then
|
||||
TxtnLote.Visible = True
|
||||
ThLote.Visible = True
|
||||
TdLote.Visible = True
|
||||
GvDatos.Columns(5).Visible = True
|
||||
GvDatos.Columns(6).Visible = True
|
||||
|
||||
TxtnBatch.Visible = True
|
||||
ThBatch.Visible = True
|
||||
TdBatch.Visible = True
|
||||
GvDatos.Columns(6).Visible = True
|
||||
GvDatos.Columns(7).Visible = True
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -1085,9 +1086,9 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
pDdlProducto.DataBind()
|
||||
pDdlProducto.Items.Insert(0, New ListItem("----", "-1"))
|
||||
|
||||
End Sub
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "GV DATOS"
|
||||
Private Sub CargaGvDatos()
|
||||
EscondeColumnasGVM(DtMovimientos)
|
||||
@@ -1198,67 +1199,67 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
|
||||
DtMovimientos.Rows.Remove(DbRow)
|
||||
CargaGvDatos()
|
||||
End Sub
|
||||
|
||||
'Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvDatos.RowEditing
|
||||
' GvDatos.EditIndex = e.NewEditIndex
|
||||
|
||||
' CargaGvDatos()
|
||||
'End Sub
|
||||
'Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
|
||||
' Dim dr = GvDatos.Rows(e.RowIndex)
|
||||
|
||||
' Dim Cantidad = dr.FCTextBox("TxtCantidad").Text.ToDouble
|
||||
' Dim CveUM = dr.FCDropDownList("DdlUnidad").SelectedValue.ToEntero
|
||||
' Dim CveClasificacion = dr.FCDropDownList("DdlClasificacion").SelectedValue.ToEntero
|
||||
' Dim CvePS = dr.FCDropDownList("DdlProducto").SelectedValue.ToEntero
|
||||
' Dim No = dr.DataKey("No").ToEntero
|
||||
' Dim SerieLote As String = dr.FCTextBox("TxtSerieLote").Text
|
||||
|
||||
' 'VALIDA EXISTENCIA
|
||||
' Dim Valido = True
|
||||
' Dim Inv As New ClsInventarios
|
||||
' Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, -1, TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), If(SerieLote = "", "-1", SerieLote))
|
||||
' Inv.Dispose()
|
||||
|
||||
' If Existencia - txtCantidad.Text.ToDouble < 0 Then
|
||||
' If Existencia <= 0 Then
|
||||
' Alert("No hay existencia del producto", TipoMensaje.MsgError)
|
||||
' Else
|
||||
' Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgError)
|
||||
' End If
|
||||
' Valido = False
|
||||
' End If
|
||||
|
||||
' If Valido Then
|
||||
|
||||
' Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", No))
|
||||
' If Drs.Count = 1 Then
|
||||
|
||||
' Drs(0)("Cantidad") = Cantidad
|
||||
' Drs(0)("CveUM") = CveUM
|
||||
' Drs(0)("CveClasificacion") = CveClasificacion
|
||||
' Drs(0)("CvePS") = CvePS
|
||||
' Drs(0)("EstatusExistencia") = "1"
|
||||
' End If
|
||||
|
||||
|
||||
' DtMovimientos.AcceptChanges()
|
||||
' GvDatos.EditIndex = -1
|
||||
' End If
|
||||
' CargaGvDatos()
|
||||
|
||||
'End Sub
|
||||
'Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
|
||||
' GvDatos.EditIndex = -1
|
||||
' CargaGvDatos()
|
||||
'End Sub
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
'Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvDatos.RowEditing
|
||||
' GvDatos.EditIndex = e.NewEditIndex
|
||||
|
||||
' CargaGvDatos()
|
||||
'End Sub
|
||||
'Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
|
||||
' Dim dr = GvDatos.Rows(e.RowIndex)
|
||||
|
||||
' Dim Cantidad = dr.FCTextBox("TxtCantidad").Text.ToDouble
|
||||
' Dim CveUM = dr.FCDropDownList("DdlUnidad").SelectedValue.ToEntero
|
||||
' Dim CveClasificacion = dr.FCDropDownList("DdlClasificacion").SelectedValue.ToEntero
|
||||
' Dim CvePS = dr.FCDropDownList("DdlProducto").SelectedValue.ToEntero
|
||||
' Dim No = dr.DataKey("No").ToEntero
|
||||
' Dim SerieLote As String = dr.FCTextBox("TxtSerieLote").Text
|
||||
|
||||
' 'VALIDA EXISTENCIA
|
||||
' Dim Valido = True
|
||||
' Dim Inv As New ClsInventarios
|
||||
' Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, -1, TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), If(SerieLote = "", "-1", SerieLote))
|
||||
' Inv.Dispose()
|
||||
|
||||
' If Existencia - txtCantidad.Text.ToDouble < 0 Then
|
||||
' If Existencia <= 0 Then
|
||||
' Alert("No hay existencia del producto", TipoMensaje.MsgError)
|
||||
' Else
|
||||
' Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgError)
|
||||
' End If
|
||||
' Valido = False
|
||||
' End If
|
||||
|
||||
' If Valido Then
|
||||
|
||||
' Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", No))
|
||||
' If Drs.Count = 1 Then
|
||||
|
||||
' Drs(0)("Cantidad") = Cantidad
|
||||
' Drs(0)("CveUM") = CveUM
|
||||
' Drs(0)("CveClasificacion") = CveClasificacion
|
||||
' Drs(0)("CvePS") = CvePS
|
||||
' Drs(0)("EstatusExistencia") = "1"
|
||||
' End If
|
||||
|
||||
|
||||
' DtMovimientos.AcceptChanges()
|
||||
' GvDatos.EditIndex = -1
|
||||
' End If
|
||||
' CargaGvDatos()
|
||||
|
||||
'End Sub
|
||||
'Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
|
||||
' GvDatos.EditIndex = -1
|
||||
' CargaGvDatos()
|
||||
'End Sub
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " TRANSITORIO - RECEPCION "
|
||||
|
||||
|
||||
Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs)
|
||||
|
||||
Dim TipoAlmacenOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue.ToEntero}").ToEntero
|
||||
@@ -1619,22 +1620,22 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
End If
|
||||
ObjUM.Dispose()
|
||||
DdlUnidad.DataBind()
|
||||
End Sub
|
||||
|
||||
'Protected Sub BtnImprimirTraspaso_Click(sender As Object, e As EventArgs) Handles BtnImprimirTraspaso.Click
|
||||
' Dim params As New List(Of ReportParameter)
|
||||
' params.Add(New ReportParameter("SubProyecto", DdlAlmacenDestino.SelectedItem.ToString))
|
||||
' params.Add(New ReportParameter("Folio", FolioTraspaso.ToString))
|
||||
' params.Add(New ReportParameter("Fecha", TxtFecha.Text))
|
||||
' params.Add(New ReportParameter("Observaciones", TxtObservaciones.Text))
|
||||
' params.Add(New ReportParameter("NombreEntrego", UsuarioActual.Nombre))
|
||||
' params.Add(New ReportParameter("NombreTraslado", TxtResponsable.Text))
|
||||
' params.Add(New ReportParameter("NombreRecibio", ""))
|
||||
' ImprimirPDF(String.Format("{0}Formatos\Traslado.rdlc", UsuarioActual.Empresa.Ruta), DtTraslado, params, "Reporte Traslado", RDSName:="DsInventarios")
|
||||
'End Sub
|
||||
|
||||
End Sub
|
||||
|
||||
'Protected Sub BtnImprimirTraspaso_Click(sender As Object, e As EventArgs) Handles BtnImprimirTraspaso.Click
|
||||
' Dim params As New List(Of ReportParameter)
|
||||
' params.Add(New ReportParameter("SubProyecto", DdlAlmacenDestino.SelectedItem.ToString))
|
||||
' params.Add(New ReportParameter("Folio", FolioTraspaso.ToString))
|
||||
' params.Add(New ReportParameter("Fecha", TxtFecha.Text))
|
||||
' params.Add(New ReportParameter("Observaciones", TxtObservaciones.Text))
|
||||
' params.Add(New ReportParameter("NombreEntrego", UsuarioActual.Nombre))
|
||||
' params.Add(New ReportParameter("NombreTraslado", TxtResponsable.Text))
|
||||
' params.Add(New ReportParameter("NombreRecibio", ""))
|
||||
' ImprimirPDF(String.Format("{0}Formatos\Traslado.rdlc", UsuarioActual.Empresa.Ruta), DtTraslado, params, "Reporte Traslado", RDSName:="DsInventarios")
|
||||
'End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " AGREGA CON TXT | CODIGO - SERIE "
|
||||
Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs)
|
||||
|
||||
@@ -1687,9 +1688,9 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
TxtCodigoPS.Text = ""
|
||||
TxtCodigoPS.Focus()
|
||||
|
||||
End Sub
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " AGREGA CON TXT | CODIGO - SERIE --- RECEPCION "
|
||||
Protected Sub BtnCodigoPSRecepcion_Click(sender As Object, e As EventArgs)
|
||||
If TxtCodigoPSRecepcion.Text = "" Then
|
||||
@@ -1763,11 +1764,11 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
||||
'Alert($"Ya se han cargado todos los productos o no se ha encontrado un producto de la Serie ""<b>{TxtSeriePSRecepcion.Text}</b>"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus2,200);")
|
||||
TxtSeriePSRecepcion.Text = ""
|
||||
End Sub
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "CORREO"
|
||||
|
||||
|
||||
Private Sub MandaCorreo(CveMovimiento As Integer, Para As String, Optional CCP As String = "")
|
||||
Dim Mail As New ClsSisMail()
|
||||
Dim Asunto As String = "NOTIFICACION DE TRASPASO ENTRE ALMACENES"
|
||||
@@ -1962,10 +1963,10 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
|
||||
ObjInventario.Dispose()
|
||||
Return strBody.ToString
|
||||
End Function
|
||||
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "TIMBRADO"
|
||||
Private Sub CreaObjetosVenta()
|
||||
ObjFactura = New Modelos.Factura
|
||||
@@ -2199,10 +2200,10 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
Catch ex As Exception
|
||||
Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "SECCION ALMACEN"
|
||||
Private Sub CreaDtSeccionAlmacen()
|
||||
DtSeccionAlmacen = New DataTable
|
||||
@@ -2383,31 +2384,31 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
DtSeccionAlmacen.Rows.RemoveAt(Index)
|
||||
DtSeccionAlmacen.AcceptChanges()
|
||||
CargaSeccionAlmacen()
|
||||
End Sub
|
||||
|
||||
'Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs)
|
||||
' If Not CveVentaSurtir > 0 Then
|
||||
' Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia)
|
||||
' Exit Sub
|
||||
' End If
|
||||
|
||||
' If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
|
||||
' Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia)
|
||||
' Exit Sub
|
||||
' End If
|
||||
|
||||
' Dim ObjInv As New ClsInventarios
|
||||
' If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
' GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados
|
||||
' End If
|
||||
' ObjInv.Dispose()
|
||||
' GvVerSeccionesAlmacen.DataBind()
|
||||
' UpVerSeccionesAlmacen.Update()
|
||||
' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()")
|
||||
'End Sub
|
||||
|
||||
End Sub
|
||||
|
||||
'Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs)
|
||||
' If Not CveVentaSurtir > 0 Then
|
||||
' Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia)
|
||||
' Exit Sub
|
||||
' End If
|
||||
|
||||
' If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
|
||||
' Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia)
|
||||
' Exit Sub
|
||||
' End If
|
||||
|
||||
' Dim ObjInv As New ClsInventarios
|
||||
' If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
' GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados
|
||||
' End If
|
||||
' ObjInv.Dispose()
|
||||
' GvVerSeccionesAlmacen.DataBind()
|
||||
' UpVerSeccionesAlmacen.Update()
|
||||
' RegistraScript("$('#ModalVerSeccionesAlmacen').modal()")
|
||||
'End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
Protected Sub DldChofer_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
Dim ObjAcar As New ClsAcarreos()
|
||||
|
||||
@@ -2422,5 +2423,218 @@ Partial Class Inventarios_TraspasoAlmacen
|
||||
End If
|
||||
End If
|
||||
ObjAcar.Dispose()
|
||||
End Sub
|
||||
End Sub
|
||||
Protected Sub BtnCargaExcelConceptos_Click(sender As Object, e As EventArgs)
|
||||
If TxtExcelConceptos.getfiles().Archivos.Count > 0 Then
|
||||
Dim file As Archivo = TxtExcelConceptos.getfiles().Archivos(0)
|
||||
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch
|
||||
CargarArchivoConceptos(Directorio, file.filename)
|
||||
RegistraScript("$('#DivCargaExcelConceptos').modal('hide');")
|
||||
Else
|
||||
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub BtnDescargarFormatoExcelConceptos_Click(sender As Object, e As EventArgs)
|
||||
Dim DtExcel As New DataTable
|
||||
DtExcel.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
|
||||
DtExcel.Columns.Add(New DataColumn("Codigo", GetType(String)))
|
||||
DtExcel.Columns.Add(New DataColumn("Producto", GetType(String)))
|
||||
DtExcel.Columns.Add(New DataColumn("SerieLote", GetType(String)))
|
||||
DtExcel.Columns.Add(New DataColumn("Observaciones", GetType(String)))
|
||||
|
||||
DtExcel.TableName = "Traspaso"
|
||||
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
|
||||
Dim FileExcel As New ExcelFile()
|
||||
|
||||
Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
||||
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
||||
{
|
||||
.ColumnHeaders = True,
|
||||
.StartRow = 0,
|
||||
.StartColumn = 0
|
||||
})
|
||||
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255))
|
||||
worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255)
|
||||
|
||||
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
||||
For i = 0 To columnCount
|
||||
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||
Next
|
||||
|
||||
FileExcel.Save(Response, "Traspaso.xlsx", SaveOptions.XlsxDefault)
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub CargarArchivoConceptos(Ruta As String, FileName As String)
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
|
||||
Dim dt As DataTable = Nothing
|
||||
Dim ErrorArchivo = False
|
||||
|
||||
Try
|
||||
dt = ReadExcelFile(Ruta + FileName, True)
|
||||
Catch ex As Exception
|
||||
ErrorArchivo = True
|
||||
OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
||||
End Try
|
||||
|
||||
If Not ErrorArchivo AndAlso dt IsNot Nothing Then
|
||||
|
||||
If Not dt.Columns(0).ColumnName = "Cantidad" Then
|
||||
Alert("El nombre de la primera columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(1).ColumnName = "Codigo" Then
|
||||
Alert("El nombre de la segunda columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(2).ColumnName = "Producto" Then
|
||||
Alert("El nombre de la tercera columna debe ser 'Producto'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(3).ColumnName = "SerieLote" Then
|
||||
Alert("El nombre de la cuarta columna debe ser 'SerieLote'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(4).ColumnName = "Observaciones" Then
|
||||
Alert("El nombre de la quinta columna debe ser 'Observaciones'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
dt.TableName = "Datos"
|
||||
Dim ProductosNoCargados As New StringBuilder()
|
||||
Dim RowsCargados As Integer = 0
|
||||
Dim RowsNoCargados As Integer = 0
|
||||
Dim NoPSConSerieLote As Integer = 0
|
||||
Try
|
||||
Dim DtPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa)
|
||||
For Each RowExcel As DataRow In dt.Rows
|
||||
Dim RowPS = DtPS.FiltroPrimero(String.Format("Codigo='{0}'", RowExcel("Codigo").ToString()))
|
||||
|
||||
Dim CveProducto As Integer = RowPS("CvePS").ToString().ToEntero()
|
||||
Dim CveUnidadMedida As Integer = RowPS("CveUnidadMedida").ToString().ToEntero()
|
||||
|
||||
Dim Cantidad As Double = RowExcel("Cantidad").ToString().ToDecimal()
|
||||
Dim SerieLote As String = RowExcel("SerieLote").ToString()
|
||||
Dim Observaciones As String = RowExcel("Observaciones").ToString()
|
||||
|
||||
If CveProducto > 0 Then
|
||||
|
||||
Dim Valido As Boolean = True
|
||||
|
||||
Dim CveMetodoInventario As Integer = RowPS("Inv_CveMetodoInventario").ToString().ToEntero()
|
||||
|
||||
If CveMetodoInventario = 5 And (String.IsNullOrEmpty(SerieLote.Trim()) OrElse SerieLote = "-1") Then
|
||||
Valido = False
|
||||
Alert($"El producto '{RowPS("PS")}' requiere 'SerieLote'", TipoMensaje.MsgAdvertencia)
|
||||
ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
|
||||
End If
|
||||
|
||||
If CveMetodoInventario = 5 AndAlso Not String.IsNullOrEmpty(SerieLote.Trim()) Then
|
||||
NoPSConSerieLote = NoPSConSerieLote + 1
|
||||
End If
|
||||
|
||||
If Valido AndAlso (Cantidad > 0 AndAlso RowPS("VentaMinima").ToString.ToDecimal > 0) Then
|
||||
If Cantidad Mod RowPS("VentaMinima").ToString.ToDecimal <> 0 Then
|
||||
Valido = False
|
||||
ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
|
||||
End If
|
||||
End If
|
||||
|
||||
If Valido Then
|
||||
Valido = ValidaExistencia(Cantidad, CveProducto, CveUnidadMedida, If(Not String.IsNullOrEmpty(SerieLote), SerieLote, "-1"), "-1", "-1")
|
||||
End If
|
||||
|
||||
If Valido Then
|
||||
AgregarPS(Cantidad, CveProducto, CveUnidadMedida, Observaciones, If(Not String.IsNullOrEmpty(SerieLote), SerieLote, ""), "", "", False)
|
||||
RowsCargados = RowsCargados + 1
|
||||
Else
|
||||
RowsNoCargados = RowsNoCargados + 1
|
||||
ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
|
||||
End If
|
||||
|
||||
Else
|
||||
RowsNoCargados = RowsNoCargados + 1
|
||||
ProductosNoCargados.AppendFormat("{0},", RowExcel("Producto").ToString())
|
||||
End If
|
||||
Next
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al cargar los productos.", ex)
|
||||
Finally
|
||||
|
||||
If NoPSConSerieLote > 0 Then
|
||||
ThSerieLote.Visible = True
|
||||
TdSerieLote.Visible = True
|
||||
TxtnSerieLote.Visible = True
|
||||
GvDatos.Columns(5).Visible = True
|
||||
End If
|
||||
|
||||
Dim MensajeFinal As New StringBuilder()
|
||||
If RowsNoCargados = 0 AndAlso RowsCargados > 0 Then
|
||||
MensajeFinal.Append("Los productos se cargaron correctamente. <br/><br/>")
|
||||
End If
|
||||
If RowsCargados > 0 Then
|
||||
MensajeFinal.Append("Se cargaron <b>" & RowsCargados & "</b> productos correctamente.")
|
||||
End If
|
||||
If RowsNoCargados > 0 Then
|
||||
MensajeFinal.Append("No se pudieron cargar <b>" & RowsNoCargados & "</b> productos. <br/>Los siguientes productos no se pudieron cargar: " & ProductosNoCargados.ToString())
|
||||
End If
|
||||
|
||||
Alert(MensajeFinal.ToString())
|
||||
|
||||
End Try
|
||||
UpDatos.Update()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath)
|
||||
|
||||
Dim unnamed As Integer = 0
|
||||
Dim cols As Integer
|
||||
Dim columns As String()
|
||||
Dim curRow As Integer = 0
|
||||
Dim curCol As Integer = 0
|
||||
Dim dataTable As DataTable = New DataTable()
|
||||
Dim worksheet As ExcelWorksheet = excelFile.Worksheets(0)
|
||||
|
||||
For cols = 0 To worksheet.Rows(0).AllocatedCells.Count - 1
|
||||
|
||||
If firstRowHasHeaders Then
|
||||
|
||||
If worksheet.Rows(0).Cells(cols).Value IsNot Nothing Then
|
||||
dataTable.Columns.Add(worksheet.Rows(0).Cells(cols).Value.ToString())
|
||||
Else
|
||||
dataTable.Columns.Add("Unnamed Column " & (System.Threading.Interlocked.Increment(unnamed)))
|
||||
End If
|
||||
|
||||
curRow = 1
|
||||
Else
|
||||
dataTable.Columns.Add("Column " & (cols + 1))
|
||||
End If
|
||||
Next
|
||||
|
||||
While curRow < worksheet.Rows.Count
|
||||
columns = New String(cols - 1) {}
|
||||
|
||||
For curCol = 0 To cols - 1
|
||||
|
||||
If worksheet.Rows(curRow).Cells(curCol).Value Is Nothing Then
|
||||
columns(curCol) = ""
|
||||
Else
|
||||
columns(curCol) = worksheet.Rows(curRow).Cells(curCol).Value.ToString()
|
||||
End If
|
||||
Next
|
||||
|
||||
dataTable.Rows.Add(columns)
|
||||
curRow += 1
|
||||
End While
|
||||
|
||||
Return dataTable
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user