diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index 77259bc99..1d8d3ddcc 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -666,12 +666,12 @@ Public Class ClsAcumuladores End Try Return Retorno - End Function - + End Function + #End Region - + #Region "GARANTIAS DETALLES" - + Public Function AddGarantiasDetalle(CveVentaDetalle As Integer, CveFolioGarantia As Integer, CveTipoUso As Integer, CodigoEnsamble As String, CodigoLinea As String, CodigoInspeccion As String, CveTipoDefecto As Integer, NumPoliza As String, Importe As Double, @@ -697,10 +697,25 @@ Public Class ClsAcumuladores OnError("Ocurrió un al agregar la garantia detalle. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try Return Retorno - End Function - + End Function + Public Function GetGarantiasDetalle(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + SqlDataAdapter("PA_Acum_GarantiasDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un al agregar la garantia detalle. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + #End Region - + Public Function DistribuidorMovtosAdd(CveCliente As Integer, Cantidad As Integer, CveTamaño As Integer, CveConcepto As Integer, CveVenta As Integer, CveUsuario As Integer, CveEmpresa As Integer, ImporteCompras As Decimal, Observaciones As String, Optional CveMovimiento As Integer = -1) As Boolean Dim Retorno As Boolean = False diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index 46a58a11a..6ffc5438a 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -1552,7 +1552,7 @@ Public Class ClsClientes Return Retorno End Function - Public Function AgregarClienteNoFrecuente(Nombre As String, Direccion As String, NoExt As String, NoInt As String, Colonia As String, Localidad As String, Ciudad As String, Estado As String, Pais As String, RFC As String, CP As String, Telefono As String, Mail As String, CveSubProyecto As Integer, CveUsuario As Integer, CveEmpresa As Integer, NumCuentaPago As String) As Boolean + Public Function AgregarClienteNoFrecuente(Nombre As String, Direccion As String, NoExt As String, NoInt As String, Colonia As String, Localidad As String, Ciudad As String, Estado As String, Pais As String, RFC As String, CP As String, Telefono As String, Mail As String, CveSubProyecto As Integer, CveUsuario As Integer, CveEmpresa As Integer, NumCuentaPago As String, Optional CvePrecioLista As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_ClientesNoFrecuenteAdd") @@ -1574,6 +1574,7 @@ Public Class ClsClientes .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@NumCuentaPago", SqlDbType.VarChar).Value = NumCuentaPago + .Add("@CvePrecioLista", SqlDbType.Int).Value = CvePrecioLista End With diff --git a/App_Code/ClsContPAQi.vb b/App_Code/ClsContPAQi.vb index 2abd5de9e..57b8483c9 100644 --- a/App_Code/ClsContPAQi.vb +++ b/App_Code/ClsContPAQi.vb @@ -1067,11 +1067,12 @@ Public Class ClsContPAQi StrSQL.Append(" CASE WHEN ISNUMERIC(c.Codigo) = 1 THEN FORMAT(CAST (c.Codigo AS FLOAT),(SELECT REPLACE(Mascarilla,'X','0') FROM Parametros)) ELSE c.Codigo END + ' - ' + c.Nombre + ' ' AS CtaCodigo, ") 'Roberto 8/Nov/2014 StrSQL.Append(" SUM (CASE WHEN mp.TipoMovto = 0 THEN mp.Importe ELSE 0 END) AS Cargo, SUM (CASE WHEN mp.TipoMovto = 1 THEN mp.Importe ELSE 0 END) AS Abono, ") StrSQL.Append(" SUM (CASE WHEN mp.TipoMovto = 0 THEN mp.ImporteME ELSE 0 END) AS CargoME, SUM (CASE WHEN mp.TipoMovto = 1 THEN mp.ImporteME ELSE 0 END) AS AbonoME, ") - StrSQL.Append(" mp.TipoMovto, CASE WHEN ISNUMERIC(c.CODIGO) = 1 THEN FORMAT(CAST (c.CODIGO AS FLOAT),(SELECT REPLACE(Mascarilla,'X','0') FROM Parametros)) ELSE c.CODIGO END CuentaFormato, '' as Estado ") + StrSQL.Append(" mp.TipoMovto, CASE WHEN ISNUMERIC(c.CODIGO) = 1 THEN FORMAT(CAST (c.CODIGO AS FLOAT),(SELECT REPLACE(Mascarilla,'X','0') FROM Parametros)) ELSE c.CODIGO END CuentaFormato, '' as Estado,MAX(U.Nombre) AS UsuarioRegistro ") StrSQL.Append(" FROM MovimientosPoliza mp ") StrSQL.Append(" INNER JOIN Polizas p ON mp.IdPoliza = p.Id ") StrSQL.Append(" INNER JOIN Cuentas c ON c.Id = mp.IdCuenta ") StrSQL.Append(" INNER JOIN TiposPolizas t ON mp.TipoPol = t.Codigo ") + StrSQL.Append(" LEFT JOIN SERVIDOR.Ventas.dbo.Usuarios U ON U.CveUsuario = P.IdUsuario ") StrSQL.Append(" LEFT JOIN SegmentosNegocio s ON mp.IdSegNeg = s.id ") StrSQL.Append(" WHERE (@IdPoliza = -1 OR mp.IdPoliza = @IdPoliza) ") StrSQL.Append(" AND (@Eje = -1 OR mp.Ejercicio = @Eje) ") diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 06f6f4033..d3a93936f 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -13,7 +13,8 @@ Imports System Imports System.Net Imports System.IO.Compression Imports System.Text - +Imports System.Net.Http + Namespace Modelos @@ -375,6 +376,7 @@ Namespace Modelos Me.RemisionesLista = New List(Of Integer) Me.ListaMensajes = New List(Of String) Me.FolioFiscal = "" + Me.GenerarPDFFactura = False IniciaValores() Dim ObjVentas As New ClsVentas() If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then @@ -895,16 +897,21 @@ Namespace Modelos If Me.TipoDocto.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Pd2") Then 'If Not ImprimeAlert Then - Dim ArchivoIngPyMe As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta)) - Dim ArchivoIng As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.rdlc", UsuarioActual.Empresa.Ruta)) - Dim ArchivoRem As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.rdlc", UsuarioActual.Empresa.Ruta)) - Dim ArchivoEgs As New System.IO.FileInfo(String.Format("{0}Formatos/NotaCredito.rdlc", UsuarioActual.Empresa.Ruta)) - - If ArchivoIng.Exists Or ArchivoRem.Exists Or ArchivoIngPyMe.Exists Or ArchivoEgs.Exists Then - MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))) - Else - MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") + If Me.GenerarPDFFactura Then + DescargarFactura(CveVenta, CveEmpresa) + + Dim ArchivoIngPyMe As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta)) + Dim ArchivoIng As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.rdlc", UsuarioActual.Empresa.Ruta)) + Dim ArchivoRem As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.rdlc", UsuarioActual.Empresa.Ruta)) + Dim ArchivoEgs As New System.IO.FileInfo(String.Format("{0}Formatos/NotaCredito.rdlc", UsuarioActual.Empresa.Ruta)) + + If ArchivoIng.Exists Or ArchivoRem.Exists Or ArchivoIngPyMe.Exists Or ArchivoEgs.Exists Then + MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))) + Else + MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") + End If End If + End If 'ERROR DE NO TIMBRADO @@ -1016,6 +1023,28 @@ Namespace Modelos Return Retorno End Function + Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer) As Byte() + Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", ClsPaginas.UrlSitio, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta)))) + Dim File As Byte() = Nothing + Try + Using httpClient = New HttpClient() + httpClient.Timeout = New TimeSpan(0, 15, 0) + Using request = New HttpRequestMessage(HttpMethod.Get, Url) + request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}", CveEmpresa, DateTime.UtcNow.Ticks))) + Dim response = httpClient.SendAsync(request).Result + If response.StatusCode = Net.HttpStatusCode.OK Then + File = response.Content.ReadAsByteArrayAsync().Result + End If + End Using + End Using + Catch ex As Exception + File = Nothing + OnError("Ocurrió un error al descargar la factura", ex) + End Try + + Return File + End Function + #Region " GUARDAR - VENTA, PREPOLIZAS, INV, NC , ESTIMACIONES, AC, NOTA DE CRÉDITO " Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean Dim ProcesoCorrecto As Boolean = True @@ -1758,7 +1787,6 @@ Namespace Modelos Private Function GuardarUsados(SqlTransaccion As SqlClient.SqlTransaction, CveVenta As Integer, ByRef ObjVentas As ClsVentas) As Boolean Dim Resultado As Boolean = True - 'If ClienteEsDistribuidor Then If UsuarioActual.Empresa.Funcionalidad(533).ToEntero > 0 Then Dim CvePSPSA As Integer = UsuarioActual.Empresa.Funcionalidad(533).ToEntero @@ -1785,19 +1813,9 @@ Namespace Modelos Exit For End If Next - Else - Resultado = False End If End If - - - Else - ErrorList.Add("El cliente es Distribuidor y no se tiene un producto o servicio asigando como PS Acumulador") - Resultado = False End If - 'Else - ' Resultado = True - 'End If Return Resultado @@ -8258,6 +8276,7 @@ Namespace Modelos Public Property CveContratoSecciones As String Public Property CveEstatus As Integer + Public Property GenerarPDFFactura As Boolean = False #End Region End Class diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 1bf975aa1..557ae3e82 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -3755,7 +3755,7 @@ Partial Class Compras_Compras Dim GuardaNoDeducibles As Boolean = False If ChkEsNoDeducible.Checked Then For Each Row As DataRow In TmpDT.Rows - If Row("NoDeducible").ToString = "True" Then + If Row("NoDeducible").ToString().ToUpper() = "TRUE" OrElse Row("NoDeducible").ToString().ToUpper() = "1" Then GuardaNoDeducibles = True End If Next @@ -4748,7 +4748,7 @@ Partial Class Compras_Compras CveTipoGasto:=Row("CveTipoGasto").ToString.ToEntero, AF_Medida:=Row("AFMedida").ToString.ToEntero, AF_TipoMantenimiento:=Row("AFTipoMantenimiento").ToString.ToEntero, Referencia:=Referencia, OtrosGastos:=Row("OtrosGastos").ToString.ToDecimal, RetIVA:=Row("RetIVA").ToString.ToDouble, RetISR:=Row("RetISR").ToString.ToDouble, IEPSPS:=Row("IEPSPS").ToString.ToDouble, IEPSPSIVA:=Row("IEPSPSIVA").ToString.ToDouble, IVAPorcentaje:=Row("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=Row("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=Row("RetISRPorcentaje").ToString.ToDouble, - IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If(Row("NoDeducible").ToString = "True" AndAlso EsNoDeducible, True, False)) Then + IEPSPSPorcentaje:=Row("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=Row("IEPSPSIVAPorcentaje").ToString.ToDouble, NoDeducible:=If((Row("NoDeducible").ToString = "True" OrElse Row("NoDeducible").ToString = "1") AndAlso EsNoDeducible, True, False)) Then ErrorDetalles = True Exit For @@ -9518,15 +9518,15 @@ Partial Class Compras_Compras Dim Referencia As String = $"{TxtSerie.Text}-{TxtFolio.Text}" ' concatenation interpolation Select Case ConceptoContable - Case 5 - IdCtaContable = 1244 - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 5, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TxtTotal.Text.ToDecimal, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - End If - IdCtaContable = 1243 - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, 205, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TxtTotal.Text.ToDecimal, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - End If + 'Case 5 + ' IdCtaContable = 1244 + ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 5, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TxtTotal.Text.ToDecimal, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then + ' ErrorPrepoliza = True + ' End If + ' IdCtaContable = 1243 + ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, 205, Referencia, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=DdlProveedor.SelectedValue.ToEntero, CvePersonal:=CvePersonal, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TxtTotal.Text.ToDecimal, ImporteME:=If(tipoCambioActual = 1, 0, TxtTotal.Text.ToDecimal), CveCuenta:=CveCuenta) Then + ' ErrorPrepoliza = True + ' End If Case 6 Dim CveProveedorConcepto As Integer = 0, CveAcreedor As Integer = 0, CveIE As Integer = 0, CveColectiva As Integer = 0, CveCreditoDetalle As Integer = 0 Dim ConceptoPersonal As String = "", Concepto As String = "" @@ -9815,11 +9815,11 @@ Partial Class Compras_Compras BtnGuardar.Enabled = True UpFacturar.Update() - End Sub + End Sub #End Region - + #Region "CargaXML" - + Private Function ValorXML(n As XmlNode, Campo As String, Optional Retorno As String = "") As String Dim o As XmlNode = n.Attributes.Cast(Of XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0) If o Is Nothing Then @@ -10024,10 +10024,10 @@ Partial Class Compras_Compras 'End Try - End Sub - + End Sub + #End Region - + #Region "GV'S" Protected Sub GVAnticipos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVAnticipos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -10292,9 +10292,9 @@ Partial Class Compras_Compras End If - End Sub + End Sub #End Region - + #Region "METODOS" Private Sub GeneraGlobalDT(data As Object) Dim ObjPS As New ClsProductosServicios @@ -10727,66 +10727,66 @@ Partial Class Compras_Compras CargarUMAlias() - End Sub + End Sub #End Region - + #Region " ALGO DE AF QUE NUNCA SE USABA " - 'Protected Sub GVAF_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAF.RowCreated - ' If e.Row.RowType = DataControlRowType.DataRow AndAlso (e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal) Then - ' e.Row.FCDropDownList("DdlTipoActivoFijo").DataSource = TmpDTTiposAF - ' e.Row.FCDropDownList("DdlTipoActivoFijo").DataBind() - - ' e.Row.FCDropDownList("DdlSubTipoActivoFijo").DataSource = Nothing - ' e.Row.FCDropDownList("DdlSubTipoActivoFijo").DataBind() - ' e.Row.FCDropDownList("DdlSubTipoActivoFijo").Items.Insert(0, New ListItem("Seleccione", "-1")) - - - ' e.Row.FCDropDownList("DdlAF").DataSource = Nothing - ' e.Row.FCDropDownList("DdlAF").DataBind() - ' e.Row.FCDropDownList("DdlAF").Items.Insert(0, New ListItem("Seleccione", "-1")) - - ' End If - 'End Sub - - 'Protected Sub GVAF_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAF.RowDataBound - ' If e.Row.RowType = DataControlRowType.DataRow Then - ' If e.Row.RowIndex = 0 Then - ' e.Row.Cells(0).Width = Unit.Pixel(20) - ' e.Row.Cells(1).Width = Unit.Pixel(140) - ' e.Row.Cells(2).Width = Unit.Pixel(250) - ' End If - - ' e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Right - ' e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left - ' e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left - ' End If - 'End Sub - - 'Protected Sub DdlTipoActivoFijo_SelectedIndexChanged(sender As Object, e As System.EventArgs) - ' Dim Array() As String = Nothing - ' Dim DdlGVSubTipoAF As DropDownList = Nothing - - ' Array = DirectCast(sender, DropDownList).ClientID.Split("_"c) - ' If Array.Length > 0 Then - ' DdlGVSubTipoAF = DirectCast(GVAF.Rows(Array(3).ToEntero).Controls(4).Controls(1), DropDownList) - ' End If - - ' If DdlGVSubTipoAF IsNot Nothing Then CargaSubTipoAF(DirectCast(sender, DropDownList), DdlGVSubTipoAF) - 'End Sub - - 'Protected Sub GvOCC2_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvOCC2.RowDataBound - ' If e.Row.RowType = DataControlRowType.DataRow Then - - ' e.Row.Cells(0).Text = (e.Row.RowIndex + 1).ToString - - ' End If - 'End Sub - - 'Protected Sub chkFuncionariosEmpleados_CheckedChanged(sender As Object, e As EventArgs) Handles chkFuncionariosEmpleados.CheckedChanged - ' PnlPagoContado.Visible = Not chkFuncionariosEmpleados.Checked - ' PnlFuncionarioEmpleado.Visible = chkFuncionariosEmpleados.Checked - ' UPCondicionesPago.Update() - 'End Sub + 'Protected Sub GVAF_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAF.RowCreated + ' If e.Row.RowType = DataControlRowType.DataRow AndAlso (e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal) Then + ' e.Row.FCDropDownList("DdlTipoActivoFijo").DataSource = TmpDTTiposAF + ' e.Row.FCDropDownList("DdlTipoActivoFijo").DataBind() + + ' e.Row.FCDropDownList("DdlSubTipoActivoFijo").DataSource = Nothing + ' e.Row.FCDropDownList("DdlSubTipoActivoFijo").DataBind() + ' e.Row.FCDropDownList("DdlSubTipoActivoFijo").Items.Insert(0, New ListItem("Seleccione", "-1")) + + + ' e.Row.FCDropDownList("DdlAF").DataSource = Nothing + ' e.Row.FCDropDownList("DdlAF").DataBind() + ' e.Row.FCDropDownList("DdlAF").Items.Insert(0, New ListItem("Seleccione", "-1")) + + ' End If + 'End Sub + + 'Protected Sub GVAF_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAF.RowDataBound + ' If e.Row.RowType = DataControlRowType.DataRow Then + ' If e.Row.RowIndex = 0 Then + ' e.Row.Cells(0).Width = Unit.Pixel(20) + ' e.Row.Cells(1).Width = Unit.Pixel(140) + ' e.Row.Cells(2).Width = Unit.Pixel(250) + ' End If + + ' e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Right + ' e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left + ' e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left + ' End If + 'End Sub + + 'Protected Sub DdlTipoActivoFijo_SelectedIndexChanged(sender As Object, e As System.EventArgs) + ' Dim Array() As String = Nothing + ' Dim DdlGVSubTipoAF As DropDownList = Nothing + + ' Array = DirectCast(sender, DropDownList).ClientID.Split("_"c) + ' If Array.Length > 0 Then + ' DdlGVSubTipoAF = DirectCast(GVAF.Rows(Array(3).ToEntero).Controls(4).Controls(1), DropDownList) + ' End If + + ' If DdlGVSubTipoAF IsNot Nothing Then CargaSubTipoAF(DirectCast(sender, DropDownList), DdlGVSubTipoAF) + 'End Sub + + 'Protected Sub GvOCC2_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvOCC2.RowDataBound + ' If e.Row.RowType = DataControlRowType.DataRow Then + + ' e.Row.Cells(0).Text = (e.Row.RowIndex + 1).ToString + + ' End If + 'End Sub + + 'Protected Sub chkFuncionariosEmpleados_CheckedChanged(sender As Object, e As EventArgs) Handles chkFuncionariosEmpleados.CheckedChanged + ' PnlPagoContado.Visible = Not chkFuncionariosEmpleados.Checked + ' PnlFuncionarioEmpleado.Visible = chkFuncionariosEmpleados.Checked + ' UPCondicionesPago.Update() + 'End Sub Protected Sub BtnOCAceptar_Click(sender As Object, e As EventArgs) Handles BtnOCAceptar.Click 'carga la OC Dim CveOC As Integer = -1 @@ -10823,45 +10823,45 @@ Partial Class Compras_Compras 'UpnAF.Update() - End Sub + End Sub #End Region - + #Region "Estimaciones" - - 'Private Sub CargaDatosEstimaciones(pCveProveedor As Integer) - ' Dim Con As New ClsContratos - ' If Con.GetEstimaciones(pCveProveedor, -1, -1, -1, -1, 0, UsuarioActual.CveEmpresa) Then - ' GVEst.DataSource = Con.DtResultados - ' GVEst.DataBind() - - ' End If - ' UPEstimaciones.Update() - ' Con.Dispose() - 'End Sub - - 'Protected Sub GVEst_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVEst.RowDataBound - ' If e.Row.RowType = DataControlRowType.DataRow Then - ' If e.Row.RowIndex = 0 Then - ' e.Row.Cells(0).Width = Unit.Pixel(30) - ' e.Row.Cells(1).Width = Unit.Pixel(30) 'Seccion - ' e.Row.Cells(2).Width = Unit.Pixel(300) 'SubSeccion - ' e.Row.Cells(3).Width = Unit.Pixel(100) 'Cantidad - ' End If - - ' If e.Row.DBCampo("RazonSocial") = "" Then - ' e.Row.CssClass = "Totales" : e.Row.Height = 25 - ' ElseIf e.Row.DBCampo("Contrato") = "" Then - ' e.Row.CssClass = "SubTotales2" : e.Row.Height = 25 - ' ElseIf e.Row.DBCampo("Seccion") = "" Then - ' e.Row.CssClass = "SubTotales" : e.Row.Height = 25 - ' ElseIf e.Row.DBCampo("Clasificacion") = "" Then - ' e.Row.CssClass = "SubTotales3" : e.Row.Height = 25 - ' End If - - ' End If - 'End Sub + + 'Private Sub CargaDatosEstimaciones(pCveProveedor As Integer) + ' Dim Con As New ClsContratos + ' If Con.GetEstimaciones(pCveProveedor, -1, -1, -1, -1, 0, UsuarioActual.CveEmpresa) Then + ' GVEst.DataSource = Con.DtResultados + ' GVEst.DataBind() + + ' End If + ' UPEstimaciones.Update() + ' Con.Dispose() + 'End Sub + + 'Protected Sub GVEst_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVEst.RowDataBound + ' If e.Row.RowType = DataControlRowType.DataRow Then + ' If e.Row.RowIndex = 0 Then + ' e.Row.Cells(0).Width = Unit.Pixel(30) + ' e.Row.Cells(1).Width = Unit.Pixel(30) 'Seccion + ' e.Row.Cells(2).Width = Unit.Pixel(300) 'SubSeccion + ' e.Row.Cells(3).Width = Unit.Pixel(100) 'Cantidad + ' End If + + ' If e.Row.DBCampo("RazonSocial") = "" Then + ' e.Row.CssClass = "Totales" : e.Row.Height = 25 + ' ElseIf e.Row.DBCampo("Contrato") = "" Then + ' e.Row.CssClass = "SubTotales2" : e.Row.Height = 25 + ' ElseIf e.Row.DBCampo("Seccion") = "" Then + ' e.Row.CssClass = "SubTotales" : e.Row.Height = 25 + ' ElseIf e.Row.DBCampo("Clasificacion") = "" Then + ' e.Row.CssClass = "SubTotales3" : e.Row.Height = 25 + ' End If + + ' End If + 'End Sub #End Region - + #Region " ALMACEN " Private Sub CargaGvInv() @@ -11178,11 +11178,11 @@ Partial Class Compras_Compras UpAlmacenEvidencia.Update() - End Sub + End Sub #End Region - + #Region "PESTAÑA INFORMACION GENERAL DE BANCO IE" - + Private Sub CargaTipoTransaccion() DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'") DdlTipoTransaccion.DataBind() @@ -11203,52 +11203,52 @@ Partial Class Compras_Compras DdlCuentaCaja.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros(String.Format("CveTipoCuenta = 1")) DdlCuentaCaja.DataBind() DdlCuentaCaja.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - + End Sub + #End Region - + #Region "FINANCIAMIENTO - AC" - 'Private Sub CreaDtAC() - ' DtAC = New DataTable - ' DtAC.Columns.Add("IdCuenta", GetType(String)) - ' DtAC.Columns.Add("Cuenta", GetType(String)) - ' DtAC.Columns.Add("Saldo", GetType(String)) - 'End Sub - 'Protected Sub CargaGvAc(Optional datos As DataTable = Nothing) - ' If UsuarioActual.Empresa.UsaAC Then - ' GvAC.DataBind() - ' GvAC.DataSource = If(datos IsNot Nothing, datos, DtAC) - ' GvAC.DataBind() - - ' Dim Total As Double = GvAC.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("PorDevengar").ToDouble) - - ' Lbtotalsaldo.Text = Total.ToString.FormatoNumero - ' UPPM.Update() - ' PnlAC.Visible = True - ' End If - 'End Sub - - 'Protected Sub CargaAC() - ' Dim Cont As New ClsContPAQi(UsuarioActual.Empresa) - - ' If Cont.GetACSaldos(UsuarioActual.Empresa.EjercicioActual, 2) Then - ' DtAC = Cont.DtResultados.Copy.FiltraParametros("PorDevengar > 0") - ' Else - ' Alert("Ocurrio un error al cargar los Presupuestos. Por favor vuelva a cargar la pagina") - ' End If - - ' Cont.Dispose() - 'End Sub - - 'Protected Sub GvAC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAC.RowDataBound - ' If e.Row.RowType = DataControlRowType.DataRow Then - - ' e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", String.Format("ValidaImporte(this,{0});", e.Row.DBCampo("PorDevengar"))) - ' End If - 'End Sub - + 'Private Sub CreaDtAC() + ' DtAC = New DataTable + ' DtAC.Columns.Add("IdCuenta", GetType(String)) + ' DtAC.Columns.Add("Cuenta", GetType(String)) + ' DtAC.Columns.Add("Saldo", GetType(String)) + 'End Sub + 'Protected Sub CargaGvAc(Optional datos As DataTable = Nothing) + ' If UsuarioActual.Empresa.UsaAC Then + ' GvAC.DataBind() + ' GvAC.DataSource = If(datos IsNot Nothing, datos, DtAC) + ' GvAC.DataBind() + + ' Dim Total As Double = GvAC.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("PorDevengar").ToDouble) + + ' Lbtotalsaldo.Text = Total.ToString.FormatoNumero + ' UPPM.Update() + ' PnlAC.Visible = True + ' End If + 'End Sub + + 'Protected Sub CargaAC() + ' Dim Cont As New ClsContPAQi(UsuarioActual.Empresa) + + ' If Cont.GetACSaldos(UsuarioActual.Empresa.EjercicioActual, 2) Then + ' DtAC = Cont.DtResultados.Copy.FiltraParametros("PorDevengar > 0") + ' Else + ' Alert("Ocurrio un error al cargar los Presupuestos. Por favor vuelva a cargar la pagina") + ' End If + + ' Cont.Dispose() + 'End Sub + + 'Protected Sub GvAC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAC.RowDataBound + ' If e.Row.RowType = DataControlRowType.DataRow Then + + ' e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", String.Format("ValidaImporte(this,{0});", e.Row.DBCampo("PorDevengar"))) + ' End If + 'End Sub + #End Region - + #Region "TAB - PERSONAL" Private Sub CargaGvPersonal() GvPersonal.DataSource = TmpDT @@ -11419,13 +11419,13 @@ Partial Class Compras_Compras Next - End Sub - - - - + End Sub + + + + #End Region - + #Region "TAB - ACTIVOS FIJOS -AF" Protected Sub CargarGvActivosFijos(sender As Object, e As EventArgs) Tab.ActiveTabIndex = 3 @@ -11655,58 +11655,58 @@ Partial Class Compras_Compras End Sub Protected Sub BtnAFMedida_Click(sender As Object, e As EventArgs) TmpDT(HdnIndexTmpDT.Value.ToEntero)("AFMedida") = HdnTxtAFMedida.Value - End Sub + End Sub #End Region - + #Region "C O N T R A T O S" - 'Protected Sub ImgBtnBuscarContrato_Click(sender As Object, e As ImageClickEventArgs) Handles ImgBtnBuscarContrato.Click - ' If CveProveedor <= 0 Then - ' Alert("Debe de Seleccionar un proveedor") - ' Exit Sub - ' End If - - ' RegistraScript(String.Format("AbrirVentana('/Contratos/PopUpBuscarContrato.aspx?V=VCCOMP',730,300,'N');")) - 'End Sub - - 'Protected Sub CargaVContrato(sender As Object, e As EventArgs) - ' CargaVContrato2(HdnVCveContrato.Value) - 'End Sub - - 'Protected Sub CargaVContrato2(CveContrato As String) - ' If TxtContrato.Text <> "" Then - ' Dim ObjContratos As New ClsContratos - ' Dim DTContratosTemp As DataTable = Nothing - - ' GvContratos1.DataSource = TmpDT - ' GvContratos1.DataBind() - ' UPGVContratos1.Update() - - ' Dim ArrayCveContratos As String() = HdnVCveContrato.Value.Split(New Char() {","c}) - ' For i As Integer = 1 To ArrayCveContratos.Count - ' If ObjContratos.GetContratosDetalle(ArrayCveContratos(i - 1).ToEntero) Then - ' If IsNothing(DTContratosTemp) Then - ' DTContratosTemp = ObjContratos.DtResultados.Copy - ' Else - ' DTContratosTemp.Merge(ObjContratos.DtResultados) - ' End If - ' Else - ' Alert("Ocurrio un ERROR al cargar el Contrato") - ' DTContratosTemp.Rows.Clear() - ' Exit For - ' End If - ' Next - - ' GvContratos2.DataSource = DTContratosTemp - ' GvContratos2.DataBind() - ' UPGVContratos2.Update() - - ' ObjContratos.Dispose() - ' End If - 'End Sub + 'Protected Sub ImgBtnBuscarContrato_Click(sender As Object, e As ImageClickEventArgs) Handles ImgBtnBuscarContrato.Click + ' If CveProveedor <= 0 Then + ' Alert("Debe de Seleccionar un proveedor") + ' Exit Sub + ' End If + + ' RegistraScript(String.Format("AbrirVentana('/Contratos/PopUpBuscarContrato.aspx?V=VCCOMP',730,300,'N');")) + 'End Sub + + 'Protected Sub CargaVContrato(sender As Object, e As EventArgs) + ' CargaVContrato2(HdnVCveContrato.Value) + 'End Sub + + 'Protected Sub CargaVContrato2(CveContrato As String) + ' If TxtContrato.Text <> "" Then + ' Dim ObjContratos As New ClsContratos + ' Dim DTContratosTemp As DataTable = Nothing + + ' GvContratos1.DataSource = TmpDT + ' GvContratos1.DataBind() + ' UPGVContratos1.Update() + + ' Dim ArrayCveContratos As String() = HdnVCveContrato.Value.Split(New Char() {","c}) + ' For i As Integer = 1 To ArrayCveContratos.Count + ' If ObjContratos.GetContratosDetalle(ArrayCveContratos(i - 1).ToEntero) Then + ' If IsNothing(DTContratosTemp) Then + ' DTContratosTemp = ObjContratos.DtResultados.Copy + ' Else + ' DTContratosTemp.Merge(ObjContratos.DtResultados) + ' End If + ' Else + ' Alert("Ocurrio un ERROR al cargar el Contrato") + ' DTContratosTemp.Rows.Clear() + ' Exit For + ' End If + ' Next + + ' GvContratos2.DataSource = DTContratosTemp + ' GvContratos2.DataBind() + ' UPGVContratos2.Update() + + ' ObjContratos.Dispose() + ' End If + 'End Sub #End Region - + #Region "TAB ALMACEN - INVENTARIOS ISRAEL PIÑA - 5 FEBRERO 2015" - + Protected Sub CalculaTotalPorDevengar() Dim total = TxtTotal.Text.ToDouble For Each Gvr As GridViewRow In GvInv.Rows @@ -11720,10 +11720,10 @@ Partial Class Compras_Compras Protected Sub CambiaTotalDevengar(sender As Object, e As EventArgs) CalculaTotalPorDevengar() - End Sub - + End Sub + #End Region - + #Region " AJUSTA IMPORTES " Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False) 'Dim TempSubTotal = TxtSubTotal.Text.ToDouble @@ -11822,9 +11822,9 @@ Partial Class Compras_Compras GvPS.DataBind() UpPS.Update() - End Sub + End Sub #End Region - + #Region "DDL'S" Protected Sub DdlCredito_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCredito.SelectedIndexChanged CargaCreditosDetalle(DdlCredito.SelectedValue.ToEntero) @@ -12053,9 +12053,9 @@ Partial Class Compras_Compras RVDocumentoImporteFE.MaximumValue = saldo.ToString UPCondicionesPago.Update() - End Sub + End Sub #End Region - + #Region "CHK'S" Protected Sub RBLCajaChica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLCajaChica.SelectedIndexChanged Select Case RBLCajaChica.SelectedValue @@ -12277,9 +12277,9 @@ Partial Class Compras_Compras ElseIf RblRembolso.SelectedValue.ToEntero = 2 Then TrRembolsoCajaChica.Visible = True End If - End Sub + End Sub #End Region - + #Region "ARMONIZACION CONTABLE - AC - SIMPLIFICADO" Private Sub CargaPresupuestosEgresos(Optional CargaTodo As Boolean = True) @@ -12543,10 +12543,10 @@ Partial Class Compras_Compras EjercicioAC = Ejercicio End If - End Sub - + End Sub + #End Region - + #Region "E V E N T O - B I T A C O R A" Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -12643,9 +12643,9 @@ Partial Class Compras_Compras End If ObjEventoBitacora.Dispose() GvEB.DataBind() - End Sub + End Sub #End Region - + #Region " C O N T A B I L I D A D " Protected Sub BtnDescontabilizar_Click(sender As Object, e As EventArgs) 'Alert("Hola entre", TipoMensaje.MsgError) @@ -13034,10 +13034,10 @@ Partial Class Compras_Compras If Not ErrorCompra Then CargaCompra() End If - End Sub - + End Sub + #End Region - + #Region " REEMBOLSOS NO USA AC " Protected Sub DdlPersonal2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonalReembolso.SelectedIndexChanged ViewState("CvePersonal") = DdlPersonalReembolso.SelectedValue @@ -13051,13 +13051,13 @@ Partial Class Compras_Compras CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero End If ViewState("CveCajaChica") = DdlCuentaCajaChicaReembolso.SelectedValue - End Sub + End Sub #End Region - + #Region " ALMACEN " - + #End Region - + #Region " CONSIGNACIONES " Protected Sub ChkConsignacion_CheckedChanged(sender As Object, e As EventArgs) @@ -13327,13 +13327,13 @@ Partial Class Compras_Compras BtnGuardar.Enabled = True UpFacturar.Update() - End Sub + End Sub #End Region - + #Region " ***** Devoluciones INV ***** " - - '*se envia true si hubo un error*' - + + '*se envia true si hubo un error*' + Private Function guardardevolucion(ObjInventario As ClsInventarios, CveCompra As Integer, subtotal As Double, Fecha As Date) As Boolean Dim ErrorMovInv As Boolean = False Dim CveAlmacen As Integer @@ -13530,9 +13530,9 @@ Partial Class Compras_Compras ImgBtnBuscarOC.Visible = False UpParametros.Update() UpPSS.Update() - End Sub + End Sub #End Region - + #Region " REFACTURACION " Private Sub ValidaRefacturacion() If Not CveCompra > 0 AndAlso DdlTipoComprobante.SelectedValue = "Fac" And UsuarioActual.Empresa.CvePlataforma <> 2 Then @@ -13766,10 +13766,10 @@ Partial Class Compras_Compras End If Return ErrorBitacora - End Function - + End Function + #End Region - + #Region " CANCELAR COMPRA " Private Sub ValidaCancelarCompra() If UsuarioActual.TienePermisoProceso(140) Then @@ -14048,10 +14048,10 @@ Partial Class Compras_Compras DivValesCombustible.Visible = True RegistraScript(String.Format("$('#{0}').modal('show')", DivValesCombustible.ClientID)) UPPValesCombustible.Update() - End Sub - + End Sub + #End Region - + #Region " VALES COMBUSTIBLES " Protected Sub BtnValesVincular_Click(sender As Object, e As EventArgs) IdVale = New List(Of Integer) @@ -14071,9 +14071,9 @@ Partial Class Compras_Compras ' Alert(cve.ToString) 'Next End If - End Sub + End Sub #End Region - + #Region " VINCULAR OC " Private Sub InicializaOC() 'BORRAR OC @@ -15106,11 +15106,11 @@ Partial Class Compras_Compras Alert($"El concepto {PS} tiene especificada la cantidad {Cantidad} pero un costo de cero ($0).

