From b4cf55b1902175d3bfaacc4440ed171a859d1dd1 Mon Sep 17 00:00:00 2001 From: rrene Date: Sun, 30 Mar 2025 18:30:01 -0700 Subject: [PATCH 01/27] - creadt --- Ashx/SIGFacturacion.ashx | 91 +--------------------------------------- 1 file changed, 2 insertions(+), 89 deletions(-) diff --git a/Ashx/SIGFacturacion.ashx b/Ashx/SIGFacturacion.ashx index f9ff0d3cb..034a71d08 100644 --- a/Ashx/SIGFacturacion.ashx +++ b/Ashx/SIGFacturacion.ashx @@ -280,7 +280,6 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState ObjFactura.Serie = Serie ObjFactura.Folio = Folio.ToEntero() ObjFactura.TipoMensajeRespuesta = TipoMensajeRespuesta.TextoLimpio - ObjFactura.Version = "4.0" ObjFactura.CveUsuario = UsuarioActual.CveUsuario ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa @@ -290,16 +289,11 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState ObjFactura.TipoDocto = "Ing" 'ObjFactura.CveMesa = -1 ObjFactura.Fecha = ClsPaginas.NowADS() - ObjFactura.CvePrePoliza = -1 ObjFactura.FechaPago = ClsPaginas.NowADS() - ObjFactura.MotivoDescuento = "" ObjFactura.FechaEjecucion = ClsPaginas.NowADS() ObjFactura.UsuarioCreo = UsuarioActual.Usuario - ObjFactura.CveCondicionEntrega = -1 - ObjFactura.CondicionesPago = 0 ObjFactura.TipoDocumento = "Ingresos" - ObjFactura.ConvertirPesos = False ObjFactura.CveSubProyecto = CveSubProyecto ObjFactura.CveSubProyectoCobranza = CveSubProyecto ObjFactura.CveSubProyectoEjecucion = CveSubProyecto @@ -309,8 +303,6 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState 'CLIENTE ObjFactura.CveCliente = CveCliente ObjFactura.SetCliente() - ObjFactura.CveAlmacen = -1 - 'DETALLES ObjFactura.DtDetalle = CreaDTDetalle(Resp, UsuarioActual, DTRemisionesPS) @@ -485,89 +477,10 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState Next Return Timbre End Function + Private Function CreaDTDetalle(ByRef Retorno As Modelos.Factura.MMensajeFactura, UsuarioActual As Usuario, DtRemisionesPS As DataTable) As DataTable - Dim TmpDT As New DataTable - TmpDT.Columns.Add("CveVenta", GetType(Integer)) - TmpDT.Columns.Add("Consec", GetType(Integer)) - TmpDT.Columns.Add("Cantidad", GetType(Decimal)) - TmpDT.Columns.Add("Codigo", GetType(String)) - TmpDT.Columns.Add("CveUM", GetType(Integer)) - TmpDT.Columns.Add("UM", GetType(String)) - TmpDT.Columns.Add("SATClaveUM", GetType(String)) - TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) - TmpDT.Columns.Add("Clasificacion", GetType(String)) - TmpDT.Columns.Add("CvePS", GetType(Integer)) - TmpDT.Columns.Add("PS", GetType(String)) - TmpDT.Columns.Add("CodigoPS", GetType(String)) - TmpDT.Columns.Add("SATClaveProdServ", GetType(String)) - TmpDT.Columns.Add("NoIdentificacion", GetType(String)) - TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) - TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) - TmpDT.Columns.Add("Serie", GetType(String)) - TmpDT.Columns.Add("CuentaPredial", GetType(String)) - TmpDT.Columns.Add("Obs", GetType(String)) - TmpDT.Columns.Add("TiempoEntrega", GetType(String)) - TmpDT.Columns.Add("PU", GetType(Decimal)) - TmpDT.Columns.Add("IVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) - TmpDT.Columns.Add("IEPS", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) - TmpDT.Columns.Add("Descuento", GetType(Decimal)) - TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) - TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) - TmpDT.Columns.Add("Total", GetType(Decimal)) - 'Para uso del módulo contable - TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer)) - TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) - TmpDT.Columns.Add("CveProyecto", GetType(Integer)) - TmpDT.Columns.Add("Proyecto", GetType(String)) - TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) - TmpDT.Columns.Add("SubProyecto", GetType(String)) - 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto - TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) - TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) - 'Contratos - TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) - 'Remisiones a Facturas - TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) - 'Pedido2 a Facturas - TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) - - TmpDT.Columns.Add("Origen", GetType(Integer)) - 'Ordenes Servicio - TmpDT.Columns.Add("CveOS", GetType(Integer)) - TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) - TmpDT.Columns.Add("SeFacturara", GetType(Integer)) - TmpDT.Columns.Add("Folio", GetType(Integer)) - TmpDT.Columns.Add("Estatus", GetType(String)) - 'Ordenamiento - TmpDT.Columns.Add("Orden", GetType(Integer)) - TmpDT.Columns.Add("TipoDocto", GetType(String)) - 'OC - TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) - TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) - - TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) - TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) - - TmpDT.Columns.Add("CveTamaño", GetType(Integer)) - TmpDT.Columns.Add("CvePromocionDetalle", GetType(Integer)) + Dim TmpDT As DataTable = Modelos.Factura.CreaDTFactura Try For Each Dr As DataRow In DtRemisionesPS.Select() Dim Row As DataRow = AgregarProductoServicio(Retorno, UsuarioActual, TmpDT, Dr("Consec").ToString.ToEntero(), Dr("Cantidad").ToString.ToDecimal(), Dr("CveUM").ToString.ToEntero, Dr("UM").ToString, Dr("CveClasificacion").ToString.ToEntero, Dr("Clasificacion").ToString, From 2b7f0a3034e7be17b5e56100c1de4018b09694ed Mon Sep 17 00:00:00 2001 From: rrene Date: Mon, 31 Mar 2025 19:48:39 -0700 Subject: [PATCH 02/27] -- cambio indicador SMS --- App_Code/ClsVentas.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index c663c819a..3738ec5bf 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -7703,7 +7703,8 @@ Public Class ClsVentas .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa End With Try - SqlAdapter.Fill(Data) + Dataset = New DataSet() + SqlAdapter.Fill(Dataset) Retorno = True Catch ex As Exception OnError("Ocurrió un error al obtener los indicadores de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) From 419d6d2572ca013ab390f6ace5ae9290b081984f Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 31 Mar 2025 19:49:35 -0700 Subject: [PATCH 03/27] --Cambios en autorizacion de anticipos --- App_Code/ClsVentas.vb | 20 +++----------------- Ventas/PVCobranza.aspx.vb | 21 ++++++++------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index a4af209d8..4a76036b7 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -826,27 +826,13 @@ Public Class ClsVentas Return Retorno End Function - Public Function UpdateVentaAnticipoAutorizado(CveVenta As Integer, Autorizado As Boolean) As Boolean + Public Function UpdateAnticipoAutorizado(CveVenta As Integer, CveIE As Integer, Tipo As String, Autorizado As Boolean) As Boolean Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentaAnticipoAutorizadoUpdate") + DataAdapter("PA_Vta_AnticipoAutorizadoUpdate") With SqlAdapter.SelectCommand.Parameters .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Autorizado", SqlDbType.Bit).Value = Autorizado - End With - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el estatus del anticipo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - Return Retorno - End Function - - Public Function UpdateIxCAnticipoAutorizado(CveIE As Integer, Autorizado As Boolean) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_IxCAnticipoAutorizadoUpdate") - With SqlAdapter.SelectCommand.Parameters .Add("@CveIE", SqlDbType.Int).Value = CveIE + .Add("@Tipo", SqlDbType.VarChar).Value = Tipo .Add("@Autorizado", SqlDbType.Bit).Value = Autorizado End With Try diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index e8c8fa9f8..bf5fbf010 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -1156,18 +1156,13 @@ Partial Class Ventas_PVCobranza If CveVenta > 0 OrElse CveIE > 0 Then Dim Actualizo As Boolean = False - If Tipo.Contiene("NC", "Ant") Then - If ObjVentas.UpdateVentaAnticipoAutorizado(CveVenta, False) Then - Actualizo = True - End If - ElseIf Tipo.Contiene("IxC") Then - If ObjVentas.UpdateIxCAnticipoAutorizado(CveIE, False) Then - Actualizo = True - End If + + If ObjVentas.UpdateAnticipoAutorizado(CveVenta, CveIE, Tipo.Trim(), False) Then + Actualizo = True End If If Actualizo Then - Retorno = ObjEventoBitacora.AddEventoBitacora($"El anticipo se desautorizó correctamente. Folio: {Folio}", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveIE, -1, CveCliente, -1, -1, -1, -1, -1, CveVenta:=CveVenta) + Retorno = ObjEventoBitacora.AddEventoBitacora($"El anticipo se aplicó correctamente. Folio: {Folio}", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveIE, -1, CveCliente, -1, -1, -1, -1, -1, CveVenta:=CveVenta) End If End If @@ -2279,7 +2274,7 @@ Partial Class Ventas_PVCobranza Dim CveIE As Integer = gvr.DataKey("CveIE").ToEntero() Dim ObjVta As New ClsVentas - If ObjVta.AddAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, Saldo, 0, UsuarioActual.CveUsuario, 1, TipoDocumento:="Ant", DiasVencidos:=1, CveVenta:=CveVenta, CveIE:=CveIE) Then + If ObjVta.AddAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, Saldo, CveEstatus:=0, CveUsuario:=UsuarioActual.CveUsuario, TipoAutorizacion:=1, TipoDocumento:="Ant", DiasVencidos:=1, CveVenta:=CveVenta, CveIE:=CveIE) Then Dim msgAlert = "La autorización se agregó correctamente." If EnvioMsg Then msgAlert = $"{msgAlert} Se envió una notificación de autorización a los usuarios" @@ -2381,9 +2376,9 @@ Partial Class Ventas_PVCobranza Dim AnticipoAutorizado = CBool(e.Row.DBCampo("AnticipoAutorizado")) - If Not EsProduccion AndAlso UsuarioActual.CveRol = 1 Then - AnticipoAutorizado = True - End If + 'If Not EsProduccion AndAlso UsuarioActual.CveRol = 1 Then + ' AnticipoAutorizado = True + 'End If If UsuarioActual.Empresa.Funcionalidad(185) = "1" Then If e.Row.DBCampo("Tipo").ToString().Contiene("NC", "Ant", "IxC") AndAlso Not AnticipoAutorizado Then From 756c92cd69318679e999cbb4e2cc2c15f3a8586b Mon Sep 17 00:00:00 2001 From: rakcsle Date: Sat, 29 Mar 2025 08:42:54 -0700 Subject: [PATCH 04/27] Compras correcion total al actualizar compra ya registrada --- App_WebReferences/GrowerService/service.disco | 6 + .../GrowerService/service.discomap | 7 + App_WebReferences/GrowerService/service.wsdl | 350 ++++++++++++++++++ Ashx/E158.ashx | 169 +++++++++ Compras/Compras.aspx.vb | 4 +- 5 files changed, 535 insertions(+), 1 deletion(-) create mode 100644 App_WebReferences/GrowerService/service.disco create mode 100644 App_WebReferences/GrowerService/service.discomap create mode 100644 App_WebReferences/GrowerService/service.wsdl create mode 100644 Ashx/E158.ashx diff --git a/App_WebReferences/GrowerService/service.disco b/App_WebReferences/GrowerService/service.disco new file mode 100644 index 000000000..ee543b932 --- /dev/null +++ b/App_WebReferences/GrowerService/service.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/App_WebReferences/GrowerService/service.discomap b/App_WebReferences/GrowerService/service.discomap new file mode 100644 index 000000000..a7281ccc9 --- /dev/null +++ b/App_WebReferences/GrowerService/service.discomap @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/GrowerService/service.wsdl b/App_WebReferences/GrowerService/service.wsdl new file mode 100644 index 000000000..487453d24 --- /dev/null +++ b/App_WebReferences/GrowerService/service.wsdl @@ -0,0 +1,350 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ashx/E158.ashx b/Ashx/E158.ashx new file mode 100644 index 000000000..9ca13d1cc --- /dev/null +++ b/Ashx/E158.ashx @@ -0,0 +1,169 @@ +<%@ WebHandler Language="VB" Class="E158" %> + +Imports System +Imports System.Web +Imports System.Data +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq +Imports Extensiones +Imports System.IO +Imports CrystalDecisions.CrystalReports.Engine +Imports CrystalDecisions.Shared +Imports Microsoft.Reporting.WebForms +Imports System.Threading +Imports System.Threading.Tasks +Imports System.Net.Http +Imports System.Net.Http.Headers +Imports SharpCompress.Archive.Rar +Imports SharpCompress.Common +Imports SharpCompress.Reader +Imports System.Xml +'Imports ADSistemaLibrary.SatXml +'Imports ADSistemaLibrary.SatXml.XmlSatCFDI +Imports System.Diagnostics +Imports System.Drawing +Imports System.Drawing.Imaging + + + +Public Class E158 : Implements IHttpHandler, IReadOnlySessionState + + + Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable + Get + Return False + End Get + End Property + + Private currentcontext As HttpContext + Private URLParametros As New Hashtable + Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest + context.Response.ContentType = "text/plain" + currentcontext = context + Dim retorno As String = "no se encontro la variable" + Try + Dim metodo As String = "" + Dim FechaActual As DateTime = ClsPaginas.NowADS() + Dim FechaEnvio As DateTime = FechaActual + + If context.Request("var") IsNot Nothing Then + URLParametros = Parametros(context.Request("var")) + metodo = URLParametros("metodo").ToString + 'SI TRAE UN JSON COMO PARAMETRO + ElseIf context.Request("metodo") IsNot Nothing Then + metodo = context.Request("metodo").ToString() + If context.Request("FechaEnvio") IsNot Nothing Then + FechaEnvio = context.Request("FechaEnvio").ToString().ToDateTime() + End If + End If + + Select Case metodo + Case "PreciosVentaCultivo" + Dim tCveEmpresa As Integer = context.Request("CveEmpresa").ToString.ToEntero + If PreciosVentaCultivo(tCveEmpresa, context) Then + retorno = "OK" + Else + retorno = "Error" + End If + + context.Response.Write(retorno) + End Select + Catch ex As Exception + ex.GuardaLog(ex.ToString()) + context.Response.Write(retorno) + End Try + + End Sub + + Private Function PreciosVentaCultivo(ByVal CveEmpresa As Integer, ByVal context As HttpContext) As Boolean + Dim Respuesta As Boolean = False + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) + + ' Crear una instancia del servicio web + Dim wsservice As New GrowerService.Service() + wsservice.Url = "http://webservices.optimaproduce.net/GrowerService/service.asmx" + + ' Llamar al método GetSales con los parámetros necesarios + + Dim Parametro1 As Integer = 9 + Dim Parametro2 As Integer = 1 + Dim Parametro3 As Integer = 43 + Dim Parametro4 As Integer = 0 '–batchid de una liquidación – 0 Todos + Dim Parametro5 As Integer = 3 '– Para agropecuaria Jam + Dim Parametro6 As Integer = 0 + Dim Parametro6Date As Date = Now.AddDays(-3) + + 'Dim DTresp As DataTable = wsservice.GetSales(Parametro1, Parametro2, Parametro3, Parametro4, Parametro5, Parametro6) + 'DTresp.WriteXml("C:\temp\GrowerService\Sales.xml", XmlWriteMode.WriteSchema) + + 'Dim DTAdjustements As DataTable = wsservice.GetAdjustements(Parametro1, Parametro2, Parametro4, Parametro5, Parametro6) + 'DTAdjustements.WriteXml("C:\temp\GrowerService\Adjustements.xml", XmlWriteMode.WriteSchema) + + + + 'Dim DTGeneralExpenses As DataTable = wsservice.GetGeneralExpenses(Parametro1, Parametro2, Parametro3, Parametro4, Parametro5, Parametro6, expenseID:=) + 'DTGeneralExpenses.WriteXml("C:\temp\GrowerService\GeneralExpenses.xml", XmlWriteMode.WriteSchema) + + 'Dim DTLotexpenses As DataTable = wsservice.GetLotExpenses(Parametro1, Parametro2, Parametro3, Parametro4, Parametro5, Parametro6, expenseID:=) + 'DTLotexpenses.WriteXml("C:\temp\GrowerService\Lotexpenses.xml", XmlWriteMode.WriteSchema) + + Dim DTTodayInvoices As DataTable = wsservice.GetTodayInvoices(Parametro1, Parametro2, Parametro3, Parametro4, Parametro5, Parametro6Date, ContractFilter:=1) + DTTodayInvoices.WriteXml("C:\temp\GrowerService\TodayInvoices.xml", XmlWriteMode.WriteSchema) + + Dim InvParametro1 As Integer = 9 + Dim InvParametro2 As Integer = 1 + Dim InvParametro3 As Date = Now.AddDays(-3) ' “01/01/2025” '- ldDate + Dim InvParametro4 As Integer = 3 '- PackerID + Dim InvParametro5 As Integer = 0 ' - GrowerID + Dim InvParametro6 As Integer = 0 '- LabelID(0 = Todos) + Dim InvParametro7 As String = ”E” '- Language + + 'Dim DTIntentoryActivity As DataTable = wsservice.GetInventoryActivity(InvParametro1, InvParametro2, InvParametro3, InvParametro4, InvParametro5, InvParametro6, InvParametro7) + 'DTIntentoryActivity.WriteXml("C:\temp\GrowerService\IntentoryActivity.xml", XmlWriteMode.WriteSchema) + + + + + + Return Respuesta + End Function + + + Private Function ValidaUsuarioSistema(CveUsuario As Integer, CveEmpresa As Integer) As Usuario + Dim UsuarioActual As Usuario = Nothing + Dim NombreCadena As String = ClsPaginas.GlobalNombreCadenaConexion(CveEmpresa) + Dim ObjUsuarios As New ClsSisUsuarioAutenticacion(NombreCadena:=NombreCadena) + UsuarioActual = ObjUsuarios.GetUsuarioDetalle(CveUsuario, CveEmpresa) + If UsuarioActual IsNot Nothing Then + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual + 'CreaObjetoEmpresa(UsuarioActual) + End If + ObjUsuarios.Dispose() + + Return UsuarioActual + End Function + + Private Function Parametros(Cadena As String) As Hashtable + Cadena = Decripta(Cadena) + Dim P1() As String = Cadena.Split("&"c) + Dim Tmp As String + Dim P2() As String + + Dim URLParametros As New Hashtable + + For Each Tmp In P1 + P2 = Tmp.Replace("%26%", "&").Split("="c) + URLParametros.Add(P2(0).ToString(), P2(1)) + Next + Return URLParametros + End Function + + +End Class + + + + + + + diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 1c656dea0..784aaecf0 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -17381,7 +17381,9 @@ Partial Class Compras_Compras If TxtIEPS.Text.ToDouble > 0 Then TrIEPS.Visible = True End If If TxtDescuento.Text.ToDouble > 0 Then TrDescuento.Visible = True - If ActualizaTotales And UsuarioActual.CveEmpresa = 72 Then TxtTotal.Text = Total.ToString.FormatoNumero() + 'If ActualizaTotales And UsuarioActual.CveEmpresa = 72 Then + TxtTotal.Text = Total.ToString.FormatoNumero() + 'End If Else TxtSubTotal.Text = SubTotal.ToString.FormatoNumero() TxtSubTotal2.Text = SubTotal2.ToString.FormatoNumero() From 929f160a3d76e740236f761214cd249bd1468100 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Mon, 31 Mar 2025 22:58:55 -0700 Subject: [PATCH 05/27] Ventas Actualizar Linea Adicional --- Agropecuaria/RepPreciosVentaManifiesto.aspx | 157 +++++++++++ .../RepPreciosVentaManifiesto.aspx.vb | 261 ++++++++++++++++++ App_Code/ClsPaginas.vb | 2 + App_Code/ClsVentas.vb | 3 +- Compras/Compras.aspx.vb | 26 +- Ventas/Ventas.aspx.vb | 19 +- 6 files changed, 462 insertions(+), 6 deletions(-) create mode 100644 Agropecuaria/RepPreciosVentaManifiesto.aspx create mode 100644 Agropecuaria/RepPreciosVentaManifiesto.aspx.vb diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx b/Agropecuaria/RepPreciosVentaManifiesto.aspx new file mode 100644 index 000000000..d61fd61be --- /dev/null +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx @@ -0,0 +1,157 @@ +<%@ Page Title="Reporte de Ordenes de Servicio Médicas" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepPreciosVentaManifiesto.aspx.vb" Inherits="Agrupecuaria_RepPreciosVentaManifiesto" %> + + + + + + + + + + + + + + Reporte de Ordenes de Servicio Médicas + + + + +
  • + Excel +
  • +
    + + + +
    +
    + + + + +
    +
    +
    + + +
    +
    +
    + + + +
    + Fecha Inicio: + +
    +
    +
    + + + + +
    + + + + + + +
    +
    + Fecha Fin: + +
    +
    +
    + + + + +
    + + + + + + +
    + + SubProyecto: +
    + +
    + + + +
    +
    +
    + +
    +
    +
    + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + + + + + + <%--0--%> + + <%----%> + <%--1--%> + + <%--2--%> + + <%--3--%> + + <%--4--%> + + <%--5--%> + + <%--6--%> + + <%--7--%> + + <%--8--%> + + <%--9--%> + + <%--10--%> + + <%--11--%> + + <%--12--%> + + <%--13--%> + + <%--14--%> + + + + + + + + + +
    + + diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb new file mode 100644 index 000000000..53e5f678f --- /dev/null +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb @@ -0,0 +1,261 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports Extensiones + +Partial Class Agrupecuaria_RepPreciosVentaManifiesto + Inherits ClsPaginas + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx") + + CargaCombos() + CargaDatos() + End If + + End Sub + + +#Region " CARGA COMBOS " + + + Private Sub CargaCombos() + + CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto) + + CargaCultivo() + + 'CargaEstatus + DdlEstatusOS.DataSource = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa) + DdlEstatusOS.DataBind() + DdlEstatusOS.Items.Insert(0, New ListItem("Todos", "-1")) + Dim DTTecnicos As DataTable = Nothing + + Dim ObjOS As New ClsOS + If ObjOS.GetSubProyectosEstatusInicial(-1, 3, UsuarioActual.CveEmpresa) Then + DTTecnicos = ObjOS.DtResultados + End If + ObjOS.Dispose() + + DdlTecnico.DataSource = DTTecnicos + DdlTecnico.DataBind() + DdlTecnico.Items.Insert(0, New ListItem("Todos", "-1")) + DdlTecnico.Items.Insert(1, New ListItem("Sin Asignar", "-2")) + + '376 + If UsuarioActual.TienePermisoProceso(376) Then + DdlTecnico.Enabled = False + DdlTecnico.SelectedValueExist(UsuarioActual.CveUsuario) + End If + + + If IfNull(Request("CveUsuarioTecnico"), 0).ToString.ToEntero > 0 Then + DdlTecnico.SelectedValueExist(Request("CveUsuarioTecnico").ToString) + Else + ViewState("CveUsuarioTecnico") = -1 + End If + + 'CargaClientes + Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + 'If EsWS Then + ' DdlClientes.setEsWebService(True) + 'Else + ' DdlClientes.setEsWebService(False) + ' DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + ' DdlClientes.DataBind() + ' DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + 'End If + + 'Vendedor + DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltraParametros("VendedorTipo in (1,4)") 'vendedores y vendedores de piso + DdlVendedor.DataBind() + DdlVendedor.Items.Insert(0, New ListItem("Todos", "-1")) + DdlVendedor.Items.Insert(1, New ListItem("Sin Vendedor", "-2")) + + If UsuarioActual.CveVendedor > 0 Then + DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor) + DdlVendedor.Enabled = False + End If + + txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString + txtFechaF.Text = NowADS().AddDays(2).ToShortDateString + + + DdlMedico.DataSource = If(UsuarioActual.CveVendedor > 0, GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros($" Estatus = 'True' AND CveVendedor = {UsuarioActual.CveVendedor} "), GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")) + DdlMedico.DataBind() + + DdlProcedimiento.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") + DdlProcedimiento.DataBind() + + DdlTipoVenta.DataSource = GlobalDTTipoVenta(UsuarioActual.CveEmpresa) + DdlTipoVenta.DataBind + + Dim ObjVentas As New ClsVentas + + If ObjVentas.GetMedicosEspecialidades(-1, UsuarioActual.CveEmpresa, -1) Then + DdlEspecialidad.DataSource = ObjVentas.DtResultados + Else + DdlEspecialidad.DataSource = Nothing + End If + + ObjVentas.Dispose() + + DdlEspecialidad.DataBind() + DdlEspecialidad.Items.Insert(0, New ListItem("Todas", "-1")) + + DdlClienteSucursal.DataSource = GlobalDTClientesTodosSucursales(UsuarioActual.CveEmpresa) + DdlClienteSucursal.DataBind() + DdlClienteSucursal.Items.Insert(0, New ListItem("Todos", "-1")) + + 'Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + 'If EsWS Then + ' DdlCliente.setEsWebService(True) + + 'Else + ' DdlCliente.setEsWebService(False) + ' DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) + ' DdlCliente.DataBind() + ' DdlCliente.ddl.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) + 'End If + + End Sub + + Private Sub CargaCultivo() + DdlCultivo.Items.Clear() + If DdlSubProyecto.GetSelectedValuesM(True) <> "" Then + DdlCultivo.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveSubProyecto IN ({0})", DdlSubProyecto.GetSelectedValuesM(True))) + DdlCultivo.DataBind() + Else + DdlCultivo.DataSource = Nothing + DdlCultivo.DataBind() + End If + End Sub + +#End Region + +#Region " CARGA DATOS " + Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click + + CargaDatos() + + End Sub + + Private Sub CargaDatos() + + Dim ObjOS As New ClsOS + Dim FechaI As Date = If(txtFechaI.Text.Trim = "", MinFecha, txtFechaI.Text.ToDate) + Dim FechaF As Date = If(txtFechaF.Text.Trim = "", MaxFecha, txtFechaF.Text.ToDate) + Dim Cvecliente As Integer = DdlClienteSucursalCliente() + Dim CveClienteSucursal As Integer = DdlClienteSucursalSucursal() + LnkPersonalizar.Visible = False + + If ObjOS.GetRepOrdenesServicioMedicasRep(FechaI, FechaF, Cvecliente, DdlVendedor.SelectedValue.ToEntero, DdlEstatusOS.SelectedValue.ToEntero, DdlTecnico.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, + CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, CveEspecialidad:=DdlEspecialidad.SelectedValue.ToEntero, + CveClienteSucursal:=CveClienteSucursal, CveUsuario:=UsuarioActual.CveUsuario, CveTipoVenta:=DdlTipoVenta.SelectedValue.ToEntero) Then + GvDatos.DataSource = ObjOS.DtResultados + If ObjOS.DtResultados IsNot Nothing AndAlso ObjOS.DtResultados.Rows.Count > 0 Then + LnkPersonalizar.Visible = True + End If + Else + GvDatos.DataSource = Nothing + End If + + ObjOS.Dispose() + + GvDatos.DataBind() + + + LnkExportar.Visible = If(GvDatos.Rows.Count > 0, True, False) + UpAcciones.Update() + + + UPDatos.Update() + + End Sub + + +#End Region + + + 'Private Sub CargaClientes() + ' DdlClientes.ddl.Items.Clear() + ' DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) '.FiltraParametros($"CveClienteClasificacion = {DdlClienteClasificacion.SelectedValue.ToEntero} OR {DdlClienteClasificacion.SelectedValue.ToEntero} = -1") + ' DdlClientes.DataBind() + ' DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + 'End Sub + + Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged + CargarSubProyecto(DdlSubProyecto, DdlProyecto.SelectedValue) + End Sub + + +#Region " GV DATOS - ROW DATABOUND " + Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.Cells(1).Attributes.Add("data-order", e.Row.DBCampo("FechaCita").ToDateTime.ToString("yyyyMMddHHmm")) + If e.Row.DBCampo("CveOS") = "" Then + e.Row.CssClass = "Totales" + End If + End If + End Sub +#End Region + + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + + Dim SubProyecto As String = "" + + If DdlSubProyecto.SelectedValue.ToEntero > 0 Then + SubProyecto = DdlSubProyecto.SelectedItem.Text + End If + + Dim SbFiltros As New StringBuilder() + SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|") + SbFiltros.AppendFormat("SubProyecto: {0}|", SubProyecto) + + + GvDatos.ExportToExcelGembox("OrdenesServicio", UsuarioActual, "Ordenes de Servicio Medicas", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString()) + + End Sub + + Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) + End Sub + + Protected Sub LnkPersonalizar_Click(sender As Object, e As EventArgs) + + ' ChkGuardarPersonalizacion.Checked = False + RegistraScript("$('#DivPersonalizar').modal('show')") + + End Sub + + Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click + Personaliza() + End Sub + + Private Sub Personaliza() + GvDatos.Columns(13).Visible = ChkObservaciones.Checked + GvDatos.Columns(14).Visible = ChkFolioAdicional.Checked + CargaDatos() + End Sub + + Private Function DdlClienteSucursalCliente() As Integer + If DdlClienteSucursal.SelectedValue = "-1" Then + Return -1 + Else + Dim array As String() = DdlClienteSucursal.SelectedValue.Split("|"c) + Return If(array(0).ToEntero > 0, array(0).ToEntero, -1) + End If + End Function + + Private Function DdlClienteSucursalSucursal() As Integer + If DdlClienteSucursal.SelectedValue = "-1" Then + Return -1 + Else + Dim array As String() = DdlClienteSucursal.SelectedValue.Split("|"c) + Return If(array(1).ToEntero > 0, array(1).ToEntero, -1) + End If + End Function + + +End Class diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index ac4aa3906..8e1b2afe6 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -11138,6 +11138,8 @@ Public Class ClsPaginas PaginaDict.Add("/Contabilidad/OCDetalleAlmacen.aspx".ToUpper(), -1) PaginaDict.Add("/Contabilidad/RepBalanceGeneralHorizontal.aspx".ToUpper(), -1) PaginaDict.Add("/Agropecuaria/CierreCultivo.aspx".ToUpper(), 1326) + PaginaDict.Add("/Agropecuaria/RepPreciosVentaManifiesto.aspx".ToUpper(), -1) + PaginaDict.Add("/Inventarios/RepRSCO.aspx".ToUpper(), 1328) PaginaDict.Add("/testApi.aspx".ToUpper(), -1) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 7e514cd05..81ca7b875 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -6335,7 +6335,7 @@ Public Class ClsVentas End Function - Public Function UpdateVentaLineaAdicional(CveLineaAdicional As Integer, CveVenta As Integer, LineaAdicionalComprobante As String, CveLineaAdicionalEstatus As Integer, CveEmpresa As Integer) As Boolean + Public Function UpdateVentaLineaAdicional(CveLineaAdicional As Integer, CveVenta As Integer, LineaAdicionalComprobante As String, CveLineaAdicionalEstatus As Integer, CveEmpresa As Integer, Optional OrdenCompra As String = "-1") As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_LineasAdicionalesVentaUpdate") @@ -6345,6 +6345,7 @@ Public Class ClsVentas .Add("@LineaAdicionalComprobante", SqlDbType.VarChar).Value = LineaAdicionalComprobante .Add("@CveLineaAdicionalEstatus", SqlDbType.Int).Value = CveLineaAdicionalEstatus .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra End With Try SqlAdapter.Fill(Data) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 784aaecf0..986c618b0 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -252,6 +252,20 @@ Partial Class Compras_Compras Return ViewState("CveCompra").ToString.ToEntero End Get End Property + + Private Property CveCompraFactura As Integer + Get + If ViewState("CveCompraFactura") Is Nothing Then + ViewState("CveCompraFactura") = -1 + End If + Return ViewState("CveCompraFactura").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCompraFactura") = value + End Set + End Property + + Private ReadOnly Property CveFactura As Integer Get Return ViewState("CveFactura").ToString.ToEntero @@ -1545,7 +1559,7 @@ Partial Class Compras_Compras If UsuarioActual.Empresa.Funcionalidad(562).ToEntero > 0 Then CargaGastosServicios(UsuarioActual.Empresa.Funcionalidad(562).ToEntero) End If - + CargaGvPersonal() ElseIf Request("CveCompra") IsNot Nothing AndAlso IsNumeric(Request("CveCompra")) AndAlso Request("CveCompra").ToEntero > 0 Then 'If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 Then @@ -1594,6 +1608,7 @@ Partial Class Compras_Compras 'End If LnkAgregarGuia.Visible = False UpLnkPaqueteriaGuias.Update() + CargaGvPersonal() End If If UsuarioActual.TienePermisoProceso(360) AndAlso UsuarioActual.CveEmpresa = 119 Then BtnProrateoDeducible.Visible = True @@ -2973,6 +2988,7 @@ Partial Class Compras_Compras LblRetISR.Text = If(dr("RetISR").ToString.ToDecimal > 0, TmpDT.MAX("RetISRPorcentaje").ToDecimal * 100, 0).ToString.FormatoNumero(4) '(If(SubTotal2 > 0, (RetencionISR / SubTotal2), 0) * 100).FormatoNumero(3) If dr("TipoFactura").ToString <> "CFDi" Then LblTipoFact.Text = dr("TipoFactura").ToString : divTipoFactura.Visible = True ViewState("CveFactura") = dr("CveFactura").ToString.ToEntero + CveCompraFactura = dr("CveFactura").ToString.ToEntero ViewState("IdPoliza") = dr("IdPoliza").ToString.ToEntero DdlMoneda.SelectedValue = dr("CveMoneda").ToString @@ -17381,9 +17397,11 @@ Partial Class Compras_Compras If TxtIEPS.Text.ToDouble > 0 Then TrIEPS.Visible = True End If If TxtDescuento.Text.ToDouble > 0 Then TrDescuento.Visible = True - 'If ActualizaTotales And UsuarioActual.CveEmpresa = 72 Then - TxtTotal.Text = Total.ToString.FormatoNumero() - 'End If + + If ActualizaTotales And UsuarioActual.CveEmpresa = 72 Or Not CveCompraFactura > 0 Then + TxtTotal.Text = Total.ToString.FormatoNumero() + End If + Else TxtSubTotal.Text = SubTotal.ToString.FormatoNumero() TxtSubTotal2.Text = SubTotal2.ToString.FormatoNumero() diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index e4f747f8b..b9612d751 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -39669,8 +39669,25 @@ Partial Class Ventas End If End If + + Dim OrdenCompra As String = "-1" + + If UsuarioActual.CveEmpresa = 119 Then + Dim arrayStr As String() = DdlLineaAdicional.SelectedItem.Text.Split(":"c) + If arrayStr.Length > 0 Then + Dim OrdenCompraTmp As String = arrayStr(0).Replace("IMP", "").Trim + If TxtOrdenCompra.Text.Trim.Length > 0 Then + If OrdenCompraTmp.ToUpper <> TxtOrdenCompra.Text.Trim.ToUpper Then + OrdenCompra = $"{TxtOrdenCompra.Text}, {OrdenCompraTmp}" + End If + Else + OrdenCompra = $"{OrdenCompraTmp}" + End If + End If + End If + Using ObjVentas As New ClsVentas - If ObjVentas.UpdateVentaLineaAdicional(DdlLineaAdicional.SelectedValue.ToEntero(), CveVenta, "", 1, UsuarioActual.CveEmpresa) Then + If ObjVentas.UpdateVentaLineaAdicional(DdlLineaAdicional.SelectedValue.ToEntero(), CveVenta, "", 1, UsuarioActual.CveEmpresa, OrdenCompra:=OrdenCompra) Then Alert("Se actualizó la linea adicional de crédito de la venta") End If End Using From 1d902f26b40fb1373694a6fb4f8e398ab431acd9 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 1 Apr 2025 11:21:25 -0700 Subject: [PATCH 06/27] --FIX autorizaciones de NC --- Ventas/Ventas.aspx.vb | 45 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index b9612d751..dbece0253 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -10505,7 +10505,7 @@ Partial Class Ventas End Sub - Private Sub VerificaAutorizacionEgs(Optional VerificarImportes As Boolean = True) + Private Sub VerificaAutorizacionEgs(Optional VerificarImportes As Boolean = True, Optional MostrarAlertas As Boolean = True) Dim ImporteAutorizacion As Decimal = 0 Dim TipoAutorizacion As Integer = 0 @@ -10535,7 +10535,10 @@ Partial Class Ventas CveAutorizacion = -1 If BloquearCredito Then - Alert($"El importe autorizado es insuficiente. Importe autorizado:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia) + If MostrarAlertas Then + Alert($"El importe autorizado es insuficiente. Importe autorizado:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia) + End If + Exit Sub End If End If @@ -10543,7 +10546,10 @@ Partial Class Ventas Else CveAutorizacion = -1 - Alert($"No se encontro una autorización de crédito.", TipoMensaje.MsgAdvertencia) + If MostrarAlertas Then + Alert($"No se encontro una autorización de crédito.", TipoMensaje.MsgAdvertencia) + End If + Exit Sub End If End Sub @@ -31508,6 +31514,23 @@ Partial Class Ventas Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional AplicaNuevoDocumento As Boolean = False, Optional AplicoNCFacturaActual As Boolean = False, Optional TipoDoctoNC As String = "Egs") Try + 'VALIDACION DE AUTORIZACION PARA NC, POR AHORA SOLO BDH + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso AplicoNCFacturaActual AndAlso TipoDoctoNC = "Egs" Then + Dim PermiteAutorizacion = False + 'SI NO ES GENERADA CON REMISIONES DE NC, UTILIZAR LA AUTORIZACION + If (ListaRemisionesNC Is Nothing OrElse ListaRemisionesNC.Count = 0) Then + PermiteAutorizacion = True + End If + + If PermiteAutorizacion Then + VerificaAutorizacionEgs(VerificarImportes:=True, MostrarAlertas:=True) + If Me.CveAutorizacion <= 0 Then + Exit Sub + End If + End If + End If + + Me.AplicaDocumentoNuevoNC = AplicaNuevoDocumento Dim DrPS As DataRow = Nothing @@ -40582,10 +40605,13 @@ Partial Class Ventas RblRNCTipo_SelectedIndexChanged(RblRNCTipo, EventArgs.Empty) If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - VerificaAutorizacionEgs(VerificarImportes:=True) - If Me.CveAutorizacion <= 0 Then - Exit Sub - Else + + TxtImportesRemisionesNC.Text = "0.00" + TxtNCImporte.Text = "0.00" + + VerificaAutorizacionEgs(VerificarImportes:=True, MostrarAlertas:=False) + + If Me.CveAutorizacion > 0 Then Using ObjVentas As New ClsVentas If ObjVentas.GetAutorizacion(Me.CveAutorizacion, UsuarioActual.CveEmpresa) Then If ObjVentas.DtResultados.FiltroPrimeroValor("CveTipoVenta").ToEntero() > 0 Then @@ -40595,7 +40621,12 @@ Partial Class Ventas End If End If End Using + Else + DivTipoVentaAsingado.Visible = True + LblTipoVentaAsignado.Text = "Sin definir" + DdlNCPS.Enabled = True End If + End If RegistraScript("$('#ModalAplicarNC').modal('show');", "ModalNC") From 2dbb10247b04f360cf2af41161506dd8e0aa4a83 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 1 Apr 2025 15:39:39 -0700 Subject: [PATCH 07/27] =?UTF-8?q?--=20dem=C3=A1s=20empresa=20sde=20gdiaz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ventas/PVCobranza.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ventas/PVCobranza.aspx.vb b/Ventas/PVCobranza.aspx.vb index e8c8fa9f8..bca3f5a5d 100644 --- a/Ventas/PVCobranza.aspx.vb +++ b/Ventas/PVCobranza.aspx.vb @@ -523,7 +523,7 @@ Partial Class Ventas_PVCobranza HdnVentaCondicionesPago.Value = GvRow.DataKey("CondicionesPago") HdnPlazoCobranza.Value = GvRow.DataKey("PlazoCobranza") - If UsuarioActual.CveEmpresa.Contiene(189, 1) AndAlso GvRow.DataKey("TipoDocto") = "Rem" Then + If UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197) AndAlso GvRow.DataKey("TipoDocto") = "Rem" Then DivAnticipo.Visible = True ImgAntiPend.Visible = True End If From 9dd55cf486270b774a30be5ff1a4d4e94f5707c1 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 1 Apr 2025 18:05:44 -0700 Subject: [PATCH 08/27] =?UTF-8?q?-=20activaci=C3=B3n=20de=20otros=20campos?= =?UTF-8?q?=20para=20el=20txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Contabilidad/RepIVA.aspx.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Contabilidad/RepIVA.aspx.cs b/Contabilidad/RepIVA.aspx.cs index a15292e63..ab9ce005e 100644 --- a/Contabilidad/RepIVA.aspx.cs +++ b/Contabilidad/RepIVA.aspx.cs @@ -377,7 +377,7 @@ public partial class Contabilidad_RepIVA : ClsPaginas else { DataTable dtt = new DataTable(); - dtt = Objconta.DtResultados.FiltraParametros("CveCompra is null and CveProveedor > 0 AND ( ActosFN > 0 OR ActosFS > 0 OR Actos16 > 0 OR ActosImp16 > 0 OR ActosImpNotan16 > 0 OR DATasa0 > 0 OR DANoObjetoTN > 0 OR DANoObjetoNoTN > 0)"); + dtt = Objconta.DtResultados.FiltraParametros("CveCompra is null and CveProveedor > 0 AND ( ActosFN > 0 OR ActosFS > 0 OR Actos16 > 0 OR ActosImp16 > 0 OR ActosImpNotan16 > 0 OR DATasa0 > 0 OR DANoObjetoTN > 0 OR DANoObjetoNoTN > 0 OR NoAcredFN > 0 OR NoAcredNoFN > 0)"); //acumula los prov, globales en un solo registro dtt = AcumularYReemplazar(dtt); @@ -799,7 +799,7 @@ public partial class Contabilidad_RepIVA : ClsPaginas TmpDIOT.Columns.Add("DAManifiesto", typeof(string)); DataTable dtt = new DataTable(); - dtt = Objconta.DtResultados.FiltraParametros("CveCompra is null and CveProveedor > 0 AND ( ActosFN > 0 OR ActosFS > 0 OR Actos16 > 0 OR ActosImp16 > 0 OR ActosImpNotan16 > 0 OR DATasa0 > 0 OR DANoObjetoTN > 0 OR DANoObjetoNoTN > 0)"); + dtt = Objconta.DtResultados.FiltraParametros("CveCompra is null and CveProveedor > 0 AND ( ActosFN > 0 OR ActosFS > 0 OR Actos16 > 0 OR ActosImp16 > 0 OR ActosImpNotan16 > 0 OR DATasa0 > 0 OR DANoObjetoTN > 0 OR DANoObjetoNoTN > 0 OR NoAcredFN > 0 OR NoAcredNoFN > 0)"); //acumula los prov, globales en un solo registro dtt = AcumularYReemplazar(dtt); From 588ee12b07b8f0db5a48b8db0ea1af75bcbd5be8 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 1 Apr 2025 18:32:10 -0700 Subject: [PATCH 09/27] -- condiciion especial de GDiaz, para no cambiar un cliente de depositos x identificar --- Ventas/Clientes.aspx.vb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index daa096874..cfa20e4e5 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -1475,6 +1475,10 @@ Partial Class Clientes LtlTareaNueva.Text = String.Format(" Tarea", CveCliente) BtnEliminar.Visible = PermiteEliminar() BtnGuardar.Visible = PermiteEditar() + 'condicion especial. + If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso CveCliente = 1582883 Then 'que no se pueda editar. INGRESOS NO IDENTIFICADOS + BtnGuardar.Visible = False + End If CargaDdlSucursalCliente() CargaDocumentosVenta(CveCliente) From 1eb75a4ec5b13def2df7be361ae6d571fa3c4780 Mon Sep 17 00:00:00 2001 From: Luis Quijada Date: Wed, 2 Apr 2025 16:15:55 -0700 Subject: [PATCH 10/27] Finalizacion de Orden Produccion --- App_Code/ClsOP.vb | 48 ++ Inventarios/TrasladoSolicitud.aspx.vb | 2 +- OP/OP.aspx | 841 +++++++++++++++++++++----- OP/OP.aspx.vb | 779 +++++++++++++++++++++--- OP/RepOP.aspx | 2 +- 5 files changed, 1441 insertions(+), 231 deletions(-) diff --git a/App_Code/ClsOP.vb b/App_Code/ClsOP.vb index 8688a3969..eb34c60ee 100644 --- a/App_Code/ClsOP.vb +++ b/App_Code/ClsOP.vb @@ -408,6 +408,33 @@ Public Class ClsOP #Region "O R D E N E S D E P R O D U C C I O N" + + Public Function OPAdd(Descripcion As String, CveCliente As Integer, CveEmpresa As Integer, CveUsuario As Integer, Fecha As Date, CveSubProyecto As Integer, xmlproductos As String, ByRef CveOP As Integer, ByRef Folio As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_OrdendeProduccionAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@xmlproductos", SqlDbType.Xml).Value = xmlproductos + .Add("@CveOP", SqlDbType.Int).Direction = ParameterDirection.Output + .Add("@Folio", SqlDbType.Int).Value = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + CveOP = CInt(SqlAdapter.SelectCommand.Parameters("@CveOP").Value) + Folio = CInt(SqlAdapter.SelectCommand.Parameters("@Folio").Value) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar la Orden de Produccion.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Retorno = False + End Try + Return Retorno + End Function + Public Function GetReportesOP(CveOP As Integer, CveCliente As Integer, CveSubProyecto As Integer, CvePS As Integer, CveEstatus As Integer, Asignado As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OP_OrdendeProduccionGet") @@ -474,6 +501,27 @@ Public Class ClsOP Return Retorno End Function + Public Function UpdateEstatusOP(CveOP As Integer, CveEstatusOP As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_OP_OrdendeProduccionEstatusUp") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOP", SqlDbType.Int).Value = CveOP + .Add("@CveEstatusOP", SqlDbType.Int).Value = CveEstatusOP + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True ' Éxito si no hay excepciones + Catch ex As Exception + OnError("Error al actualizar estatus de la OP", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + Retorno = False + End Try + + Return Retorno + End Function + Public Function UpdateOP(CveOP As Integer, Descripcion As String, CveCliente As Integer, CvePS As Integer, CveSubProyecto As Integer, Cantidad As Integer, Fecha As Date, CveEmpresa As Integer, CveUsuario As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OP_OrdendeProduccionUp") diff --git a/Inventarios/TrasladoSolicitud.aspx.vb b/Inventarios/TrasladoSolicitud.aspx.vb index 53d05aefa..7b5ff9426 100644 --- a/Inventarios/TrasladoSolicitud.aspx.vb +++ b/Inventarios/TrasladoSolicitud.aspx.vb @@ -335,7 +335,7 @@ Partial Class Inventarios_TrasladoSolicitud Dim CodigoPS As String = "" For Each row As GridViewRow In GvDatos.Rows - Existencia = ObjInventarios.GetExistenciasPS(row.DataKey("CvePS").ToEntero, row.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=NowADS.ToString("yyyy/MM/dd 23:59"), Lote:=row.DataKey("Lote").ToString, FechaCaducidad:=row.DataKey("FechaCaducidad").ToString.ToDate) + Existencia = ObjInventarios.GetExistenciasPS(row.DataKey("CvePS").ToEntero, row.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=NowADS.ToString("yyyy/MM/dd 23:59"), FechaCaducidad:=row.DataKey("FechaCaducidad").ToString.ToDate) If Existencia - TempDT.SUM("Cantidad", $"CvePS = {row.DataKey("CvePS").ToEntero} AND CveUM = {row.DataKey("CveUM").ToEntero}") < 0 Then CodigoPS = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=row.DataKey("CvePS").ToEntero).FiltroPrimeroValor("PSCodigo", "") MensajeExistencia.AppendFormat("
    - {0}. Existencia: {1}", CodigoPS, Existencia) diff --git a/OP/OP.aspx b/OP/OP.aspx index f42a51846..7ca37ef2a 100644 --- a/OP/OP.aspx +++ b/OP/OP.aspx @@ -1,9 +1,227 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="OP.aspx.vb" Inherits="OP_OP" %> +<%@ Import Namespace="Extensiones" %> + +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="OP.aspx.vb" Inherits="OP_OP" %> + @@ -81,109 +293,177 @@ - + +
    + + +
    +
    +
    +
    + Orden de producción # +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    +
    +
    + + + +
    + +
    + + + +
    + +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    + + + +
    +
    +
    + + + + + +
    +
    +
    +
    + +
    +
    +
    + + + + +
    + + + + + + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + Estatus +
    + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + -
    - -
    -

    Orden de producción #

    -
    - - - -
    -
    -
    -
    - - -
    -
    - - -
    - -
    - - Proyecto: - -
    - +
    +
    +
    +
    +
    + Productos +
    - - Subproyecto: - -
    - +
    +
    + +
    + +
    +
    + + + + + + + + + +
    +
    -
    -
    - - -
    - - - -
    - - -
    -
    - -
    -
    -
    - - - - -
    - - - - - - -
    -
    - - -
    - -
    - -
    - - -
    - - - -
    -
    +
    Productos
    @@ -191,60 +471,347 @@ + + + + +
    -
    -
    -
    Materia prima
    - - - - - - - - +
    +
    +
    + + +
    +
    +
    +
    +
    + Materia Prima +
    +
    + + Solicitar MP +
    -
    +
    + +
    Materia prima
    + + + + + + + + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + Mano de Obra +
    +
    + + +
    Mano de obra
    - +
    - -
    -
    -
    Costo indirecto
    - - - - - - +
    +
    +
    +
    +
    +
    + Costo Indirecto
    - - - - -
    - +
    +
    Costo indirecto
    + + + + + + +
    +
    + + + + + + + +
    + +
    + +
    +
    + +
    +
    + + + + diff --git a/OP/OP.aspx.vb b/OP/OP.aspx.vb index 912e1f845..4e48eecba 100644 --- a/OP/OP.aspx.vb +++ b/OP/OP.aspx.vb @@ -5,6 +5,9 @@ Imports System.IO Imports Extensiones Imports Microsoft.Reporting.WebForms Imports Org.BouncyCastle.Asn1.Utilities +Imports Profact.TimbraCFDI.Complementos.Ecc.Ecc11 +Imports System.Xml +Imports System.Data.SqlClient Partial Class OP_OP Inherits ClsPaginas @@ -54,6 +57,23 @@ Partial Class OP_OP End Set End Property + Private Property DtMPAgregados As DataTable + Get + If ViewState("DtMPAgregados") Is Nothing Then + DtMPAgregados = New DataTable() + DtMPAgregados.Columns.Add("Clave", GetType(Integer)) + DtMPAgregados.Columns.Add("PSCodigo", GetType(String)) + DtMPAgregados.Columns.Add("CveUM", GetType(Integer)) + DtMPAgregados.Columns.Add("UnidadMedida", GetType(String)) + DtMPAgregados.Columns.Add("Cantidad", GetType(Decimal)) + End If + Return CType(ViewState("DtMPAgregados"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMPAgregados") = value + End Set + End Property + #End Region @@ -72,27 +92,37 @@ Partial Class OP_OP DtPS.Columns.Add("PSCodigo", GetType(String)) DtPS.Columns.Add("UnidadMedida", GetType(String)) DtPS.Columns.Add("Cantidad", GetType(Decimal)) + DtPS.Columns.Add("CveUM", GetType(Integer)) DtPS.Columns.Add("Surtido", GetType(Decimal)) DtPS.Columns.Add("Costo", GetType(Decimal)) DtMP = New DataTable() DtMP.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI DtMP.Columns.Add("Clave", GetType(Integer)) - DtMP.Columns.Add("Producto", GetType(String)) + DtMP.Columns.Add("CvePSMateriaPrima", GetType(Integer)) + DtMP.Columns.Add("CveUM", GetType(Integer)) + DtMP.Columns.Add("CveUMMateriaPrima", GetType(Integer)) + DtMP.Columns.Add("PSCodigo", GetType(String)) DtMP.Columns.Add("UnidadMedida", GetType(String)) DtMP.Columns.Add("Cantidad", GetType(Decimal)) DtMP.Columns.Add("Surtido", GetType(Decimal)) + 'DtMP.Columns.Add("CveAlmacenDestino", GetType(Integer)) DtMO = New DataTable() DtMO.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI DtMO.Columns.Add("Clave", GetType(Integer)) + DtMO.Columns.Add("CveUM", GetType(Integer)) + DtMO.Columns.Add("CvePuesto", GetType(Integer)) DtMO.Columns.Add("Puesto", GetType(String)) DtMO.Columns.Add("Cantidad", GetType(Decimal)) DtCI = New DataTable() DtCI.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI DtCI.Columns.Add("Clave", GetType(Integer)) - DtCI.Columns.Add("Producto", GetType(String)) + 'DtCI.Columns.Add("CveUM", GetType(Integer)) + 'DtCI.Columns.Add("CvePSMateriaPrima", GetType(Integer)) + 'DtCI.Columns.Add("CveUMMateriaPrima", GetType(Integer)) + DtCI.Columns.Add("productoMateriaPrima", GetType(String)) DtCI.Columns.Add("Cantidad", GetType(Decimal)) @@ -105,17 +135,20 @@ Partial Class OP_OP CargarProductos() If CveOP = -1 Then - ' Modo registro: mostrar dropdowns y ocultar los TextBox + DdlClientes.Enabled = True DdlProyecto.Enabled = True DdlSubProyecto.Enabled = True DdlPS.Enabled = True - + LnkSolicitarMP.Visible = False + BtnSimularMP.Visible = True + BtnFinalizarOP.Visible = False Else DdlClientes.Enabled = False - DdlProyecto.Enabled = False - DdlSubProyecto.Enabled = False DdlPS.Enabled = False + LnkSolicitarMP.Visible = False + BtnSimularMP.Visible = False + BtnFinalizarOP.Visible = True CargaDatos() End If End Sub @@ -127,18 +160,76 @@ Partial Class OP_OP Dim DTOP As DataTable = ObjOP.DtResultados If DTOP.Rows.Count > 0 Then Dim dr As DataRow = DTOP.Rows(0) - LblCveOP.Text = CveOP.ToString + LblFolio.Text = dr("Folio").ToString DdlClientes.txtText.Value = dr("Cliente").ToString DdlClientes.txtValue.Value = dr("CveCliente").ToString TxtEstatus.Text = dr("Estatus").ToString - DdlSubProyecto.SelectedValue = dr("CveSubProyecto").ToString + DdlSubProyecto.SelectedValueExist(dr("CveSubProyecto").ToString) DdlPS.txtText.Value = dr("Producto").ToString DdlPS.txtValue.Value = dr("CvePS").ToString Txtfecha.Text = dr("Fecha").ToString TxtDescripcion.Text = dr("Descripcion").ToString + + + If ObjOP.GetProductosOP(CveOP, UsuarioActual.CveEmpresa) Then + DtPS.Rows.Clear() + For Each rowProducto As DataRow In ObjOP.DtResultados.Rows + Dim newRow As DataRow = DtPS.NewRow() + newRow("Tipo") = "Producto" + newRow("Clave") = rowProducto("CvePS").ToString.ToEntero + newRow("PSCodigo") = rowProducto("Producto").ToString + + newRow("UnidadMedida") = rowProducto("UnidadMedida").ToString + newRow("Cantidad") = rowProducto("Cantidad").ToString.ToDecimal + newRow("CveUM") = rowProducto("CveUM").ToString.ToEntero + DtPS.Rows.Add(newRow) + Next + End If + + If ObjOP.GetProductosMP(CveOP, UsuarioActual.CveEmpresa) Then + DtMP.Rows.Clear() + For Each rowMP As DataRow In ObjOP.DtResultados.Rows + Dim newRow As DataRow = DtMP.NewRow() + newRow("Tipo") = "MP" + newRow("Clave") = rowMP("CvePS").ToString.ToEntero + newRow("PSCodigo") = rowMP("Producto").ToString + newRow("CvePSMateriaPrima") = rowMP("CvePS").ToString.ToEntero + newRow("CveUMMateriaPrima") = rowMP("CveUM").ToString.ToEntero + newRow("UnidadMedida") = rowMP("UnidadMedida").ToString + newRow("Cantidad") = rowMP("Cantidad").ToString.ToDecimal + newRow("Surtido") = rowMP("Surtido").ToString.ToDecimal() + DtMP.Rows.Add(newRow) + Next + End If + + '----- Cargar Mano de Obra ----- + If ObjOP.GetProductosMO(CveOP, UsuarioActual.CveEmpresa) Then + DtMO.Rows.Clear() + For Each rowMO As DataRow In ObjOP.DtResultados.Rows + Dim newRow As DataRow = DtMO.NewRow() + newRow("Tipo") = "MO" + newRow("Puesto") = rowMO("Puesto").ToString + newRow("Cantidad") = rowMO("Cantidad").ToString.ToDecimal + DtMO.Rows.Add(newRow) + Next + End If + + '----- Cargar Costos Indirectos ----- + If ObjOP.GetProductosCI(CveOP, UsuarioActual.CveEmpresa) Then + DtCI.Rows.Clear() + For Each rowCI As DataRow In ObjOP.DtResultados.Rows + Dim newRow As DataRow = DtCI.NewRow() + newRow("Tipo") = "CI" + newRow("productoMateriaPrima") = rowCI("producto").ToString + newRow("Cantidad") = rowCI("Cantidad").ToString.ToDecimal + DtCI.Rows.Add(newRow) + + Next + End If End If End If ObjOP.Dispose() + ActualizarGrids() End If End Sub @@ -180,10 +271,11 @@ Partial Class OP_OP newRow("PSCodigo") = DrPS("PSCodigo") newRow("UnidadMedida") = DrPS("UnidadMedida") newRow("Cantidad") = 1 + newRow("CveUM") = DrPS("CveUnidadMedida").ToString.ToEntero newRow("Surtido") = 0 newRow("Costo") = 0 DtPS.Rows.Add(newRow) - 'consultas GetMPReceta, GetMOReceta, GetCIReceta + Dim CveUM As Integer = DrPS("CveUnidadMedida").ToString.ToEntero @@ -194,7 +286,10 @@ Partial Class OP_OP Dim rowMP As DataRow = DtMP.NewRow() rowMP("Tipo") = "MP" rowMP("Clave") = CvePS - rowMP("Producto") = drMP("productoMateriaPrima").ToString() + rowMP("CvePSMateriaPrima") = CvePS + rowMP("CveUM") = CveUM + rowMP("CveUMMateriaPrima") = CveUM 'drMP("CveUMMateriaPrima").ToString().ToEntero() + rowMP("PSCodigo") = drMP("productoMateriaPrima").ToString() rowMP("UnidadMedida") = drMP("UnidadMedidaMateriaPrima").ToString() rowMP("Cantidad") = drMP("Cantidad").ToString().ToDecimal() rowMP("Surtido") = 0 @@ -218,11 +313,13 @@ Partial Class OP_OP Dim ObjCI As New ClsOP() If ObjCI.GetCIReceta(CvePS, CveUM, UsuarioActual.CveEmpresa) Then + For Each drCI As DataRow In ObjCI.DtResultados.Rows Dim rowCI As DataRow = DtCI.NewRow() rowCI("Tipo") = "CI" rowCI("Clave") = CvePS - rowCI("Producto") = drCI("productoMateriaPrima").ToString() + 'rowCI("CvePSMateriaPrima") = drCI("CvePSMateriaPrima").ToString().ToEntero() + rowCI("productoMateriaPrima") = drCI("productoMateriaPrima").ToString() rowCI("Cantidad") = drCI("Cantidad").ToString().ToDecimal() DtCI.Rows.Add(rowCI) Next @@ -232,42 +329,332 @@ Partial Class OP_OP End Sub Protected Sub BtnEliminarProducto_Click(sender As Object, e As EventArgs) - If DdlPS.SelectedValue = "-1" Then - Alert("Seleccione un producto del listado.", TipoMensaje.MsgAdvertencia) - Return - End If - - Dim CveProducto As Integer = DdlPS.SelectedValue.ToEntero() + Dim btnEliminar As LinkButton = DirectCast(sender, LinkButton) + Dim CveProducto As Integer = btnEliminar.CommandArgument.ToEntero() Dim filasProducto As DataRow() = DtPS.Select($"Clave = {CveProducto}") If filasProducto.Length > 0 Then DtPS.Rows.Remove(filasProducto(0)) + EliminarDatosRelacionados(CveProducto) + ActualizarGrids() End If - - EliminarDatosRelacionados(CveProducto) - - ActualizarGrids() End Sub Private Sub EliminarDatosRelacionados(CveProducto As Integer) + + ' Materia Prima Dim filasMP As DataRow() = DtMP.Select($"Clave = {CveProducto}") For Each fila As DataRow In filasMP DtMP.Rows.Remove(fila) Next + ' Mano de Obra Dim filasMO As DataRow() = DtMO.Select($"Clave = {CveProducto}") For Each fila As DataRow In filasMO DtMO.Rows.Remove(fila) Next + ' Costos Indirectos Dim filasCI As DataRow() = DtCI.Select($"Clave = {CveProducto}") For Each fila As DataRow In filasCI DtCI.Rows.Remove(fila) Next End Sub + Protected Sub LnkSolicitarMP_Click(sender As Object, e As EventArgs) + ' Cargar almacenes + DdlAlmacenOrigenMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") + DdlAlmacenOrigenMP.DataBind() + DdlAlmacenDestinoMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28") + DdlAlmacenDestinoMP.DataBind() + + GvMPAgregados.DataKeyNames = New String() {"CvePSMateriaPrima", "CveUMMateriaPrima"} + + ' Filtrar MP no surtida + Dim DtMPFaltante As DataTable = DtMP.FiltraParametros("Surtido = 0").Copy() + GvMPAgregados.DataSource = DtMPFaltante + GvMPAgregados.DataBind() + + + ' Mostrar modal + RegistraScript("$('#DVModalSolicitarMP').modal('show');") + UpModalMP.Update() + End Sub + + Protected Sub BtnSimularMP_Click(sender As Object, e As EventArgs) + If CveOP <> -1 Then Exit Sub + If DdlPS.SelectedValue = "-1" Then Exit Sub + + Dim nombreProducto As String = DdlPS.txtText.Value ' Ajusta según tu control + Dim spanNombre As HtmlGenericControl = DirectCast(UpModalSimular.FindControl("SpanNombreProducto"), HtmlGenericControl) + spanNombre.InnerText = nombreProducto + + GvSimulacionMP.DataSource = Nothing + GvSimulacionMP.DataBind() + LblCantidadPosibleGlobal.Visible = False + + ' Cargar almacenes (sin borrar el ítem inicial) + DdlAlmacenSimular.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") + DdlAlmacenSimular.DataTextField = "Almacen" ' Nombre de la columna para mostrar + DdlAlmacenSimular.DataValueField = "CveAlmacen" ' Columna para el valor + DdlAlmacenSimular.DataBind() + + CalcularSimulacion() + + RegistraScript("$('#DVModalSimularMP').modal('show');") + UpModalSimular.Update() + End Sub + + Protected Sub RblModoSimulacion_SelectedIndexChanged(sender As Object, e As EventArgs) + ' Controlar visibilidad del TextBox + PnlCantidad.Visible = (RblModoSimulacion.SelectedValue = "1") + + ' Resetear valor si cambian de modo + If RblModoSimulacion.SelectedValue = "2" Then + TxtCantidadSimular.Text = "1" + End If + + UpModalSimular.Update() + CalcularSimulacion() + End Sub + + Protected Sub DdlAlmacenSimular_SelectedIndexChanged(sender As Object, e As EventArgs) + If DdlAlmacenSimular.SelectedValue = "-1" Then + Alert("Por favor selecciona un almacén.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + CalcularSimulacion() + End Sub + + Protected Sub TxtCantidadSimular_TextChanged(sender As Object, e As EventArgs) + CalcularSimulacion() + UpModalSimular.Update() + End Sub + + Private Sub CalcularSimulacion() + If DdlAlmacenSimular.SelectedValue = "-1" Then Exit Sub + If DdlPS.SelectedValue = "-1" Then Exit Sub + + Dim CvePS As Integer = DdlPS.SelectedValue.ToEntero() + Dim DtMP As DataTable = ObtenerMPRequerida(CvePS) + AgregarColumnasSimulacion(DtMP) + Dim listaCantidadesPosibles As New List(Of Decimal) + Dim MinCantidadPosible As Decimal = 0D + + For Each rowMP As DataRow In DtMP.Rows + Dim CveMP As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero() + Dim CveUMMP As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero() + Dim CveAlmacen As Integer = DdlAlmacenSimular.SelectedValue.ToEntero() + + Dim Existencia As Decimal = 0 + Using ObjInventario As New ClsInventarios() + Existencia = ObjInventario. + GetExistenciasPS( + CvePS:=CveMP, + CveUnidadMedida:=CveUMMP, + CveEmpresa:=UsuarioActual.CveEmpresa, + CveAlmacen:=CveAlmacen + ) + End Using + + rowMP("Disponible") = Existencia + Dim CantidadUnitaria As Decimal = rowMP("Cantidad").ToString.ToDecimal() + rowMP("CantidadUnitaria") = CantidadUnitaria ' Fija (no se modifica) + + If RblModoSimulacion.SelectedValue = "1" Then + Dim CantidadProducto As Decimal = TxtCantidadSimular.Text.ToDecimal() + If RblModoSimulacion.SelectedValue = "1" AndAlso TxtCantidadSimular.Text.Trim() = "" Then + Alert("Ingresa la cantidad a simular", TipoMensaje.MsgAdvertencia) + Return + End If + Dim TotalRequerido As Decimal = CantidadUnitaria * CantidadProducto + rowMP("TotalRequerido") = TotalRequerido + rowMP("Faltante") = Math.Max(TotalRequerido - Existencia, 0D) + + Else + If CantidadUnitaria > 0 Then + Dim CantidadProducible As Decimal = Math.Floor(Existencia / CantidadUnitaria) + rowMP("CantidadPosible") = CantidadProducible ' ✔️ Valor individual por material + listaCantidadesPosibles.Add(CantidadProducible) + Else + rowMP("CantidadPosible") = 0D + End If + End If + Next + + If RblModoSimulacion.SelectedValue = "2" AndAlso listaCantidadesPosibles.Count > 0 Then + MinCantidadPosible = listaCantidadesPosibles.Min() + Else + MinCantidadPosible = 0D + End If + + GvSimulacionMP.Columns(3).Visible = (RblModoSimulacion.SelectedValue = "1") ' Total Requerido (Índice 3) + GvSimulacionMP.Columns(4).Visible = (RblModoSimulacion.SelectedValue = "1") ' Faltante (Índice 4) + GvSimulacionMP.Columns(5).Visible = (RblModoSimulacion.SelectedValue = "2") ' CantidadPosible (Índice 5) + + ' Asegurar visibilidad de columnas fijas + GvSimulacionMP.Columns(0).Visible = True + GvSimulacionMP.Columns(1).Visible = True + GvSimulacionMP.Columns(2).Visible = True + + GvSimulacionMP.DataSource = DtMP + GvSimulacionMP.DataBind() + LblCantidadPosibleGlobal.Text = $"Cantidad: {MinCantidadPosible:N0}" + LblCantidadPosibleGlobal.Visible = (RblModoSimulacion.SelectedValue = "2") + End Sub + + Private Sub AgregarColumnasSimulacion(ByRef dt As DataTable) + If Not dt.Columns.Contains("CantidadUnitaria") Then + dt.Columns.Add("CantidadUnitaria", GetType(Decimal)).DefaultValue = 0D + End If + + If Not dt.Columns.Contains("TotalRequerido") Then + dt.Columns.Add("TotalRequerido", GetType(Decimal)).DefaultValue = 0D + End If + + If Not dt.Columns.Contains("Disponible") Then + dt.Columns.Add("Disponible", GetType(Decimal)).DefaultValue = 0D + End If + If Not dt.Columns.Contains("Faltante") Then + dt.Columns.Add("Faltante", GetType(Decimal)).DefaultValue = 0D + End If + If Not dt.Columns.Contains("CantidadPosible") Then + dt.Columns.Add("CantidadPosible", GetType(Decimal)).DefaultValue = 0D + End If + End Sub + + Private Function ObtenerMPRequerida(CvePS As Integer) As DataTable + Dim ObjOP As New ClsOP() + ObjOP.GetMPReceta(CvePS, -1, UsuarioActual.CveEmpresa) + + ' Verificar y convertir CvePSMateriaPrima a Integer + For Each row As DataRow In ObjOP.DtResultados.Rows + If Not IsDBNull(row("CvePSMateriaPrima")) Then + row("CvePSMateriaPrima") = Convert.ToInt32(row("CvePSMateriaPrima")) + Else + row("CvePSMateriaPrima") = 0 ' Valor por defecto si es nulo + End If + Next + + Return ObjOP.DtResultados.Copy() + End Function + + Protected Sub BtnGuardarSolicitudMP_Click(sender As Object, e As EventArgs) + + Dim CveTraspasoSolicitud As Integer = -1 + + If DdlAlmacenOrigenMP.SelectedValue = DdlAlmacenDestinoMP.SelectedValue Then + Alert("Los almacenes de origen y destino no pueden ser el mismo. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not GvMPAgregados.Rows.Count > 0 Then + Alert("No se ha seleccionado ningún producto para trasladar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim EstatusAlmacen As Integer = 2 + Dim Estatus As Integer = If(UsuarioActual.Empresa.Funcionalidad(105) <> "", 1, 3) + Dim ObjInventario As New ClsInventarios() + Dim TieneErrorExistencia As Boolean = False + Dim MensajeExistencia As New StringBuilder + MensajeExistencia.Append("No hay la existencia suficiente de los siguientes productos:
    ") + + '✅ 1. Validar existencias de MP + For Each row As GridViewRow In GvMPAgregados.Rows + '✅ Obtener claves CORRECTAS de la materia prima + Dim CveMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString().ToEntero() + Dim CveUMMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString().ToEntero() + Dim CantidadSolicitada As Decimal = DtMP.Rows(row.RowIndex)("Cantidad").ToString().ToDecimal() + + 'DtMP.Rows(row.RowIndex)("CveAlmacenDestino") = DdlAlmacenDestinoMP.SelectedValue.ToEntero() + + '✅ Verificar existencias + Dim Existencia As Decimal = ObjInventario.GetExistenciasPS( + CvePS:=CveMP, + CveUnidadMedida:=CveUMMP, + CveEmpresa:=UsuarioActual.CveEmpresa, + CveAlmacen:=DdlAlmacenOrigenMP.SelectedValue.ToEntero() + ) + + If Existencia < CantidadSolicitada Then + Dim NombreProducto As String = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveMP).FiltroPrimeroValor("Producto", "") + Dim Faltante As Decimal = CantidadSolicitada - Existencia + MensajeExistencia.AppendFormat( + "
    - {0} ({1}) Existencia: {2}, Faltante: {3}", + NombreProducto, + row.Cells(0).Text, ' Código del producto + Existencia.ToString("N2"), + Faltante.ToString("N2") + ) + TieneErrorExistencia = True + End If + Next + + If TieneErrorExistencia Then + Alert(MensajeExistencia.ToString, TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + '✅ 2. Crear traspaso si todo está correcto + ObjInventario.IniciaTransacSQL() + Dim TieneError As Boolean = False + + Dim FolioSolicitud As Integer = ObjInventario.AddTrasladoSolicitud( + TxtObservacionesMP.Text.Trim(), + DdlAlmacenOrigenMP.SelectedValue.ToEntero(), + DdlAlmacenDestinoMP.SelectedValue.ToEntero(), + Estatus, + -1, + NowADS, + CveUsuario:=UsuarioActual.CveUsuario, + CveEmpresa:=UsuarioActual.CveEmpresa, + EstatusAlmacen:=EstatusAlmacen + ) + + If FolioSolicitud > 0 Then + CveTraspasoSolicitud = ObjInventario.CveTraspasoSolicitud + Else + TieneError = True + End If + + '✅ 3. Agregar detalles del traspaso + If Not TieneError Then + For Each row As GridViewRow In GvMPAgregados.Rows + '✅ Usar claves de MATERIA PRIMA (CvePSMateriaPrima y CveUMMateriaPrima) + Dim CveMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CvePSMateriaPrima").ToString().ToEntero() + Dim CveUMMP As Integer = GvMPAgregados.DataKeys(row.RowIndex)("CveUMMateriaPrima").ToString().ToEntero() + Dim Cantidad As Decimal = DtMP.Rows(row.RowIndex)("Cantidad").ToString().ToDecimal() + + If Not ObjInventario.AddTrasladoSolicitudDetalle( + CveTraspasoSolicitud, + Cantidad, + CveUMMP, '✅ Unidad de medida de la MP + CveMP, '✅ Clave de la MP + 0, "", -1, "-1", "-1", MinFecha + ) Then + TieneError = True + Exit For + End If + Next + End If + + '✅ 4. Confirmar o cancelar transacción + If Not TieneError Then + ObjInventario.Commit() + Alert($"Solicitud de Traspaso guardada. Folio: {FolioSolicitud}", TipoMensaje.MsgInformacion) + RegistraScript("$('#DVModalSolicitarMP').modal('hide');") + CargaDatos() + Else + ObjInventario.RollBack() + Alert("Error al guardar el traspaso.", TipoMensaje.MsgError) + End If + ObjInventario.Dispose() + + End Sub + Protected Sub BtnGuardarOP_Click(sender As Object, e As EventArgs) - ' Validar campos obligatorios + ' Validaciones básicas If DdlClientes.SelectedValue = "-1" Then Alert("Seleccione un cliente.", TipoMensaje.MsgAdvertencia) Return @@ -278,94 +665,86 @@ Partial Class OP_OP Return End If - ' Iniciar transacción Dim clsOP As New ClsOP() clsOP.IniciaTransacSQL() + Dim transactionActive As Boolean = False Try - ' Insertar/Actualizar cabecera de la OP usando UpdateOP - Dim CveOP As Integer = Me.CveOP ' Si es nuevo, CveOP = -1 - Dim Success As Boolean = clsOP.UpdateOP( - CveOP:=CveOP, - Descripcion:=TxtDescripcion.Text, - CveCliente:=DdlClientes.SelectedValue.ToEntero(), - CvePS:=DdlPS.SelectedValue.ToEntero(), - CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero(), - Cantidad:=1, ' Ajustar según lógica de negocio - Fecha:=Convert.ToDateTime(Txtfecha.Text), - CveEmpresa:=UsuarioActual.CveEmpresa, - CveUsuario:=UsuarioActual.CveUsuario - ) - If Not Success Then - Throw New Exception("Error al guardar la cabecera de la OP.") - End If - ' Obtener el CveOP generado (asumiendo que se actualiza en la propiedad) - If Me.CveOP = -1 Then - ' Si es nuevo, recuperar el CveOP de la base de datos - ' (Requiere que el SP PA_OP_OrdendeProduccionUp devuelva el ID) - ' Esto depende de la implementación del SP. - ' Ejemplo hipotético: - clsOP.GetOP(-1, DdlClientes.SelectedValue.ToEntero(), DdlSubProyecto.SelectedValue.ToEntero(), -1, -1, -1, MinFecha, MaxFecha, UsuarioActual.CveEmpresa) - If clsOP.DtResultados.Rows.Count > 0 Then - Me.CveOP = clsOP.DtResultados.Rows(0)("CveOP").ToString.ToEntero() + + If Me.CveOP = -1 Then ' Modo CREACIÓN + + Dim xmlProductos As String = DataTableToXML(DtPS) + Dim CveOPGenerado As Integer = -1 + Dim FolioGenerado As Integer = -1 + + If clsOP.OPAdd( + Descripcion:=TxtDescripcion.Text, + CveCliente:=DdlClientes.SelectedValue.ToEntero(), + CveEmpresa:=UsuarioActual.CveEmpresa, + CveUsuario:=UsuarioActual.CveUsuario, + Fecha:=Convert.ToDateTime(Txtfecha.Text), + CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero(), + xmlproductos:=xmlProductos, + CveOP:=CveOPGenerado, + Folio:=FolioGenerado + ) Then + Me.CveOP = CveOPGenerado + LblFolio.Text = FolioGenerado.ToString + Alert("Orden creada con Folio: " & FolioGenerado, TipoMensaje.MsgInformacion) + End If + Else ' Modo EDICIÓN + Dim CvePS As Integer = DtPS.Rows(0)("Clave").ToString.ToEntero() + Dim Cantidad As Integer = DtPS.Rows(0)("Cantidad").ToString.ToEntero() + BtnFinalizarOP.Visible = True + If Not clsOP.UpdateOP( + CveOP:=Me.CveOP, + Descripcion:=TxtDescripcion.Text, + CveCliente:=DdlClientes.SelectedValue.ToEntero(), + CvePS:=CvePS, + CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero(), + Cantidad:=Cantidad, + Fecha:=Convert.ToDateTime(Txtfecha.Text), + CveEmpresa:=UsuarioActual.CveEmpresa, + CveUsuario:=UsuarioActual.CveUsuario + ) Then + Throw New Exception("Error al actualizar la OP") End If End If - ' Insertar detalles de Productos, MP, MO, CI - For Each drProducto As DataRow In DtPS.Rows - Dim CvePS As Integer = drProducto("Clave").ToString().ToEntero() - - ' Insertar Materia Prima relacionada - For Each drMP As DataRow In DtMP.Select($"Clave = {CvePS}") - clsOP.AddMP( - Cantidad:=drMP("Cantidad").ToString().ToDecimal(), - CvePS:=CvePS, - CvePSMateriaPrima:=drMP("CvePSMateriaPrima").ToString().ToEntero(), - CveUM:=drMP("CveUM").ToString().ToEntero(), - CveUMMateriaPrima:=drMP("CveUMMateriaPrima").ToString().ToEntero() - ) - Next - - ' Insertar Mano de Obra relacionada - For Each drMO As DataRow In DtMO.Select($"Clave = {CvePS}") - clsOP.AddMO( - Cantidad:=drMO("Cantidad").ToString().ToDecimal(), - CvePS:=CvePS, - CvePuesto:=drMO("CvePuesto").ToString().ToEntero(), - CveUM:=drMO("CveUM").ToString().ToEntero() - ) - Next - - ' Insertar Costos Indirectos relacionados - For Each drCI As DataRow In DtCI.Select($"Clave = {CvePS}") - clsOP.AddCI( - Cantidad:=drCI("Cantidad").ToString().ToDecimal(), - CvePS:=CvePS, - CvePSMateriaPrima:=drCI("CvePSMateriaPrima").ToString().ToEntero(), - CveUM:=drCI("CveUM").ToString().ToEntero(), - CveUMMateriaPrima:=drCI("CveUMMateriaPrima").ToString().ToEntero() - ) - Next - Next - - ' Commit si todo es exitoso clsOP.Commit() - Alert("Orden de Producción guardada correctamente.", TipoMensaje.MsgInformacion) - Response.Redirect($"OP.aspx?CveOP={Me.CveOP}") ' Redirigir a la OP guardada + transactionActive = False + + + Response.Redirect($"OP.aspx?CveOP={Me.CveOP}", False) + Context.ApplicationInstance.CompleteRequest() Catch ex As Exception - ' Rollback en caso de error - clsOP.RollBack() - Alert($"Error al guardar: {ex.Message}", TipoMensaje.MsgError) + If transactionActive Then + clsOP.RollBack() + End If + Alert($"Error: {ex.Message}", TipoMensaje.MsgError) Finally clsOP.Dispose() End Try End Sub + Private Function DataTableToXML(dt As DataTable) As String + Dim xmlDoc As New XmlDocument() + xmlDoc.LoadXml("") + + For Each row As DataRow In dt.Rows + Dim producto As XmlElement = xmlDoc.CreateElement("Producto") + producto.InnerXml = $"{row("Clave")}{row("Cantidad")}{row("CveUM")}" + xmlDoc.DocumentElement.AppendChild(producto) + Next + + Return xmlDoc.OuterXml + End Function + Private Sub ActualizarGrids() - Dim dtProductosFiltrados As DataTable = DtPS.Clone() ' Clona la estructura + Dim dtProductosFiltrados As DataTable = DtPS.Clone() Dim rowsProductos As DataRow() = DtPS.Select("Tipo = 'Producto'") If rowsProductos.Length > 0 Then dtProductosFiltrados = rowsProductos.CopyToDataTable() @@ -397,11 +776,227 @@ Partial Class OP_OP GvCostosIndirectos.DataSource = dtCIFiltrados GvCostosIndirectos.DataBind() + ' Calcular suma de "Surtido" + Dim sumSurtido As Decimal = DtMP.AsEnumerable().Sum(Function(row) row.Field(Of Decimal)("Surtido")) + + + LnkSolicitarMP.Visible = (CveOP > -1 AndAlso sumSurtido = 0) + UpGvDatosOP.Update() End Sub + Protected Sub DdlAlmacenOrigenMP_SelectedIndexChanged(sender As Object, e As EventArgs) + ' ✅ Mantener siempre el almacén de producción (tipo 28) en destino + DdlAlmacenDestinoMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28") + DdlAlmacenDestinoMP.DataBind() + + ' ✅ Opcional: Seleccionar el primer almacén de producción por defecto + If DdlAlmacenDestinoMP.Items.Count > 0 Then + DdlAlmacenDestinoMP.SelectedIndex = 0 + End If + End Sub + +#Region "Eventos de Botones" + + Protected Sub BtnFinalizarOP_Click(sender As Object, e As EventArgs) + If CveOP = -1 Then Exit Sub + + ' 1. Cargar almacén de salida (Tipo 28) + DdlAlmacenOrigenSalidaMP.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 28") + DdlAlmacenOrigenSalidaMP.DataBind() + ' 2. Cargar almacén de producto terminado + DdlAlmacenTerminado.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen = 1") + DdlAlmacenTerminado.DataBind() + DdlAlmacenTerminado.Items.Insert(0, New ListItem("Seleccionar almacén", "-1")) + + ' 3. Cargar GridViews + GvProductoTerminado.DataSource = DtPS.FiltraParametros("Tipo = 'Producto'") + GvProductoTerminado.DataBind() + + GvMPUtilizada.DataSource = DtMP.FiltraParametros("Tipo = 'MP'").Copy() + GvMPUtilizada.DataBind() + + RegistraScript("$('#DVModalFinalizarOP').modal('show');") + UpModalFinalizar.Update() + End Sub + + Protected Sub BtnGuardarFinalizarOP_Click(sender As Object, e As EventArgs) Handles BtnGuardarFinalizarOP.Click + If DdlAlmacenOrigenSalidaMP.SelectedValue = "-1" OrElse DdlAlmacenTerminado.SelectedValue = "-1" Then + Alert("Selecciona ambos almacenes.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + ' Dim TotalCantidad As Decimal = DtMovimientos.SUMD("Cantidad") + 'Inicia la transacción + + Dim CveMovimientoSalida As Integer = 0 + Dim CveMovimientoEntrada As Integer = 0 + Dim IDPoliza As Integer = 0 + Dim FolioSalida As Integer = 0 + 'Dim CveMovimientoVirtualEntrada As Integer = 0 + 'Dim CveMovimientoVirtualSalida As Integer = 0 + 'Dim FolioVirtualEntrada As Integer = 0 + 'Dim FolioVirtualSalida As Integer = 0 + Dim FolioEntrada As Integer = 0 + Dim Fecha As DateTime = Txtfecha.Text.ToDate + Dim ErrorMovInv As Boolean = False + Dim ErrorAC As Boolean = False + Dim TextoError As String = "" + Dim TipoMovimientoSalida As Integer = 8 + Dim CveConceptoEntrada As Integer = 9 + Dim TotalCostoMP As Decimal = 0 + + Dim ObjInventario As New ClsInventarios() + + ObjInventario.IniciaTransacSQL() + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Try + + CveMovimientoSalida = ObjInventario.AddMovimiento( + CveAlmacen:=DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), + CveConcepto:=TipoMovimientoSalida, + CveMoneda:=1, + FechaMovto:=Fecha, + tFolio:=-1, + CveUsuario:=UsuarioActual.CveUsuario, + CveEmpresa:=UsuarioActual.CveEmpresa, + CveCompra:=-1, + CveVenta:=-1, + CveSubProyecto:=-1, + CveActivoFijo:=-1, + Observaciones:="Finalización OP #" & LblFolio.Text, + CveAlmacenDestino:=DdlAlmacenTerminado.SelectedValue.ToEntero(), + Modulo:="OP/FinalizarOPSalida" + ) + + + For Each rowMP As DataRow In DtMP.Select("Tipo = 'MP'") + If Not ObjInventario.AddMovimientoDetalle( + CveMovimientoSalida, + rowMP("Cantidad").ToString.ToDecimal(), + rowMP("CveUMMateriaPrima").ToString.ToEntero(), + rowMP("CvePSMateriaPrima").ToString.ToEntero(), + 1 + ) Then + Throw New Exception("Error al agregar detalle de MP") + End If + TotalCostoMP += rowMP("Cantidad").ToString.ToDecimal() + Next + + + CveMovimientoEntrada = ObjInventario.AddMovimiento( + CveAlmacen:=DdlAlmacenTerminado.SelectedValue.ToEntero(), + CveConcepto:=CveConceptoEntrada, + CveMoneda:=1, + FechaMovto:=Fecha, + tFolio:=-1, + CveUsuario:=UsuarioActual.CveUsuario, + CveEmpresa:=UsuarioActual.CveEmpresa, + CveCompra:=-1, CveVenta:=-1, CveSubProyecto:=-1, CveActivoFijo:=-1, + Observaciones:="Finalización OP #" & LblFolio.Text, + Modulo:="OP/FinalizarOPEntrada", + CveMovimientoRelacionado:=CveMovimientoSalida + ) + + + Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(row) Convert.ToDecimal(row("Cantidad"))) + Dim PU_PT As Decimal = If(CantidadPT > 0, TotalCostoMP / CantidadPT, 1) + + + For Each rowPT As DataRow In DtPS.Select("Tipo = 'Producto'") + If Not ObjInventario.AddMovimientoDetalle( + CveMovimientoEntrada, + rowPT("Cantidad").ToString.ToDecimal(), + rowPT("CveUM").ToString.ToEntero(), + rowPT("Clave").ToString.ToEntero(), + PU_PT + ) Then + Throw New Exception("Error al agregar detalle de PT") + End If + Next + + + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas( + Modulo:="Inventario/OPFinalizada", + CvePlantillaPoliza:=53, + Cargos:=0, + Abonos:=0, + CveMoneda:=1, + Fecha:=Fecha, + Concepto:="Producción OP #" & LblFolio.Text, + CveUsuario:=UsuarioActual.CveUsuario, + CveEmpresa:=UsuarioActual.CveEmpresa + ) + + + If Not ObjConta.AddPrePolizasDetalle( + CvePrePoliza, + False, + TotalCostoMP, + TotalCostoMP, + 68, + "Consumo MP OP #" & LblFolio.Text, + "Consumo MP OP #" & LblFolio.Text, + CveMovimientoAlmacen:=CveMovimientoSalida + ) Then ErrorMovInv = True + + + If Not ObjConta.AddPrePolizasDetalle( + CvePrePoliza, + True, + TotalCostoMP, + TotalCostoMP, + 68, + "Producción PT OP #" & LblFolio.Text, + "Producción PT OP #" & LblFolio.Text, + CveMovimientoAlmacen:=CveMovimientoEntrada + ) Then ErrorMovInv = True + + + If Not ErrorMovInv Then + Dim ObjOP As New ClsOP() + If Not ObjOP.UpdateEstatusOP(CveOP, 3, UsuarioActual.CveEmpresa) Then + ErrorMovInv = True + TextoError = "Error al actualizar estatus de la OP" + End If + End If + + + If Not ErrorMovInv Then + If Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then + ErrorMovInv = True + TextoError = "Error en validación de póliza" + ElseIf ObjConta.ValorPolizaDescuadre > 0 Then + ErrorMovInv = True + TextoError = "Descuadre en póliza contable" + End If + End If + + + If Not ErrorMovInv Then + ObjInventario.Commit() + Alert($"OP finalizada. Folio Contable: {ObjConta.ContaFolio}", TipoMensaje.MsgInformacion) + Else + ObjInventario.RollBack() + Alert($"Error contable: {TextoError}", TipoMensaje.MsgError) + End If + + RegistraScript("$('#DVModalFinalizarOP').modal('hide');") + CargaDatos() + + Catch ex As Exception + ObjInventario.RollBack() + Alert($"Error crítico: {ex.Message}", TipoMensaje.MsgError) + Finally + ObjInventario.Dispose() + ObjConta.Dispose() + End Try + + + End Sub +#End Region End Class diff --git a/OP/RepOP.aspx b/OP/RepOP.aspx index 43dfa4ed2..07e4fce50 100644 --- a/OP/RepOP.aspx +++ b/OP/RepOP.aspx @@ -174,7 +174,7 @@ - Date: Wed, 2 Apr 2025 17:37:19 -0700 Subject: [PATCH 11/27] -- --- OP/OP.aspx.vb | 167 ++++++++++++++++---------------------------------- 1 file changed, 53 insertions(+), 114 deletions(-) diff --git a/OP/OP.aspx.vb b/OP/OP.aspx.vb index 4e48eecba..3053d6962 100644 --- a/OP/OP.aspx.vb +++ b/OP/OP.aspx.vb @@ -822,7 +822,7 @@ Partial Class OP_OP UpModalFinalizar.Update() End Sub - Protected Sub BtnGuardarFinalizarOP_Click(sender As Object, e As EventArgs) Handles BtnGuardarFinalizarOP.Click + Protected Sub BtnGuardarFinalizarOP_Click(sender As Object, e As EventArgs) If DdlAlmacenOrigenSalidaMP.SelectedValue = "-1" OrElse DdlAlmacenTerminado.SelectedValue = "-1" Then Alert("Selecciona ambos almacenes.", TipoMensaje.MsgAdvertencia) Exit Sub @@ -840,9 +840,8 @@ Partial Class OP_OP 'Dim FolioVirtualEntrada As Integer = 0 'Dim FolioVirtualSalida As Integer = 0 Dim FolioEntrada As Integer = 0 - Dim Fecha As DateTime = Txtfecha.Text.ToDate + Dim Fecha As DateTime = NowADS() Dim ErrorMovInv As Boolean = False - Dim ErrorAC As Boolean = False Dim TextoError As String = "" Dim TipoMovimientoSalida As Integer = 8 Dim CveConceptoEntrada As Integer = 9 @@ -852,132 +851,72 @@ Partial Class OP_OP ObjInventario.IniciaTransacSQL() Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) + Dim ObjOP As New ClsOP(ObjInventario.IniciaTransacSQL()) Try - CveMovimientoSalida = ObjInventario.AddMovimiento( - CveAlmacen:=DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), - CveConcepto:=TipoMovimientoSalida, - CveMoneda:=1, - FechaMovto:=Fecha, - tFolio:=-1, - CveUsuario:=UsuarioActual.CveUsuario, - CveEmpresa:=UsuarioActual.CveEmpresa, - CveCompra:=-1, - CveVenta:=-1, - CveSubProyecto:=-1, - CveActivoFijo:=-1, - Observaciones:="Finalización OP #" & LblFolio.Text, - CveAlmacenDestino:=DdlAlmacenTerminado.SelectedValue.ToEntero(), - Modulo:="OP/FinalizarOPSalida" - ) + CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPSalida") + If CveMovimientoSalida > 0 Then + For Each rowMP As DataRow In DtMP.Select("Tipo = 'MP'") - For Each rowMP As DataRow In DtMP.Select("Tipo = 'MP'") - If Not ObjInventario.AddMovimientoDetalle( - CveMovimientoSalida, - rowMP("Cantidad").ToString.ToDecimal(), - rowMP("CveUMMateriaPrima").ToString.ToEntero(), - rowMP("CvePSMateriaPrima").ToString.ToEntero(), - 1 - ) Then - Throw New Exception("Error al agregar detalle de MP") + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, rowMP("Cantidad").ToString.ToDecimal(), rowMP("CveUMMateriaPrima").ToString.ToEntero(), rowMP("CvePSMateriaPrima").ToString.ToEntero(), 1) Then + ErrorMovInv = True : TextoError = "x" : Exit For + End If + Next + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + TotalCostoMP = ObjInventario.DtResultados.SUMD("Total") End If - TotalCostoMP += rowMP("Cantidad").ToString.ToDecimal() - Next - - CveMovimientoEntrada = ObjInventario.AddMovimiento( - CveAlmacen:=DdlAlmacenTerminado.SelectedValue.ToEntero(), - CveConcepto:=CveConceptoEntrada, - CveMoneda:=1, - FechaMovto:=Fecha, - tFolio:=-1, - CveUsuario:=UsuarioActual.CveUsuario, - CveEmpresa:=UsuarioActual.CveEmpresa, - CveCompra:=-1, CveVenta:=-1, CveSubProyecto:=-1, CveActivoFijo:=-1, - Observaciones:="Finalización OP #" & LblFolio.Text, - Modulo:="OP/FinalizarOPEntrada", - CveMovimientoRelacionado:=CveMovimientoSalida - ) - - - Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(row) Convert.ToDecimal(row("Cantidad"))) - Dim PU_PT As Decimal = If(CantidadPT > 0, TotalCostoMP / CantidadPT, 1) - - - For Each rowPT As DataRow In DtPS.Select("Tipo = 'Producto'") - If Not ObjInventario.AddMovimientoDetalle( - CveMovimientoEntrada, - rowPT("Cantidad").ToString.ToDecimal(), - rowPT("CveUM").ToString.ToEntero(), - rowPT("Clave").ToString.ToEntero(), - PU_PT - ) Then - Throw New Exception("Error al agregar detalle de PT") + If Not ErrorMovInv Then + CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenTerminado.SelectedValue.ToEntero(), CveConceptoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPEntrada", CveMovimientoRelacionado:=CveMovimientoSalida) End If - Next + + If CveMovimientoEntrada > 0 AndAlso Not ErrorMovInv Then + Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(row) Convert.ToDecimal(row("Cantidad"))) + Dim PU_PT As Decimal = If(CantidadPT > 0, TotalCostoMP / CantidadPT, 1) + + For Each rowPT As DataRow In DtPS.Select("Tipo = 'Producto'") + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, rowPT("Cantidad").ToString.ToDecimal(), rowPT("CveUM").ToString.ToEntero(), rowPT("Clave").ToString.ToEntero(), PU_PT) Then + ErrorMovInv = True : TextoError = "x" : Exit For + End If + Next + + If Not ErrorMovInv Then + + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/OPFinalizada", 53, 0, 0, 1, Fecha, "Producción OP #" & LblFolio.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + If CvePrePoliza > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalCostoMP, TotalCostoMP, 68, "Consumo MP OP #" & LblFolio.Text, "Consumo MP OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoSalida) Then + ErrorMovInv = True + End If + + If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCostoMP, TotalCostoMP, 68, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoEntrada) Then + ErrorMovInv = True + End If + + If Not ErrorMovInv Then + + If Not ObjOP.UpdateEstatusOP(CveOP, 3, UsuarioActual.CveEmpresa) Then + ErrorMovInv = True : TextoError = "Error al actualizar estatus de la OP" + End If + End If - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas( - Modulo:="Inventario/OPFinalizada", - CvePlantillaPoliza:=53, - Cargos:=0, - Abonos:=0, - CveMoneda:=1, - Fecha:=Fecha, - Concepto:="Producción OP #" & LblFolio.Text, - CveUsuario:=UsuarioActual.CveUsuario, - CveEmpresa:=UsuarioActual.CveEmpresa - ) - - - If Not ObjConta.AddPrePolizasDetalle( - CvePrePoliza, - False, - TotalCostoMP, - TotalCostoMP, - 68, - "Consumo MP OP #" & LblFolio.Text, - "Consumo MP OP #" & LblFolio.Text, - CveMovimientoAlmacen:=CveMovimientoSalida - ) Then ErrorMovInv = True - - - If Not ObjConta.AddPrePolizasDetalle( - CvePrePoliza, - True, - TotalCostoMP, - TotalCostoMP, - 68, - "Producción PT OP #" & LblFolio.Text, - "Producción PT OP #" & LblFolio.Text, - CveMovimientoAlmacen:=CveMovimientoEntrada - ) Then ErrorMovInv = True - - - If Not ErrorMovInv Then - Dim ObjOP As New ClsOP() - If Not ObjOP.UpdateEstatusOP(CveOP, 3, UsuarioActual.CveEmpresa) Then - ErrorMovInv = True - TextoError = "Error al actualizar estatus de la OP" + 'If Not ErrorMovInv Then + ' If Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then + ' ErrorMovInv = True : TextoError = "Error en validación de póliza" + ' ElseIf ObjConta.ValorPolizaDescuadre > 0 Then + ' ErrorMovInv = True : TextoError = "Descuadre en póliza contable" + ' End If + 'End If + End If End If End If - If Not ErrorMovInv Then - If Not ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual) Then - ErrorMovInv = True - TextoError = "Error en validación de póliza" - ElseIf ObjConta.ValorPolizaDescuadre > 0 Then - ErrorMovInv = True - TextoError = "Descuadre en póliza contable" - End If - End If - - If Not ErrorMovInv Then ObjInventario.Commit() - Alert($"OP finalizada. Folio Contable: {ObjConta.ContaFolio}", TipoMensaje.MsgInformacion) + Alert($"Orden de producción finalizada. +
    {ObjInventario.Folio} ", TipoMensaje.MsgInformacion) Else ObjInventario.RollBack() Alert($"Error contable: {TextoError}", TipoMensaje.MsgError) From db978c769e57036bb6524ccf615065a92fbe70c9 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Thu, 3 Apr 2025 13:35:46 -0700 Subject: [PATCH 12/27] Rep Agro Precios Ventas --- Agropecuaria/RepPreciosVentaManifiesto.aspx | 381 +++++++++++++---- .../RepPreciosVentaManifiesto.aspx.vb | 403 ++++++++++-------- App_Code/ClsVentas.vb | 176 ++++++++ Compras/Compras.aspx.vb | 2 +- 4 files changed, 712 insertions(+), 250 deletions(-) diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx b/Agropecuaria/RepPreciosVentaManifiesto.aspx index d61fd61be..053da4e12 100644 --- a/Agropecuaria/RepPreciosVentaManifiesto.aspx +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx @@ -1,30 +1,40 @@ -<%@ Page Title="Reporte de Ordenes de Servicio Médicas" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepPreciosVentaManifiesto.aspx.vb" Inherits="Agrupecuaria_RepPreciosVentaManifiesto" %> +<%@ Page Title="Precios Ventas" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepPreciosVentaManifiesto.aspx.vb" Inherits="Agrupecuaria_RepPreciosVentaManifiesto" %> + + + +
  • + + Agregar Precio + +
  • +
    +
    - Reporte de Ordenes de Servicio Médicas + Precios Ventas - - -
  • - Excel -
  • -
    - - - -
    +
    @@ -37,17 +47,13 @@
    -
    - - - +
    - Fecha Inicio: - + Fecha Inicio:
    -
    +
    - + @@ -60,12 +66,11 @@
    - Fecha Fin: - + Fecha Fin:
    -
    +
    - + @@ -78,26 +83,28 @@
    - SubProyecto: -
    - +
    + : +
    +
    +
    - - + +
    + +
    +
    @@ -110,48 +117,272 @@ - - - <%--0--%> - - <%----%> - <%--1--%> - - <%--2--%> - - <%--3--%> - - <%--4--%> - - <%--5--%> - - <%--6--%> - - <%--7--%> - - <%--8--%> - - <%--9--%> - - <%--10--%> - - <%--11--%> - - <%--12--%> - - <%--13--%> - - <%--14--%> - - - - - +
    +
    + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +<%-- POPUP Modal GV Precios Venta Fecha --%> + + + +<%-- POPUP AGREGAR Precios Venta Fecha --%> + + + + + diff --git a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb index 53e5f678f..83e69a17a 100644 --- a/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb +++ b/Agropecuaria/RepPreciosVentaManifiesto.aspx.vb @@ -2,260 +2,315 @@ Option Strict On Imports System.Data +Imports System.DirectoryServices.ActiveDirectory Imports Extensiones Partial Class Agrupecuaria_RepPreciosVentaManifiesto Inherits ClsPaginas + Private Property CvePrecioVentaFecha As Integer + Get + If ViewState("CvePrecioVentaFecha") Is Nothing Then + ViewState("CvePrecioVentaFecha") = -1 + End If + Return ViewState("CvePrecioVentaFecha").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CvePrecioVentaFecha") = value + End Set + End Property + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario.Contiene(77, 21) Then Response.Redirect("/Inicio.aspx") + txtFechaI.Text = $"01/{Now.Month.ToString("0#")}/{Now.Year}" + txtFechaF.Text = Now.ToString("dd/MM/yyyy") + + TxtModalFechaInicio.Text = $"01/{Now.Month.ToString("0#")}/{Now.Year}" + TxtModalFechaFin.Text = Now.ToString("dd/MM/yyyy") + CargaCombos() CargaDatos() End If End Sub - #Region " CARGA COMBOS " - Private Sub CargaCombos() + CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto) + CargaManifiesto(-1) + CargaCultivo(-1) + End Sub - CargarCentrosDeCosto(DdlProyecto, DdlSubProyecto, LblProyecto, LblSubProyecto, divProyecto:=DivProyecto) + Private Sub CargaManifiesto(CveSubProyecto As Integer) - CargaCultivo() + DdlManifiesto.ClearSelection() + DdlManifiesto.SelectedValue = Nothing + DdlManifiesto.Items.Clear() - 'CargaEstatus - DdlEstatusOS.DataSource = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa) - DdlEstatusOS.DataBind() - DdlEstatusOS.Items.Insert(0, New ListItem("Todos", "-1")) - Dim DTTecnicos As DataTable = Nothing + Dim objNow As New ClsNominas - Dim ObjOS As New ClsOS - If ObjOS.GetSubProyectosEstatusInicial(-1, 3, UsuarioActual.CveEmpresa) Then - DTTecnicos = ObjOS.DtResultados - End If - ObjOS.Dispose() - - DdlTecnico.DataSource = DTTecnicos - DdlTecnico.DataBind() - DdlTecnico.Items.Insert(0, New ListItem("Todos", "-1")) - DdlTecnico.Items.Insert(1, New ListItem("Sin Asignar", "-2")) - - '376 - If UsuarioActual.TienePermisoProceso(376) Then - DdlTecnico.Enabled = False - DdlTecnico.SelectedValueExist(UsuarioActual.CveUsuario) + If objNow.EmbarqueManifiestoGet(CveSubProyecto, -1, UsuarioActual.CveEmpresa, -1) Then + DdlManifiesto.DataSource = objNow.DtResultados.FiltraParametros("", "", {"CveEmbarqueManifiesto", "NoEmbarque"}) End If + objNow.Dispose() - If IfNull(Request("CveUsuarioTecnico"), 0).ToString.ToEntero > 0 Then - DdlTecnico.SelectedValueExist(Request("CveUsuarioTecnico").ToString) - Else - ViewState("CveUsuarioTecnico") = -1 - End If + DdlManifiesto.DataBind() + DdlManifiesto.Items.Insert(0, New ListItem("Todos", "-1")) - 'CargaClientes - Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) - 'If EsWS Then - ' DdlClientes.setEsWebService(True) - 'Else - ' DdlClientes.setEsWebService(False) - ' DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) - ' DdlClientes.DataBind() - ' DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) - 'End If + End Sub + Private Sub CargaCultivo(CveSubProyecto As Integer) - 'Vendedor - DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltraParametros("VendedorTipo in (1,4)") 'vendedores y vendedores de piso - DdlVendedor.DataBind() - DdlVendedor.Items.Insert(0, New ListItem("Todos", "-1")) - DdlVendedor.Items.Insert(1, New ListItem("Sin Vendedor", "-2")) - - If UsuarioActual.CveVendedor > 0 Then - DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor) - DdlVendedor.Enabled = False - End If - - txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString - txtFechaF.Text = NowADS().AddDays(2).ToShortDateString - - - DdlMedico.DataSource = If(UsuarioActual.CveVendedor > 0, GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros($" Estatus = 'True' AND CveVendedor = {UsuarioActual.CveVendedor} "), GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")) - DdlMedico.DataBind() - - DdlProcedimiento.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") - DdlProcedimiento.DataBind() - - DdlTipoVenta.DataSource = GlobalDTTipoVenta(UsuarioActual.CveEmpresa) - DdlTipoVenta.DataBind + DdlCultivo.ClearSelection() + DdlCultivo.SelectedValue = Nothing + DdlCultivo.Items.Clear() Dim ObjVentas As New ClsVentas - If ObjVentas.GetMedicosEspecialidades(-1, UsuarioActual.CveEmpresa, -1) Then - DdlEspecialidad.DataSource = ObjVentas.DtResultados + If ObjVentas.GetCultivos(-1, UsuarioActual.CveEmpresa) Then + DdlCultivo.DataSource = ObjVentas.DtResultados Else - DdlEspecialidad.DataSource = Nothing + DdlCultivo.DataSource = Nothing End If ObjVentas.Dispose() - DdlEspecialidad.DataBind() - DdlEspecialidad.Items.Insert(0, New ListItem("Todas", "-1")) + DdlCultivo.DataBind() + DdlCultivo.Items.Insert(0, New ListItem("Todos", "-1")) - DdlClienteSucursal.DataSource = GlobalDTClientesTodosSucursales(UsuarioActual.CveEmpresa) - DdlClienteSucursal.DataBind() - DdlClienteSucursal.Items.Insert(0, New ListItem("Todos", "-1")) - - 'Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) - 'If EsWS Then - ' DdlCliente.setEsWebService(True) - - 'Else - ' DdlCliente.setEsWebService(False) - ' DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) - ' DdlCliente.DataBind() - ' DdlCliente.ddl.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) - 'End If - - End Sub - - Private Sub CargaCultivo() - DdlCultivo.Items.Clear() - If DdlSubProyecto.GetSelectedValuesM(True) <> "" Then - DdlCultivo.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveSubProyecto IN ({0})", DdlSubProyecto.GetSelectedValuesM(True))) - DdlCultivo.DataBind() - Else - DdlCultivo.DataSource = Nothing - DdlCultivo.DataBind() - End If End Sub #End Region + Protected Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaCultivo(DdlSubProyecto.SelectedValue.ToEntero) + CargaManifiesto(DdlSubProyecto.SelectedValue.ToEntero) + UPFiltros.Update() + End Sub + #Region " CARGA DATOS " Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click - CargaDatos() - End Sub Private Sub CargaDatos() - Dim ObjOS As New ClsOS - Dim FechaI As Date = If(txtFechaI.Text.Trim = "", MinFecha, txtFechaI.Text.ToDate) - Dim FechaF As Date = If(txtFechaF.Text.Trim = "", MaxFecha, txtFechaF.Text.ToDate) - Dim Cvecliente As Integer = DdlClienteSucursalCliente() - Dim CveClienteSucursal As Integer = DdlClienteSucursalSucursal() - LnkPersonalizar.Visible = False + Dim objVenas As New ClsVentas - If ObjOS.GetRepOrdenesServicioMedicasRep(FechaI, FechaF, Cvecliente, DdlVendedor.SelectedValue.ToEntero, DdlEstatusOS.SelectedValue.ToEntero, DdlTecnico.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, - CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, CveEspecialidad:=DdlEspecialidad.SelectedValue.ToEntero, - CveClienteSucursal:=CveClienteSucursal, CveUsuario:=UsuarioActual.CveUsuario, CveTipoVenta:=DdlTipoVenta.SelectedValue.ToEntero) Then - GvDatos.DataSource = ObjOS.DtResultados - If ObjOS.DtResultados IsNot Nothing AndAlso ObjOS.DtResultados.Rows.Count > 0 Then - LnkPersonalizar.Visible = True - End If + If objVenas.GetPreciosVentaManifiesto(txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, DdlManifiesto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlCultivo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + GvDatos.DataSource = objVenas.DtResultados Else GvDatos.DataSource = Nothing End If - - ObjOS.Dispose() + objVenas.Dispose() GvDatos.DataBind() - - LnkExportar.Visible = If(GvDatos.Rows.Count > 0, True, False) UpAcciones.Update() - - UPDatos.Update() End Sub - #End Region - 'Private Sub CargaClientes() - ' DdlClientes.ddl.Items.Clear() - ' DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) '.FiltraParametros($"CveClienteClasificacion = {DdlClienteClasificacion.SelectedValue.ToEntero} OR {DdlClienteClasificacion.SelectedValue.ToEntero} = -1") - ' DdlClientes.DataBind() - ' DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) - 'End Sub - - Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged - CargarSubProyecto(DdlSubProyecto, DdlProyecto.SelectedValue) - End Sub - - #Region " GV DATOS - ROW DATABOUND " Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.Cells(1).Attributes.Add("data-order", e.Row.DBCampo("FechaCita").ToDateTime.ToString("yyyyMMddHHmm")) - If e.Row.DBCampo("CveOS") = "" Then - e.Row.CssClass = "Totales" - End If - End If End Sub #End Region - Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + Protected Sub LnkAddPreciosVentaFecha_Click(sender As Object, e As EventArgs) - Dim SubProyecto As String = "" + CargaCultivoModal(-1) + CargaPreciosVentaFecha() + CargaTamaños() - If DdlSubProyecto.SelectedValue.ToEntero > 0 Then - SubProyecto = DdlSubProyecto.SelectedItem.Text - End If - - Dim SbFiltros As New StringBuilder() - SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|") - SbFiltros.AppendFormat("SubProyecto: {0}|", SubProyecto) - - - GvDatos.ExportToExcelGembox("OrdenesServicio", UsuarioActual, "Ordenes de Servicio Medicas", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString()) + RegistraScript("$('#DVModalGVPreciosVentaFecha').modal('show');") End Sub - Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) - End Sub + Private Sub CargaCultivoModal(CveSubProyecto As Integer) - Protected Sub LnkPersonalizar_Click(sender As Object, e As EventArgs) + DdlModalCultivo.ClearSelection() + DdlModalCultivo.SelectedValue = Nothing + DdlModalCultivo.Items.Clear() - ' ChkGuardarPersonalizacion.Checked = False - RegistraScript("$('#DivPersonalizar').modal('show')") + Dim ObjVentas As New ClsVentas - End Sub - - Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click - Personaliza() - End Sub - - Private Sub Personaliza() - GvDatos.Columns(13).Visible = ChkObservaciones.Checked - GvDatos.Columns(14).Visible = ChkFolioAdicional.Checked - CargaDatos() - End Sub - - Private Function DdlClienteSucursalCliente() As Integer - If DdlClienteSucursal.SelectedValue = "-1" Then - Return -1 + If ObjVentas.GetCultivos(-1, UsuarioActual.CveEmpresa) Then + DdlModalCultivo.DataSource = ObjVentas.DtResultados Else - Dim array As String() = DdlClienteSucursal.SelectedValue.Split("|"c) - Return If(array(0).ToEntero > 0, array(0).ToEntero, -1) + DdlModalCultivo.DataSource = Nothing End If - End Function - Private Function DdlClienteSucursalSucursal() As Integer - If DdlClienteSucursal.SelectedValue = "-1" Then - Return -1 + ObjVentas.Dispose() + + DdlModalCultivo.DataBind() + DdlModalCultivo.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + + Private Sub CargaCultivoVariedadModal(CveCultivo As Integer) + + DdlModalCultivoVariedad.ClearSelection() + DdlModalCultivoVariedad.SelectedValue = Nothing + DdlModalCultivoVariedad.Items.Clear() + + Dim objVentas As New ClsVentas + + If objVentas.GetCultivosVariedad(CveCultivo, -1, UsuarioActual.CveEmpresa) Then + DdlModalCultivoVariedad.DataSource = objVentas.DtResultados + End If + + objVentas.Dispose() + + DdlModalCultivoVariedad.DataBind() + DdlModalCultivoVariedad.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + + Private Sub CargaTamaños() + + DdlModalTamaño.ClearSelection() + DdlModalTamaño.SelectedValue = Nothing + DdlModalTamaño.Items.Clear() + + Dim objVentas As New ClsVentas + + If objVentas.GetEmbarqueTamaño(-1, -1, UsuarioActual.CveEmpresa) Then + DdlModalTamaño.DataSource = objVentas.DtResultados + End If + + objVentas.Dispose() + + DdlModalTamaño.DataBind() + DdlModalTamaño.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + Protected Sub DdlModalCultivo_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaCultivoVariedadModal(DdlModalCultivo.SelectedValue.ToEntero) + UpModalPreciosVentaFecha.Update() + End Sub + + + Protected Sub LnkModalBuscar_Click(sender As Object, e As EventArgs) + CargaPreciosVentaFecha() + End Sub + + Private Sub CargaPreciosVentaFecha() + + Dim objVentas As New ClsVentas + Dim FechaInicio As Date = If(TxtModalFechaInicio.Text.ToDate > MinFecha, TxtModalFechaInicio.Text.ToDate, MinFecha) + Dim FechaFin As Date = If(TxtModalFechaFin.Text.ToDate > MinFecha, TxtModalFechaFin.Text.ToDate, MaxFecha) + + If objVentas.GetPreciosVentaFecha(FechaInicio, FechaFin, -1, -1, -1, UsuarioActual.CveEmpresa) Then + GVPrecioVentaFecha.DataSource = objVentas.DtResultados Else - Dim array As String() = DdlClienteSucursal.SelectedValue.Split("|"c) - Return If(array(1).ToEntero > 0, array(1).ToEntero, -1) + GVPrecioVentaFecha.DataSource = Nothing End If - End Function + + objVentas.Dispose() + + GVPrecioVentaFecha.DataBind() + + UpModalGVPreciosVentaFecha.Update() + + End Sub + + Protected Sub LnkModalGuardarPreciosVentaFecha_Click(sender As Object, e As EventArgs) + + Dim objVentas As New ClsVentas + Dim ProcesoOC As Boolean = True + + If CvePrecioVentaFecha > 0 Then + + If Not objVentas.UpdatePreciosVentaFecha(CvePrecioVentaFecha, DdlModalCultivo.SelectedValue.ToEntero, DdlModalTamaño.SelectedValue.ToEntero, TxtModalDescripcion.Text.Trim, TxtModalFecha.Text.ToDate, DdlModalCultivoVariedad.SelectedValue.ToEntero, + TxtPrecioVentaFecha.Text.ToDecimal, UsuarioActual.CveEmpresa, UsuarioActual.CveEmpresa) Then + ProcesoOC = False + End If + + Else + If Not objVentas.AddPreciosVentaFecha(DdlModalCultivo.SelectedValue.ToEntero, TxtModalDescripcion.Text.Trim, TxtModalFecha.Text.ToDate, DdlModalCultivoVariedad.SelectedValue.ToEntero, + DdlModalTamaño.SelectedValue.ToEntero, TxtPrecioVentaFecha.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + ProcesoOC = False + End If + End If + + objVentas.Dispose() + + If ProcesoOC Then + CargaPreciosVentaFecha() + Alert("Precio Guardado correctamente.") + End If + + End Sub + + Protected Sub LnkEditarPrecioVentaFecha_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim ProcesoOK As Boolean = True + + CvePrecioVentaFecha = GvRow.DataKey("CvePrecioVentaFecha").ToEntero + + DdlModalCultivo.SelectedValueExist(GvRow.DataKey("CveCultivo")) + CargaCultivoVariedadModal(DdlModalCultivo.SelectedValue.ToEntero) + DdlModalTamaño.SelectedValueExist(GvRow.DataKey("CveTamaño")) + TxtModalDescripcion.Text = GvRow.DataKey("Descripcion") + TxtModalFecha.Text = GvRow.DataKey("Fecha").ToDate.ToString("dd/MM/yyyy") + DdlModalCultivoVariedad.SelectedValueExist(GvRow.DataKey("CveCultivoVariedad")) + + 'If ProcesoOK Then + ' CargaPreciosVentaFecha() + 'End If + + UpModalPreciosVentaFecha.Update() + RegistraScript("$('#DVModalPreciosVentaFecha').modal('show');") + + End Sub + + Protected Sub LnkEliminarPrecioVentaFecha_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim ProcesoOK As Boolean = True + Dim CvePrecioVentaFechaElimianr As Integer = GvRow.DataKey("CvePrecioVentaFecha").ToEntero + Dim objVentas As New ClsVentas + + If Not objVentas.DeletePreciosVentaFecha(CvePrecioVentaFechaElimianr, UsuarioActual.CveEmpresa) Then + ProcesoOK = False + End If + + objVentas.Dispose() + + If ProcesoOK Then + CargaPreciosVentaFecha() + UpModalPreciosVentaFecha.Update() + RegistraScript("$('#DVModalPreciosVentaFecha').modal('hide');") + Alert("Precio eliminado correctamente.") + End If + + + + End Sub + + Protected Sub LnkModalMuestraAdd_Click(sender As Object, e As EventArgs) + + CvePrecioVentaFecha = -1 + + DdlModalCultivo.SelectedValueExist(-1) + DdlModalTamaño.SelectedValueExist(-1) + TxtModalDescripcion.Text = "" + TxtModalFecha.Text = "" + DdlModalCultivoVariedad.SelectedValueExist(-1) + + UpModalPreciosVentaFecha.Update() + + RegistraScript("$('#DVModalPreciosVentaFecha').modal('show');") + + End Sub End Class diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 81ca7b875..fc516e130 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -3,6 +3,7 @@ Option Strict On Imports System.Data Imports System.Data.SqlClient +Imports System.Runtime.CompilerServices Imports Extensiones Imports Profact.TimbraCFDI40 @@ -7715,6 +7716,181 @@ Public Class ClsVentas Return Retorno End Function + + Public Function GetPreciosVentaManifiesto(FechaInicio As Date, FechaFin As Date, CveEmbarqueManifiesto As Integer, CveSubProyecto As Integer, CveCultivo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaManifiestoGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CveEmbarqueManifiesto", SqlDbType.Int).Value = CveEmbarqueManifiesto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los indicadores de venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + Public Function AddPreciosVentaFecha(CveCultivo As Integer, Descripcion As String, Fecha As Date, CveCultivoVariedad As Integer, CveTamaño As Integer, PrecioVenta As Decimal, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaFechaAdd") + With SqlAdapter.SelectCommand.Parameters + + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveCultivoVariedad", SqlDbType.Int).Value = CveCultivoVariedad + .Add("@PrecioVenta", SqlDbType.Money).Value = PrecioVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al agregar los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + Public Function UpdatePreciosVentaFecha(CvePrecioVentaFecha As Integer, CveCultivo As Integer, CveTamaño As Integer, Descripcion As String, Fecha As Date, CveCultivoVariedad As Integer, PrecioVenta As Decimal, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaFechaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrecioVentaFecha", SqlDbType.Int).Value = CvePrecioVentaFecha + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño + .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CveCultivoVariedad", SqlDbType.Int).Value = CveCultivoVariedad + .Add("@PrecioVenta", SqlDbType.Money).Value = PrecioVenta + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + Public Function GetPreciosVentaFecha(FechaInicio As Date, FechaFin As Date, CvePrecioVentaFecha As Integer, CveCultivo As Integer, CveCultivoVariedad As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaFechaGet") + With SqlAdapter.SelectCommand.Parameters + + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@CvePrecioVentaFecha", SqlDbType.Int).Value = CvePrecioVentaFecha + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@CveCultivoVariedad", SqlDbType.Int).Value = CveCultivoVariedad + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + Public Function DeletePreciosVentaFecha(CvePrecioVentaFecha As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_PreciosVentaFechaDelete") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePrecioVentaFecha", SqlDbType.Int).Value = CvePrecioVentaFecha + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + + + Public Function GetCultivos(CveCultivo As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_AgroCultivoGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@cveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@cveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los cultivos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + Public Function GetCultivosVariedad(CveCultivo As Integer, cveCultivosVariedad As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_CultivosVariedadGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCultivo", SqlDbType.Int).Value = CveCultivo + .Add("@cveCultivosVariedad", SqlDbType.Int).Value = cveCultivosVariedad + .Add("@cveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los precios del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + Public Function GetEmbarqueTamaño(CveTamaño As Integer, Estatus As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Agro_Embarque_TamañoGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño + .Add("@Estatus", SqlDbType.Int).Value = Estatus + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los tamaños del día.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + + End Function + + + + + + + + #Region "IDisposable Support" diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 986c618b0..a948d5b24 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -15627,7 +15627,7 @@ Partial Class Compras_Compras Amortizacion = TmpDT.SUMD("ImporteSinImpuestos") End If Dim SubTotalCompra As Decimal = Amortizacion - Dim DiferenciaPermitida As Decimal = 1 + Dim DiferenciaPermitida As Decimal = 5 Dim Cont As Integer = 0 'Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") For Each gvr As GridViewRow In GvOC1.Rows From 3ca364b713ed28cfe85380add5580c63134f28d3 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Thu, 3 Apr 2025 16:48:05 -0700 Subject: [PATCH 13/27] =?UTF-8?q?Formato=20factura=20=20153=20actualizaci?= =?UTF-8?q?=C3=B3n=20direcci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Empresas/153/Formatos/Factura.rdlc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Empresas/153/Formatos/Factura.rdlc b/Empresas/153/Formatos/Factura.rdlc index e44358833..6803ae6a7 100644 --- a/Empresas/153/Formatos/Factura.rdlc +++ b/Empresas/153/Formatos/Factura.rdlc @@ -1471,7 +1471,7 @@ - CAMELIA 619 LIBERTAD HERMOSILLO + SIMON BLEY 355, COL. OLIVARES @@ -140,13 +319,7 @@ - - - - - - - +
    @@ -175,6 +348,55 @@
    +
    +
    +
    +
    + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + Ventas +
    +
    + + + + +
    +
    +
    +
    + loading +
    +
    +
    + +
    +
    +
    @@ -1617,7 +1839,11 @@ <%----%> - + + + + + --%> - - - - - + --%> - + + + + + + --%> + +<%-- --%> + +<%-- + + + + --%> - - - - - + + <%: Scripts.Render("~/Metronic/assets/global/scripts/JS") %> + <%: Scripts.Render("~/bundles/highcharts") %> + +