En caso de vincular la OC de esta manera la cantidad especificada sera considerada como recibida.

De ser correcto Continue o de lo contrario rectifique.", TipoMensaje.MsgAdvertencia) - End Sub + End Sub #End Region - + #Region "F L E T E S Y S E R V I C I O S" - + Public Sub CreaDTFacturas() Dim dt As New DataTable @@ -18959,11 +18959,11 @@ Partial Class Compras_Compras Dim gvr As GridViewRow = CType(Chk.BindingContainer, GridViewRow) For Each drt As DataRow In TmpDT.Select("Consec = " & gvr.RowIndex + 1) - drt("NoDeducible") = Chk.Checked Next TmpDT.AcceptChanges() + Alert((TmpDT.Select("Consec = " & gvr.RowIndex + 1)(0))("NoDeducible").ToString()) AddPS2(EsNoDeducible:=EsNoDeducible) End Sub diff --git a/Empresas/119/Formatos/Polizas.rdlc b/Empresas/119/Formatos/Polizas.rdlc index 5df38836e..71816c9f8 100644 --- a/Empresas/119/Formatos/Polizas.rdlc +++ b/Empresas/119/Formatos/Polizas.rdlc @@ -1099,10 +1099,10 @@ - + =Fields!UsuarioRegistro.Value @@ -1120,6 +1120,7 @@ 1pt + true diff --git a/Inventarios/RecepcionEntrega.aspx.vb b/Inventarios/RecepcionEntrega.aspx.vb index dab265de2..8bb30551f 100644 --- a/Inventarios/RecepcionEntrega.aspx.vb +++ b/Inventarios/RecepcionEntrega.aspx.vb @@ -1517,6 +1517,7 @@ Partial Class Inventarios_RecepcionEntrega Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL()) Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) + Dim ObjAcumuladores As New ClsAcumuladores(ObjInventario.IniciaTransacSQL()) Dim CveMovimiento As Integer Dim Folio As Integer Dim ErrorMovInv As Boolean @@ -1524,6 +1525,8 @@ Partial Class Inventarios_RecepcionEntrega Dim DtDetalleLote As New DataTable Dim TextoError = "" + Dim CveMovimientoGarantia As Integer = -1 + Dim FolioGarantia As Integer = -1 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH Dim Index = 0 @@ -1561,131 +1564,6 @@ Partial Class Inventarios_RecepcionEntrega Exit Sub End If - - 'VALIDA EXISTENCIA 2 - If TipoMovimiento = 1 Then - - 'For Each Dr As DataRow In DtDatos.Rows - ' If Dr("CantidadGV").ToString.ToDecimal > 0 Then - ' If Dr("Inv_CveMetodoInventario").ToString = "5" Then - ' DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - ' For Each Dr1 As DataRow In DtDetalle.Rows - ' If Not ObjInventario.GetExistenciasPS(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Dr1("SerieLote").ToString, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) >= 1 Then - ' TextoError += String.Format(" - {0} Serie: {1}
", Dr("PS"), Dr1("SerieLote")) - ' End If - ' Next - ' ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then - ' DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - ' For Each Dr1 As DataRow In DtDetalle.Rows - ' If Not ObjInventario.GetExistenciasPS(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) >= DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'") Then - ' TextoError += String.Format(" - {0} Lote: {1} Batch: {2}
", Dr("PS"), Dr1("Lote"), Dr1("Batch")) - ' End If - ' Next - ' Else - 'If Not ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) >= Dr("CantidadGV").ToString.ToDecimal Then - ' TextoError += String.Format(" - {0}
", Dr("PS")) - ' End If - ' End If - - ' End If - 'Next - - Dim StrXML As New StringBuilder - StrXML.Append("") - For Each Dr As DataRow In DtDatos.Rows - If Dr("CantidadGV").ToString.ToDecimal > 0 Then - If Dr("Inv_CveMetodoInventario").ToString = "5" Then - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), 1, Dr1("SerieLote")) - Next - ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then - DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'"), Dr1("Lote")) - Next - Else - StrXML.AppendFormat("", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), "-1") - End If - End If - Next - StrXML.Append("") - - 'Alert(StrXML.ToString()) - 'ObjInventario.RollBack() - 'ObjInventario.Dispose() - 'Exit Sub - - Dim TieneErrorExistencia = False - If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - If ObjInventario.DtResultados.Rows.Count > 0 Then - TieneErrorExistencia = True - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - TextoError += $" - {Dr("CodigoPS")} Existencia: {Dr("Existencia").ToString.ToDecimal.ToString("#,##0.##")}
" - Next - End If - Else - TieneErrorExistencia = True - End If - - If TieneErrorExistencia Then - ObjInventario.RollBack() - ObjInventario.Dispose() - ObjConta.Dispose() - ObjVentas.Dispose() - ObjEventos.Dispose() - If TextoError.Length > 0 Then - Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:

{TextoError}", TipoMensaje.MsgAdvertencia) - End If - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - - Else - 'If Not UsuarioActual.TienePermisoProceso(223) Then 'INVALIDA LA VALIDACION DE EXISTENCIA DE LA VENTA ORIGINAL - ' If DtExistencias IsNot Nothing Then - ' For Each Dr As DataRow In DtDatos.Rows - ' If Dr("CantidadGV").ToString.ToDecimal > 0 Then - - ' If Dr("Inv_CveMetodoInventario").ToString = "5" Then - ' DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - ' For Each Dr1 As DataRow In DtDetalle.Rows - ' If Not DtExistencias.SUM("Cantidad", $"CvePS = {Dr1("CvePS").ToString.ToEntero} AND CveUM = {Dr1("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'") >= 1 Then - ' TextoError += String.Format(" - {0}
", Dr1("PS")) - ' End If - ' Next - ' ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then - ' DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - ' For Each Dr1 As DataRow In DtDetalle.Rows - ' If Not DtExistencias.SUM("Cantidad", $"CvePS = {Dr1("CvePS").ToString.ToEntero} AND CveUM = {Dr1("CveUM").ToString.ToEntero} AND Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'") >= DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'") Then - ' TextoError += String.Format(" - {0}
", Dr1("PS")) - ' End If - ' Next - ' Else - ' If Not DtExistencias.SUM("Cantidad", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}") >= Dr("CantidadGV").ToString.ToDecimal Then - ' TextoError += String.Format(" - {0}
", Dr("PS")) - ' End If - ' End If - ' End If - ' Next - ' If TextoError <> "" Then - ' Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:

{TextoError}", TipoMensaje.MsgAdvertencia) - ' RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ' ObjInventario.RollBack() - ' ObjInventario.Dispose() - ' ObjConta.Dispose() - ' ObjVentas.Dispose() - ' ObjEventos.Dispose() - ' Exit Sub - ' End If - ' End If - 'End If - End If - - '' TERMINA: VALIDACIONES - - - '' COMIENZA: APARTADOS Dim DtTraspasos As New DataTable DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer)) DtTraspasos.Columns.Add("Almacen", GetType(String)) @@ -1695,77 +1573,250 @@ Partial Class Inventarios_RecepcionEntrega DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer)) Dim CveMovimientoSalida = -1, FolioSalida = -1, CveMovimientoEntrada = -1, CveMovimientoEntradaApartado = -1, FolioEntrada = -1, CveMovimientoSalidaDevRem = -1, FolioMovimientoSalidaDevRem = -1, CveMovimientoEntradaDevRem = -1, FolioMovimientoEntradaDevRem = -1 - Dim CantidadPendiente As Decimal = 0 - Dim CantidadSaldo As Decimal = 0 + Try + 'VALIDA EXISTENCIA 2 + If TipoMovimiento = 1 Then - If CveVendedor > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(146) = "1" Or CveCliente > 0) AndAlso TipoDocto <> "Ped" Then 'no debe considerar cuando es pedido de contrato - If TipoMovimiento = 1 Then ' SI ES DEVOLUCION NO APLICA APARTADO - ' SALIDA POR TRASPASO DE LOS ALMACENES DE APARTADO + 'For Each Dr As DataRow In DtDatos.Rows + ' If Dr("CantidadGV").ToString.ToDecimal > 0 Then + ' If Dr("Inv_CveMetodoInventario").ToString = "5" Then + ' DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) + ' For Each Dr1 As DataRow In DtDetalle.Rows + ' If Not ObjInventario.GetExistenciasPS(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Dr1("SerieLote").ToString, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) >= 1 Then + ' TextoError += String.Format(" - {0} Serie: {1}
", Dr("PS"), Dr1("SerieLote")) + ' End If + ' Next + ' ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then + ' DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) + ' For Each Dr1 As DataRow In DtDetalle.Rows + ' If Not ObjInventario.GetExistenciasPS(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) >= DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'") Then + ' TextoError += String.Format(" - {0} Lote: {1} Batch: {2}
", Dr("PS"), Dr1("Lote"), Dr1("Batch")) + ' End If + ' Next + ' Else + 'If Not ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) >= Dr("CantidadGV").ToString.ToDecimal Then + ' TextoError += String.Format(" - {0}
", Dr("PS")) + ' End If + ' End If + + ' End If + 'Next + + Dim StrXML As New StringBuilder + StrXML.Append("") For Each Dr As DataRow In DtDatos.Rows If Dr("CantidadGV").ToString.ToDecimal > 0 Then - If Dr("Inv_CveMetodoInventario").ToString = "5" Then - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) For Each Dr1 As DataRow In DtDetalle.Rows - If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Dr1("SerieLote").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then - For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows + StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), 1, Dr1("SerieLote")) + Next + ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then + DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) + For Each Dr1 As DataRow In DtDetalle.Rows + StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'"), Dr1("Lote")) + Next + Else + StrXML.AppendFormat("", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), "-1") + End If + End If + Next + StrXML.Append("") - 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO - CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero + 'Alert(StrXML.ToString()) + 'ObjInventario.RollBack() + 'ObjInventario.Dispose() + 'Exit Sub - If Not CveMovimientoSalida > 0 Then - CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) - FolioSalida = ObjInventario.Folio + Dim TieneErrorExistencia = False + If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + If ObjInventario.DtResultados.Rows.Count > 0 Then + TieneErrorExistencia = True + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + TextoError += $" - {Dr("CodigoPS")} Existencia: {Dr("Existencia").ToString.ToDecimal.ToString("#,##0.##")}
" + Next + End If + Else + TieneErrorExistencia = True + End If + + If TieneErrorExistencia Then + ObjInventario.RollBack() + ObjInventario.Dispose() + ObjConta.Dispose() + ObjVentas.Dispose() + ObjEventos.Dispose() + If TextoError.Length > 0 Then + Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:

{TextoError}", TipoMensaje.MsgAdvertencia) + End If + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + Exit Sub + End If + + Else + 'If Not UsuarioActual.TienePermisoProceso(223) Then 'INVALIDA LA VALIDACION DE EXISTENCIA DE LA VENTA ORIGINAL + ' If DtExistencias IsNot Nothing Then + ' For Each Dr As DataRow In DtDatos.Rows + ' If Dr("CantidadGV").ToString.ToDecimal > 0 Then + + ' If Dr("Inv_CveMetodoInventario").ToString = "5" Then + ' DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) + ' For Each Dr1 As DataRow In DtDetalle.Rows + ' If Not DtExistencias.SUM("Cantidad", $"CvePS = {Dr1("CvePS").ToString.ToEntero} AND CveUM = {Dr1("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'") >= 1 Then + ' TextoError += String.Format(" - {0}
", Dr1("PS")) + ' End If + ' Next + ' ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then + ' DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) + ' For Each Dr1 As DataRow In DtDetalle.Rows + ' If Not DtExistencias.SUM("Cantidad", $"CvePS = {Dr1("CvePS").ToString.ToEntero} AND CveUM = {Dr1("CveUM").ToString.ToEntero} AND Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'") >= DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'") Then + ' TextoError += String.Format(" - {0}
", Dr1("PS")) + ' End If + ' Next + ' Else + ' If Not DtExistencias.SUM("Cantidad", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}") >= Dr("CantidadGV").ToString.ToDecimal Then + ' TextoError += String.Format(" - {0}
", Dr("PS")) + ' End If + ' End If + ' End If + ' Next + ' If TextoError <> "" Then + ' Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:

{TextoError}", TipoMensaje.MsgAdvertencia) + ' RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + ' ObjInventario.RollBack() + ' ObjInventario.Dispose() + ' ObjConta.Dispose() + ' ObjVentas.Dispose() + ' ObjEventos.Dispose() + ' Exit Sub + ' End If + ' End If + 'End If + End If + + '' TERMINA: VALIDACIONES + + + '' COMIENZA: APARTADOS + Dim CantidadPendiente As Decimal = 0 + Dim CantidadSaldo As Decimal = 0 + + + If CveVendedor > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(146) = "1" Or CveCliente > 0) AndAlso TipoDocto <> "Ped" Then 'no debe considerar cuando es pedido de contrato + If TipoMovimiento = 1 Then ' SI ES DEVOLUCION NO APLICA APARTADO + ' SALIDA POR TRASPASO DE LOS ALMACENES DE APARTADO + For Each Dr As DataRow In DtDatos.Rows + If Dr("CantidadGV").ToString.ToDecimal > 0 Then + + If Dr("Inv_CveMetodoInventario").ToString = "5" Then + + DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) + For Each Dr1 As DataRow In DtDetalle.Rows + If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Dr1("SerieLote").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then + For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows + + 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO + CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero If Not CveMovimientoSalida > 0 Then + CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) + FolioSalida = ObjInventario.Folio + + If Not CveMovimientoSalida > 0 Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." + Exit For + End If + + Dim DrMovto = DtTraspasos.NewRow + DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero + DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero + DrMovto("CveMovimientoSalida") = CveMovimientoSalida + DrMovto("FolioSalida") = FolioSalida + DtTraspasos.Rows.Add(DrMovto) + End If + + + CantidadPendiente = 1 + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." + TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." Exit For End If - Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero - DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero - DrMovto("CveMovimientoSalida") = CveMovimientoSalida - DrMovto("FolioSalida") = FolioSalida - DtTraspasos.Rows.Add(DrMovto) - End If - - - CantidadPendiente = 1 - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." + DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1 + DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle") + Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente Exit For - End If + Next + End If + If ErrorMovInv Then Exit For + Next - DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1 - DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle") - Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente - Exit For - Next - End If - If ErrorMovInv Then Exit For - Next + ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then - ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then + DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) + For Each Dr1 As DataRow In DtDetalle.Rows + If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then - DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then + CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal + + For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows + + 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO + CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero + + If Not CveMovimientoSalida > 0 Then + CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) + FolioSalida = ObjInventario.Folio + + If Not CveMovimientoSalida > 0 Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." + Exit For + End If + + Dim DrMovto = DtTraspasos.NewRow + DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero + DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero + DrMovto("CveMovimientoSalida") = CveMovimientoSalida + DrMovto("FolioSalida") = FolioSalida + DtTraspasos.Rows.Add(DrMovto) + End If + + CantidadPendiente = If(Dr1("Cantidad").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("Cantidad").ToString.ToDecimal) + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." + Exit For + End If + + DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1 + DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle") + + CantidadSaldo -= CantidadPendiente + Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente + If CantidadSaldo <= 0 Then Exit For + Next + End If + Next + + Else + + If ObjInventario.GetExistenciasProducto(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal - For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows + For Each Dr1 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO - CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero + CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr1("CveAlmacen")}").ToEntero If Not CveMovimientoSalida > 0 Then - CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) + CveMovimientoSalida = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) FolioSalida = ObjInventario.Folio If Not CveMovimientoSalida > 0 Then @@ -1775,382 +1826,44 @@ Partial Class Inventarios_RecepcionEntrega End If Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero - DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero + DrMovto("Almacen") = Dr1("Almacen").ToString.ToEntero + DrMovto("CveAlmacen") = Dr1("CveAlmacen").ToString.ToEntero DrMovto("CveMovimientoSalida") = CveMovimientoSalida DrMovto("FolioSalida") = FolioSalida DtTraspasos.Rows.Add(DrMovto) End If - CantidadPendiente = If(Dr1("Cantidad").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("Cantidad").ToString.ToDecimal) - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + CantidadPendiente = If(Dr1("ExistenciaFinal").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("ExistenciaFinal").ToString.ToDecimal) + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then ErrorMovInv = True TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." Exit For End If - DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1 - DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle") - CantidadSaldo -= CantidadPendiente Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente If CantidadSaldo <= 0 Then Exit For Next + + If ErrorMovInv Then Exit For + End If - Next - - Else - - If ObjInventario.GetExistenciasProducto(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then - - CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal - - For Each Dr1 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows - - 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO - CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr1("CveAlmacen")}").ToEntero - - If Not CveMovimientoSalida > 0 Then - CveMovimientoSalida = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) - FolioSalida = ObjInventario.Folio - - If Not CveMovimientoSalida > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr1("Almacen").ToString.ToEntero - DrMovto("CveAlmacen") = Dr1("CveAlmacen").ToString.ToEntero - DrMovto("CveMovimientoSalida") = CveMovimientoSalida - DrMovto("FolioSalida") = FolioSalida - DtTraspasos.Rows.Add(DrMovto) - End If - - - CantidadPendiente = If(Dr1("ExistenciaFinal").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("ExistenciaFinal").ToString.ToDecimal) - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - CantidadSaldo -= CantidadPendiente - Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente - If CantidadSaldo <= 0 Then Exit For - Next - - If ErrorMovInv Then Exit For End If + If ErrorMovInv Then Exit For End If - If ErrorMovInv Then Exit For - - End If - - Next - - 'ENTRADA POR TRASPASO AL ALMACEN GENERAL - If Not ErrorMovInv Then - For Each Dr1 As DataRow In DtTraspasos.Rows - CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero - - CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente) - FolioEntrada = ObjInventario.Folio - - If Not CveMovimientoEntradaApartado > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado - Dr1("FolioEntrada") = FolioEntrada - - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - End If - - If ErrorMovInv Then Exit For Next - End If - End If - End If - '' TERMINA: APARTADOS - - - If Not ErrorMovInv Then - Dim ConceptoMovimiento = 3 - ConceptoMovimiento = If(TipoMovimiento = 1, ConceptoMovimiento, 18) - ConceptoMovimiento = If(CveAlmacenTraspasoDestino > 0, 8, ConceptoMovimiento) - - Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero - - 'DEVOLUCION REMISION - If TipoMovimiento = 2 And TipoDocto = "Rem" Then - ConceptoMovimiento = 8 - Almacen1 = CveAlmacenTraspasoDestino - CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero - End If - - 'CANCELACION DE DEVOLUCION - If TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1 Then - ConceptoMovimiento = 3 - Almacen1 = DdlAlmacen.SelectedValue.ToEntero - CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero - End If - - CveMovimiento = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveAlmacenDestino:=CveAlmacenTraspasoDestino) - Folio = ObjInventario.Folio - - 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) - 'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then - If CveMovimiento > 0 Then - - 'SACA LO DE TRASPASOS - APARTADO - For Each Dr1 As DataRow In DtTraspasos.Rows - CveMovimientoSalida = Dr1("CveMovimientoEntrada").ToString.ToEntero - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - End If - If ErrorMovInv Then Exit For - Next - - 'ES EL MOVIMIENTO PRINCIPAL - CantidadPendiente = 0 - Dim Cont As Integer = 0 - For Each Dr As DataRow In DtDatos.Rows - CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal - If CantidadPendiente > 0 Then - Dim PU As Decimal = 0 - - 'SI FUE POR SERIELOTE - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) - DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) - If DtDetalle.Rows.Count > 0 Then - For Each Dr1 As DataRow In DtDetalle.Rows - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." - Exit For - End If - Next - ElseIf DtDetalleLote.Rows.Count > 0 Then - For Each Dr1 As DataRow In DtDetalleLote.Rows - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." - Exit For - End If - Next - Else - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." - Exit For - End If - End If - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - Cont += 1 - End If - Next - Else - ErrorMovInv = True - End If - End If - 'End If - - - 'ENTRADA POR TRASPASO CUANDO ES REMISION - If Not ErrorMovInv Then - If CveAlmacenTraspasoDestino > 0 AndAlso Not (TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1) Then ' TRASPASO CUANDO ES REMISION - CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestino, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) - FolioEntrada = ObjInventario.Folio - - If CveMovimientoEntrada <= 0 Then - TextoError = "No se pudo generar el movimiento de entrada correctamente" - ErrorMovInv = True - Else - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, EsInterno:=EsInterno) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - End If - Next - End If - End If - - Else 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN - SALIDA ALMACEN - Dim DtCostos As DataTable = Nothing - Dim ValorInventario As Decimal = 0 - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtCostos = ObjInventario.DtResultados - - Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) - Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero - Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - If tmpCostos.Rows.Count > 0 Then - - - If ObjVentas.GetVenta(CveVentaSurtir, UsuarioActual.CveEmpresa) Then - Dim Fecha As Date = TxtFecha.Text.ToDate ' If(TipoMovimiento <> 1, TxtFecha.Text.ToDate, ObjVentas.DtResultados(0)("Fecha").ToString.ToDate) - Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero - Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString - Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString - Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL() - Dim TotalCostoAcumulado As Decimal = 0 - Dim cont As Integer = 1 - - Dim ValorMultiplicador = 1 - - If TipoMovimiento = 1 Then - ValorMultiplicador = 1 - ElseIf TipoMovimiento = 2 Then - ValorMultiplicador = -1 - ElseIf TipoMovimiento = 2 AndAlso TipoDocto.Contiene({"Dev"}) And (EsDevolucionVenta = 1) Then - ValorMultiplicador = 1 - End If - - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - 'Se agrega movimiento separado por la cuenta de ventas (ER) - For Each RowInv As DataRow In tmpCostos.Rows - ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL() - TotalCostoAcumulado += ValorInventario - - 'cuando es el último movimiento y hay diferencias en los importes - If cont = DtCostos.FiltraParametros("", "", {"CveClasificacion"}).Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then - ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) - End If - - 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString) - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - - If Not ErrorMovInv Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then - ErrorMovInv = True - End If - End If - - cont += 1 - Next - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorMultiplicador * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * TotalCosto, CveCuenta:=CveCuentaAlmacen) Then - ErrorMovInv = True - End If - - 'AutoConta - El movimiento 1 es el de Venta - Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" - - If AutoConta And Not ErrorMovInv Then - Dim ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) - - If IdCtaContable > 0 Then - If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then - Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico") - End If - Else - Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia) - End If - - ObjContPaq.Dispose() - End If - - Else - ErrorMovInv = True - TextoError = "Ocurrió un Error al ingresar las prepolizas" - End If - - End If - End If - End If - - End If - - 'DEVOLUCION APARTADOS - If Not ErrorMovInv Then - If TipoMovimiento = 2 Then - If ObjInventario.VentasAlmacenApartadosGet(CveVentaSurtir) Then - - Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen") - Dim CveMovimientoSalidaApartado = -1 - Dim CveAlmacenApartado = -1 - Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero) - - For Each Dr As DataRow In DtTempApartados.Rows - - If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString.ToEntero Then - CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, CveAlmacenDestino:=Dr("CveAlmacen").ToString.ToEntero) - FolioSalida = ObjInventario.Folio - CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero - - Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr("Almacen").ToString.ToEntero - DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString.ToEntero - DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado - DrMovto("FolioSalida") = FolioSalida - DtTraspasos.Rows.Add(DrMovto) - End If - - If Not CveMovimientoSalidaApartado > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de control de apartados" - Exit For - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de control de apartados" - Exit For - End If - Next + 'ENTRADA POR TRASPASO AL ALMACEN GENERAL If Not ErrorMovInv Then For Each Dr1 As DataRow In DtTraspasos.Rows CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero - CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente) + CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente) FolioEntrada = ObjInventario.Folio If Not CveMovimientoEntradaApartado > 0 Then @@ -2164,7 +1877,7 @@ Partial Class Inventarios_RecepcionEntrega If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then ErrorMovInv = True TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." Exit For @@ -2176,97 +1889,404 @@ Partial Class Inventarios_RecepcionEntrega Next End If - End If End If - End If + '' TERMINA: APARTADOS - 'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION - If Not ErrorMovInv And EsDevolucionVenta = 1 And TipoDocto = "Ing" Then - Dim DtDevRem As New DataTable - Dim DtMovtosDev As New DataTable - Dim CveAlmacenTraspasoDestinoDevRem = -1 + ' COMIENZA: GARANTIAS + If TipoDocto.Contiene("Rem") AndAlso UsuarioActual.CveEmpresa = 140 AndAlso TipoMovimiento = 1 Then - Dim CveVentaDetalleRem = -1 - Dim CantidadDevolver As Decimal = 0 - Dim CantidadRem As Decimal = 0 + Dim CveAlmacenGarantia As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() + Dim DtGarantias As DataTable = Nothing - 'CARGA REMISIONES DE LA VENTA DEVUELTA - If ObjInventario.GetDevolucionRemisionesFacturadas(CveVentaSurtir) Then - DtDevRem = ObjInventario.DtResultados.FiltraParametros("CantidadAlmacen > 0") - Else - ErrorMovInv = True + If ObjAcumuladores.GetGarantiasDetalle(CveVentaSurtir) Then + DtGarantias = ObjAcumuladores.DtResultados.Copy() + End If + + If DtGarantias IsNot Nothing AndAlso DtGarantias.Rows.Count > 0 Then + CveMovimientoGarantia = ObjInventario.AddMovimiento(CveAlmacenGarantia, 2, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text) + FolioGarantia = ObjInventario.Folio + + For Each RowGarantia As DataRow In DtGarantias.Rows + Dim CvePS = RowGarantia("CvePS").ToString().ToEntero() + Dim CveTamaño As Integer = RowGarantia("CveTamaño").ToString().ToEntero() + Dim CveUM As Integer = RowGarantia("CveUnidadMedida").ToString().ToEntero() + Dim PU As Double = RowGarantia("Importe").ToString().ToDouble() ' / RowGarantia("Cantidad").ToString().ToDouble() + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU, -1) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." + Exit For + End If + Next + End If End If - 'CARGA CONCEPTOS DEVUELTOS EN LA VENTA - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtMovtosDev = ObjInventario.DtResultados - Else - ErrorMovInv = True - End If + ' TERMINA: GARANTIAS If Not ErrorMovInv Then - If DtDevRem.Rows.Count > 0 And DtMovtosDev.Rows.Count > 0 Then + Dim ConceptoMovimiento = 3 + ConceptoMovimiento = If(TipoMovimiento = 1, ConceptoMovimiento, 18) + ConceptoMovimiento = If(CveAlmacenTraspasoDestino > 0, 8, ConceptoMovimiento) - For Each DrMovtos As DataRow In DtDevRem.FiltraParametros("", "CveRem", {"CveRem", "CveAlmacenTraspasoDestino"}).Rows - CveAlmacenTraspasoDestinoDevRem = DrMovtos("CveAlmacenTraspasoDestino").ToString.ToEntero - If Not CveAlmacenTraspasoDestinoDevRem > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al obtener el almacén de devolucion de remisión." - Exit For - End If + Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero - 'SALIDA GENERAL - CveMovimientoSalidaDevRem = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=CveAlmacenTraspasoDestinoDevRem) - FolioMovimientoSalidaDevRem = ObjInventario.Folio + 'DEVOLUCION REMISION + If TipoMovimiento = 2 And TipoDocto = "Rem" Then + ConceptoMovimiento = 8 + Almacen1 = CveAlmacenTraspasoDestino + CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero + End If - 'ENTRADA ADELANTADO - CveMovimientoEntradaDevRem = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestinoDevRem, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalidaDevRem, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) - FolioMovimientoEntradaDevRem = ObjInventario.Folio + 'CANCELACION DE DEVOLUCION + If TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1 Then + ConceptoMovimiento = 3 + Almacen1 = DdlAlmacen.SelectedValue.ToEntero + CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero + End If - If Not (CveMovimientoSalidaDevRem > 0 And CveMovimientoEntradaDevRem > 0) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al generar los movimientos de devolución a remisión." - Exit For - End If + CveMovimiento = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveAlmacenDestino:=CveAlmacenTraspasoDestino) + Folio = ObjInventario.Folio + 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) + 'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then + If CveMovimiento > 0 Then - 'SALIDA POR TRAPASO DE GENERAL - For Each DrRem As DataRow In DtDevRem.FiltraParametros($"CveRem = {DrMovtos("CveRem")}").Rows - CveVentaDetalleRem = DrRem("CveVentaDetalleRem").ToString.ToEntero - CantidadRem = DrRem("CantidadFacturada").ToString.ToDecimal - 'CantidadDevolver = DtMovtosDev.FiltroPrimeroValor("Cantidad", $"CveVentaDetalle = {DrRem("CveVentaDetalle").ToString.ToEntero}").ToDouble - 'If (Dr("Cantidad").ToString.ToDouble > CantidadRem, CantidadRem, Dr("Cantidad").ToString.ToDouble) Then - - If Not CveVentaDetalleRem > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al obtener la relación de la venta con la remisión." - Exit For - End If - - For Each Dr As DataRow In DtMovtosDev.FiltraParametros($"CveVentaDetalle = {DrRem("CveVentaDetalle").ToString.ToEntero}").Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=CveVentaDetalleRem, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + 'SACA LO DE TRASPASOS - APARTADO + For Each Dr1 As DataRow In DtTraspasos.Rows + CveMovimientoSalida = Dr1("CveMovimientoEntrada").ToString.ToEntero + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de salida de traspaso de devolucion de remisión." + TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." Exit For End If Next + End If + If ErrorMovInv Then Exit For + Next - If ErrorMovInv Then + 'ES EL MOVIMIENTO PRINCIPAL + CantidadPendiente = 0 + Dim Cont As Integer = 0 + For Each Dr As DataRow In DtDatos.Rows + CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal + If CantidadPendiente > 0 Then + Dim PU As Decimal = 0 + + 'SI FUE POR SERIELOTE + DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) + DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) + If DtDetalle.Rows.Count > 0 Then + For Each Dr1 As DataRow In DtDetalle.Rows + If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then + PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." + Exit For + End If + Next + ElseIf DtDetalleLote.Rows.Count > 0 Then + For Each Dr1 As DataRow In DtDetalleLote.Rows + If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then + PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." + Exit For + End If + Next + Else + If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then + PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." + Exit For + End If + End If + If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then + For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows + If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." + Exit For + End If + Next + End If + Cont += 1 + End If + Next + Else + ErrorMovInv = True + End If + End If + 'End If + + + 'ENTRADA POR TRASPASO CUANDO ES REMISION + If Not ErrorMovInv Then + If CveAlmacenTraspasoDestino > 0 AndAlso Not (TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1) Then ' TRASPASO CUANDO ES REMISION + CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestino, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) + FolioEntrada = ObjInventario.Folio + + If CveMovimientoEntrada <= 0 Then + TextoError = "No se pudo generar el movimiento de entrada correctamente" + ErrorMovInv = True + Else + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, EsInterno:=EsInterno) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de entrada" + Exit For + End If + Next + End If + End If + + Else 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN - SALIDA ALMACEN + Dim DtCostos As DataTable = Nothing + Dim ValorInventario As Decimal = 0 + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtCostos = ObjInventario.DtResultados + + Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero + Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + If tmpCostos.Rows.Count > 0 Then + + + If ObjVentas.GetVenta(CveVentaSurtir, UsuarioActual.CveEmpresa) Then + Dim Fecha As Date = TxtFecha.Text.ToDate ' If(TipoMovimiento <> 1, TxtFecha.Text.ToDate, ObjVentas.DtResultados(0)("Fecha").ToString.ToDate) + Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero + Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString + Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL() + Dim TotalCostoAcumulado As Decimal = 0 + Dim cont As Integer = 1 + + Dim ValorMultiplicador = 1 + + If TipoMovimiento = 1 Then + ValorMultiplicador = 1 + ElseIf TipoMovimiento = 2 Then + ValorMultiplicador = -1 + ElseIf TipoMovimiento = 2 AndAlso TipoDocto.Contiene({"Dev"}) And (EsDevolucionVenta = 1) Then + ValorMultiplicador = 1 + End If + + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + 'Se agrega movimiento separado por la cuenta de ventas (ER) + For Each RowInv As DataRow In tmpCostos.Rows + ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL() + TotalCostoAcumulado += ValorInventario + + 'cuando es el último movimiento y hay diferencias en los importes + If cont = DtCostos.FiltraParametros("", "", {"CveClasificacion"}).Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString) + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + + If Not ErrorMovInv Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then + ErrorMovInv = True + End If + End If + + cont += 1 + Next + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorMultiplicador * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * TotalCosto, CveCuenta:=CveCuentaAlmacen) Then + ErrorMovInv = True + End If + + 'AutoConta - El movimiento 1 es el de Venta + Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" + + If AutoConta And Not ErrorMovInv Then + Dim ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) + + If IdCtaContable > 0 Then + If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then + Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico") + End If + Else + Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia) + End If + + ObjContPaq.Dispose() + End If + + Else + ErrorMovInv = True + TextoError = "Ocurrió un Error al ingresar las prepolizas" + End If + + End If + End If + End If + + End If + + 'DEVOLUCION APARTADOS + If Not ErrorMovInv Then + If TipoMovimiento = 2 Then + If ObjInventario.VentasAlmacenApartadosGet(CveVentaSurtir) Then + + Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen") + Dim CveMovimientoSalidaApartado = -1 + Dim CveAlmacenApartado = -1 + Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero) + + For Each Dr As DataRow In DtTempApartados.Rows + + If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString.ToEntero Then + CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, CveAlmacenDestino:=Dr("CveAlmacen").ToString.ToEntero) + FolioSalida = ObjInventario.Folio + CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero + + Dim DrMovto = DtTraspasos.NewRow + DrMovto("Almacen") = Dr("Almacen").ToString.ToEntero + DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString.ToEntero + DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado + DrMovto("FolioSalida") = FolioSalida + DtTraspasos.Rows.Add(DrMovto) + End If + + If Not CveMovimientoSalidaApartado > 0 Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de control de apartados" + Exit For + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de control de apartados" Exit For End If Next - If ErrorMovInv Then - Exit For + If Not ErrorMovInv Then + For Each Dr1 As DataRow In DtTraspasos.Rows + CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero + + CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente) + FolioEntrada = ObjInventario.Folio + + If Not CveMovimientoEntradaApartado > 0 Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." + Exit For + End If + + Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado + Dr1("FolioEntrada") = FolioEntrada + + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." + Exit For + End If + Next + End If + + If ErrorMovInv Then Exit For + + Next End If - 'ENTRADA POR TRAPASO A ENTREGA POR ADELANTADO - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaDevRem, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + End If + End If + End If + + 'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION + If Not ErrorMovInv And EsDevolucionVenta = 1 And TipoDocto = "Ing" Then + Dim DtDevRem As New DataTable + Dim DtMovtosDev As New DataTable + Dim CveAlmacenTraspasoDestinoDevRem = -1 + + Dim CveVentaDetalleRem = -1 + Dim CantidadDevolver As Decimal = 0 + Dim CantidadRem As Decimal = 0 + + 'CARGA REMISIONES DE LA VENTA DEVUELTA + If ObjInventario.GetDevolucionRemisionesFacturadas(CveVentaSurtir) Then + DtDevRem = ObjInventario.DtResultados.FiltraParametros("CantidadAlmacen > 0") + Else + ErrorMovInv = True + End If + + 'CARGA CONCEPTOS DEVUELTOS EN LA VENTA + If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtMovtosDev = ObjInventario.DtResultados + Else + ErrorMovInv = True + End If + + If Not ErrorMovInv Then + If DtDevRem.Rows.Count > 0 And DtMovtosDev.Rows.Count > 0 Then + + For Each DrMovtos As DataRow In DtDevRem.FiltraParametros("", "CveRem", {"CveRem", "CveAlmacenTraspasoDestino"}).Rows + CveAlmacenTraspasoDestinoDevRem = DrMovtos("CveAlmacenTraspasoDestino").ToString.ToEntero + If Not CveAlmacenTraspasoDestinoDevRem > 0 Then + ErrorMovInv = True + TextoError = "Ocurrió un error al obtener el almacén de devolucion de remisión." + Exit For + End If + + 'SALIDA GENERAL + CveMovimientoSalidaDevRem = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=CveAlmacenTraspasoDestinoDevRem) + FolioMovimientoSalidaDevRem = ObjInventario.Folio + + 'ENTRADA ADELANTADO + CveMovimientoEntradaDevRem = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestinoDevRem, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalidaDevRem, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero) + FolioMovimientoEntradaDevRem = ObjInventario.Folio + + If Not (CveMovimientoSalidaDevRem > 0 And CveMovimientoEntradaDevRem > 0) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al generar los movimientos de devolución a remisión." + Exit For + End If + + + 'SALIDA POR TRAPASO DE GENERAL + For Each DrRem As DataRow In DtDevRem.FiltraParametros($"CveRem = {DrMovtos("CveRem")}").Rows + CveVentaDetalleRem = DrRem("CveVentaDetalleRem").ToString.ToEntero + CantidadRem = DrRem("CantidadFacturada").ToString.ToDecimal + 'CantidadDevolver = DtMovtosDev.FiltroPrimeroValor("Cantidad", $"CveVentaDetalle = {DrRem("CveVentaDetalle").ToString.ToEntero}").ToDouble + 'If (Dr("Cantidad").ToString.ToDouble > CantidadRem, CantidadRem, Dr("Cantidad").ToString.ToDouble) Then + + If Not CveVentaDetalleRem > 0 Then ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de entrada de traspaso de devolucion de remisión." + TextoError = "Ocurrió un error al obtener la relación de la venta con la remisión." + Exit For + End If + + For Each Dr As DataRow In DtMovtosDev.FiltraParametros($"CveVentaDetalle = {DrRem("CveVentaDetalle").ToString.ToEntero}").Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=CveVentaDetalleRem, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de salida de traspaso de devolucion de remisión." + Exit For + End If + Next + + If ErrorMovInv Then Exit For End If Next @@ -2275,50 +2295,70 @@ Partial Class Inventarios_RecepcionEntrega Exit For End If - Else - ErrorMovInv = True - TextoError = "Ocurrió un error al obtener los detalles de la devolución de almacén" - Exit For - End If + 'ENTRADA POR TRAPASO A ENTREGA POR ADELANTADO + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaDevRem, UsuarioActual.CveEmpresa) Then + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de entrada de traspaso de devolucion de remisión." + Exit For + End If + Next + + If ErrorMovInv Then + Exit For + End If + + Else + ErrorMovInv = True + TextoError = "Ocurrió un error al obtener los detalles de la devolución de almacén" + Exit For + End If - If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, DrMovtos("CveRem").ToString.ToEntero) Then - TextoError = "Ocurrió un error al hacer la devolucion hacia la remision. Por favor vuelva a intentar." - ErrorMovInv = True - Exit For - End If + If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, DrMovtos("CveRem").ToString.ToEntero) Then + TextoError = "Ocurrió un error al hacer la devolucion hacia la remision. Por favor vuelva a intentar." + ErrorMovInv = True + Exit For + End If - Next + Next + End If + Else + TextoError = "Ocurrió un error al hacer la devolucion a remisión. Por favor vuelva a intentar." + ErrorMovInv = True End If - Else - TextoError = "Ocurrió un error al hacer la devolucion a remisión. Por favor vuelva a intentar." - ErrorMovInv = True + End If - End If - - 'QUEMA DEVOLUCION | QUEMA = LA QUITA DE PENDIENTE POR RECIBIR (DEVOLVER) - If Not ErrorMovInv And EsDevolucionVenta = 1 Then - If Not ObjVentas.UpdateVentasDevolucionAlmacen(2, CveVentaSurtir) Then - TextoError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar." - ErrorMovInv = True + 'QUEMA DEVOLUCION | QUEMA = LA QUITA DE PENDIENTE POR RECIBIR (DEVOLVER) + If Not ErrorMovInv And EsDevolucionVenta = 1 Then + If Not ObjVentas.UpdateVentasDevolucionAlmacen(2, CveVentaSurtir) Then + TextoError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar." + ErrorMovInv = True + End If End If - End If - If Not ErrorMovInv And EsDevolucionVenta = 0 Then - If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, CveVentaSurtir) Then - TextoError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar." - ErrorMovInv = True + If Not ErrorMovInv And EsDevolucionVenta = 0 Then + If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, CveVentaSurtir) Then + TextoError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar." + ErrorMovInv = True + End If End If - End If - 'AGREGA BITACORA A VENTA - If Not ErrorMovInv Then - Dim MensajeBitacora = If(TipoMovimiento = 1, "Surtida", "Devuelta") - If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then - ErrorMovInv = True + 'AGREGA BITACORA A VENTA + If Not ErrorMovInv Then + Dim MensajeBitacora = If(TipoMovimiento = 1, "Surtida", "Devuelta") + If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then + ErrorMovInv = True + End If End If - End If + + + Catch ex As Exception + ErrorMovInv = True + OnError("Ocurrió un error al guardar",ex) + End Try If Not ErrorMovInv Then ObjInventario.Commit() @@ -2345,6 +2385,11 @@ Partial Class Inventarios_RecepcionEntrega Next End If + If CveMovimientoGarantia > 0 Then + Msg.AppendFormat("
Movimiento de Entrada (garantías): {1}", CveMovimientoGarantia, FolioGarantia) + Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoGarantia))) + End If + 'If CveMovimientoSalidaDevRem > 0 Then ' Msg.AppendFormat("

Movimiento de salida de devolución (Traspaso): {1}", CveMovimientoSalidaDevRem, FolioMovimientoSalidaDevRem) ' Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalidaDevRem))) @@ -2358,11 +2403,12 @@ Partial Class Inventarios_RecepcionEntrega Limpia() CargaPendientes() Else + ObjInventario.RollBack() Alert(TextoError, TipoMensaje.MsgError) RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ObjInventario.RollBack() End If + ObjAcumuladores.Dispose() ObjInventario.Dispose() ObjConta.Dispose() ObjVentas.Dispose() diff --git a/Inventarios/RecepcionUsados.aspx b/Inventarios/RecepcionUsados.aspx index 21a160f2c..85275e53c 100644 --- a/Inventarios/RecepcionUsados.aspx +++ b/Inventarios/RecepcionUsados.aspx @@ -1,838 +1,890 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RecepcionUsados.aspx.vb" Inherits="Inventarios_RecepcionUsados" %> - -<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %> - - - - - - - - - Recepción/Entrega de Usados - - - - -
  • - Imprimir -
  • -
  • - Traspaso Almacen -
  • - <%--
  • +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RecepcionUsados.aspx.vb" Inherits="Inventarios_RecepcionUsados" %> + +<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %> + + + + + + + + + Recepción/Entrega de Usados + + + + +
  • + Imprimir +
  • +
  • + Traspaso Almacen +
  • + <%--
  • -
  • --%> -
  • - Ver PrePóliza -
  • -
  • - -
  • - -
    -
    -
    - - - - - - -
    - - - - -
    -
    -
    -
    - "> - -
    -
    + --%> +
  • + Ver PrePóliza +
  • +
  • + +
  • + + + + + + + +
    + + +
    +
    +
    +
    + "> + +
    +
    Información del movimiento -
    -
    -
    > -
    - -
    - - -
    - - - -
    - -<%-- + +
    +
    +
    > +
    + +
    + + +
    + + + +
    + + <%--
    -
    --%> -
    - -
    - -
    - -
    - -
    -
    - -
    - -
    - - - - - -
    -
    -
    - -
    - -
    - -
    - - -
    - -
    -
    - -
    - -
    -
    -
    - - - - - - - - - - - - - - -
    -
    -
    - - - -
    - - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - - <%----%> -
    -
    -
    -
    --%> +
    + +
    + +
    + +
    + +
    +
    + +
    + +
    + + + + + +
    +
    +
    + +
    + +
    + +
    + + +
    + +
    +
    + +
    + +
    +
    +
    + + + + + + + + + + + + + + +
    +
    +
    + + + +
    + + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + <%----%> +
    +
    +
    + -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - - - -
    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    - -
    -
    - - <%--INVENTARIO INICIAL--%> - - -
    -
    -
    -
    - "> -
    -
    + + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Remisiones por Recibir +
    +
    +
    +
    +
    +
    + +   + + Sucursal: + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + <%--INVENTARIO INICIAL--%> + + +
    +
    +
    +
    + "> +
    +
    Agregar Producto -
    -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - - - - - - - -
    -
    -
    - -
    - - - - - - - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    - - - - -
    - -
    -
    -
    - "> - -
    -
    + +
    +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + + + + + + +
    +
    +
    + +
    + + + + + + + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + + +
    + +
    +
    +
    + "> + +
    +
    Información de registro -
    -
    -
    -
    -
    +
    +
    +
    + -
    - -
    - -
    -
    - +
    + +
    + +
    +
    + -
    - -
    -
    -
    - +
    + +
    +
    +
    + -
    - Ver Compra - Ver Venta - Ver Póliza - Ver Orden Compra - -
    -
    -
    - +
    + Ver Compra + Ver Venta + Ver Póliza + Ver Orden Compra + +
    +
    +
    + -
    - - <%----%> -
    -
    -
    - +
    + + <%----%> +
    +
    +
    + -
    - -
    -
    -
    - +
    + +
    +
    +
    + -
    - ver -
    -
    -
    - -
    - -
    -
    -
    - "> - -
    -
    + + +
    + ver +
    +
    +
    + +
    + +
    +
    +
    + "> + +
    +
    Tipo de Cambio -
    -
    -
    - - - - - - - - - - - - -
    Moneda: - - - - - - -
    Tipo de Cambio: - - - -
    - -
    -
    -
    - - -
    -
    -
    - -
    - - - -
    -
    - - - - - - -
    - - - <%-- - - - - <%-- -
    -
    -
    -
    -
    - - - - - - -
    -
    - - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - - - - - - - - - -
    -
    - -
    -

    - - - -

    -
    -
    -
    -
    - -
    -
    - - -
    - - - <%-- EMPIEZA: BITACORA --%> - - - - - -
    - - - -
    -
    - <%-- TERMINA: BITACORA --%> - - - - - - - - +
    +
    + + + + + + + + + - - - +
    --%> +
    + + + +
    + +
    +
    +
    + + + + +
    + +
    + + + +
    + +
    + + +
    + +
    + +
    +
    + + + +
    + - - + + + diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 76700abb6..572b90a62 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -197,6 +197,22 @@ Partial Class Inventarios_RecepcionUsados Set(value As Integer) ViewState("FolioAsignado") = value End Set + End Property + Private Property CveRemisionRecibida As Integer + Get + Return IfNull(ViewState("CveRemisionRecibida"), -1, CType(ViewState("CveRemisionRecibida"), Integer)).ToString().ToEntero() + End Get + Set(value As Integer) + ViewState("CveRemisionRecibida") = value + End Set + End Property + Private Property EsDistribuidor As Boolean + Get + Return CBool(IfNull(ViewState("EsDistribuidor"), False, CBool(ViewState("EsDistribuidor")))) + End Get + Set(value As Boolean) + ViewState("EsDistribuidor") = value + End Set End Property @@ -270,6 +286,7 @@ Partial Class Inventarios_RecepcionUsados CreaDT() CargaCombos() TxtFecha.Text = Now.ToShortDateString + TxtFechaPendientes.Text = Now.ToShortDateString RVFecha.MaximumValue = Now.ToShortDateString InicializaClientes() @@ -298,6 +315,7 @@ Partial Class Inventarios_RecepcionUsados End If End If + CargaSubProyectosUsados() InicializaBitacoraTemporal() If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then @@ -506,9 +524,31 @@ Partial Class Inventarios_RecepcionUsados End Sub Private Sub CargaSubProyectos() DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)) - DdlSubProyecto.DataBind() + DdlSubProyecto.DataBind() + + 'DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub + + Private Sub CargaSubProyectosUsados() + If UsuarioActual.CveEmpresa = 140 Then + DivRecepcionUsados.Visible = True + + If Not UsuarioActual.TienePermisoProceso(190) Then + 'CARGA SOLO LAS SUCURSALES DE LOS ALMCENES QUE TIENE ASIGNADO EL USUARIO + Dim ObjInventarios As New ClsInventarios + If ObjInventarios.GetSucursalesAlmacenUsuario(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + DdlSubProyectos.DataSource = ObjInventarios.DtResultados + End If + ObjInventarios.Dispose() + Else + DdlSubProyectos.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) + End If + DdlSubProyectos.DataBind() + DdlSubProyectos.SelectedValueExist(UsuarioActual.CveSubProyecto.ToString) + End If + + End Sub Private Sub CargaPersonal() TrPersonal.Visible = True Dim dt As DataTable = Nothing @@ -940,16 +980,12 @@ Partial Class Inventarios_RecepcionUsados End Sub Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click - - - - If GvM.Rows.Count > 0 Then 'Dim CveMovimiento As Integer Dim ObjInventario As New ClsInventarios Dim ObjAcum As New ClsAcumuladores(ObjInventario.IniciaTransacSQL()) - + Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL()) Dim ErrorMovInv As Boolean = False Dim ErrorAC As Boolean = False @@ -978,9 +1014,12 @@ Partial Class Inventarios_RecepcionUsados End If Dim tCveProveedor As Integer = -1 If DdlProveedor.SelectedValue.ToEntero > 0 Then tCveProveedor = DdlProveedor.SelectedValue.ToEntero - + Dim CveVenta As Integer = -1 + If CveRemisionRecibida > 0 Then + CveVenta = CveRemisionRecibida + End If 'Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inv/ES", 53, 0, 0, 1, TxtFecha.Text.ToDate, $" {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3) - CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, CveConcepto, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, + CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, CveConcepto, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, CveSubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text, CvePersonal:=DdlPersonal.SelectedValue.ToEntero, Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text, PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor) @@ -1007,23 +1046,31 @@ Partial Class Inventarios_RecepcionUsados Exit For End If + If Not ObjVentas.UpdateVentaUsadoRecibido(CveRemisionRecibida, Dr("CvePS").ToString.ToEntero, True) Then + Mensaje = "Error al actualizar el recibo de los usados" + ErrorMovInv = True + Exit For + End If + Dim CveConceptoUsados As Integer = If(RBLOpcion.SelectedValue.ToEntero = 2, 1, 2) If RBLOpcion.SelectedValue.ToEntero <> 3 Then - - If Not ObjAcum.DistribuidorMovtosAdd(DdlClientes.SelectedValue.ToEntero, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, CveConceptoUsados, -1, UsuarioActual.CveUsuario, - UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, CveMovimiento:=CveMovimiento) Then - - - 'CveCliente As Integer, Cantidad As Integer, CveTamaño As Integer, CveConcepto As Integer, CveVenta As Integer, CveUsuario As Integer, - 'CveEmpresa As Integer, ImporteCompras As Decimal, Observaciones As String - - Mensaje = "Error al guardar Movimientos de distribuidor" - ErrorMovInv = True - Exit For + If EsDistribuidor Then + If Not ObjAcum.DistribuidorMovtosAdd(DdlClientes.SelectedValue.ToEntero, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, CveConceptoUsados, -1, UsuarioActual.CveUsuario, + UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, CveMovimiento:=CveMovimiento) Then + + + 'CveCliente As Integer, Cantidad As Integer, CveTamaño As Integer, CveConcepto As Integer, CveVenta As Integer, CveUsuario As Integer, + 'CveEmpresa As Integer, ImporteCompras As Decimal, Observaciones As String + + Mensaje = "Error al guardar Movimientos de distribuidor" + ErrorMovInv = True + Exit For + End If End If + End If @@ -1091,11 +1138,11 @@ Partial Class Inventarios_RecepcionUsados Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgError) RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") End If - End Sub - + End Sub + #End Region - - + + #Region " ADD INVENTARIO INICIAL " Protected Sub BtnCodigoBarras_Click(sender As Object, e As EventArgs) @@ -1931,6 +1978,64 @@ Partial Class Inventarios_RecepcionUsados End If SiguienteFolio() UpGenerales.Update() - End Sub - + End Sub + + Protected Sub BtnConsultarPendientes_Click(sender As Object, e As EventArgs) + Dim ObjVentas As New ClsVentas + If ObjVentas.GetVentasUsados(-1, DdlSubProyectos.SelectedValue.ToEntero(), TxtFechaPendientes.Text.ToDateTime(), UsuarioActual.CveEmpresa) Then + GVPendientes.DataSource = ObjVentas.DtResultados + End If + ObjVentas.Dispose() + GVPendientes.DataBind() + + UpGenerales.Update() + End Sub + Protected Sub BtnRecibir_Click(sender As Object, e As EventArgs) + DtMovimientos.Rows.Clear() + + Me.CveRemisionRecibida = -1 + Me.CveRemisionRecibida = CType(CType(sender, LinkButton).NamingContainer, GridViewRow).DataKey("CveVenta").ToEntero() + + + Dim DtUsados As DataTable = Nothing + Dim CveCliente As Integer = -1 + + Dim ObjVentas As New ClsVentas + If ObjVentas.GetVenta(CveRemisionRecibida, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + EsDistribuidor = CBool(ObjVentas.DtResultados.Rows(0)("EsDistribuidor").ToString()) + CveCliente = ObjVentas.DtResultados.Rows(0)("CveCliente").ToString().ToEntero() + End If + + If EsDistribuidor Then + DivCliente.Visible = True + Else + DivCliente.Visible = False + End If + DdlClientes.SelectedValueExist(CveCliente) + + If ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then + DtUsados = ObjVentas.DtResultados.Copy() + End If + ObjVentas.Dispose() + + If DtUsados IsNot Nothing Then + For Each RowUsado As DataRow In DtUsados.Rows + Dim CvePS = RowUsado("CvePS").ToString().ToEntero() + + Dim RowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).Rows(0) '.FiltroPrimeroValor("CveTamaño", $"CvePS = { DdlProducto2.SelectedValue.ToEntero }").ToEntero + Dim CveTamaño As Integer = RowPS("CveTamaño").ToString().ToEntero() + + Dim PS As String = RowPS("PS").ToString() + Dim CveUM As Integer = RowPS("CveUnidadMedida").ToString().ToEntero() + Dim UM As String = RowPS("UnidadMedida").ToString() + Dim Cantidad As Double = RowUsado("Cantidad").ToString().ToEntero() + Dim PU As Double = RowUsado("PU").ToString().ToDouble() + + AddNew(CvePS, PS, CveUM, UM, Cantidad, PU, "", "-1", "-1", "-1", "", "", "", DdlAlmacen.SelectedValue.ToEntero, DdlAlmacen.SelectedItem.Text, "", CveTamaño) + + Next + End If + + UpGenerales.Update() + End Sub End Class diff --git a/LogMail.txt b/LogMail.txt index 6d47c895f..6b789a002 100644 --- a/LogMail.txt +++ b/LogMail.txt @@ -4,23 +4,4 @@ en ClsSisMail.FinalSend(Mail ObjMail) en C:\inetpub\WWWSIGIT\App_Code\ClsSisMail.vb:línea 129 05/09/2019:12:31 p. m. From:'signotificaciones@adssistemas.mx' - Para:';' - Asunto:'Envío de complemento de pago' - CCP: '' - Adjuntos: 2 - Ocurrió un error al mandar correo.System.InvalidOperationException: Se debe especificar un destinatario. en System.Net.Mail.SmtpClient.Send(MailMessage message) - en ClsSisMail.FinalSend(Mail ObjMail) en C:\inetpub\WWWSIGIT\App_Code\ClsSisMail.vb:línea 129 10/09/2019:12:16 p. m. From:'signotificaciones@adssistemas.mx' - Para:'DSDDS@hotmail.com' - Asunto:'SIG - La Orden Compra #26598 cambió de estatus.' - CCP: '' - Adjuntos: 0 10/09/2019:02:58 p. m. No se especifico a remitente - SIG - La Orden Compra #28107 cambió de estatus. 11/09/2019:11:56 a. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'Solicitud Vacaciones ' - CCP: '' - Adjuntos: 0 11/09/2019:12:35 p. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'(Vacaciones:Permisos) Asistencia Técnica AD Sistemas' - CCP: '' - Adjuntos: 0 11/09/2019:01:02 p. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'Permiso para Asistencia Técnica AD Sistemas' - CCP: '' - Adjuntos: 0 11/09/2019:01:03 p. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'Vacaciones Asistencia Técnica AD Sistemas' - CCP: '' - Adjuntos: 0 11/09/2019:01:10 p. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'Vacaciones Asistencia Técnica AD Sistemas' - CCP: '' - Adjuntos: 0 20/09/2019:05:15 p. m. From:'ENVIOFACTURADIGITAL@COMPUPROVEEDORES.COM' - Para:'japmx95@gmail.com' - Asunto:'Entrega de Factura HMO - 29109' - CCP: '' - Adjuntos: 1 20/09/2019:05:36 p. m. No se especifico a remitente - Entrega de Factura HMO - 29110 20/09/2019:05:45 p. m. From:'ENVIOFACTURADIGITAL@COMPUPROVEEDORES.COM' - Para:'japmx95@gmail.com' - Asunto:'Entrega de Factura HMO - 29111' - CCP: '' - Adjuntos: 1 20/09/2019:05:47 p. m. From:'ENVIOFACTURADIGITAL@COMPUPROVEEDORES.COM' - Para:'japmx95@gmail.com' - Asunto:'Entrega de Factura HMO - 29112' - CCP: '' - Adjuntos: 1 23/09/2019:10:55 a. m. From:'signotificaciones@adssistemas.mx' - Para:'japmx95@gmail.com' - Asunto:'Solicitud de anticipo de Orden de Compra' - CCP: '' - Adjuntos: 0 23/09/2019:11:05 a. m. No se especifico a remitente - Solicitud de anticipo de Orden de Compra 23/09/2019:11:34 a. m. No se especifico a remitente - Solicitud de anticipo de Orden de Compra 25/09/2019:05:06 p. m. No se especifico a remitente - SIG - La Orden Compra #4860 cambió de estatus. 30/09/2019:07:28 p. m. From:'signotificaciones@adssistemas.mx' - Para:'lillianrivas@compuproveedores.com;athziryrodriguez@compuproveedores.com' - Asunto:'Vinculación de factura de OC ' - CCP: '' - Adjuntos: 0 01/10/2019:12:27 a. m. From:'signotificaciones@adssistemas.mx' - Para:'lillianrivas@compuproveedores.com;' - Asunto:'NOTIFICACION DE 100% DE AVANCE DE CONTRATO' - CCP: '' - Adjuntos: 0 01/10/2019:12:28 a. m. From:'ENVIOFACTURADIGITAL@COMPUPROVEEDORES.COM' - Para:'pagaduria@difson.gob.mx;enrique.garcia@difson.gob.mx;laura.romero@difson.gob.mx' - Asunto:'Entrega de Factura HMO-29475' - CCP: 'LILLIANRIVAS@COMPUPROVEEDORES.COM' - Adjuntos: 2 - - Ocurrió Cargar datos Correo.System.IO.IOException: No se puede escribir datos de en la conexión de transporte: Se ha forzado la interrupción de una conexión existente por el host remoto. ---> System.Net.Sockets.SocketException: Se ha forzado la interrupción de una conexión existente por el host remoto - en System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) - --- Fin del seguimiento de la pila de la excepción interna --- - en System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) - en System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) - en System.Net.Security._SslStream.StartFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) - en System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) - en System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) - en System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) - en System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) - en System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) - en System.Net.Mail.SmtpPooledStream.Dispose(Boolean disposing) - en System.IO.Stream.Close() - en System.Net.ConnectionPool.Destroy(PooledStream pooledStream) - en System.Net.ConnectionPool.ForceCleanup() - en System.Net.ConnectionPoolManager.CleanupConnectionPool(ServicePoint servicePoint, String groupName) - en System.Net.Mail.SmtpClient.Dispose(Boolean disposing) - en System.Net.Mail.SmtpClient.Dispose() - en ClsSisMail.FinalSend(Mail ObjMail) en C:\inetpub\wwwVentas\App_Code\ClsSisMail.vb:línea 138 01/10/2019:12:28 a. m. From:'ENVIOFACTURADIGITAL@COMPUPROVEEDORES.COM' - Para:'pagaduria@difson.gob.mx;enrique.garcia@difson.gob.mx;laura.romero@difson.gob.mx' - Asunto:'Entrega de Factura HMO-29475' - CCP: 'LILLIANRIVAS@COMPUPROVEEDORES.COM' - Adjuntos: 2 \ No newline at end of file + en ClsSisMail.FinalSend(Mail ObjMail) en C:\inetpub\WWWSIGIT\App_Code\ClsSisMail.vb:línea 129 10/09/2019:12:16 p. m. From:'signotificaciones@adssistemas.mx' - Para:'DSDDS@hotmail.com' - Asunto:'SIG - La Orden Compra #26598 cambió de estatus.' - CCP: '' - Adjuntos: 0 10/09/2019:02:58 p. m. No se especifico a remitente - SIG - La Orden Compra #28107 cambió de estatus. 11/09/2019:11:56 a. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'Solicitud Vacaciones ' - CCP: '' - Adjuntos: 0 11/09/2019:12:35 p. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'(Vacaciones:Permisos) Asistencia Técnica AD Sistemas' - CCP: '' - Adjuntos: 0 11/09/2019:01:02 p. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'Permiso para Asistencia Técnica AD Sistemas' - CCP: '' - Adjuntos: 0 11/09/2019:01:03 p. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'Vacaciones Asistencia Técnica AD Sistemas' - CCP: '' - Adjuntos: 0 11/09/2019:01:10 p. m. From:'signotificaciones@adssistemas.mx' - Para:'antonio.gonzalez@adssistemas.mx' - Asunto:'Vacaciones Asistencia Técnica AD Sistemas' - CCP: '' - Adjuntos: 0 20/09/2019:05:15 p. m. From:'ENVIOFACTURADIGITAL@COMPUPROVEEDORES.COM' - Para:'japmx95@gmail.com' - Asunto:'Entrega de Factura HMO - 29109' - CCP: '' - Adjuntos: 1 20/09/2019:05:36 p. m. No se especifico a remitente - Entrega de Factura HMO - 29110 20/09/2019:05:45 p. m. From:'ENVIOFACTURADIGITAL@COMPUPROVEEDORES.COM' - Para:'japmx95@gmail.com' - Asunto:'Entrega de Factura HMO - 29111' - CCP: '' - Adjuntos: 1 20/09/2019:05:47 p. m. From:'ENVIOFACTURADIGITAL@COMPUPROVEEDORES.COM' - Para:'japmx95@gmail.com' - Asunto:'Entrega de Factura HMO - 29112' - CCP: '' - Adjuntos: 1 23/09/2019:10:55 a. m. From:'signotificaciones@adssistemas.mx' - Para:'japmx95@gmail.com' - Asunto:'Solicitud de anticipo de Orden de Compra' - CCP: '' - Adjuntos: 0 23/09/2019:11:05 a. m. No se especifico a remitente - Solicitud de anticipo de Orden de Compra 23/09/2019:11:34 a. m. No se especifico a remitente - Solicitud de anticipo de Orden de Compra 25/09/2019:05:06 p. m. No se especifico a remitente - SIG - La Orden Compra #4860 cambió de estatus. \ No newline at end of file diff --git a/OS/CatEstatusOrdenServicio.aspx b/OS/CatEstatusOrdenServicio.aspx index ac8306322..fc7f2c5ef 100644 --- a/OS/CatEstatusOrdenServicio.aspx +++ b/OS/CatEstatusOrdenServicio.aspx @@ -4,6 +4,10 @@