diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index 2f7ac71dc..a52ab1a98 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -833,7 +833,7 @@ Public Class ClsAcumuladores #Region "P O L I Z A - V I R T U A L" Public Function AddPolizaVirtual(CveVenta As Integer, CveVentaDetalle As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, Descuento As Decimal, Total As Decimal, TipoServicio As Integer, TipoPoliza As Integer, CveModeloAuto As Integer, AnioVehiculo As Integer, TieneUsado As Boolean, FechaUsado As DateTime, - CvePSUsado As Integer, CveBCIUsado As Integer) As Boolean + CvePSUsado As Integer, CveBCIUsado As Integer, CveMarcaUsado As Integer) As Boolean Dim Retorno As Boolean = False SqlDataAdapter("PA_Vta_PolizaVirtualAdd") With SqlAdapter.SelectCommand.Parameters @@ -852,6 +852,7 @@ Public Class ClsAcumuladores .Add("@FechaUsado", SqlDbType.DateTime).Value = FechaUsado .Add("@CvePSUsado", SqlDbType.Int).Value = CvePSUsado .Add("@CveBCIUsado", SqlDbType.Int).Value = CveBCIUsado + .Add("@CveMarcaUsado", SqlDbType.Int).Value = CveMarcaUsado End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/ClsCRM.vb b/App_Code/ClsCRM.vb index acabd6abe..76da1aa43 100644 --- a/App_Code/ClsCRM.vb +++ b/App_Code/ClsCRM.vb @@ -806,7 +806,13 @@ Public Class ClsCRM SqlAdapter.Fill(Data) Retorno = True Catch ex As Exception - OnError("Ocurrió un error al eliminar el Acercamiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + If ex.Message.Contains("CveVenta = ") Then + Dim CveVenta As String = ex.Message + CveVenta = CveVenta.Substring(11, 8) + Alert(String.Format("Este acercamiento esta ligado a una cotización
Cotización: {0}", CveVenta), TipoMensaje.MsgAdvertencia) + Else + OnError("Ocurrió un error al eliminar el Acercamiento.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If End Try Return Retorno End Function diff --git a/App_Code/ClsContPAQi.vb b/App_Code/ClsContPAQi.vb index 10b6cbae5..58cd8559f 100644 --- a/App_Code/ClsContPAQi.vb +++ b/App_Code/ClsContPAQi.vb @@ -7282,19 +7282,21 @@ Public Class ClsContPAQi Return Retorno End Function - Public Function GetPolizas(Ejercicio As Integer, Periodo As Integer, TipoPoliza As Integer, SegmentoNegocio As Integer) As Boolean + Public Function GetPolizas(Ejercicio As Integer, Periodo As Integer, TipoPoliza As Integer, SegmentoNegocio As Integer, Optional CveEmpresa As Integer = -1) As Boolean Dim Retorno As Boolean = False StrSQL.Clear() - StrSQL.Append(" SELECT P.Id, P.Fecha, T.Nombre AS TipoPol, P.Concepto, P.Cargos, P.Abonos, P.Folio ") + StrSQL.Append(" SELECT P.Id, P.Fecha, T.Nombre AS TipoPol, P.Concepto, P.Cargos, P.Abonos, P.Folio, PP.CvePrepoliza ") StrSQL.Append(" FROM [dbo].[Polizas] P ") StrSQL.Append(" LEFT JOIN TiposPolizas T ON T.Id = P.TipoPol ") StrSQL.Append(" LEFT JOIN MovimientosPoliza M ON M.IdPoliza = P.Id ") + StrSQL.Append(" LEFT JOIN [SERVIDOR].[Ventas].dbo.Conta_PrePolizas PP on P.Id = PP.IdPoliza") StrSQL.Append(" WHERE P.Ejercicio = @Ejercicio ") StrSQL.Append(" AND P.Periodo = @Periodo ") StrSQL.Append(" AND (@TipoPoliza = -1 OR P.TipoPol = @TipoPoliza) ") StrSQL.Append(" AND (@SegmentoNegocio = -1 OR M.IdSegNeg = @SegmentoNegocio) ") - StrSQL.Append(" GROUP BY P.Id, P.Fecha, T.Nombre, P.Concepto, P.Cargos, P.Abonos, P.Folio ") + StrSQL.Append(" AND (PP.CveEmpresa = @CveEmpresa) ") + StrSQL.Append(" GROUP BY P.Id, P.Fecha, T.Nombre, P.Concepto, P.Cargos, P.Abonos, P.Folio, PP.CvePrepoliza ") StrSQL.Append(" ORDER BY P.Folio ") SqlDataAdapter(StrSQL.ToString, CommandType.Text) @@ -7305,6 +7307,8 @@ Public Class ClsContPAQi .Add("@Periodo", SqlDbType.Int).Value = Periodo .Add("@TipoPoliza", SqlDbType.Int).Value = TipoPoliza .Add("@SegmentoNegocio", SqlDbType.Int).Value = SegmentoNegocio + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index bde65432e..2959aba4a 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -5726,7 +5726,7 @@ Public Class ClsContabilidad Public Function AddCuentasAsignaciones(Optional CveConceptoContable As Integer = -1, Optional CveEmpresa As Integer = -1, Optional CveCuenta As Integer = -1, Optional IdCtaContable As Integer = -1, Optional CveProveedor As Integer = -1, Optional CveCliente As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveClasificacion As Integer = -1, - Optional CveAlmacen As Integer = -1, Optional PorcentajeIVA As Decimal = -1, Optional CveConceptoNomina As Decimal = -1) As Boolean + Optional CveAlmacen As Integer = -1, Optional PorcentajeIVA As Decimal = -1, Optional CveConceptoNomina As Decimal = -1, Optional CveBancoCuenta As Integer = -1) As Boolean Dim Retorno = False DataAdapter("PA_Conta_CuentasAsignacionesAdd") @@ -5743,6 +5743,7 @@ Public Class ClsContabilidad .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen .Add("@PorcentajeIVA", SqlDbType.Decimal).Value = PorcentajeIVA .Add("@CveConceptoNomina", SqlDbType.Decimal).Value = CveConceptoNomina + .Add("@CveBancoCuenta", SqlDbType.Int).Value = CveBancoCuenta End With Try @@ -5777,7 +5778,7 @@ Public Class ClsContabilidad Public Function UpdateCuentasAsignaciones(CveConceptoAsignacion As Integer, Optional CveConceptoContable As Integer = -1, Optional CveCuenta As Integer = -1, Optional IdCtaContable As Integer = -1, Optional CveProveedor As Integer = -1, Optional CveCliente As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveClasificacion As Integer = -1, Optional CveAlmacen As Integer = -1, - Optional PorcentajeIVA As Decimal = -1, Optional CveConceptoNomina As Decimal = -1) As Boolean + Optional PorcentajeIVA As Decimal = -1, Optional CveConceptoNomina As Decimal = -1, Optional CveBancoCuenta As Integer = -1) As Boolean Dim Retorno = False DataAdapter("PA_Conta_CuentasAsignacionesUpdate") @@ -5794,6 +5795,7 @@ Public Class ClsContabilidad .Add("@CveAlmacen", SqlDbType.Int).Value = CveAlmacen .Add("@PorcentajeIVA", SqlDbType.Decimal).Value = PorcentajeIVA .Add("@CveConceptoNomina", SqlDbType.Decimal).Value = CveConceptoNomina + .Add("@CveBancoCuenta", SqlDbType.Int).Value = CveBancoCuenta End With Try diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index 8cc4b1e42..e21615b2c 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -3232,6 +3232,32 @@ Public Class ClsInventarios Return Retorno End Function + + Public Function GetProductosDevolucion(CvePS As Integer, CveCliente As Integer, CveSubProyecto As Integer, FechaInicio As DateTime, FechaFin As DateTime, Serie As String, Lote As String, FechaCaducidad As DateTime, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_ProductosDevolucionAlmacen") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveSubProyecto", SqlDbType.Int).Value = CvePS + .Add("@FechaInicio", SqlDbType.DateTime).Value = FechaInicio + .Add("@FechaFin", SqlDbType.DateTime).Value = FechaFin + .Add("@Serie", SqlDbType.VarChar).Value = Serie + .Add("@Lote", SqlDbType.VarChar).Value = Lote + .Add("@FechaCaducidad", SqlDbType.DateTime).Value = FechaCaducidad + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener datos de devolución.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function Public Function GetSaldoVentaDetalle(CveVenta As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentaDetalleSaldo") diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index c8e653938..b52ea6e94 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4681,6 +4681,7 @@ Public Class ClsPaginas PaginaDict.Add("/Inventarios/EntregasPorRealizar.aspx".ToUpper(), 728) PaginaDict.Add("/Inventarios/CatAlmacenClasificacionSecciones.aspx".ToUpper(), 764) PaginaDict.Add("/Inventarios/ReconstruirCostos.aspx".ToUpper(), 764) + PaginaDict.Add("/Inventarios/RecepcionDevolucion.aspx".ToUpper(), 696) #End Region @@ -6150,7 +6151,8 @@ Public Class ClsPaginas params.Add(New CrystalParametro("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal)) Else params.Add(New CrystalParametro("ClienteContactoMail", Vta.Cliente.MailCotizacion)) - params.Add(New CrystalParametro("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", Vta.TelefonoGenerico, Vta.Cliente.Telefono))) + params.Add(New CrystalParametro("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.Telefono.Length > 6, Vta.TelefonoGenerico, Vta.Cliente.Telefono))) + End If If UsuarioActual.CveEmpresa.Contiene(17) Then diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index bc165de82..6242b9d0e 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -1450,6 +1450,22 @@ Public Class ClsProductosServicios Return Retorno End Function + Public Function GetMarcasUsados(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_MarcasUsadosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Catálogo de Marcas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + Public Function AddMarcas(Marca As String, Estatus As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index adda24263..f57554961 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -1507,10 +1507,17 @@ Namespace Modelos Row("CveVentaDetalle") = ObjVentas.CveVentaDetalle If DtInventario IsNot Nothing Then - If DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then - Dim rowInv As DataRow = DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) - rowInv("CveVentaDetalle") = ObjVentas.CveVentaDetalle - End If + 'If DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}").Length > 0 Then + ' Dim rowInv As DataRow = DtInventario.Select($"CvePS={Row("CvePS").ToString.ToEntero}")(0) + ' rowInv("CveVentaDetalle") = ObjVentas.CveVentaDetalle + 'End If + + Try + Dim InvDr As DataRow = DtInventario.Select($"Consec = {Row("Consec").ToString()}")(0) + InvDr("CveVentaDetalle") = ObjVentas.CveVentaDetalle + Catch ex As Exception + End Try + End If If DtRecepcionUsados IsNot Nothing Then @@ -1738,7 +1745,7 @@ Namespace Modelos GuardarVentaPrePolizas(factura, ObjConta, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, ObjInventario:=ObjInventario) If ErrorList.Count = 0 Then 'inventarios - GuardarVentaInventarios(factura, ObjInventario, ObjConta, ObjVentas, ObjAcum) + GuardarVentaInventarios(Resp, factura, ObjInventario, ObjConta, ObjVentas, ObjAcum) 'GuardaRecepcionUsados(factura, ObjInventario, ObjConta) @@ -2142,7 +2149,7 @@ Namespace Modelos For Each drow As DataRow In ObjFactura.DtPolizasVirtuales.Rows If ObjAcum.AddPolizaVirtual(ObjFactura.CveVenta, drow("CveVentaDetalle").ToString().ToEntero(), drow("CvePS").ToString.ToEntero, drow("Cantidad").ToString.ToDecimal, drow("PU").ToString.ToDecimal, drow("Descuento").ToString.ToDecimal, drow("Total").ToString.ToDecimal, drow("TipoServicio").ToString.ToEntero, drow("TipoPoliza").ToString.ToEntero, drow("CveModeloAuto").ToString.ToEntero, drow("AnioVehiculo").ToString.ToEntero, CBool(drow("TieneUsado").ToString), - drow("FechaUsado").ToString().ToDateTime, drow("CvePSUsado").ToString.ToEntero, drow("CveBCIUsado").ToString.ToEntero) Then + drow("FechaUsado").ToString().ToDateTime, drow("CvePSUsado").ToString.ToEntero, drow("CveBCIUsado").ToString.ToEntero, drow("CveMarcaUsado").ToString.ToEntero) Then Else Resultado = False Exit For @@ -3709,7 +3716,7 @@ Namespace Modelos Return OcurrioError End Function - Private Function GuardarVentaInventarios(ByRef factura As Modelos.Factura, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad, ObjVentas As ClsVentas, ObjAcum As ClsAcumuladores) As Boolean + Private Function GuardarVentaInventarios(ByRef Resp As MMensajeFactura, ByRef factura As Modelos.Factura, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad, ObjVentas As ClsVentas, ObjAcum As ClsAcumuladores) As Boolean Dim OcurrioError As Boolean = False If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then @@ -3751,6 +3758,24 @@ Namespace Modelos End If + 'SI ES UNA RNC DE CARGO GENERA EL MOVIMIENTO DE ALMACEN AQUI + If factura.TipoDocto = "RNC" AndAlso factura.Num3 = 10 Then + Dim CveMovimiento = GenerarMovimientoAlmacenDevolucionRNC(ObjInventario, factura, DtInventario, factura.CveAlmacen, factura.CveConceptoMovimiento, factura.CveMoneda, factura.CveVenta, "Modelos/RNC1") + If CveMovimiento <= 0 Then + OcurrioError = True + Else + If Resp IsNot Nothing Then + Resp.CveMovimientoUsado = CveMovimiento + + If CveMovimiento > 0 Then + If ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) Then + Resp.FolioUsado = ObjInventario.DtResultados.FiltroPrimeroValor("Folio") + End If + End If + End If + End If + End If + Return OcurrioError End Function Private Function CuadrarFacturaMovimientos(MovDetalle As DataTable) As DataTable @@ -4158,6 +4183,148 @@ Namespace Modelos Return CveMovimientoInventario End Function + Private Function GenerarMovimientoAlmacenDevolucionRNC(ByRef ObjInventario As ClsInventarios, ByRef factura As Modelos.Factura, DtInventario As DataTable, CveAlmacen As Integer, CveConcepto As Integer, CveMoneda As Integer, CveVenta As Integer, Modulo As String, Optional MovimientoPrePoliza As Boolean = False, Optional ByRef ObjConta As ClsContabilidad = Nothing, Optional CveMovimientoRelacionado As Integer = -1) As Integer + Dim OcurrioError As Boolean = False + + Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, CveConcepto, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1, Modulo:=Modulo, CveMovimientoRelacionado:=CveMovimientoRelacionado) + + If CveMovimientoInventario <= 0 Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + Else + If CveMovimientoRelacionado > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoRelacionado, UsuarioActual.CveEmpresa) Then + + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Dr("Cantidad").ToString().ToDouble, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("FechaCaducidad").ToString().ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString(), "-1"), CveSeccionAlmacen:=-3) Then + OcurrioError = True + ErrorList.Add("Ocurrió un Error al guardar los movimientos de entrada") + Exit For + End If + Next + + End If + Else + Dim Mensaje As String = "" + Dim i As Integer = 0 + + Dim Cantidad As Decimal = 0 + Dim PU As Decimal = 0 + Dim CveUM As Integer = 0 + Dim CvePS As Integer = 0 + + Dim AplicaSerie As Boolean + Dim AplicaLote As Boolean + Dim AplicaCaducidad As Boolean + + Dim Serie As String = "" + Dim Lote As String = "" + Dim FechaCaducidad As DateTime = MinFecha + + For Each Dr As DataRow In DtInventario.Rows + + CvePS = Dr("CvePS").ToString.ToEntero + CveUM = Dr("CveUM").ToString.ToEntero + Cantidad = Dr("Cantidad").ToString.ToDecimal + PU = Dr("PU").ToString.ToDecimal + + AplicaSerie = CBool(Dr("AplicaSerie")) + Serie = If(AplicaSerie, Dr("Serie").ToString, "") + + AplicaLote = CBool(Dr("AplicaLote")) + Lote = If(AplicaLote, Dr("Lote").ToString, "") + + AplicaCaducidad = CBool(Dr("AplicaCaducidad")) + FechaCaducidad = If(AplicaCaducidad, Dr("FechaCaducidad").ToString.ToDateTime, MinFecha) + + If Dr("CveTipoInvPS").ToString.ToEntero = 5 AndAlso AplicaSerie AndAlso Serie = "" Then + OcurrioError = True + ErrorList.Add("Se deben especificar las Series de los productos de almacén") + Exit For + End If + + If CvePS > 0 Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUM, CvePS, PU, CveSeccionAlmacen:=-3, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
") + Exit For + End If + Else + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
") + Exit For + End If + + + i = i + 1 + Next + End If + + 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN + If MovimientoPrePoliza AndAlso Not OcurrioError Then + Dim DtCostos As DataTable = Nothing + Dim ValorInventario As Decimal = 0 + Dim TotalCosto As Decimal = 0 + + Dim TipoMovto68 As Boolean = True + Dim TipoMovto69 As Boolean = False + + If CveConcepto.Contiene(18, 41) Then + TipoMovto68 = False + TipoMovto69 = True + End If + + If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) Then + DtCostos = ObjInventario.DtResultados + TotalCosto = DtCostos.SUMD("Total").RoundSQL + Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + If tmpCostos.Rows.Count > 0 Then + Dim TotalCostoAcumulado As Decimal = 0 + Dim cont As Integer = 1 + 'Se agrega movimiento separado por la cuenta de ventas (ER) + For Each RowInv As DataRow In tmpCostos.Rows + ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL + TotalCostoAcumulado += ValorInventario + + 'cuando es el último movimiento y hay diferencias en los importes + If cont = tmpCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString(), Row2("SubProyecto").ToString()) + IdCtaContable = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() + 'CveCuenta = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() + 'If ValorInventario <> 0 Then + + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, TipoMovto69, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero(), CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then + OcurrioError = True + End If + 'End If + cont += 1 + Next + End If + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero() + + 'If TotalCosto <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, TipoMovto68, TotalCosto, factura.SerieFolio, 68, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=factura.CveSubProyecto) Then + OcurrioError = True + End If + 'End If + + Else + OcurrioError = True + End If + factura.Inv_CveMovimiento = CveMovimientoInventario + factura.Inv_ValorInventario = ValorInventario + End If + + End If + + Return CveMovimientoInventario + End Function + Private Sub GuardarVentaEstimaciones(ByRef factura As Modelos.Factura, ObjContr As ClsContratos) 'debe de ser por contrato el movimiento If factura.CveContratoSecciones.Length > 0 Then diff --git a/Bancos/DepositosCaja.aspx b/Bancos/DepositosCaja.aspx index 20e230d4d..adbf00f56 100644 --- a/Bancos/DepositosCaja.aspx +++ b/Bancos/DepositosCaja.aspx @@ -256,30 +256,89 @@ function FnSuma(chk, cantidad) { var saldoInicial = ToDouble($('#C_lblValorTotal').text()); + var ValorTotalSeleccionado2 = 0; + + $('#C_GvFacturas input[type=checkbox]').each( + function () { + if (this.checked) { + ValorTotalSeleccionado2 = ValorTotalSeleccionado2 + ToDouble(FormatoNumero($(this).val(), 2)); + } + } + ); + + ValorTotalSeleccionado = ValorTotalSeleccionado2; + if (chk.checked == false) { cantidad = cantidad * -1; } saldoInicial = saldoInicial + cantidad; $('#C_lblValorTotal').text(FormatoNumero(saldoInicial, 2)); - $('#C_lblValorTotalSeleccionado').text(FormatoNumero(saldoInicial, 2)); - ValorTotalSeleccionado = saldoInicial - + $('#C_lblValorTotalSeleccionado').text(FormatoNumero(ValorTotalSeleccionado, 2)); + debugger; + + + if ($('#C_ChkFaltante').attr('checked')) { + var txtcomision = ToDouble($('#C_TxtComision').val()); + if (txtcomision != 0) { + var comisionNegativa = 0; + if (txtcomision < 0) { + comisionNegativa = txtcomision * -1; + } + if (comisionNegativa > saldo) { + $('#C_TxtComision').val(0); + comision = 0; + descuento = 0; + txtcomision = 0; + alert("No es posible poner un importe Faltante/Sobrante superior a lo seleccionado"); + saldo = 0; + $('#C_lblValorTotal').text(FormatoNumero(ValorTotalSeleccionado, 2)); + debugger; + } else { + + //debugger; + } + } + } + if ($('#C_ChkDescuento').attr('checked')) { + var txtdescuento = ToDouble($('#C_TxtDescuento').val()); + if (txtdescuento != 0) { + var DescuentoNegativa = 0; + if (txtdescuento < 0) { + DescuentoNegativa = txtdescuento * -1; + } + if (DescuentoNegativa > saldo) { + $('#C_TxtDescuento').val(0); + comision = 0; + descuento = 0; + txtdescuento = 0; + alert("No es posible poner un descuento superior a lo seleccionado"); + saldo = 0; + $('#C_lblValorTotal').text(FormatoNumero(ValorTotalSeleccionado, 2)); + debugger; + } else { + //saldo = ValorTotalSeleccionado + txtdescuento + comision; + //$('#C_lblValorTotal').text(FormatoNumero(saldo, 2)); + //descuento = ToDouble($('#C_TxtDescuento').val()) + //debugger; + } + } + } + } function txtSuma(txt) { var comision2 = ToDouble($('#C_TxtComision').val()); var comisionNegativa = 0; if (comision2 < 0) { - comisionNegativa = comision2 * -1 + comisionNegativa = comision2 * -1; } if (comisionNegativa > ValorTotalSeleccionado) { - $('#C_TxtComision').val(comision) + $('#C_TxtComision').val(0) alert("No es posible poner una comision superior a lo seleccionado") } else { saldo = ValorTotalSeleccionado + comision2 + descuento; $('#C_lblValorTotal').text(FormatoNumero(saldo, 2)); comision = ToDouble($('#C_TxtComision').val()) - debugger; } } @@ -288,7 +347,7 @@ var comision2 = ToDouble($('#C_TxtDescuento').val()); var comisionNegativa = 0; if (comision2 < 0) { - comisionNegativa = comision2 * -1 + comisionNegativa = comision2 * -1; } if (comisionNegativa > ValorTotalSeleccionado) { $('#C_TxtDescuento').val(descuento) @@ -297,7 +356,6 @@ saldo = ValorTotalSeleccionado + comision2 + comision; $('#C_lblValorTotal').text(FormatoNumero(saldo, 2)); descuento = ToDouble($('#C_TxtDescuento').val()) - debugger; } } @@ -311,7 +369,7 @@ $('#divClasificacion').css("display", "block"); } else { $('#DivComision').css("display", "none"); - $('#divSubProyecto').css("display", "none"); + $('#LblSubproyecto').css("display", "none"); $('#divSubProyecto').css("display", "none"); $('#LblClasificacion').css("display", "none"); $('#divClasificacion').css("display", "none"); diff --git a/Bancos/DepositosCaja.aspx.vb b/Bancos/DepositosCaja.aspx.vb index 9274e79ab..ef5e7ca4e 100644 --- a/Bancos/DepositosCaja.aspx.vb +++ b/Bancos/DepositosCaja.aspx.vb @@ -148,11 +148,11 @@ Partial Class Bancos_DepositosCaja NuevaCvePrePoliza = ObjContabilidad.AddPrePolizas("Vta", 13, TotalImportePrePoliza, TotalImportePrePoliza, CveMoneda, Fecha, "Depósito Bancario", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) 'Entrada a bancos - FolioIE = ObjBancos.GetNextFolio(DdlCuentaDeposito.SelectedValue.ToEntero, 8) + FolioIE = ObjBancos.GetNextFolio(DdlCuentaDeposito.SelectedValue.ToEntero, 13) If Not FolioIE > 0 Then OcurrioError = True End If - CveIEOrigen = ObjBancos.AddBancos_IE(DdlCuentaDeposito.SelectedValue.ToEntero, 8, Fecha, FolioIE.ToString, "Depósito Bancario", TotalImporte, CveMoneda, 1, "Depósito Bancario", "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + CveIEOrigen = ObjBancos.AddBancos_IE(DdlCuentaDeposito.SelectedValue.ToEntero, 13, Fecha, FolioIE.ToString, "Depósito Bancario", TotalImporte, CveMoneda, 1, "Depósito Bancario", "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) documentos += String.Format("Depósito: {1}    
", CveIEOrigen, FolioIE) @@ -253,6 +253,8 @@ Partial Class Bancos_DepositosCaja Protected Sub GvFacturas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvFacturas.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then e.Row.FCCheckBox("ChkFactura").Attributes.Add("onclick", String.Format("FnSuma(this,{0});", e.Row.DBCampo("Importe"))) + e.Row.FCCheckBox("ChkFactura").InputAttributes.Add("Value", e.Row.DBCampo("Importe")) + End If End Sub diff --git a/Bancos/IE.aspx b/Bancos/IE.aspx index b60f17172..2db50bfd5 100644 --- a/Bancos/IE.aspx +++ b/Bancos/IE.aspx @@ -30,6 +30,9 @@
  • Actualizar Tipo Cambio
  • +
  • + PrePoliza +
  • <%--
  • Emitir Complemento de Pago diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index d2f2a0233..5dab27d13 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -863,6 +863,8 @@ Partial Class Bancos_IE LblCuenta.Text = ObjIE.BancoNumCuentaMoneda ViewState("CvePrePoliza") = ObjIE.DtResultados.Rows(0)("CvePrePoliza").ToString.ToEntero + HpLPrePoliza.NavigateUrl = String.Format("/Contabilidad/RegPrePoliza.aspx?CvePrepoliza={0}", ViewState("CvePrePoliza")) + HpLPrePoliza.Visible = True TxtFechaDocumento.Text = ObjIE.FechaDocumento.ToShortDateString TxtFolio.Text = ObjIE.Folio LblBeneficiario.Text = ObjIE.PagueseA diff --git a/Bancos/PopUpBuscarIE.aspx b/Bancos/PopUpBuscarIE.aspx index 228691300..def89512c 100644 --- a/Bancos/PopUpBuscarIE.aspx +++ b/Bancos/PopUpBuscarIE.aspx @@ -51,7 +51,7 @@ - + diff --git a/Bancos/RepCobradoPagadoDetalle.aspx.vb b/Bancos/RepCobradoPagadoDetalle.aspx.vb index 46ed75b7c..9fd9a2b39 100644 --- a/Bancos/RepCobradoPagadoDetalle.aspx.vb +++ b/Bancos/RepCobradoPagadoDetalle.aspx.vb @@ -48,8 +48,9 @@ Partial Class Bancos_RepCobradoPagadoDetalle ' GvDatos.Columns(5).HeaderText = "Cobrado" ' End If 'End If - - CargaDatos() + If Modalidad <> 0 Then + CargaDatos() + End If End Sub #End Region diff --git a/CRM/CatEmpresasCRM.aspx.cs b/CRM/CatEmpresasCRM.aspx.cs index 3f91131e8..729929056 100644 --- a/CRM/CatEmpresasCRM.aspx.cs +++ b/CRM/CatEmpresasCRM.aspx.cs @@ -176,59 +176,62 @@ public partial class CRM_CatEmpresasCRM : ClsPaginas string Correo = row["Correo"].ToString(); int CveMedioCaptacion = -1; - if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa)) - { - DataRow MediosCaptacion = ObjCRM.DtResultados.FiltroPrimero(String.Format("MedioCaptacion = '{0}'",MedioCaptacion)); - if(MediosCaptacion != null) + if (MedioCaptacion != "" || Agente != "") { + + if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa)) { - CveMedioCaptacion = MediosCaptacion["CveMedioCaptacion"].ToString().ToEntero(); + DataRow MediosCaptacion = ObjCRM.DtResultados.FiltroPrimero(String.Format("MedioCaptacion = '{0}'",MedioCaptacion)); + if(MediosCaptacion != null) + { + CveMedioCaptacion = MediosCaptacion["CveMedioCaptacion"].ToString().ToEntero(); + }else + { + Alert(String.Format("El medio de captación '{0}' no fue encontrado", MedioCaptacion), ModExtensiones.TipoMensaje.MsgAdvertencia); + TieneError = true; + break; + } + } + + int CveVendedor = -1; + DataRow Vendedor = get_GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("Vendedor = '{0}'",Agente)); + if (Vendedor != null) + { + CveVendedor = Vendedor["CveVendedor"].ToString().ToEntero(); }else { - Alert(String.Format("El medio de captación '{0}' no fue encontrado", MedioCaptacion), ModExtensiones.TipoMensaje.MsgAdvertencia); + Alert(String.Format("El vendedor '{0}' no fue encontrado", Agente), ModExtensiones.TipoMensaje.MsgAdvertencia); TieneError = true; break; } - } - int CveVendedor = -1; - DataRow Vendedor = get_GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("Vendedor = '{0}'",Agente)); - if (Vendedor != null) - { - CveVendedor = Vendedor["CveVendedor"].ToString().ToEntero(); - }else - { - Alert(String.Format("El vendedor '{0}' no fue encontrado", MedioCaptacion), ModExtensiones.TipoMensaje.MsgAdvertencia); - TieneError = true; - break; - } + int CveSubProyecto = -1; + DataRow SubProyecto = get_GlobalDTSubProyectos(-1,CveEmpresa:UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("SubProyecto = '{0}'",Sucursal)); + if(SubProyecto != null) + { + CveSubProyecto = SubProyecto["CveSubProyecto"].ToString().ToEntero(); + }else + { + Alert(String.Format("El SubProyecto '{0}'", Sucursal), ModExtensiones.TipoMensaje.MsgAdvertencia); + TieneError = true; + break; + } - int CveSubProyecto = -1; - DataRow SubProyecto = get_GlobalDTSubProyectos(-1,CveEmpresa:UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("SubProyecto = '{0}'",Sucursal)); - if(SubProyecto != null) - { - CveSubProyecto = SubProyecto["CveSubProyecto"].ToString().ToEntero(); - }else - { - Alert(String.Format("El SubProyecto '{0}'", Sucursal), ModExtensiones.TipoMensaje.MsgAdvertencia); - TieneError = true; - break; - } + int CveGiro = -1; + DataRow GiroDt = get_GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("ClienteClasificacion = '{0}'", Giro)); + if (GiroDt != null) + { + CveGiro = GiroDt["CveClienteClasificacion"].ToString().ToEntero(); + } + else + { + Alert(String.Format("El Giro de Empresa '{0}', No está especificado", Giro), ModExtensiones.TipoMensaje.MsgAdvertencia); + TieneError = true; + break; + } - int CveGiro = -1; - DataRow GiroDt = get_GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("ClienteClasificacion = '{0}'", Giro)); - if (GiroDt != null) - { - CveGiro = GiroDt["CveClienteClasificacion"].ToString().ToEntero(); - } - else - { - Alert(String.Format("El Giro de Empresa '{0}', No está especificado", Giro), ModExtensiones.TipoMensaje.MsgAdvertencia); - TieneError = true; - break; - } - - TieneError = (!(ObjCRM.AddEmpresaCRM(NombreEmpresa, RFC, CveMedioCaptacion, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, -1, CveVendedor, CveSubProyecto, Mail, CveGiro) > 0)); + TieneError = (!(ObjCRM.AddEmpresaCRM(NombreEmpresa, RFC, CveMedioCaptacion, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, -1, CveVendedor, CveSubProyecto, Mail, CveGiro) > 0)); + } } if (TieneError) diff --git a/CRM/EmpresaCRM.aspx b/CRM/EmpresaCRM.aspx index 3e8c7d744..46b0baf93 100644 --- a/CRM/EmpresaCRM.aspx +++ b/CRM/EmpresaCRM.aspx @@ -88,8 +88,8 @@
    - - + +
    diff --git a/CRM/EmpresaCRM.aspx.cs b/CRM/EmpresaCRM.aspx.cs index 7fdf33a49..b0dc49fe5 100644 --- a/CRM/EmpresaCRM.aspx.cs +++ b/CRM/EmpresaCRM.aspx.cs @@ -571,10 +571,10 @@ public partial class CRM_EmpresaCRM : ClsPaginas ClsCRM ObjCRM = new ClsCRM(); if (ObjCRM.GetTipoProceso(UsuarioActual.CveEmpresa)) { - DdlTipoPrceso2.DataSource = ObjCRM.DtResultados; - DdlTipoPrceso2.Items.Insert(0, new ListItem("Seleccione","-1")); + DdlTipoProceso2.DataSource = ObjCRM.DtResultados; + DdlTipoProceso2.Items.Insert(0, new ListItem("Seleccione","-1")); } - DdlTipoPrceso2.DataBind(); + DdlTipoProceso2.DataBind(); ObjCRM.Dispose(); } @@ -583,7 +583,7 @@ public partial class CRM_EmpresaCRM : ClsPaginas ClsCRM ObjCRM = new ClsCRM(); if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa, -1)) { - DdlMedioCaptacion.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}", DdlTipoPrceso2.SelectedValue)); + DdlMedioCaptacion.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}", DdlTipoProceso2.SelectedValue)); DdlMedioCaptacion.Items.Insert(0, new ListItem("Seleccione ", "-1")); DdlMedioCaptacionAcercamiento.Items.Clear(); DdlMedioCaptacionAcercamiento.DataSource = ObjCRM.DtResultados; @@ -638,7 +638,7 @@ public partial class CRM_EmpresaCRM : ClsPaginas TxtNombreEmpresa.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Empresa"); TxtRFC.Text = ObjCRM.DtResultados.FiltroPrimeroValor("RFC"); - DdlTipoPrceso2.SelectedValue = ObjCRM.DtResultados.FiltroPrimeroValor("CveTipoProceso"); + DdlTipoProceso2.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveTipoProceso")); CargaMetodosCaptacion(); TxtCorreoEmpresaCRM.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Correo"); DdlMedioCaptacion.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveMedioCaptacion")); diff --git a/Compras/Proveedores.aspx.vb b/Compras/Proveedores.aspx.vb index 25346b21c..09f67a4e8 100644 --- a/Compras/Proveedores.aspx.vb +++ b/Compras/Proveedores.aspx.vb @@ -1457,7 +1457,8 @@ Partial Class Compras_Proveedores #Region "LL E N A R - C O M B O S" Private Sub CargaResponsable() - DdlCveUsuarioResponsable.DataSource = GlobalDTUsuarioResponsable.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + 'DdlCveUsuarioResponsable.DataSource = GlobalDTUsuarioResponsable.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa, DistinctColumns:={"CveUsuario", "Nombre"}) + DdlCveUsuarioResponsable.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltraParametros("", DistinctColumns:={"CveUsuario", "Nombre"}) DdlCveUsuarioResponsable.DataBind() End Sub Private Sub CargaClasificacionProveedor() diff --git a/Contabilidad/FiltraPolizas.aspx b/Contabilidad/FiltraPolizas.aspx index f14fbb7d1..32e4f7f93 100644 --- a/Contabilidad/FiltraPolizas.aspx +++ b/Contabilidad/FiltraPolizas.aspx @@ -33,12 +33,12 @@
    - +
    - + @@ -56,7 +56,7 @@
    - + @@ -171,6 +171,14 @@ + + + + + + + + diff --git a/Contabilidad/FiltraPolizas.aspx.vb b/Contabilidad/FiltraPolizas.aspx.vb index 3465ec8a5..a2095a75f 100644 --- a/Contabilidad/FiltraPolizas.aspx.vb +++ b/Contabilidad/FiltraPolizas.aspx.vb @@ -49,7 +49,7 @@ Partial Class Contabilidad_FiltraPolizas Dim Periodo As Integer = DdlPeriodo.SelectedValue.ToString().ToEntero() Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) - If ObjConta.GetPolizas(Ejercicio, Periodo, DdlTipoPoliza.SelectedValue.ToEntero(), DdlSegmentoNeg.SelectedValue.ToEntero()) Then + If ObjConta.GetPolizas(Ejercicio, Periodo, DdlTipoPoliza.SelectedValue.ToEntero(), DdlSegmentoNeg.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa) Then DtDatos = ObjConta.DtResultados Gv.DataSource = ObjConta.DtResultados 'If DdlTipoPoliza.SelectedValue.ToEntero > 0 Then diff --git a/Contabilidad/RegPrePoliza.aspx b/Contabilidad/RegPrePoliza.aspx index 0ef7196ce..ddfbb440e 100644 --- a/Contabilidad/RegPrePoliza.aspx +++ b/Contabilidad/RegPrePoliza.aspx @@ -70,13 +70,24 @@
  • - Cargar Excel + Cargar Excel
  • Crear Complemento de Pago
  • +
  • + Paquete Egresos +
  • +
  • + Cargar Comprobante +
  • + + + + + @@ -783,7 +794,50 @@ + diff --git a/Contabilidad/RegPrePoliza.aspx.vb b/Contabilidad/RegPrePoliza.aspx.vb index c5225c895..8c836c659 100644 --- a/Contabilidad/RegPrePoliza.aspx.vb +++ b/Contabilidad/RegPrePoliza.aspx.vb @@ -5,6 +5,9 @@ Imports Extensiones Imports System.Linq Imports System.Web.Services Imports GemBox.Spreadsheet +Imports System.IO +Imports iTextSharp.text.pdf +Imports Microsoft.Reporting.WebForms Partial Class ContabilidadC_RegPrePoliza Inherits ClsPaginas @@ -167,12 +170,39 @@ Partial Class ContabilidadC_RegPrePoliza ViewState("IdPoliza") = value End Set End Property + + Public Property Tick As String + Get + Return CType(ViewState("Tick"), String) + End Get + Set(value As String) + ViewState("Tick") = value + End Set + End Property + + Public Property CveIE As Integer + Get + Return CType(ViewState("CveIE"), Integer) + End Get + Set(value As Integer) + ViewState("CveIE") = value + End Set + End Property + + Public Property TipoPoliza As String + Get + Return CType(ViewState("TipoPoliza"), String) + End Get + Set(value As String) + ViewState("TipoPoliza") = value + End Set + End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then - + Tick = DateTime.Now.Ticks.ToString If UsuarioActual.Empresa.TipoContabilizacion = 1 OrElse UsuarioActual.Empresa.TipoContabilidad = 1 Then Response.Redirect(Request.Url.PathAndQuery.Replace("RegPrePoliza", "RegPrePolizaS")) @@ -265,8 +295,8 @@ Partial Class ContabilidadC_RegPrePoliza ViewState("CveSubProyecto") = Request("CveSubProyecto").ToEntero ViewState("CveTurno") = Request("CveTurno").ToEntero - DdlPlantilla.Items.Add(New ListItem("Pago Nomina", "61")) - DdlPlantilla.SelectedValue = "61" + 'DdlPlantilla.Items.Add(New ListItem("Pago Nomina", "61")) + 'DdlPlantilla.SelectedValue = "61" DdlPlantilla.Enabled = False DivAgregarConceptos.Visible = False @@ -418,6 +448,9 @@ Partial Class ContabilidadC_RegPrePoliza TxtFechaDocumento.Text = dr("Fecha") TxtConcepto.Text = dr("Concepto") DivDatosPoliza.Visible = True + TipoPoliza = DdlTipoPoliza.SelectedItem.Text + Folio = dr("FolioPoliza").ToString + If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then DivAgregarConceptos.Visible = True @@ -485,19 +518,19 @@ Partial Class ContabilidadC_RegPrePoliza 'Asignamos los Subproyectos e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) e.Row.FCDropDownList("DdlSubProyecto").DataBind() - e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem(" - ", "-1")) + 'e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem(" - ", "-1")) e.Row.FCDropDownList("DdlSubProyecto").SelectedValueExist(e.Row.DataKey("CveSubProyecto")) 'Asignamos los Tipos de Gasto e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) e.Row.FCDropDownList("DdlTipoGasto").DataBind() - e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1")) + 'e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1")) e.Row.FCDropDownList("DdlTipoGasto").SelectedValueExist(e.Row.DataKey("CveTipoGasto")) 'ASignamos las CuentasContables e.Row.FCDropDownList("DdlCtaContable").DataSource = Session("DtCuentas") e.Row.FCDropDownList("DdlCtaContable").DataBind() - e.Row.FCDropDownList("DdlCtaContable").Items.Insert(0, New ListItem("Sin Asignar", "0")) + 'e.Row.FCDropDownList("DdlCtaContable").Items.Insert(0, New ListItem("Sin Asignar", "0")) e.Row.FCDropDownList("DdlCtaContable").SelectedValueExist(e.Row.DataKey("IdCtaContable")) TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + e.Row.FCTextBox("TxtCargo").Text.ToDouble).ToString.FormatoNumero @@ -511,6 +544,11 @@ Partial Class ContabilidadC_RegPrePoliza If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen")) If CveConceptoContable.Contiene(30, 204) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")) + If CveConceptoContable.Contiene(30) Then + LnkImprimirPDF.Visible = True + LnkComprobante.Visible = True + CveIE = e.Row.DBCampo("CveIE").ToString.ToEntero + End If 'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable @@ -811,6 +849,8 @@ Partial Class ContabilidadC_RegPrePoliza dr("MultipleSubProyecto") = drt("MultipleSubProyecto") dr("PorcentajeImpuesto") = drt("PorcentajeImpuesto") dr("CveCuenta") = drt("CveCuenta") + dr("FolioPoliza") = drt("FolioPoliza") + DtMovimientos.Rows.Add(dr) @@ -891,7 +931,6 @@ Partial Class ContabilidadC_RegPrePoliza If e.Row.DataKey("CveConcepto").ToEntero.Contiene(30) Then e.Row.FCLinkButton("ImgBancos").Visible = True - If CveTipoTransaccion > 0 And CveCuenta > 0 And Folio.Length > 0 And ImporteDocumento > 0 And Beneficiario.Length > 0 Then e.Row.FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green" End If @@ -1724,6 +1763,236 @@ Partial Class ContabilidadC_RegPrePoliza Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs) GeneraTimbre(CvePrePoliza) End Sub + + Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs) + Dim filtro() As String = {"CveCompra", "CveIE", "CveConceptoContable"} + Dim filtroComplemento() As String = {"CveIE"} + Dim Pathpdf As New List(Of String) + Dim pdfs = New List(Of Byte()) + Dim Path As String + Dim dt As DataTable = DtMovimientos.FiltraParametros("", "", filtro) + Dim ObjCompra As New ClsCompras + Dim ObjIE As New ClsBancos() + Dim pathPoliza As String = "" + Dim TieneComprobante As Boolean + + Try + TieneComprobante = VerificarComprobante() + If TieneComprobante Then + + Path = ImprimirPolizaPDF(IdPoliza) + pathPoliza = Path + If File.Exists(Path) Then + Pathpdf.Add(Path) + End If + + For Each Row As DataRow In dt.Rows + If Row("CveConceptoContable").ToString.ToEntero = 30 Then + If Row("CveIE").ToString.ToEntero > 0 Then + If ObjIE.GetBancosIE(Row("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjIE.DtResultados.Rows.Count > 0 Then + Path = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString) + If File.Exists(Path) Then + Dim formato As String = System.IO.Path.GetExtension(Path) + If formato.ToLower.Contiene(".jpg", ".png", ".jpeg") Then + Dim ComprobantePDF As String = String.Format("{0}\{1}\comprobante.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick) + Using crea_archivo = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 18, 18, 18, 18) + PdfWriter.GetInstance(crea_archivo, New FileStream(ComprobantePDF, FileMode.Create)) + crea_archivo.Open() + Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Path) + If image.Height > image.Width Then + Dim percentage As Double = 0.0F + percentage = 700 / image.Height + image.ScalePercent(percentage * 100) + Else + Dim percentage As Double = 0.0F + percentage = 540 / image.Width + image.ScalePercent(percentage * 100) + End If + crea_archivo.Add(image) + End Using + Pathpdf.Add(ComprobantePDF) + Else + Pathpdf.Add(Path) + End If + End If + End If + End If + End If + End If + If Row("CveConceptoContable").ToString.ToEntero.Contiene(17, 309, 312, 308) Then + If ObjCompra.GetCompras(Row("CveCompra").ToString.ToEntero, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then + If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then + Dim dr As DataRow = ObjCompra.DtResultados.Rows(0) + Dim RFC As String = dr("RFC").ToString + Dim CveFactura As String = dr("CveFactura").ToString + Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura) + If File.Exists(Path) Then + + Pathpdf.Add(Path) + End If + End If + End If + End If + Next + + + dt = DtMovimientos.FiltraParametros("", "", filtroComplemento) + For Each Row As DataRow In dt.Rows + If ObjCompra.GetCompraComplementoPago(-1, UsuarioActual.CveEmpresa, Row("CveIE").ToString.ToEntero) Then + Console.WriteLine(Row("CveIE").ToString) + If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then + Dim dr As DataRow = ObjCompra.DtResultados.Rows(0) + Dim RFC As String = dr("RFCde").ToString + Dim CveFactura As String = dr("CveFactura").ToString + Console.WriteLine(RFC & CveFactura) + If CveFactura <> "" Then + Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura) + Console.WriteLine(Path) + If File.Exists(Path) Then + Pathpdf.Add(Path) + End If + End If + End If + End If + Next + + MergePdfFiles(Pathpdf.ToArray) + If File.Exists(pathPoliza) Then + Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True) + End If + + Else + Alert("No se tiene cargado comprobante de pago", TipoMensaje.MsgAdvertencia) + End If + + + Catch ex As Exception + Alert("Error al descargar el paquete", TipoMensaje.MsgError) + End Try + End Sub + Private Function ImprimirPolizaPDF(IdPoliza As Integer) As String + Dim ObjConta As New ClsContabilidad + 'Dim ObjPoliza As New ClsContPAQi(UsuarioActual.Empresa) + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/Polizas.rdlc", UsuarioActual.Empresa.Ruta)) + Dim params As New List(Of ReportParameter) + Dim Bytes As Byte() = Nothing + + + 'If ObjPoliza.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjPoliza.DtResultados.Rows.Count > 0 Then + If ObjConta.GetPrePolizasDetalle(CvePrePoliza) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + Dim dtVC As DataTable + Dim dr As DataRow + dtVC = ObjConta.DtResultados + dr = dtVC.Rows(0) + Dim ruta As String = "" + params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("TipoPoliza", dr("TipoPoliza").ToString)) + params.Add(New ReportParameter("Finicio", dr("Fecha").ToString.ToDate.ToShortDateString)) + params.Add(New ReportParameter("FFin", dr("Fecha").ToString.ToDate.ToShortDateString)) + params.Add(New ReportParameter("Fecha", dr("Fecha").ToString.ToDate.ToShortDateString)) + 'params.Add(New ReportParameter("Nombre", dr("Cuenta").ToString)) + 'params.Add(New ReportParameter("Cuenta", dr("Codigo").ToString)) + params.Add(New ReportParameter("Numero", dr("FolioPoliza").ToString)) + params.Add(New ReportParameter("Moneda", "")) + params.Add(New ReportParameter("CodigoPostal", "")) + If UsuarioActual.CveEmpresa = 119 Then + params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre"))) + End If + If Archivo.Exists Then + ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc" + Else + ruta = "Empresas/Grales/Formatos/Polizas.rdlc" + End If + Bytes = StreamPDF(ruta, dtVC, params, "ppoliza") + If Not File.Exists(String.Format("{0}{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)) Then + DirectoryExistsCreate(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick)) + File.WriteAllBytes(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString), Bytes) + End If + End If + Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString) + ObjConta.Dispose() + + End Function + Private Sub MergePdfFiles(ByVal pdfFiles() As String) + Dim result As Boolean = False + Dim pdfCount As Integer = 0 + Dim f As Integer = 0 + Dim fileName As String + Dim reader As iTextSharp.text.pdf.PdfReader = Nothing + Dim pageCount As Integer = 0 + Dim pdfDoc As iTextSharp.text.Document = Nothing + Dim writer As PdfWriter = Nothing + Dim cb As PdfContentByte = Nothing + + Dim page As PdfImportedPage = Nothing + Dim rotation As Integer = 0 + + + Try + pdfCount = pdfFiles.Length + If pdfCount > 0 Then + fileName = pdfFiles(f) + reader = New iTextSharp.text.pdf.PdfReader(fileName) + pageCount = reader.NumberOfPages + pdfDoc = New iTextSharp.text.Document(reader.GetPageSizeWithRotation(1), 18, 18, 18, 18) + writer = PdfWriter.GetInstance(pdfDoc, New FileStream(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio), FileMode.Create)) + + With pdfDoc + .Open() + End With + cb = writer.DirectContent + While f < pdfCount + Dim i As Integer = 0 + While i < pageCount + i += 1 + pdfDoc.SetPageSize(reader.GetPageSizeWithRotation(i)) + pdfDoc.NewPage() + page = writer.GetImportedPage(reader, i) + rotation = reader.GetPageRotation(i) + If rotation = 90 Then + cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(i).Height) + ElseIf rotation = 270 Then + cb.AddTemplate(page, 0, 1.0F, -1.0F, 0, reader.GetPageSizeWithRotation(i).Width + 60, -30) + Else + cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0) + End If + End While + f += 1 + If f < pdfCount Then + fileName = pdfFiles(f) + reader = New iTextSharp.text.pdf.PdfReader(fileName) + pageCount = reader.NumberOfPages + End If + End While + + + pdfDoc.Close() + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio)) + + If Archivo.Exists Then + HttpContext.Current.Response.Clear() + HttpContext.Current.Response.ClearContent() + HttpContext.Current.Response.ContentType = "application/octet-stream" + HttpContext.Current.Response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", Archivo.Name)) + HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) + HttpContext.Current.Response.TransmitFile(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio)) + Response.Flush() ' send it to the client to download + HttpContext.Current.Response.SuppressContent = True + HttpContext.Current.ApplicationInstance.CompleteRequest() + + End If + result = True + End If + Catch ex As Exception + End Try + + + + End Sub + #End Region @@ -1945,7 +2214,7 @@ Partial Class ContabilidadC_RegPrePoliza Next If Not TieneError Then ObjConta.Commit() - Alert(String.Format("

    Prepóliza: {1}", CvePrePoliza, ObjConta.ContaFolio)) + Alert(String.Format("

    Prepóliza: {1}", CvePrePoliza, ObjConta.ContaFolio)) Alert($"Se agregó la póliza {ObjConta.ContaFolio}") @@ -2014,5 +2283,76 @@ Partial Class ContabilidadC_RegPrePoliza Return dataTable End Function + + Protected Sub BtnGuardarArchivo_Click(sender As Object, e As EventArgs) Handles BtnGuardarArchivo.Click + Dim ObjIE As New ClsBancos + Dim Comprobante As String = "" + + Dim Filesgral As List(Of Archivo) = TxtCargarArchivo.getfiles().Archivos + If Filesgral.Count > 0 Then + Dim fileItem As Archivo = Filesgral(0) + Dim Path As String = HttpContext.Current.Request.ApplicationPath + Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + + Path = Extensiones.DirectorioBaseEmpresas + Path += String.Format("Empresas/{0}/IE", UsuarioActual.CveEmpresa) + + + + If Not Directory.Exists(Path) Then + Directory.CreateDirectory(Path) + End If + Path += $"/{CveIE}.{Comprobante}" + If File.Exists(Path) Then + File.Delete(Path) + End If + My.Computer.FileSystem.MoveFile(fileItem.FileUrl, Path) + End If + TxtCargarArchivo.Text = "" + RegistraScript("$('#ModalUpload').modal('hide')", "hidemodal1") + + If ObjIE.UpdateComprobanteIE(Comprobante.Replace("."c, ""), CveIE) Then + Alert("El Comprobante se guardo exitosamente.", TipoMensaje.MsgInformacion) + End If + + ObjIE.Dispose() + + End Sub + + Private Function VerificarComprobante() As Boolean + Dim filtro() As String = {"CveCompra", "CveIE", "CveConceptoContable"} + Dim Path As String + Dim dt As DataTable = DtMovimientos.FiltraParametros("", "", filtro) + Dim ObjIE As New ClsBancos() + Dim TieneComprobante As Boolean = True + + For Each Row As DataRow In dt.Rows + + If TieneComprobante Then + If Row("CveConceptoContable").ToString.ToEntero = 30 Then + If Row("CveIE").ToString.ToEntero > 0 Then + If ObjIE.GetBancosIE(Row("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjIE.DtResultados.Rows.Count > 0 Then + Path = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString) + If File.Exists(Path) Then + TieneComprobante = True + Else + TieneComprobante = False + Exit For + End If + Else + TieneComprobante = False + Exit For + End If + End If + End If + End If + End If + Next + ObjIE.Dispose() + Return TieneComprobante + + End Function + End Class diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx index 421303bcd..1bc7203c1 100644 --- a/Contabilidad/RegPrePolizaS.aspx +++ b/Contabilidad/RegPrePolizaS.aspx @@ -75,7 +75,14 @@
  • Crear Complemento de Pago
  • +
  • + Imprimir Poliza +
  • + + + + @@ -835,7 +842,7 @@ - +
    diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index f62902ab6..50e7e9ff7 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -5,7 +5,10 @@ Imports Extensiones Imports System.Linq Imports System.Web.Services Imports GemBox.Spreadsheet - +Imports Microsoft.Reporting.WebForms +Imports System.IO +Imports iTextSharp.text.pdf + Partial Class ContabilidadC_RegPrePolizaS Inherits ClsPaginas @@ -159,6 +162,40 @@ Partial Class ContabilidadC_RegPrePolizaS ViewState("IndiceGrid") = value End Set End Property + Public Property IdPoliza As Integer + Get + Return CType(ViewState("IdPoliza"), Integer) + End Get + Set(value As Integer) + ViewState("IdPoliza") = value + End Set + End Property + Public Property Tick As String + Get + Return CType(ViewState("Tick"), String) + End Get + Set(value As String) + ViewState("Tick") = value + End Set + End Property + + Public Property CveIE As Integer + Get + Return CType(ViewState("CveIE"), Integer) + End Get + Set(value As Integer) + ViewState("CveIE") = value + End Set + End Property + + Public Property TipoPoliza As String + Get + Return CType(ViewState("TipoPoliza"), String) + End Get + Set(value As String) + ViewState("TipoPoliza") = value + End Set + End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load @@ -175,6 +212,8 @@ Partial Class ContabilidadC_RegPrePolizaS Observaciones = "-1" Beneficiario = "-1" Actualizar = False + IdPoliza = -1 + If IfNull(Request("Tipo"), "").ToString = "NOMPROV" Then DivTipoGasto.Visible = True @@ -365,7 +404,9 @@ Partial Class ContabilidadC_RegPrePolizaS DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza") TxtFechaDocumento.Text = dr("Fecha") TxtConcepto.Text = dr("Concepto") - DivDatosPoliza.Visible = True + DivDatosPoliza.Visible = True + TipoPoliza = DdlTipoPoliza.SelectedItem.Text + Folio = dr("FolioPoliza").ToString If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then 'DivAgregarConceptos.Visible = True @@ -470,7 +511,13 @@ Partial Class ContabilidadC_RegPrePolizaS If CveConceptoContable.Contiene(1, 2, 13, 38, 207, 203, 39, 61, 62, 63) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta")) If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 234, 235, 240) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra")) If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen")) - If CveConceptoContable.Contiene(30, 204) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")) + If CveConceptoContable.Contiene(30, 204) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")) + + If CveConceptoContable.Contiene(30) Then + LnkImprimirPDF.Visible = True + LnkComprobante.Visible = True + CveIE = e.Row.DBCampo("CveIE").ToString.ToEntero + End If 'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable @@ -689,6 +736,8 @@ Partial Class ContabilidadC_RegPrePolizaS dr("CvePersonal") = drt("CvePersonal") dr("CveClasificacion") = -1 dr("MultipleSubProyecto") = drt("MultipleSubProyecto") + dr("FolioPoliza") = drt("FolioPoliza") + DtMovimientos.Rows.Add(dr) Next @@ -1951,5 +2000,150 @@ Partial Class ContabilidadC_RegPrePolizaS End Sub #End Region +#Region "Paquete Egresos" + Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs) + Dim Pathpdf As New List(Of String) + Dim Path As String + Try + + Path = ImprimirPolizaPDF(IdPoliza) + If File.Exists(Path) Then + Pathpdf.Add(Path) + End If + + MergePdfFiles(Pathpdf.ToArray) + If File.Exists(Path) Then + Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True) + End If + + Catch ex As Exception + Alert("Error al descargar la poliza", TipoMensaje.MsgError) + End Try + End Sub + Private Function ImprimirPolizaPDF(IdPoliza As Integer) As String + Dim ObjConta As New ClsContabilidad + 'Dim ObjPoliza As New ClsContPAQi(UsuarioActual.Empresa) + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/Polizas.rdlc", UsuarioActual.Empresa.Ruta)) + Dim params As New List(Of ReportParameter) + Dim Bytes As Byte() = Nothing + + + 'If ObjPoliza.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjPoliza.DtResultados.Rows.Count > 0 Then + If ObjConta.GetPrePolizasDetalle(CvePrePoliza) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then + Dim dtVC As DataTable + Dim dr As DataRow + dtVC = ObjConta.DtResultados + dr = dtVC.Rows(0) + Dim ruta As String = "" + params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("TipoPoliza", dr("TipoPoliza").ToString)) + params.Add(New ReportParameter("Finicio", dr("Fecha").ToString.ToDate.ToShortDateString)) + params.Add(New ReportParameter("FFin", dr("Fecha").ToString.ToDate.ToShortDateString)) + params.Add(New ReportParameter("Fecha", dr("Fecha").ToString.ToDate.ToShortDateString)) + 'params.Add(New ReportParameter("Nombre", dr("Cuenta").ToString)) + 'params.Add(New ReportParameter("Cuenta", dr("Codigo").ToString)) + params.Add(New ReportParameter("Numero", dr("FolioPoliza").ToString)) + params.Add(New ReportParameter("Moneda", "")) + params.Add(New ReportParameter("CodigoPostal", "")) + If UsuarioActual.CveEmpresa = 119 Then + params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre"))) + End If + If Archivo.Exists Then + ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc" + Else + ruta = "Empresas/Grales/Formatos/Polizas.rdlc" + End If + Bytes = StreamPDF(ruta, dtVC, params, "ppoliza") + If Not File.Exists(String.Format("{0}{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)) Then + DirectoryExistsCreate(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick)) + File.WriteAllBytes(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString), Bytes) + End If + End If + Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString) + ObjConta.Dispose() + + End Function + Private Sub MergePdfFiles(ByVal pdfFiles() As String) + Dim result As Boolean = False + Dim pdfCount As Integer = 0 + Dim f As Integer = 0 + Dim fileName As String + Dim reader As iTextSharp.text.pdf.PdfReader = Nothing + Dim pageCount As Integer = 0 + Dim pdfDoc As iTextSharp.text.Document = Nothing + Dim writer As PdfWriter = Nothing + Dim cb As PdfContentByte = Nothing + + Dim page As PdfImportedPage = Nothing + Dim rotation As Integer = 0 + + + Try + pdfCount = pdfFiles.Length + If pdfCount > 0 Then + fileName = pdfFiles(f) + reader = New iTextSharp.text.pdf.PdfReader(fileName) + pageCount = reader.NumberOfPages + pdfDoc = New iTextSharp.text.Document(reader.GetPageSizeWithRotation(1), 18, 18, 18, 18) + writer = PdfWriter.GetInstance(pdfDoc, New FileStream(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio), FileMode.Create)) + + With pdfDoc + .Open() + End With + cb = writer.DirectContent + While f < pdfCount + Dim i As Integer = 0 + While i < pageCount + i += 1 + pdfDoc.SetPageSize(reader.GetPageSizeWithRotation(i)) + pdfDoc.NewPage() + page = writer.GetImportedPage(reader, i) + rotation = reader.GetPageRotation(i) + If rotation = 90 Then + cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(i).Height) + ElseIf rotation = 270 Then + cb.AddTemplate(page, 0, 1.0F, -1.0F, 0, reader.GetPageSizeWithRotation(i).Width + 60, -30) + Else + cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0) + End If + End While + f += 1 + If f < pdfCount Then + fileName = pdfFiles(f) + reader = New iTextSharp.text.pdf.PdfReader(fileName) + pageCount = reader.NumberOfPages + End If + End While + + + pdfDoc.Close() + + Dim Archivo As New System.IO.FileInfo(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio)) + + If Archivo.Exists Then + HttpContext.Current.Response.Clear() + HttpContext.Current.Response.ClearContent() + HttpContext.Current.Response.ContentType = "application/octet-stream" + HttpContext.Current.Response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", Archivo.Name)) + HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) + HttpContext.Current.Response.TransmitFile(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio)) + Response.Flush() ' send it to the client to download + HttpContext.Current.Response.SuppressContent = True + HttpContext.Current.ApplicationInstance.CompleteRequest() + + End If + result = True + End If + Catch ex As Exception + End Try + + + + End Sub + + +#End Region + End Class diff --git a/Contabilidad/RepIVA.aspx b/Contabilidad/RepIVA.aspx index d7c95adc4..b5e938280 100644 --- a/Contabilidad/RepIVA.aspx +++ b/Contabilidad/RepIVA.aspx @@ -216,6 +216,7 @@ + @@ -231,7 +232,7 @@ - + diff --git a/Contabilidad/RepIVA.aspx.cs b/Contabilidad/RepIVA.aspx.cs index 659597ce7..dd79dcb50 100644 --- a/Contabilidad/RepIVA.aspx.cs +++ b/Contabilidad/RepIVA.aspx.cs @@ -53,7 +53,6 @@ public partial class Contabilidad_RepIVA : ClsPaginas if (!IsPostBack) { InicializaValores(); - } } @@ -61,8 +60,9 @@ public partial class Contabilidad_RepIVA : ClsPaginas { TipoCambio = 1; TCEspecifico = -1; - txtFechaI.Text = $"01/{DateTime.Now.Month}/{DateTime.Now.Year}"; - txtFechaF.Text = DateTime.Now.ToShortDateString(); + DateTime FF = DateTime.Now.AddMonths(-1); + txtFechaI.Text = $"01/{FF.Month}/{FF.Year}"; + txtFechaF.Text = FF.ToShortDateString(); LnkAccionesDIOT.Visible = true; @@ -104,6 +104,8 @@ public partial class Contabilidad_RepIVA : ClsPaginas LblMsgAcreditable.Text = "La información presenta importes en negativo, estos no se incluirán en el archivo generado para DIOT"; } + GvA.Columns[11].Visible = DtIVAAcreditable.SUM("IvaExentoImpo") > 0; // sino tiene valor la columna de importación de oculta + if (ObjCont.GetRepIVAAcumulado(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), Conciliado, 3, DdlCuenta.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)) { diff --git a/Contabilidad2/CatCuentasAsignaciones.aspx b/Contabilidad2/CatCuentasAsignaciones.aspx index f326424ab..2ba7351cd 100644 --- a/Contabilidad2/CatCuentasAsignaciones.aspx +++ b/Contabilidad2/CatCuentasAsignaciones.aspx @@ -24,7 +24,7 @@ @@ -87,6 +87,10 @@
    +
    + + +
    diff --git a/Contabilidad2/CatCuentasAsignaciones.aspx.vb b/Contabilidad2/CatCuentasAsignaciones.aspx.vb index 323a90ca7..886765323 100644 --- a/Contabilidad2/CatCuentasAsignaciones.aspx.vb +++ b/Contabilidad2/CatCuentasAsignaciones.aspx.vb @@ -42,7 +42,7 @@ Partial Class Contabilidad2_CatCuentasAsignaciones If ObjConta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then DdlCuenta.DataSource = ObjConta.DtResultados End If - + ObjConta.Dispose() DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) DdlClientes.setEsWebService(True) @@ -51,17 +51,25 @@ Partial Class Contabilidad2_CatCuentasAsignaciones DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) - DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - - ObjConta.Dispose() - + DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa) + + + + Dim ObjBancos As New ClsBancos + If ObjBancos.GetBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) Then + DdlCuentaBancaria.DataSource = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + End If + ObjBancos.Dispose() + + DdlCuentaBancaria.DataBind() DdlCconceptosContables.DataBind() DdlCuenta.DataBind() DdlProveedor.DataBind() 'DdlPersonal.DataBind() DdlClasificacion.DataBind() - DdlAlmacen.DataBind() - + DdlAlmacen.DataBind() + + DdlCuentaBancaria.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlConceptoNomina.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlCconceptosContables.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1")) @@ -71,16 +79,20 @@ Partial Class Contabilidad2_CatCuentasAsignaciones End Sub Protected Sub ActualizaModulo(sender As Object, e As EventArgs) + LimpiarDatos() + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) CveConceptoAsignacion = GvRow.DataKey("CveCuentaAsignacion").ToEntero DdlCconceptosContables.SelectedValue = GvRow.DataKey("CveConceptoContable").ToEntero DdlCuenta.SelectedValue = GvRow.DataKey("CveCuenta").ToEntero - DdlConceptoNomina.SelectedValueexist(GvRow.DataKey("CveConceptoNomina").ToEntero) + DdlConceptoNomina.SelectedValueExist(GvRow.DataKey("CveConceptoNomina").ToEntero) DdlProveedor.SelectedValue = GvRow.DataKey("CveProveedor").ToEntero DdlClasificacion.SelectedValue = GvRow.DataKey("CveClasificacion").ToEntero DdlAlmacen.SelectedValue = GvRow.DataKey("CveAlmacen").ToEntero TxtIdCuentaContable.Text = GvRow.DataKey("IdCuenta") TxtPorcentajeIVA.Text = GvRow.DataKey("PorcentajeIVA") + DdlCuentaBancaria.SelectedValueExist(GvRow.DataKey("CveBancoCuenta")) + Dim CveCliente As Integer = GvRow.DataKey("CveCliente").ToEntero Dim CvePersonal As Integer = GvRow.DataKey("CvePersonal").ToEntero @@ -120,14 +132,23 @@ Partial Class Contabilidad2_CatCuentasAsignaciones ObjConta.Dispose() End Sub - Protected Sub BtnAgregarMotivoD_Click(sender As Object, e As EventArgs) Handles BtnAgregarMotivoD.Click + Protected Sub BtnAgregarMotivoD_Click(sender As Object, e As EventArgs) Handles BtnAgregarMotivoD.Click + LimpiarDatos() + + LbAgregar.Text = "Agregar" + UpModalModulos.Update() + RegistraScript("$('#ModalCat').modal();") + End Sub + + Private Sub LimpiarDatos() CveConceptoAsignacion = -1 DdlCconceptosContables.SelectedValue = -1 DdlCuenta.SelectedValue = -1 DdlProveedor.SelectedValue = -1 DdlClasificacion.SelectedValue = -1 DdlAlmacen.SelectedValue = -1 - DdlConceptoNomina.SelectedValue = -1 + DdlConceptoNomina.SelectedValue = -1 + DdlCuentaBancaria.SelectedValueExist("-1") TxtIdCuentaContable.Text = "" TxtPorcentajeIVA.Text = "" DdlClientes.ddl.DataSource = "" @@ -135,10 +156,7 @@ Partial Class Contabilidad2_CatCuentasAsignaciones DdlClientes.setEsWebService(True) DdlPersonal.ddl.DataSource = "" DdlPersonal.ddl.DataBind() - DdlPersonal.setEsWebService(True) - LbAgregar.Text = "Agregar" - UpModalModulos.Update() - RegistraScript("$('#ModalCat').modal();") + DdlPersonal.setEsWebService(True) End Sub Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click @@ -147,13 +165,13 @@ Partial Class Contabilidad2_CatCuentasAsignaciones If LbAgregar.Text = "Agregar" Then If Not ObjConta.AddCuentasAsignaciones(DdlCconceptosContables.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlCuenta.SelectedValue.ToEntero, TxtIdCuentaContable.Text.ToEntero, DdlProveedor.SelectedValue.ToEntero, DdlClientes.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero, - DdlClasificacion.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, TxtPorcentajeIVA.Text.ToDecimal) Then + DdlClasificacion.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, TxtPorcentajeIVA.Text.ToDecimal, CveBancoCuenta:=DdlCuentaBancaria.SelectedValue.ToEntero) Then ErrorString = "Error al agregar" End If ElseIf LbAgregar.Text = "Actualizar" Then If Not ObjConta.UpdateCuentasAsignaciones(CveConceptoAsignacion, DdlCconceptosContables.SelectedValue.ToEntero, DdlCuenta.SelectedValue.ToEntero, TxtIdCuentaContable.Text.ToEntero, DdlProveedor.SelectedValue.ToEntero, DdlClientes.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero, - DdlClasificacion.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, TxtPorcentajeIVA.Text.ToDecimal) Then + DdlClasificacion.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, TxtPorcentajeIVA.Text.ToDecimal, CveBancoCuenta:=DdlCuentaBancaria.SelectedValue.ToEntero) Then ErrorString = "Error al actualizar" End If End If diff --git a/Empresas/119/Formatos/Polizas.rdlc b/Empresas/119/Formatos/Polizas.rdlc index fa48d9432..48a40c9ba 100644 --- a/Empresas/119/Formatos/Polizas.rdlc +++ b/Empresas/119/Formatos/Polizas.rdlc @@ -1,5 +1,5 @@ - + 0 @@ -171,7 +171,6 @@ 2pt - true @@ -461,7 +460,6 @@ 7 - true @@ -553,7 +551,6 @@ 2pt - true @@ -774,7 +771,6 @@ 1pt - true @@ -885,40 +881,40 @@ - - true - - - - - = Fields!Cargo.Value - - - + + true + + + + + =Fields!Cargo.Value + + + + + + + Cargo + + =iif(Fields!TipoMovto.Value = "1", true, false) + + + 1pt + 1pt + 1pt + 1pt - - - - =iif(Fields!TipoMovto.Value ="0",False,True) - - - - 1pt - 1pt - 1pt - 1pt - es-MX - - + @@ -929,7 +925,7 @@ - = Fields!Abono.Value + =Fields!Abono.Value + true @@ -996,7 +993,6 @@ 1pt - true @@ -1071,7 +1067,7 @@ - + true true @@ -1091,7 +1087,7 @@ - Textbox113 + Textbox6 @@ -1211,7 +1207,6 @@ 1pt - true @@ -1546,7 +1541,6 @@ 3 - true @@ -2052,6 +2046,7 @@ ReportParameter1 + REM Reset Page Number: Shared offset As Integer diff --git a/Empresas/152/Formatos/Factura.rdlc b/Empresas/152/Formatos/Factura.rdlc index dd41dbdf2..248f23356 100644 --- a/Empresas/152/Formatos/Factura.rdlc +++ b/Empresas/152/Formatos/Factura.rdlc @@ -2869,6 +2869,21 @@ 2pt + + Embedded + ID2 + FitProportional + 0.29668cm + 1.15361cm + 2.413cm + 2.75323cm + 30 + + + + 19.04565cm - - -
    - - - - - - - - + + + + + + + + + + + +
    + + + +
    + + + + + + + + - + - - -
  • + + + +
  • - -
  • -
    - + + + + - + + - - - + + + diff --git a/GPS/RepPuntosDeInteres.aspx.vb b/GPS/RepPuntosDeInteres.aspx.vb index 3b818619e..444cad665 100644 --- a/GPS/RepPuntosDeInteres.aspx.vb +++ b/GPS/RepPuntosDeInteres.aspx.vb @@ -3,6 +3,7 @@ Imports Extensiones Imports System.Data Imports Microsoft.Reporting.WebForms +Imports GemBox.Spreadsheet Partial Class GPS_RepPuntosDeInteres Inherits ClsPaginas @@ -24,6 +25,14 @@ Partial Class GPS_RepPuntosDeInteres ViewState("DtDatosReporte") = value End Set End Property + Private Property DtVisitas As DataTable + Get + Return If(IsNothing(ViewState("DtVisitas")), Nothing, CType(ViewState("DtVisitas"), DataTable)) + End Get + Set(value As DataTable) + ViewState("DtVisitas") = value + End Set + End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load @@ -32,6 +41,7 @@ Partial Class GPS_RepPuntosDeInteres End If End Sub Private Sub CargaDatos() + DtDatosReporte = Nothing txtFechaF.Text = Now.ToString("dd/MM/yyyy") txtFechaI.Text = Now.AddDays(-7).ToString("dd/MM/yyyy") @@ -66,6 +76,11 @@ Partial Class GPS_RepPuntosDeInteres End Sub Private Sub ReportePuntos(Dispositivos As String) + 'LIMPIAR REPORTE + If DtDatosReporte IsNot Nothing Then + DtDatosReporte.Dispose() + DtDatosReporte = Nothing + End If Dim FechaI, FechaF As Date Dim SBBody As New StringBuilder @@ -83,11 +98,15 @@ Partial Class GPS_RepPuntosDeInteres Try For Each row As GridViewRow In GvPuntos.Rows SBBody.Clear() + If row.FCCheckBox("chkGR").Checked Then If ObjGPS.RepPuntosGet(row.DataKey("CvePuntoDeInteres").ToEntero, Dispositivos, txtFechaI.Text.ToDateTime, txtFechaF.Text.ToDateTime, UsuarioActual.CveCliente) Then - DtDatosReporte = ObjGPS.DtResultados.Copy() - GvBarra.DataSource = DtDatosReporte + If DtDatosReporte IsNot Nothing Then + DtDatosReporte.Merge(ObjGPS.DtResultados) + Else + DtDatosReporte = ObjGPS.DtResultados.Copy() + End If Coords = SQLToGmaps(row.DataKey("Punto").ToString, "POINT") SBBody.Append($"
    ") @@ -98,7 +117,7 @@ Partial Class GPS_RepPuntosDeInteres SBBody.Append($"
    ") For Each Cve As String In DispositivosLista If ObjGPS.DtResultados.FiltraParametros($"CveDispositivo = {Cve} ").Rows.Count > 0 Then - SBBody.Append($"") + SBBody.Append($"") SBBody.Append($"") End If Next @@ -111,7 +130,11 @@ Partial Class GPS_RepPuntosDeInteres RegistraScript($"CreaCirculo({Coords},'{Color}');CreaMarcador({Coords},'{row.DataKey("PuntoDeInteres")}','{SBBody.ToString}');", row.DataKey("CvePuntoDeInteres")) End If End If + Next + + GvBarra.DataSource = DtDatosReporte + GvBarra.DataBind() Catch ex As Exception OnError("Ocurrió un error al consultar los puntos de interes", ex) End Try @@ -162,13 +185,32 @@ Partial Class GPS_RepPuntosDeInteres Protected Sub BtnCargarGV_Click(sender As Object, e As EventArgs) Handles BtnCargarGV.Click - Dim GPS As New ClsGPS - If GPS.RepPuntosDetalleGet(HdnPunto.Value.ToEntero, HdnDispositivo.Value.ToEntero, txtFechaI.Text.ToDateTime, txtFechaF.Text.ToDateTime, UsuarioActual.CveCliente) Then - GVHistorico.DataSource = GPS.DtResultados.FiltraParametros("CveEvento = 106") - Else - GVHistorico.DataSource = Nothing - End If - GPS.Dispose() + DtVisitas = Nothing + + Dim ObjGPS As New ClsGPS + Try + Dim PuntoInteres As String = "", Vehiculo As String = "" + + If ObjGPS.PuntoDeInteresGet(HdnPunto.Value.ToEntero, UsuarioActual.CveCliente, 1, -1) Then + PuntoInteres = ObjGPS.DtResultados.FiltroPrimeroValor("PuntoDeInteres") + End If + + Vehiculo = GlobalDTDispositivos(UsuarioActual.CveCliente).FiltroPrimeroValor("NoEconomico", $"CveDispositivo={HdnDispositivo.Value.ToEntero}") + + LblPU.Text = PuntoInteres + LblUnidad.Text = Vehiculo + + If ObjGPS.RepPuntosDetalleGet(HdnPunto.Value.ToEntero, HdnDispositivo.Value.ToEntero, txtFechaI.Text.ToDateTime, txtFechaF.Text.ToDateTime, UsuarioActual.CveCliente) Then + DtVisitas = ObjGPS.DtResultados.FiltraParametros("CveEvento = 106") + GVHistorico.DataSource = DtVisitas + Else + GVHistorico.DataSource = Nothing + End If + Catch ex As Exception + OnError("Ocurrió un error al cargar las visitas", ex) + End Try + ObjGPS.Dispose() + GVHistorico.DataBind() UpdatePanel3.Update() RegistraScript("$('#dvHistorico').modal()") @@ -192,21 +234,215 @@ Partial Class GPS_RepPuntosDeInteres End Sub Public Sub EnviarReporteProgramado(Format As String) - Dim RutaReporte = "Empresas/Grales/ReportesProgramados/RPTPuntosInteres.rdlc" - Dim NombreReporte = "ReportePuntosInteres" - Try - Dim RptParametro As New List(Of ReportParameter) - RptParametro.Add(New ReportParameter("FechaInicio", txtFechaI.Text)) - RptParametro.Add(New ReportParameter("FechaFin", txtFechaF.Text)) - RptParametro.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) - RptParametro.Add(New ReportParameter("FechaImpresion", DateTime.Now.ToShortDateString)) + If Format = "EXCEL" Then + Dim filtros As String = $"Fecha Inicio: {txtFechaI.Text}, Fecha Fin: {txtFechaF.Text}" - Dim retorno = StreamPDF(RutaReporte, DtDatosReporte, RptParametro, $"{NombreReporte}{Date.Now.ToShortDateString}", Format, MR:=Nothing, RDSName:="DsOC") + Dim DtImprimir As DataTable = DtDatosReporte.Copy() - ImprimirbytesPDF(retorno, $"{NombreReporte}{Date.Now.ToShortDateString}", Format) - Catch ex As Exception - GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) - End Try - End Sub + DtImprimir.Columns.Remove(DtImprimir.Columns("CveDispositivo")) + + DtImprimir.Columns("PuntoDeInteres").SetOrdinal(0) + DtImprimir.Columns("Vehiculo").SetOrdinal(1) + DtImprimir.Columns("UltimaVisita").SetOrdinal(2) + DtImprimir.Columns("Visitas").SetOrdinal(3) + + DtImprimir.Columns("PuntoDeInteres").ColumnName = "Punto de Interés" + DtImprimir.Columns("Vehiculo").ColumnName = "Vehículo" + DtImprimir.Columns("UltimaVisita").ColumnName = "Última Visita" + + ImprimirExcelG(DtImprimir, "ReportePuntosInteres.xlsx", "Reporte de Puntos de Interés", filtros, NombreHoja:="ReportePuntosInteres") + Else + Dim RutaReporte = "Empresas/Grales/ReportesProgramados/RPTPuntosInteres.rdlc" + Dim NombreReporte = "ReportePuntosInteres" + Try + Dim Nombre As String = "" + Dim ObjClientes As New ClsClientes + If ObjClientes.GetClientes(UsuarioActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus:=-1) Then Nombre = ObjClientes.DtResultados.FiltroPrimeroValor("Nombre") + ObjClientes.Dispose() + + Dim RptParametro As New List(Of ReportParameter) + RptParametro.Add(New ReportParameter("FechaInicio", txtFechaI.Text)) + RptParametro.Add(New ReportParameter("FechaFin", txtFechaF.Text)) + RptParametro.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) + RptParametro.Add(New ReportParameter("FechaImpresion", DateTime.Now.ToShortDateString)) + RptParametro.Add(New ReportParameter("Cliente", Nombre)) + + 'Dim MR = New ReportViewer + 'MR.LocalReport.EnableHyperlinks = True + 'MR.HyperlinkTarget = "_blank" + + Dim retorno = StreamPDF(RutaReporte, DtDatosReporte, RptParametro, $"{NombreReporte}{Date.Now.ToShortDateString}", Format, MR:=Nothing, RDSName:="DsOC") + + ImprimirbytesPDF(retorno, $"{NombreReporte}{Date.Now.ToShortDateString}", Format) + Catch ex As Exception + GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) + End Try + End If + + End Sub + Protected Sub LnkImprimirEXCELVisita_Click(sender As Object, e As EventArgs) + Dim filtros As String = $"Punto de Interés: {LblPU.Text}, Vehículo: {LblUnidad.Text}" + + Dim DtImprimir As DataTable = DtVisitas.Copy() + + DtImprimir.Columns.Remove(DtImprimir.Columns("CveDispositivoEvento")) + DtImprimir.Columns.Remove(DtImprimir.Columns("CveEvento")) + DtImprimir.Columns.Remove(DtImprimir.Columns("FechaEvento")) + + DtImprimir.Columns("FechaEntrada").ColumnName = "Fecha Visita" + DtImprimir.Columns("Duracion").ColumnName = "Duración (min)" + + ImprimirExcelG(DtImprimir, "HistorialVistas.xlsx", "Historial de vistas", filtros, NombreHoja:="Historial") + End Sub + + Private Sub ImprimirExcelG(DtDatos As DataTable, Archivo As String, Titulo As String, Filtros As String, Optional NombreHoja As String = "Hoja1") + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + Dim excel As ExcelFile = New ExcelFile + + Dim TotalRowHeader As Integer = 8 + Dim TotalRowFooter As Integer = 2 + + Dim item = excel.Worksheets.Add(NombreHoja) + item.InsertDataTable(DtDatos, New InsertDataTableOptions() With + { + .ColumnHeaders = True, + .StartRow = 0, + .StartColumn = 0 + }) + item.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255)) + item.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255) + + Dim columnCount = item.CalculateMaxUsedColumns() + For i = 0 To columnCount + item.Columns(i).AutoFit(1, item.Rows(i), item.Rows(item.Rows.Count - 1)) + Next + + + Dim worksheet = excel.Worksheets(0) + worksheet.Rows.InsertEmpty(0, TotalRowHeader) + Dim celdasConTexto = worksheet.GetUsedCellRange(True) + celdasConTexto.Style.Font.Name = "Calibri Light" + + Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex) + RangoNombreEmpresa.Merged = True + + Dim Nombre As String = "" + + Dim ObjClientes As New ClsClientes + If ObjClientes.GetClientes(UsuarioActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus:=-1) Then Nombre = ObjClientes.DtResultados.FiltroPrimeroValor("Nombre") + ObjClientes.Dispose() + + RangoNombreEmpresa.Value = Nombre + RangoNombreEmpresa.Style.Font.Size = 18 * 20 + RangoNombreEmpresa.Style.Font.Name = "Calibri Light" + RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex) + RangoTitulo.Merged = True + RangoTitulo.Value = Titulo + RangoTitulo.Style.Font.Size = 20 * 20 + RangoTitulo.Style.Font.Name = "Calibri Light" + RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + 'If FechaIMes.Trim.Length > 0 And FechaFMes.Trim.Length > 0 Then + ' Dim RangoFechas = worksheet.Cells.GetSubrangeAbsolute(4, celdasConTexto.FirstColumnIndex, 4, celdasConTexto.LastColumnIndex) + ' RangoFechas.Merged = True + ' RangoFechas.Value = $"Fechas: {FechaIMes} a {FechaFMes}" + ' RangoFechas.Style.Font.Size = 15 * 20 + ' RangoFechas.Style.Font.Name = "Calibri Light" + ' RangoFechas.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + ' RangoFechas.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + 'End If + + + 'If SubProyecto.Length > 0 Then + ' Dim RangoSubProyecto = worksheet.Cells.GetSubrangeAbsolute(5, celdasConTexto.FirstColumnIndex, 5, celdasConTexto.LastColumnIndex) + ' RangoSubProyecto.Merged = True + ' RangoSubProyecto.Value = SubProyecto + ' RangoSubProyecto.Style.Font.Size = 20 * 20 + ' RangoSubProyecto.Style.Font.Name = "Calibri Light" + ' RangoSubProyecto.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + ' RangoSubProyecto.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + 'End If + + + If Not String.IsNullOrEmpty(Filtros) Then + Dim RangoDatoTituloExtra = worksheet.Cells.GetSubrangeAbsolute(6, celdasConTexto.FirstColumnIndex, 6, celdasConTexto.LastColumnIndex) + RangoDatoTituloExtra.Merged = True + RangoDatoTituloExtra.Value = Filtros + RangoDatoTituloExtra.Style.Font.Size = 15 * 20 + RangoDatoTituloExtra.Style.Font.Name = "Calibri Light" + RangoDatoTituloExtra.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoDatoTituloExtra.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + End If + + + For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20 + worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + worksheet.Rows(8).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + worksheet.Rows(8).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + + + + If i > 0 Then + Try + worksheet.Columns(i).AutoFit(1) + Catch ex As Exception + End Try + End If + + Next + + + + Dim IndexEndTable As Integer = DtDatos.Rows.Count + TotalRowHeader + TotalRowFooter + + worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió" + worksheet.Rows(IndexEndTable + 1).Cells(0).Value = UsuarioActual.Nombre + + worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión" + worksheet.Rows(IndexEndTable + 1).Cells(2).Value = DateTime.Now.ToString("dd/MM/yyyy") + + 'Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) + + 'If Imagen.Exists Then + ' Dim Ruta As String = String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta) + ' Using sr As New StreamReader(Ruta) + ' Dim ms As New MemoryStream() + ' sr.BaseStream.CopyTo(ms) + ' worksheet.Pictures.Add(ms, ExcelPictureFormat.Png, "A1", 100, 100, LengthUnit.Pixel) + ' End Using + 'End If + + + For I = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + If I > 0 Then + + 'If Divisor = 1 Then + ' worksheet.Columns(I + 1).Style.NumberFormat = "#,##0.00" + 'Else + ' worksheet.Columns(I + 1).Style.NumberFormat = "#,##" + 'End If + + Try + worksheet.Columns(I).AutoFit(1) + Catch ex As Exception + End Try + + End If + Next + + excel.Save(Me.Response, Archivo, SaveOptions.XlsxDefault) + + End Sub End Class diff --git a/General/CATIEPSxEntidadFed.aspx.cs b/General/CATIEPSxEntidadFed.aspx.cs index 5d9a71a71..f7b1f8390 100644 --- a/General/CATIEPSxEntidadFed.aspx.cs +++ b/General/CATIEPSxEntidadFed.aspx.cs @@ -50,7 +50,7 @@ public partial class General_CATIEPSxEntidadFed : ClsPaginas DdlEstado.DataBind(); - DdlEstado.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlEstado.Items.Insert(0, new ListItem("Todos", "-1")); RcveEstado = Request["cveEstado"] == null ? -1 : Request["cveEstado"].ToString().ToEntero(); RtasaIEPS = Request["tasaIEPS"] == null ? -1 : Request["tasaIEPS"].ToString().ToDecimal(); RfechaInicio = Request["fechaInicio"] == null ? string.Format("01/{0:MM/yyyy}", DateTime.Now.AddMonths(-1)) : Request["fechaInicio"].ToString(); diff --git a/Inventarios/AjustesSeccionAlmacen.aspx.vb b/Inventarios/AjustesSeccionAlmacen.aspx.vb index 5821d3005..d60e3cb5c 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx.vb +++ b/Inventarios/AjustesSeccionAlmacen.aspx.vb @@ -13,7 +13,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen End Sub Private Sub CargaCombos() - Dim DtAlmacenes As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros("CveTipoAlmacen in (1,12,14,16)") + Dim DtAlmacenes As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros("CveTipoAlmacen in (1,12,14,16, 26)") DdlAlmacen.DataSource = DtAlmacenes DdlAlmacen.DataBind() diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index 092dd7115..3bf93937c 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -2745,6 +2745,11 @@ Partial Class Inventarios_EntregaAlmacen ValidaVirtual = False End If + 'SI NO APLICA VIRTUAL EN LOS PRODUCTOS NO VALIDA + If CveAlmacenVirtual > 0 AndAlso DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count = 0 Then + ValidaVirtual = False + End If + If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveMovimientoRelacionado:=CveMovimientoRelacionadoVirtual, Modulo:="RE/G6") diff --git a/Inventarios/RecepcionDevolucion.aspx b/Inventarios/RecepcionDevolucion.aspx new file mode 100644 index 000000000..70f34f34e --- /dev/null +++ b/Inventarios/RecepcionDevolucion.aspx @@ -0,0 +1,376 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RecepcionDevolucion.aspx.vb" Inherits="Inventarios_RecepcionDevolucion" %> + + + + + + + + Devolución desde almacen + + + + + + +
  • + + +
  • +
    +
    +
    + + + + + +
    +
    +
    +
    +
    + "> + +
    +
    + Información del movimiento +
    +
    +
    > +
    +
    + +
    + +
    +
    +
    + +
    + + + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + + <%----%> +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    + + Productos a devolver +
    +
    +
    +
    +
    +
    + +
    +
    +
    + <%--GV DATOS--%> + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +
    +
    +
    + +
    + + + + diff --git a/Inventarios/RecepcionDevolucion.aspx.vb b/Inventarios/RecepcionDevolucion.aspx.vb new file mode 100644 index 000000000..6a937ce9a --- /dev/null +++ b/Inventarios/RecepcionDevolucion.aspx.vb @@ -0,0 +1,879 @@ +Option Strict On +Option Explicit On + +Imports System.Data +Imports Extensiones + +Partial Class Inventarios_RecepcionDevolucion + Inherits ClsPaginas + +#Region "P R O P I E D A D E S" + Private Property ObjRemisionNC As Modelos.Factura + Get + Return CType(ViewState("ObjRemisionNC"), Modelos.Factura) + End Get + Set(value As Modelos.Factura) + ViewState("ObjRemisionNC") = value + End Set + End Property + Public Property DtMovimientos As DataTable + Get + Return CType(ViewState("DtMovimientos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientos") = value + End Set + End Property +#End Region + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + InicializaValores() + End If + End Sub + + Protected Sub CreaDT() + Dim dt As New DataTable + + Dim column As DataColumn = New DataColumn("Consec") + column.DataType = GetType(Integer) + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + + dt.Columns.Add(column) + dt.Columns.Add("CantidadDevuelta", GetType(Decimal)) + dt.Columns.Add("CantidadVenta", GetType(Decimal)) + dt.Columns.Add("CveVentaDetalle", GetType(Integer)) + dt.Columns.Add("CveVenta", GetType(Integer)) + dt.Columns.Add("Venta", GetType(String)) + dt.Columns.Add("CveUM", GetType(Integer)) + dt.Columns.Add("UnidadMedida", GetType(String)) + dt.Columns.Add("CvePS", GetType(Integer)) + dt.Columns.Add("PS", GetType(String)) + dt.Columns.Add("PU", GetType(Decimal)) + dt.Columns.Add("Total", GetType(Decimal)) + dt.Columns.Add("CveClasificacion", GetType(Integer)) + dt.Columns.Add("CveSeccionAlmacen", GetType(Integer)) + dt.Columns.Add("SeccionAlmacen", GetType(String)) + dt.Columns.Add("Serie", GetType(String)) + dt.Columns.Add("Lote", GetType(String)) + dt.Columns.Add("FechaCaducidad", GetType(DateTime)) + dt.Columns.Add("Observaciones", GetType(String)) + + DtMovimientos = dt.Clone() + End Sub + + Private Sub InicializaValores() + Dim StrAlmacenes As String = "CveTipoAlmacen IN (1)" + + If (UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1") Then + DdlCliente.setEsWebService(True) + DdlCliente.Attributes.Add("data-metodo", "getcliente") + DdlCliente.SelectedText = "Todos" + DdlCliente.SelectedValue = "-1" + Else + DdlCliente.setEsWebService(False) + DdlCliente.ddl.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) + DdlCliente.ddl.DataBind() + DdlCliente.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + DdlAlmacen.DataBind() + DdlAlmacen.Items.Insert(0, New ListItem("Seleccione ", "-1")) + DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) + + + DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, CveEstatus:=1) + DdlSubProyecto.DataBind() + DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione ", "-1")) + + TxtFechaI.Text = $"01/{Now.Month}/{Now.Year}" + TxtFechaF.Text = Now.ToString("dd/MM/yyyy") + + GvDatos.DataSource = Nothing + GvDatos.DataBind() + + LimpiarDatos() + + CargaPS(-1, DdlPS, AplicaAlmacen:=False) + + CreaDT() + + UpGenerales.Update() + End Sub + + Protected Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim StrAlmacenes As String = $"CveTipoAlmacen IN (1) AND CveSubProyecto={DdlSubProyecto.SelectedValue.ToEntero()}" + + DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) + DdlAlmacen.DataBind() + DdlAlmacen.Items.Insert(0, New ListItem("Seleccione ", "-1")) + DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) + + UpGenerales.Update() + End Sub + + Protected Sub LnkAgregarProducto_Click(sender As Object, e As EventArgs) + Dim CveCliente As Integer = DdlCliente.SelectedValue.ToEntero() + Dim CveSubProyecto As Integer = DdlSubProyecto.SelectedValue.ToEntero() + + If CveCliente <= 0 Then + Alert("Debe seleccionar un cliente", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If CveSubProyecto <= 0 Then + Alert("Debe seleccionar un sub proyecto", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + LimpiarDatos() + + RegistraScript("$('#DivModalAgregar').modal('show');") + End Sub + + Private Sub LimpiarDatos() + + GvPSAgregar.DataSource = Nothing + GvPSAgregar.DataBind() + + ChkAplicaSerie.Checked = False + ChkAplicaLote.Checked = False + ChkAplicaCaducidad.Checked = False + + ChkAplicaSerie_CheckedChanged(ChkAplicaSerie, EventArgs.Empty) + ChkAplicaLote_CheckedChanged(ChkAplicaSerie, EventArgs.Empty) + ChkAplicaCaducidad_CheckedChanged(ChkAplicaSerie, EventArgs.Empty) + + End Sub + + Private Sub CargaPS(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost, Optional AplicaAlmacen As Boolean = True, Optional CveMarca As Integer = -1) + Objeto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(141).ToString = "1") + If Not UsuarioActual.Empresa.Funcionalidad(141).ToString = "1" Then + Objeto.ddl.Items.Clear() + Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1, AplicaParaVenta:=1) + Objeto.ddl.DataBind() + Objeto.ddl.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2")) + Objeto.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + Else + Objeto.Attributes.Add("data-cvesubproyecto", "-1") + Objeto.ddlWS.Attributes.Add("data-cveclasificacion", "-1") + Objeto.ddlWS.Attributes.Add("data-aplicaparaventa", "1") + + If AplicaAlmacen Then + Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas") + Else + Objeto.ddlWS.Attributes.Add("data-pagina", "-1") + End If + Objeto.ddlWS.Attributes.Add("data-aplicaparaventa", "1") + Objeto.ddlWS.Attributes.Add("data-cvemarca", CveMarca.ToString) + Objeto.ddlWS.Attributes.Add("data-Estatus", "1") + End If + End Sub + Protected Sub ChkAplicaSerie_CheckedChanged(sender As Object, e As EventArgs) + lblSerie.Visible = ChkAplicaSerie.Checked + DivSerie.Visible = ChkAplicaSerie.Checked + UpModalAgregar.Update() + End Sub + Protected Sub ChkAplicaLote_CheckedChanged(sender As Object, e As EventArgs) + lblLote.Visible = ChkAplicaLote.Checked + DivLote.Visible = ChkAplicaLote.Checked + UpModalAgregar.Update() + End Sub + Protected Sub ChkAplicaCaducidad_CheckedChanged(sender As Object, e As EventArgs) + lblCaducidad.Visible = ChkAplicaCaducidad.Checked + DivCaducidad.Visible = ChkAplicaCaducidad.Checked + UpModalAgregar.Update() + End Sub + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + Dim CvePS As Integer = DdlPS.SelectedValue.ToEntero() + Dim CveCliente As Integer = DdlCliente.SelectedValue.ToEntero() + Dim CveSubProyecto As Integer = DdlSubProyecto.SelectedValue.ToEntero() + + If CvePS <= 0 Then + Alert("Debe seleccionar un producto", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If CveCliente <= 0 Then + Alert("Debe seleccionar un cliente", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If CveSubProyecto <= 0 Then + Alert("Debe seleccionar un sub proyecto", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim FechaI As DateTime = TxtFechaI.Text.ToDateTime() + Dim FechaF As DateTime = TxtFechaF.Text.ToDateTime() + + Dim Serie As String = If(ChkAplicaSerie.Checked, TxtSerie.Text.Trim, "-1") + Dim Lote As String = If(ChkAplicaLote.Checked, TxtLote.Text.Trim, "-1") + Dim FechaCaducidad As DateTime = If(ChkAplicaCaducidad.Checked, TxtFechaCaducidad.Text.ToDateTime, MinFecha) + + Dim ObjInv As New ClsInventarios + Try + If ObjInv.GetProductosDevolucion(CvePS, CveCliente, CveSubProyecto, FechaI, FechaF, Serie, Lote, FechaCaducidad, UsuarioActual.CveEmpresa) Then + GvPSAgregar.DataSource = ObjInv.DtResultados + End If + Catch ex As Exception + OnError("Ocurrio un error al obtener los datos de devolución", ex) + End Try + ObjInv.Dispose() + + GvPSAgregar.DataBind() + + UpModalAgregar.Update() + End Sub + + Protected Sub GvPSAgregar_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPSAgregar.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("CvePS").ToEntero() <= 0 Then + e.Row.CssClass = "Totales" + e.Row.FCCheckBox("ChkAplicar").Visible = False + e.Row.FCTextBox("TxtCantidad").Visible = False + End If + End If + End Sub + Protected Sub LnkModalAgregarUsado_Click(sender As Object, e As EventArgs) + If DtMovimientos IsNot Nothing Then + For Each GvRow As GridViewRow In GvPSAgregar.Rows + If GvRow.RowType = DataControlRowType.DataRow Then + If GvRow.FCCheckBox("ChkAplicar").Checked Then + Dim RowDevolucion As DataRow = DtMovimientos.NewRow + + RowDevolucion("CantidadDevuelta") = GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() + RowDevolucion("CantidadVenta") = GvRow.DataKey("Cantidad").ToDecimal() + RowDevolucion("CveVentaDetalle") = GvRow.DataKey("CveVentaDetalle").ToEntero() + RowDevolucion("CveVenta") = GvRow.DataKey("CveVenta").ToEntero() + RowDevolucion("Venta") = GvRow.DataKey("SerieFolio") + RowDevolucion("CveUM") = GvRow.DataKey("CveUM").ToEntero() + RowDevolucion("UnidadMedida") = GvRow.DataKey("UnidadMedida") + RowDevolucion("CvePS") = GvRow.DataKey("CvePS").ToEntero() + RowDevolucion("PS") = GvRow.DataKey("PS") + RowDevolucion("PU") = GvRow.DataKey("PU").ToDecimal() + RowDevolucion("Total") = (GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() * GvRow.DataKey("PU").ToDecimal()) + RowDevolucion("CveClasificacion") = GvRow.DataKey("CveClasificacion").ToEntero() + RowDevolucion("CveSeccionAlmacen") = GvRow.DataKey("CveSeccionAlmacen").ToEntero() + RowDevolucion("SeccionAlmacen") = GvRow.DataKey("SeccionAlmacen") + RowDevolucion("Serie") = GvRow.DataKey("Serie") + RowDevolucion("Lote") = GvRow.DataKey("Lote") + RowDevolucion("FechaCaducidad") = If(String.IsNullOrEmpty(GvRow.DataKey("FechaCaducidad")), Nothing, GvRow.DataKey("FechaCaducidad").ToDateTime()) + RowDevolucion("Observaciones") = "" + + 'If GvRow.DataKey("CveAlmacen").ToEntero() > 0 AndAlso DdlAlmacen.SelectedValue.ToEntero() <= 0 Then + ' DdlAlmacen.SelectedValueExist(GvRow.DataKey("CveAlmacen")) + 'End If + + DtMovimientos.Rows.Add(RowDevolucion) + End If + + End If + Next + + GvDatos.DataSource = DtMovimientos + GvDatos.DataBind() + + If DtMovimientos.Rows.Count > 0 Then + DivFactura.Visible = True + DdlFactura.DataSource = DtMovimientos.FiltraParametros("", DistinctColumns:={"CveVenta", "Venta"}) + DdlFactura.DataBind() + End If + + End If + + UpDatos.Update() + UpGenerales.Update() + + RegistraScript("$('#DivModalAgregar').modal('hide');") + + + End Sub + + +#Region "C R E A R - R N C" + Private Sub CreaRemisionNC(CveCliente As Integer, CveSubProyecto As Integer) + If ObjRemisionNC IsNot Nothing Then + ObjRemisionNC.Dispose() + ObjRemisionNC = Nothing + End If + Me.ObjRemisionNC = New Modelos.Factura(UsuarioActual) + + Me.ObjRemisionNC.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.HTML + Me.ObjRemisionNC.Serie = "-1" + Me.ObjRemisionNC.Folio = -1 'Folio.ToEntero() + Me.ObjRemisionNC.Version = "3.3" + Me.ObjRemisionNC.FolioFiscal = "" + Me.ObjRemisionNC.CveUsuario = UsuarioActual.CveUsuario + Me.ObjRemisionNC.CveEmpresa = UsuarioActual.CveEmpresa + Me.ObjRemisionNC.ConvertirPesos = False + Me.ObjRemisionNC.CveVentaPadre = DdlFactura.SelectedValue.ToEntero() + + Dim ObjVentasPadre As New ClsVentas + If ObjVentasPadre.GetVenta(Me.ObjRemisionNC.CveVentaPadre, UsuarioActual.CveEmpresa) AndAlso ObjVentasPadre.DtResultados.Rows.Count > 0 Then + Me.ObjRemisionNC.CveMoneda = ObjVentasPadre.DtResultados.FiltroPrimeroValor("CveMoneda").ToString().ToEntero() + End If + ObjVentasPadre.Dispose() + + If Me.ObjRemisionNC.CveMoneda = 1 Then + Me.ObjRemisionNC.TipoCambio = 1 + Else + Me.ObjRemisionNC.TipoCambio = GlobalTipoCambio(Now).ToDecimal() + End If + + Me.ObjRemisionNC.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", String.Format("CveMoneda = {0} ", Me.ObjRemisionNC.CveMoneda)) + Me.ObjRemisionNC.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", String.Format("CveMoneda = {0} ", Me.ObjRemisionNC.CveMoneda)) + Me.ObjRemisionNC.TipoDocto = "RNC" + Me.ObjRemisionNC.RefDocto = "" + Me.ObjRemisionNC.CveMesa = -1 + Me.ObjRemisionNC.Fecha = Now + Me.ObjRemisionNC.CvePrePoliza = -1 + Me.ObjRemisionNC.FechaPago = Now + Me.ObjRemisionNC.MotivoDescuento = "" + Me.ObjRemisionNC.FechaEjecucion = Now + Me.ObjRemisionNC.UsuarioCreo = UsuarioActual.Usuario + Me.ObjRemisionNC.CveCondicionEntrega = -1 + Me.ObjRemisionNC.CondicionEntrega = "" + Me.ObjRemisionNC.NumeroCuenta = "" + Me.ObjRemisionNC.CondicionesPago = 0 + Me.ObjRemisionNC.FormaPago = 0 + Me.ObjRemisionNC.PedidoContrato = "" + Me.ObjRemisionNC.NumeroContrato = "" + Me.ObjRemisionNC.DescripcionContrato = "" + Me.ObjRemisionNC.CveCorte = -1 + Me.ObjRemisionNC.TipoDocumento = "Remisión" + 'NUM 1- CARGO 2- BONIFICACION + Me.ObjRemisionNC.Num1 = 0 + 'NUM 0- USADO 1- AJUSTE/GARANTIA + Me.ObjRemisionNC.Num2 = 0 + 'ES PARA GENERAR DEVOLUCION + Me.ObjRemisionNC.Num3 = 10 + Me.ObjRemisionNC.Alfa1 = "" + Me.ObjRemisionNC.Alfa2 = "" + Me.ObjRemisionNC.Alfa3 = "" + Me.ObjRemisionNC.CveContrato = -1 + Me.ObjRemisionNC.ConvertirPesos = False + Me.ObjRemisionNC.CveSubProyecto = CveSubProyecto + Me.ObjRemisionNC.CveSubProyectoCobranza = CveSubProyecto + Me.ObjRemisionNC.CveSubProyectoEjecucion = CveSubProyecto + Me.ObjRemisionNC.SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero(String.Format("CveSubProyecto = {0}", CveSubProyecto))) + Me.ObjRemisionNC.SubProyectoMatriz = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1")) + + 'CLIENTE + Me.ObjRemisionNC.CveCliente = CveCliente + Me.ObjRemisionNC.SetCliente() + Me.ObjRemisionNC.CveAlmacen = -1 + + Dim ObjCliente As New ClsClientes + If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + Me.ObjRemisionNC.CveFormaPago33 = ObjCliente.CveFormaPago33 + Me.ObjRemisionNC.FormaPago33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("FormaPago", String.Format("CveFormaPago = {0}", ObjCliente.CveFormaPago33)) + Me.ObjRemisionNC.FormaPagoSAT33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", String.Format("CveFormaPago = {0}", ObjCliente.CveFormaPago33)) + + Me.ObjRemisionNC.CveMetodoPago33 = ObjCliente.CveMetodoPago33 + Me.ObjRemisionNC.MetodoPago33 = GlobalDTVtaMetodoPago.FiltroPrimeroValor("MetodoPago", String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33)) + Me.ObjRemisionNC.ClaveMetodoPagoSAT = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33)) + + Me.ObjRemisionNC.CveUsoCFDI = ObjCliente.CveUsoCFDI + Me.ObjRemisionNC.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI)) + Me.ObjRemisionNC.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI)) + + Me.ObjRemisionNC.CveMetodoPago = ObjCliente.CveMetodoPago33 + + If GlobalDTMetodosPago.FiltraParametros(String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33)).Rows.Count > 0 Then + Me.ObjRemisionNC.MetodoPago = GlobalDTMetodosPago.FiltraParametros(String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33)).Rows(0)("MetodoPago").ToString + Else + Me.ObjRemisionNC.CveMetodoPago = 1 + Me.ObjRemisionNC.MetodoPago = "Efectivo" + End If + + If UsuarioActual.CveEmpresa = 119 Then + Me.ObjRemisionNC.FormaPago = 20 'POR DEFINIR AND (@CveMetodoPago33 = 3 AND @CveFormaPago33 <> 20) + If Me.ObjRemisionNC.CveMetodoPago33 = 3 Then + Me.ObjRemisionNC.CveFormaPago33 = 20 + End If + End If + End If + End If + + If ObjCliente.GetSucursales(CveCliente) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + Me.ObjRemisionNC.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero()) + Else + Me.ObjRemisionNC.CveClienteSucursal = -1 + End If + End If + ObjCliente.Dispose() + + 'DETALLES + Me.ObjRemisionNC.DtDetalle = CreaDTDetalleRNC() + + CargaDTDetalleRNC() + + 'VALIDA PROMOCIONES Y EXISTENCIAS + Dim ObjVentas As New ClsVentas + If ObjVentas.GetPromocionesPS(-1, Now, CveSubProyecto, Me.ObjRemisionNC.CveCliente, Me.ObjRemisionNC.CveVendedor, 1, UsuarioActual.CveEmpresa) Then + Me.ObjRemisionNC.DtPromociones = ObjVentas.DtResultados.Copy() + End If + ObjVentas.Dispose() + + Me.ObjRemisionNC.Observaciones = TxtObservaciones.Text + Me.ObjRemisionNC.OrdenCompra = "" + Me.ObjRemisionNC.PedidoContrato = "" + Me.ObjRemisionNC.ObservacionesAlmacen = "" + + + + 'If TmpDTPolizaVirtual IsNot Nothing Then + ' Me.ObjRemisionNC.DtPolizasVirtuales = TmpDTPolizaVirtual + 'End If + + End Sub + + Private Function AddPSRNC(ByRef TmpDT As DataTable, Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String, + PU As Decimal, Descuento As Decimal, + CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, + Optional Serie As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0, + Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, + Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, + Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional EsCargo As Boolean = False, Optional PorcentajeIVA As Decimal = 0D, Optional CveTamaño As Integer = 0) As Boolean + + Dim Retorno As Boolean = False + If Not CvePS > 0 Then + Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Return False + End If + + If (Obs.Length + PS.Length > 1000) Then + Alert(String.Format("El Nombre y observación del producto tiene longitud de {0} caracteres y excede los 1000 caracteres permitidos.", Obs.Length + PS.Length), TipoMensaje.MsgAdvertencia) + Return False + End If + + + Dim Row As DataRow = Nothing + Dim TotalCalculableImpuestos As Decimal = 0D, TotalCalculableImpuestosIVA = 0D + PU = Math.Round(PU, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos + + Row = TmpDT.NewRow() + Row("CveProyecto") = CveProyecto + Row("Proyecto") = Proyecto + Row("CveSubProyecto") = CveSubProyecto + Row("SubProyecto") = SubProyecto + Row("Serie") = Serie + Row("TiempoEntrega") = TiempoEntrega + Row("Orden") = TmpDT.Rows.Count + 1 + Row("Cantidad") = Cantidad + Row("CveUM") = CveUM + Row("UM") = UM + Row("CveClasificacion") = CveClasificacion + Row("Clasificacion") = Clasificacion + Row("CvePS") = CvePS + Row("Obs") = Obs + + Dim DrPS As DataRow = Nothing + + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1 + + If DrPS Is Nothing Then + Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Return False + End If + + 'verifica si tiene ventaminima + If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then + 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... + If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then + Alert(String.Format("El producto se vende solo en cantidades de {0}", DrPS("VentaMinima").ToString)) + Return False + End If + End If + + TotalCalculableImpuestos = ((Cantidad * (PU)) - Descuento) + TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal) + + Row("PU") = PU + Row("Codigo") = DrPS("Codigo") + Row("NoIdentificacion") = DrPS("Codigo") + Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria") + Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana") + Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion") + Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion") + Row("Consec") = TmpDT.Rows.Count + 1 + + Row("PS") = DrPS("PS") + Row("CodigoPS") = DrPS("PSCodigo").ToString + Row("CveTipoPS") = DrPS("CveTipoPS") + Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario") + Row("CveTamaño") = DrPS("CveTamaño") + + If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion") + If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion") + + If DrPS("IVA").ToString().Contiene("-1", "") Then + Row("PorcentajeIVA") = PorcentajeIVA + Else + Row("PorcentajeIVA") = DrPS("IVA") + End If + + Row("IVA") = Row("PorcentajeIVA") + Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestosIVA, 2) + + + Row("ImporteRetIVA") = 0D + Row("ImporteRetISR") = 0D + Row("PorcentajeRetIVA") = 0D + Row("PorcentajeRetISR") = 0D + Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje") + Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, 2) + Row("IEPS") = Row("ImporteIEPS") + Row("Descuento") = Math.Round(Descuento, 2) + Row("TipoDescuento") = 0 + Row("Total") = (Cantidad * PU) + Row("TotalImporte") = Math.Round(Cantidad * PU, 2) + + Row("SATClaveProdServ") = DrPS("SATClavePS") + Row("SATClaveUM") = DrPS("SATClaveUnidadMedida") + + + Row("EntregaDirecta") = EntregaDirecta + 'Contratos + Row("CveContratoDetalle") = CveContratoDetalle + Row("CveVentaDetalle") = CveVentaDetalle + Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido + Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle + Row("CveVentaDetalleRemision") = CveVentaDetalleRemision + Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion + Row("CveVentaDetallePedido2") = CveVentaDetallePedido2 + Row("CuentaPredial") = CuentaPredial + Row("EsCargo") = EsCargo + Row("CveTamaño") = CveTamaño + + 'RECARGAR GV + TmpDT.Rows.Add(Row) + TmpDT.AcceptChanges() + Retorno = True + Return Retorno + + End Function + Protected Function CreaDTDetalleRNC() As DataTable + Dim TmpDT = 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("IdCtaContVentas", 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)) + TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) + + '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("CantidadFacturadaPed2", 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("EsCargo", GetType(Boolean)) + + Return TmpDT + End Function + Protected Sub CargaDTDetalleRNC() + 'CvePS = Dr("CvePS").ToString.ToEntero + 'CveUM = Dr("CveUM").ToString.ToEntero + 'Cantidad = Dr("Cantidad").ToString.ToDecimal + 'PU = Dr("PU").ToString.ToDecimal + + 'AplicaSerie = CBool(Dr("AplicaSerie")) + 'Serie = If(AplicaSerie, Dr("Serie").ToString, "-1") + + 'AplicaLote = CBool(Dr("AplicaLote")) + 'Lote = If(AplicaSerie, Dr("Lote").ToString, "-1") + + 'AplicaCaducidad = CBool(Dr("AplicaCaducidad")) + 'FechaCaducidad = If(AplicaCaducidad, Dr("FechaCaducidad").ToString.ToDateTime, MinFecha) + + 'If Dr("CveTipoInvPS").ToString.ToEntero = 5 AndAlso AplicaSerie AndAlso Serie = "" Then + ' OcurrioError = True + ' ErrorList.Add("Se deben especificar las Series de los productos de almacén") + ' Exit For + 'End If + + Dim DtInventario As DataTable = New DataTable + Dim column As DataColumn = New DataColumn("Consec") + column.DataType = GetType(Integer) + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + + DtInventario.Columns.Add(column) + DtInventario.Columns.Add("Cantidad", GetType(Decimal)) + DtInventario.Columns.Add("CveVentaDetalle", GetType(Integer)) + DtInventario.Columns.Add("CvePS", GetType(Integer)) + DtInventario.Columns.Add("CveUM", GetType(Integer)) + DtInventario.Columns.Add("PU", GetType(Decimal)) + DtInventario.Columns.Add("CveTipoInvPS", GetType(Integer)) + DtInventario.Columns.Add("AplicaSerie", GetType(Boolean)) + DtInventario.Columns.Add("Serie", GetType(String)) + DtInventario.Columns.Add("AplicaLote", GetType(Boolean)) + DtInventario.Columns.Add("Lote", GetType(String)) + DtInventario.Columns.Add("AplicaCaducidad", GetType(Boolean)) + DtInventario.Columns.Add("FechaCaducidad", GetType(DateTime)) + + For Each Row As DataRow In DtMovimientos.Rows + + Dim Cantidad As Decimal = Row("CantidadDevuelta").ToString().ToDecimal() + Dim PU As Decimal = Row("PU").ToString().ToDecimal() + Dim SubTotal As Decimal = Cantidad * PU + + Dim CveUnidadMedida As Integer = 0 + Dim CveClasificacion As Integer = 0 + Dim UnidadMedida As String = "" + Dim Clasificacion As String = "" + Dim PS As String = "" + Dim PorcentajeIVA As Decimal = 0 + Dim CvePS As Integer = Row("CvePS").ToString().ToEntero() + + If CvePS > 0 Then + Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0) + Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveSubProyecto = {0}", ObjRemisionNC.CveSubProyecto)) + If Dr IsNot Nothing AndAlso DrSubProyecto IsNot Nothing Then + CveUnidadMedida = Dr("CveUnidadMedida").ToString.ToEntero + CveClasificacion = Dr("CveClasificacion").ToString.ToEntero + PS = Dr("PSCodigo").ToString + UnidadMedida = Dr("UnidadMedida").ToString + Clasificacion = Dr("Clasificacion").ToString + PorcentajeIVA = DrSubProyecto("IVA").ToString().ToDecimal + + If AddPSRNC(ObjRemisionNC.DtDetalle, Cantidad, CveUnidadMedida, UnidadMedida, CveClasificacion, Clasificacion, CvePS, PS, "", PU, 0, -1, "", ObjRemisionNC.CveSubProyecto, ObjRemisionNC.SubProyecto.SubProyecto, PorcentajeIVA:=PorcentajeIVA, CveTamaño:=-1, CveVentaDetalle:=Row("CveVentaDetalle").ToString().ToEntero()) Then + Dim RowInventario As DataRow = DtInventario.NewRow + + RowInventario("Cantidad") = Cantidad + RowInventario("CveVentaDetalle") = -1 + RowInventario("CvePS") = CvePS + RowInventario("CveUM") = CveUnidadMedida + RowInventario("PU") = PU + RowInventario("CveTipoInvPS") = 0 + RowInventario("AplicaSerie") = Not String.IsNullOrEmpty(Row("Serie").ToString()) + RowInventario("Serie") = Row("Serie") + RowInventario("AplicaLote") = Not String.IsNullOrEmpty(Row("Lote").ToString()) + RowInventario("Lote") = Row("Lote") + Dim AplicaCaducidad = If(String.IsNullOrEmpty(Row("FechaCaducidad").ToString()), False, If(Row("FechaCaducidad").ToString().ToDateTime() <= MinFecha, False, True)) + RowInventario("AplicaCaducidad") = AplicaCaducidad + RowInventario("FechaCaducidad") = Row("FechaCaducidad") + + DtInventario.Rows.Add(RowInventario) + End If + + End If + + + Else + Alert("No se pudo cargar el producto", TipoMensaje.MsgError) + End If + Next + + Dim TotalImporte As Decimal = ObjRemisionNC.DtDetalle.SUM("TotalImporte").ToDecimal() + Dim ImporteIVA As Decimal = ObjRemisionNC.DtDetalle.SUM("ImporteIVA").ToDecimal() + Dim ImporteRetIVA As Decimal = ObjRemisionNC.DtDetalle.SUM("ImporteRetIVA").ToDecimal() + Dim ImporteRetISR As Decimal = ObjRemisionNC.DtDetalle.SUM("ImporteRetISR").ToDecimal() + Dim ImporteIEPS As Decimal = ObjRemisionNC.DtDetalle.SUM("ImporteIEPS").ToDecimal() + Dim Descuento As Decimal = ObjRemisionNC.DtDetalle.SUM("Descuento").ToDecimal() + Dim Amortizacion As Decimal = 0 + + Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion) + + 'DETALLES + ObjRemisionNC.SubTotal = TotalImporte + ObjRemisionNC.Descuento = Descuento + ObjRemisionNC.Amortizacion = Amortizacion + ObjRemisionNC.IVA = ImporteIVA + ObjRemisionNC.RetIVA = ImporteRetIVA + ObjRemisionNC.RetISR = ImporteRetISR + ObjRemisionNC.IEPS = ImporteIEPS + ObjRemisionNC.Total = Total + ObjRemisionNC.TotalOtrosConceptos = 0 + ObjRemisionNC.ObservacionesMovimiento = TxtObservaciones.Text + + ObjRemisionNC.DtInventario = DtInventario + + 'Select Case DtMovimientos.FiltroPrimeroValor("CveConcepto").ToEntero() + ' Case 40 + ' ObjRemisionNC.CveConceptoMovimiento = 41 ' DEVOLUCION DEL CLIENTE + ' Case 3 + ' ObjRemisionNC.CveConceptoMovimiento = 18 ' DEVOLUCION DEL CLIENTE + 'End Select + + ObjRemisionNC.CveAlmacen = DdlAlmacen.SelectedValue.ToEntero() + + Dim CveTipoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=ObjRemisionNC.CveAlmacen).FiltroPrimeroValor("CveTipoAlmacen").ToEntero + + Select Case CveTipoAlmacen + Case 10 + ObjRemisionNC.CveConceptoMovimiento = 41 ' DEVOLUCION DIRECTA DEL CLIENTE + Case Else + ObjRemisionNC.CveConceptoMovimiento = 18 ' DEVOLUCION DEL CLIENTE + End Select + + End Sub +#End Region + + Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) + Dim CveCliente As Integer = DdlCliente.SelectedValue.ToEntero() + Dim CveSubProyecto As Integer = DdlSubProyecto.SelectedValue.ToEntero() + Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero() + + If CveCliente <= 0 Then + Alert("Debe seleccionar un cliente", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If CveSubProyecto <= 0 Then + Alert("Debe seleccionar un sub proyecto", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If CveAlmacen <= 0 Then + Alert("Debe seleccionar un almacen", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If DtMovimientos Is Nothing OrElse DtMovimientos.Rows.Count = 0 Then + Alert("No hay producto para devolver", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Try + CreaRemisionNC(CveCliente, CveSubProyecto) + + If ObjRemisionNC IsNot Nothing Then + Dim Resp = ObjRemisionNC.EmitirFactura(False) + + If Resp.Mensajes.Count > 0 AndAlso Resp.CveVenta > 0 Then + Dim Msg As New StringBuilder + + If Resp.CveVenta > 0 Then + If Resp IsNot Nothing Then + For Each mensaje2 As String In Resp.Mensajes + Msg.AppendFormat("
    {0}", mensaje2) + Next + End If + End If + + Msg.AppendFormat("
    El Movimiento se registro con el Folio: {0}", Resp.FolioUsado, Resp.CveMovimientoUsado) + Msg.AppendFormat("

    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", Resp.CveMovimientoUsado))) + + Alert(Msg.ToString(), If(Resp.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion), JSBtnAceptar:="BtnRefrescarPagina();", ShowCloseButton:=False) + + ElseIf Resp.Mensajes.Count <= 0 AndAlso Resp.CveVenta <= 0 Then + Alert("Ocurrió un error al guardar", TipoMensaje.MsgError) + ElseIf Resp.Mensajes.Count >= 0 AndAlso Resp.CveVenta <= 0 Then + For Each Mensaje In Resp.Mensajes + Alert(Mensaje, If(Resp.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion), If(Resp.TieneError, "", Resp.LigaPV), ShowCloseButton:=False) + Next + End If + + End If + + Catch ex As Exception + OnError("Ocurrió un error al guardar", ex) + End Try + + + End Sub + + Protected Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) + Dim GvRow As GridViewRow = GvDatos.Rows(e.RowIndex) + + If DtMovimientos IsNot Nothing Then + Dim ConsecEliminar As Integer = GvRow.DataKey("Consec").ToEntero() + If ConsecEliminar > 0 Then + Dim RowEliminar = DtMovimientos.Select($"Consec={ConsecEliminar}") + If RowEliminar IsNot Nothing AndAlso RowEliminar.Length > 0 AndAlso RowEliminar.Length = 1 Then + RowEliminar(0).Delete() + End If + End If + + GvDatos.DataSource = DtMovimientos + GvDatos.DataBind() + End If + + UpDatos.Update() + End Sub +End Class diff --git a/Inventarios/ResguardoMaterial.aspx.vb b/Inventarios/ResguardoMaterial.aspx.vb index ee8ee8694..42f088a0d 100644 --- a/Inventarios/ResguardoMaterial.aspx.vb +++ b/Inventarios/ResguardoMaterial.aspx.vb @@ -377,6 +377,11 @@ Partial Class Inventarios_ResguardoMaterial 'End If 'dtt.Dispose() End If + Else + ThSeccion.Visible = False + TrSeccion.Visible = False + DdlSeccionAlmacen.Items.Clear() + End If 'activa lote If CBool(drp("AplicaLote")) Then @@ -453,11 +458,11 @@ Partial Class Inventarios_ResguardoMaterial Dim Valido As Boolean = True Dim cantidadd As Double = txtCantidad.Text.ToDouble Dim Existencia As Double = GetExistencias(PSSelected, DdlUnidad.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, If(TxtnSerie.Visible, TxtnSerie.Text, "-1").ToString) - If Existencia - txtCantidad.Text.ToDouble < 0 Then + If Existencia - txtCantidad.Text.ToDouble - DtMovimientos.SUM("Cantidad", $"CvePS = {PSSelected} ") < 0 Then If Existencia <= 0 Then Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) Else - Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia) + Alert(String.Format("Solo hay en existencia: {0}", Existencia - DtMovimientos.SUM("Cantidad", $"CvePS = {PSSelected} ")), TipoMensaje.MsgAdvertencia) If Not UsuarioActual.TienePermisoProceso(114) Then cantidadd = Existencia End If @@ -496,6 +501,22 @@ Partial Class Inventarios_ResguardoMaterial DdlClasificacion.SelectedValue = "-1" txtCantidad.Text = "" TxtObservacionesdetalle.Text = "" + + ThCaducidad.Visible = False + TrCaducidad.Visible = False + TxtCaducidad.Text = "" + ThLote.Visible = False + TrLote.Visible = False + TxtLote.Text = "" + ThSerie.Visible = False + TrSerie.Visible = False + TxtnSerie.Visible = False + TxtnSerie.Text = "" + + ThSeccion.Visible = False + TrSeccion.Visible = False + DdlSeccionAlmacen.Items.Clear() + End Sub #End Region diff --git a/Inventarios/TrasladoSolicitud.aspx.vb b/Inventarios/TrasladoSolicitud.aspx.vb index ae6200ef3..ef5af71e2 100644 --- a/Inventarios/TrasladoSolicitud.aspx.vb +++ b/Inventarios/TrasladoSolicitud.aspx.vb @@ -382,8 +382,8 @@ Partial Class Inventarios_TrasladoSolicitud UpDatos.Update() RegistraScript(String.Format("$('#{0}').modal();", "ModalPS")) End Sub - Private Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) Handles BtnAgregarPS.Click - Dim Existencia As Boolean + Private Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) Handles BtnAgregarPS.Click + If Not DdlProductoServicio.SelectedValue.ToEntero > 0 Then Alert("Tiene que seleccionar un producto.", TipoMensaje.MsgAdvertencia) Exit Sub @@ -419,8 +419,8 @@ Partial Class Inventarios_TrasladoSolicitud End Sub Private Function AddPSTemporal() As Boolean Dim Row As DataRow = TempDT.NewRow() - Dim Lote As String - Dim FechaCaducidad As Date + Dim Lote As String = "-1" + Dim FechaCaducidad As Date = MinFecha Row("Cantidad") = TxtCantidad.Text.Trim.ToDouble Row("CvePS") = DdlProductoServicio.SelectedValue.ToEntero Row("CodigoPS") = DdlProductoServicio.SelectedText @@ -465,7 +465,7 @@ Partial Class Inventarios_TrasladoSolicitud If Existencia = 0 Then Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia) Else - Alert($"No hay existencia suficiente del producto. Solo hay en existencia: {Existencia}", TipoMensaje.MsgAdvertencia) + Alert($"No hay existencia suficiente del producto. Solo hay en existencia: {Existencia - TempDT.SUM("Cantidad", $"CvePS = {DdlProductoServicio.SelectedValue.ToEntero} AND CveUM = {DdlUM.SelectedValue.ToEntero}")}", TipoMensaje.MsgAdvertencia) End If Return False End If @@ -580,8 +580,10 @@ Partial Class Inventarios_TrasladoSolicitud RowTemp("CveUM") = row.DataKey("CveUM").ToEntero RowTemp("UnidadMedida") = row.DataKey("UM") RowTemp("Observaciones") = "" - 'RowTemp("CveDireccionEnvio") = DdlDireccionEnvio.SelectedValue - 'RowTemp("DireccionEnvio") = IIf(DdlDireccionEnvio.SelectedValue = "-1", "", DdlDireccionEnvio.SelectedItem) + RowTemp("Lote") = "-1" + RowTemp("FechaCaducidad") = MinFecha + 'RowTemp("CveDireccionEnvio") = DdlDireccionEnvio.SelectedValue + 'RowTemp("DireccionEnvio") = IIf(DdlDireccionEnvio.SelectedValue = "-1", "", DdlDireccionEnvio.SelectedItem) RowTemp("CveContratoDetalle") = row.DataKey("CveContratoDetalle") CodigoPS = RowTemp("CodigoPS").ToString @@ -1005,7 +1007,7 @@ Partial Class Inventarios_TrasladoSolicitud If Existencia = 0 Then Alert($"No hay existencia del producto: {CodigoPS}", TipoMensaje.MsgAdvertencia) Else - Alert($"No hay existencia suficiente del producto: {CodigoPS}, Solo hay en existencia: {Existencia}", TipoMensaje.MsgAdvertencia) + Alert($"No hay existencia suficiente del producto: {CodigoPS}, Solo hay en existencia: {Existencia - TempDT.SUM("Cantidad", $"CvePS = {RowTemp("CvePS").ToString.ToEntero} AND CveUM = {RowTemp("CveUM").ToString.ToEntero}")}", TipoMensaje.MsgAdvertencia) End If End If TempDT.Rows.Add(RowTemp) diff --git a/OC/RepSolicitudesAnticipo.aspx b/OC/RepSolicitudesAnticipo.aspx index 0d3f4f2c2..543203c73 100644 --- a/OC/RepSolicitudesAnticipo.aspx +++ b/OC/RepSolicitudesAnticipo.aspx @@ -10,15 +10,28 @@ -
  • - Generar PDF -
  • -
  • - Exporta Excel -
  • -
  • - Descargar PDFs -
  • + + +
  • + Generar PDF +
  • +
  • + Exporta Excel +
  • +
  • + Descargar PDFs +
  • +
  • + Cambiar Fechas +
  • +
  • + Guardar +
  • +
    + + + +
    @@ -108,13 +121,20 @@ " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> - + + + + + + + - + @@ -126,7 +146,7 @@ - + @@ -151,6 +171,59 @@ + + diff --git a/OC/RepSolicitudesAnticipo.aspx.cs b/OC/RepSolicitudesAnticipo.aspx.cs index bed783754..6123bbc9b 100644 --- a/OC/RepSolicitudesAnticipo.aspx.cs +++ b/OC/RepSolicitudesAnticipo.aspx.cs @@ -121,20 +121,20 @@ public partial class OC_RepSolicitudesAnticipo : ClsPaginas { if (DdlEstatus.SelectedValue.ToEntero() == 3) { - GvSolicitudes.Columns[5].Visible = false; - GvSolicitudes.Columns[9].Visible = false; + GvSolicitudes.Columns[6].Visible = false; + GvSolicitudes.Columns[10].Visible = false; - GvSolicitudes.Columns[6].Visible = true; GvSolicitudes.Columns[7].Visible = true; + GvSolicitudes.Columns[8].Visible = true; } else { - GvSolicitudes.Columns[5].Visible = true; - GvSolicitudes.Columns[9].Visible = true; + GvSolicitudes.Columns[6].Visible = true; + GvSolicitudes.Columns[10].Visible = true; - GvSolicitudes.Columns[6].Visible = false; GvSolicitudes.Columns[7].Visible = false; + GvSolicitudes.Columns[8].Visible = false; } CargaDatos(); @@ -153,6 +153,60 @@ public partial class OC_RepSolicitudesAnticipo : ClsPaginas { GenerarImpresionMasiva(); } + protected void LnkCambiarFecha_Click(object sender, EventArgs e) + { + GvSolicitudes.Columns[0].Visible = true; + LnkGuardar.Visible = true; + LnkCambiarFecha.Visible = false; + UPAcciones.Update(); + UPDatos.Update(); + } + protected void BtnGuardarArchivo_Click(object sender, EventArgs e) + { + ActualizarFechas(); + RegistraScript("$('#ModalUpload').modal('hide')", "hidemodal1"); + GvSolicitudes.Columns[0].Visible = false; + LnkGuardar.Visible = false; + LnkCambiarFecha.Visible = true; + UPAcciones.Update(); + UPDatos.Update(); + } + private void ActualizarFechas() + { + ClsOIEventos ObjEvento = new ClsOIEventos(); + DateTime FechaInicio; + DateTime FechaFin; + int CveEvento; + Boolean TieneError = true; + + foreach (GridViewRow Gvr in GvSolicitudes.Rows) + { + if (Gvr.FCCheckBox("ChkOrdenCompra").Checked) + { + FechaInicio = txtFechaActualizar.Text.ToDateTime(); + FechaFin = txtFechaActualizarFin.Text.ToDateTime(); + CveEvento = Gvr.DataKey("CveEvento").ToEntero(); + if (ObjEvento.UpdateEvento("-1", "-1", -1, -1, -1, FechaInicio, FechaFin, -1, "-1", CveEvento)) + { + TieneError = false; + } + else + { + TieneError = true; + Alert("Ocurrio un error al actulizar las fechas", TipoMensaje.MsgError); + ObjEvento.RollBack(); + break; + + } + } + } + if (TieneError == false) { + ObjEvento.Commit(); + Alert("Las Fechas se actualizaron correctamente"); + } + ObjEvento.Dispose(); + CargaDatos(); + } protected void GenerarPDF(String Opcion) { diff --git a/Planeacion/CatSubProyectos.aspx b/Planeacion/CatSubProyectos.aspx index 0a41f25c3..03c8f97f5 100644 --- a/Planeacion/CatSubProyectos.aspx +++ b/Planeacion/CatSubProyectos.aspx @@ -286,7 +286,7 @@
    - +
    diff --git a/Sistemas/CatSesiones.aspx b/Sistemas/CatSesiones.aspx index 7b5ce4727..4f55c1a69 100644 --- a/Sistemas/CatSesiones.aspx +++ b/Sistemas/CatSesiones.aspx @@ -14,6 +14,7 @@ + diff --git a/Sistemas/CatSesiones.aspx.vb b/Sistemas/CatSesiones.aspx.vb index 9e6d1ed9b..e06cf9d67 100644 --- a/Sistemas/CatSesiones.aspx.vb +++ b/Sistemas/CatSesiones.aspx.vb @@ -7,7 +7,9 @@ Partial Class Sistemas_CatSesiones Protected Sub BtnCargar_Click(sender As Object, e As EventArgs) Handles BtnCargar.Click If DdlVariable.SelectedItem.Value = "GlobalDTUsuarios" Then - CargaUsuarios() + CargaUsuarios() + ElseIf DdlVariable.SelectedItem.Value = "GlobalDTUsuarioResponsable" Then + CargaUsuariosResponsable() ElseIf DdlVariable.SelectedItem.Value = "GlobalDTAlmacenUsuarios" Then CargaAlmacenUsuarios() ElseIf DdlVariable.SelectedItem.Value = "GlobalDTCliente" Then @@ -287,6 +289,19 @@ Partial Class Sistemas_CatSesiones 'Fin Carga Usuarios End Sub + Private Sub CargaUsuariosResponsable() + 'Carga Usuarios + Dim ObjUsuarios As New ClsSisUsuarios + If ObjUsuarios.GetUsuariosEmpresas(-1) Then + Alert(ObjUsuarios.DtResultados.Rows.Count.ToString) + Application("GlobalDTUsuarioResponsable") = ObjUsuarios.DtResultados + Else + Application("GlobalDTUsuarioResponsable") = Nothing + End If + ObjUsuarios.Dispose() + 'Fin Carga Usuarios + End Sub + Private Sub CargaEmpresas() 'Carga Empresas diff --git a/Sistemas/PopUpAddUsuario.aspx.vb b/Sistemas/PopUpAddUsuario.aspx.vb index 1ec6d9763..04d76c490 100644 --- a/Sistemas/PopUpAddUsuario.aspx.vb +++ b/Sistemas/PopUpAddUsuario.aspx.vb @@ -522,30 +522,13 @@ Partial Class Sistemas_PopUpAddUsuario Alert("Ocurrió un error al agregar el usuario.", TipoMensaje.MsgInformacion) End If Catch ex As Exception + HuboError = true OnError("Ocurrió un error al agregar el usuario.", ex) End Try If Not HuboError Then ObjUsuarios.Commit() - If UsuarioActual.Empresa.CvePlataforma = 3 Then - - Using ObjNotificaciones As New ClsSisNotificaciones() - ObjNotificaciones.DeleteNotificacion(-1, CveUsuario) - For Each row As GridViewRow In GVNotificaciones.Rows - If row.FCCheckBox("chkCorreo").Checked OrElse row.FCCheckBox("chkVentana").Checked OrElse row.FCCheckBox("chkSMS").Checked OrElse - row.FCCheckBox("chkApp").Checked OrElse row.FCCheckBox("chkCampana").Checked Then - If Not ObjNotificaciones.AddUsuariosNotificacion(CveUsuario, row.DataKey("CveNotificacion"), row.FCCheckBox("chkCorreo").Checked, row.FCCheckBox("chkVentana").Checked, row.FCCheckBox("chkSMS").Checked, - row.FCCheckBox("chkApp").Checked, row.FCCheckBox("chkCampana").Checked) Then - HuboError = True - End If - End If - Next - End Using - - End If - - Dim JSBTN As String = "" If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso UsuarioActual.CveCliente > 0 Then @@ -566,7 +549,24 @@ Partial Class Sistemas_PopUpAddUsuario ObjUsuarios.RollBack() Alert("Ocurrió un error al agregar el usuario.", TipoMensaje.MsgInformacion) End If - ObjUsuarios.Dispose() + ObjUsuarios.Dispose() + + If Not HuboError AndAlso UsuarioActual.Empresa.CvePlataforma = 3 Then + + Using ObjNotificaciones As New ClsSisNotificaciones() + ObjNotificaciones.DeleteNotificacion(-1, CveUsuario) + For Each row As GridViewRow In GVNotificaciones.Rows + If row.FCCheckBox("chkCorreo").Checked OrElse row.FCCheckBox("chkVentana").Checked OrElse row.FCCheckBox("chkSMS").Checked OrElse + row.FCCheckBox("chkApp").Checked OrElse row.FCCheckBox("chkCampana").Checked Then + If Not ObjNotificaciones.AddUsuariosNotificacion(CveUsuario, row.DataKey("CveNotificacion"), row.FCCheckBox("chkCorreo").Checked, row.FCCheckBox("chkVentana").Checked, row.FCCheckBox("chkSMS").Checked, + row.FCCheckBox("chkApp").Checked, row.FCCheckBox("chkCampana").Checked) Then + HuboError = True + End If + End If + Next + End Using + + End If RecargarGlobalUsuarios() RecargarGlobal() diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 982827aa5..a24cf4999 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -2693,12 +2693,18 @@ Partial Class Ventas_ClientesAbonar If CveConceptoDeduccion = 78 Then IdCuentaContableNoDeducible = UsuarioActual.Empresa.IdCuentaOtrosIngresos If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 122) Then + ClienteMovto = False : Saldo = Saldo * -1 ImpuestosMovto = True : IVA = IVA * -1 - RETIVA = RETIVA * -1 + + 'RETIVA = RETIVA * -1 + + RETIVA = ((SubTotal * RETIVA / gr.DataKey("SubTotal").ToDecimal.RoundSQL) * -1).RoundSQL(2) + CveConceptoCliente = 1 'falta cuenta incobrable IdCuentaContableNoDeducible = 3114 + End If Dim UsaComplementaria As Boolean = False diff --git a/Ventas/PV.aspx b/Ventas/PV.aspx index 0ac8d7586..0fb66d53a 100644 --- a/Ventas/PV.aspx +++ b/Ventas/PV.aspx @@ -2746,58 +2746,81 @@
    -
    -
    - -
    - - +
    +
    +
    + + Datos de Usados +
    +
    + +
    -
    - -
    - +
    +
    +
    + +
    + + + + + + +
    +
    + +
    + + +
    +
    + +
    + +
    +
    +
    +
    + +
    + + +
    +
    + +
    + + +
    +
    +
    +
    +
    + + + + +
    +
    +
    + +
    + + + + + + + + +
    +
    +
    +
    -
    -
    - -
    - - - - - - -
    -
    -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - -
    -

    @@ -3562,37 +3585,37 @@ $get(Row).style.backgroundColor = "#82b6db"; $get(Obj).focus(); var total = parseFloat($('#<%= LblSaldoVenta.ClientID%>').text().replace(',', '')); - $get(Obj).value = 0; - var suma = 0; - $('#<%= GVAnticipos.ClientID%> input[type="text"]').each(function (index) { - var currentsaldo = parseFloat($(this).val()) - if (isNaN(currentsaldo)) { currentsaldo = 0 } - suma = currentsaldo + suma; - }); - var txtvalue = total - suma; - if (txtvalue < 0) { txtvalue = 0; } - if (txtvalue < Saldo) { Saldo = txtvalue.toFixed(2); } - $get(Obj).value = Saldo; - $get("HdnAnticipos").value = parseFloat($get("HdnAnticipos").value) + parseFloat(Saldo); - } else { - $get(Obj).readOnly = true; - $get("HdnAnticipos").value = parseFloat($get("HdnAnticipos").value) - parseFloat($get(Obj).value); - $get(Obj).value = ""; - $get(Row).style.backgroundColor = "#ffffff"; - } - //if ($("input:checkbox:not(:checked)")) - SetText2($get("LblTotalAnticipos"), formato_numero($get("HdnAnticipos").value, 2, '.', ',')); - } - function imprimircotizacion() { - __doPostBack('ctl00$HB$LnkImprimir', ''); - } - function ValidaMontoMenor(Obj, Monto) { - debugger; - Monto = ToDouble($('#C_Tab_TabGenerales_TxtTotal').val()) - - var ValorTxt = Obj.value; + $get(Obj).value = 0; var suma = 0; - var total = parseFloat($('#<%= LblSaldoVenta.ClientID%>').text().replace(',', '')); + $('#<%= GVAnticipos.ClientID%> input[type="text"]').each(function (index) { + var currentsaldo = parseFloat($(this).val()) + if (isNaN(currentsaldo)) { currentsaldo = 0 } + suma = currentsaldo + suma; + }); + var txtvalue = total - suma; + if (txtvalue < 0) { txtvalue = 0; } + if (txtvalue < Saldo) { Saldo = txtvalue.toFixed(2); } + $get(Obj).value = Saldo; + $get("HdnAnticipos").value = parseFloat($get("HdnAnticipos").value) + parseFloat(Saldo); + } else { + $get(Obj).readOnly = true; + $get("HdnAnticipos").value = parseFloat($get("HdnAnticipos").value) - parseFloat($get(Obj).value); + $get(Obj).value = ""; + $get(Row).style.backgroundColor = "#ffffff"; + } + //if ($("input:checkbox:not(:checked)")) + SetText2($get("LblTotalAnticipos"), formato_numero($get("HdnAnticipos").value, 2, '.', ',')); + } + function imprimircotizacion() { + __doPostBack('ctl00$HB$LnkImprimir', ''); + } + function ValidaMontoMenor(Obj, Monto) { + debugger; + Monto = ToDouble($('#C_Tab_TabGenerales_TxtTotal').val()) + + var ValorTxt = Obj.value; + var suma = 0; + var total = parseFloat($('#<%= LblSaldoVenta.ClientID%>').text().replace(',', '')); $('#<%= GVAnticipos.ClientID%> input[type="text"]').each(function (index) { var currentsaldo = parseFloat($(this).val()) if (isNaN(currentsaldo)) { currentsaldo = 0 } diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index d03fdcbe8..fafcab128 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -1271,15 +1271,22 @@ Partial Class PV Using ObjMarcas As New ClsProductosServicios If ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa) Then - DdlMarcaPS.DataSource = ObjMarcas.DtResultados - DdlMarcaPSAjuste.DataSource = ObjMarcas.DtResultados + DdlMarcaPS.DataSource = ObjMarcas.DtResultados.Copy() + DdlMarcaPSAjuste.DataSource = ObjMarcas.DtResultados.Copy() + End If + + If ObjMarcas.GetMarcasUsados(UsuarioActual.CveEmpresa) Then + DdlMarcaUsado.DataSource = ObjMarcas.DtResultados.Copy() End If End Using + DdlMarcaPS.DataBind() DdlMarcaPSAjuste.DataBind() + DdlMarcaUsado.DataBind() DdlMarcaPS.Items.Insert(0, New ListItem("Todas", "-1")) DdlMarcaPSAjuste.Items.Insert(0, New ListItem("Todas", "-1")) + DdlMarcaUsado.Items.Insert(0, New ListItem("Seleccione", "-1")) UpModalVenta.Update() UpAjuste.Update() @@ -2005,7 +2012,7 @@ Partial Class PV For Each drow As DataRow In TmpDTPolizaVirtual.Rows If ObjAcum.AddPolizaVirtual(CveVenta, drow("CveVentaDetalle").ToString().ToEntero(), drow("CvePS").ToString.ToEntero, drow("Cantidad").ToString.ToDecimal, drow("PU").ToString.ToDecimal, drow("Descuento").ToString.ToDecimal, drow("Total").ToString.ToDecimal, drow("TipoServicio").ToString.ToEntero, drow("TipoPoliza").ToString.ToEntero, drow("CveModeloAuto").ToString.ToEntero, drow("AnioVehiculo").ToString.ToEntero, CBool(drow("TieneUsado").ToString), - drow("FechaUsado").ToString().ToDateTime, drow("CvePSUsado").ToString.ToEntero, drow("CveBCIUsado").ToString.ToEntero) Then + drow("FechaUsado").ToString().ToDateTime, drow("CvePSUsado").ToString.ToEntero, drow("CveBCIUsado").ToString.ToEntero, drow("CveMarcaUsado").ToString.ToEntero) Then Else OcurrioError = True Exit For @@ -3255,17 +3262,47 @@ Partial Class PV If ObjFactura.CveCliente > 0 Then If TmpDT.Rows.Count > 0 Then - Dim Retorno = ObjFactura.EmitirFactura() - If Retorno.CveVenta > 0 Then - Dim SbAlert As New StringBuilder - SbAlert.AppendFormat("{0}
    ", Retorno.Mensajes(Retorno.Mensajes.Count - 1)) - SbAlert.AppendFormat("
    ", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta))) + Dim TieneError As Boolean = False - Dim urlFactura As String = $"/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta))}" - Dim urlAjuste As String = "" + Dim ObjAcum As New ClsAcumuladores + Dim ObjContPaq As ClsContPAQi = Nothing + If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) + End If + + Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing + Dim urlFactura As String = "" + Dim urlAjuste = "" + Dim SbAlert As New StringBuilder + + Try + Retorno = ObjFactura.EmitirFactura(Transac:=ObjAcum.IniciaTransacSQL(), ObjContPaqTransac:=ObjContPaq) + + If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then + + If ObjFactura.TipoDocto = "Rem" Then + If ObjAcum.GetPolizasVirtuales(Retorno.CveVenta) Then + Dim DtPoliza As DataTable = ObjAcum.DtResultados.Copy() + + For Each Row As DataRow In ObjFactura.DtPolizasVirtuales.Rows + Dim CvePolizaVirtual As Integer = DtPoliza.FiltroPrimeroValor("CvePolizaVirtual", $"CveVentaDetalle={Row("CveVentaDetalle")}").ToEntero() + + If Not ObjAcum.UpdatePolizaVirtual(CvePolizaVirtual, Row("CveMarcaUsado").ToString().ToEntero(), Row("FechaUsado").ToString().ToDateTime()) Then + SbAlert.Append("Error al guardar la póliza virtual") + TieneError = True + Exit For + End If + Next + + DtPoliza.Dispose() + Else + SbAlert.Append("Error al obtener la póliza virtual") + TieneError = True + End If + + End If - Using ObjAcum As New ClsAcumuladores If ObjAcum.GetGarantiasDetalle(Retorno.CveVenta) Then Dim RowGarantia As DataRow = ObjAcum.DtResultados.FiltroPrimero("") If RowGarantia IsNot Nothing Then @@ -3274,9 +3311,33 @@ Partial Class PV urlAjuste = $"/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=AJUSTE&CVEGARANTIADETALLE={0}", RowGarantia("CveGarantiaDetalle")))}" End If End If - End Using - Retorno.Mensajes(Retorno.Mensajes.Count - 1) = SbAlert.ToString() + SbAlert.AppendFormat("{0}
    ", Retorno.Mensajes(Retorno.Mensajes.Count - 1)) + SbAlert.AppendFormat("
    ", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta))) + + urlFactura = $"/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta))}" + + Else + TieneError = True + End If + Catch ex As Exception + TieneError = True + OnError("Ocurrió un error al generar el documento", ex) + End Try + + If TieneError Then + ObjAcum.RollBack() + If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() + + ObjAcum.Dispose() + If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose() + + Else + ObjAcum.Commit() + If ObjContPaq IsNot Nothing Then ObjContPaq.Commit() + + ObjAcum.Dispose() + If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose() RegistraScript($"descargarPDF('{urlFactura}','{urlAjuste}');", "Imprimir") @@ -3284,12 +3345,20 @@ Partial Class PV If DivBloqueo.Visible Then Retorno.LigaPV = "bloquearAcceso();" End If + End If + If Retorno IsNot Nothing AndAlso Retorno.Mensajes.Count > 0 Then + Retorno.Mensajes(Retorno.Mensajes.Count - 1) = SbAlert.ToString() End If For Each Mensaje In Retorno.Mensajes Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion), If(Retorno.TieneError, "", Retorno.LigaPV), ShowCloseButton:=False) Next + + If ObjFactura IsNot Nothing Then + ObjFactura.Dispose() + End If + Else Alert("No hay partidas agregadas a la factura", TipoMensaje.MsgAdvertencia) End If @@ -3783,11 +3852,11 @@ Partial Class PV 'Muestra la tabla de tamaños If drPS("CveTamaño").ToString().ToEntero() > 0 Then DivRecepcionUsados.Visible = True - If DdlTipoComprobante.SelectedValue <> "Rem" Then - GvRecepcionUsados.Columns(2).Visible = False - Else - GvRecepcionUsados.Columns(2).Visible = True - End If + 'If DdlTipoComprobante.SelectedValue <> "Rem" Then + ' GvRecepcionUsados.Columns(2).Visible = False + 'Else + ' GvRecepcionUsados.Columns(2).Visible = True + 'End If End If DdlUnidadMedida.Items.Clear() @@ -4335,11 +4404,13 @@ Partial Class PV ChkAgregar.Checked = True - For Each Gvr As GridViewRow In GvRecepcionUsados.Rows - If Gvr.RowType = DataControlRowType.DataRow Then - Gvr.FCTextBox("TxtCantidad").Text = "" - End If - Next + 'For Each Gvr As GridViewRow In GvRecepcionUsados.Rows + ' If Gvr.RowType = DataControlRowType.DataRow Then + ' Gvr.FCTextBox("TxtCantidad").Text = "" + ' End If + 'Next + + DdlRecepcionUsados.SelectedValueExist("-1") DivRecepcionUsados.Visible = False LimpiaAjuste() @@ -4590,14 +4661,20 @@ Partial Class PV Dim Entregado As Decimal = 0 Dim UltimoEntregado As Decimal = 0 - For Each Gvr As GridViewRow In GvRecepcionUsados.Rows - If Gvr.RowType = DataControlRowType.DataRow Then - If Gvr.FCTextBox("TxtCantidad").Text.ToEntero() > 0 Then - Entregado += (Gvr.FCTextBox("TxtCantidad").Text.ToEntero * Gvr.DataKey("Cargo").ToDecimal) - UltimoEntregado = Gvr.DataKey("Cargo").ToDecimal - End If - End If - Next + 'For Each Gvr As GridViewRow In GvRecepcionUsados.Rows + ' If Gvr.RowType = DataControlRowType.DataRow Then + ' If Gvr.FCTextBox("TxtCantidad").Text.ToEntero() > 0 Then + ' Entregado += (Gvr.FCTextBox("TxtCantidad").Text.ToEntero * Gvr.DataKey("Cargo").ToDecimal) + ' UltimoEntregado = Gvr.DataKey("Cargo").ToDecimal + ' End If + ' End If + 'Next + If DdlRecepcionUsados.SelectedValue.ToEntero() > 0 Then + Dim DrTamanio As DataRow = GlobalDTAcumTamaños.FiltroPrimero($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CvePSCargo = {DdlRecepcionUsados.SelectedValue}") + + Entregado += (1D * DrTamanio("Cargo").ToString().ToDecimal) + UltimoEntregado += (DrTamanio("Cargo").ToString().ToDecimal) + End If If Entregado > 0 Then 'Calcular Vendido @@ -4916,13 +4993,13 @@ Partial Class PV If CveVentaDetalle <= 0 AndAlso Not EsCargo Then Dim ListaPSCargo = CalculaUsados(Consec) If ListaPSCargo.Count > 0 Then - CalculaRecepcionUsados(GvRecepcionUsados, CvePS, ListaPSCargo) + CalculaRecepcionUsados(CvePS, ListaPSCargo) End If ElseIf CveVentaDetalle > 0 AndAlso Not EsCargo Then EliminarUsados() Dim ListaPSCargo = CalculaUsados(Consec, LimpiarUsados:=False) If ListaPSCargo.Count > 0 Then - CalculaRecepcionUsados(GvRecepcionUsados, CvePS, ListaPSCargo) + CalculaRecepcionUsados(CvePS, ListaPSCargo) End If End If @@ -6271,14 +6348,20 @@ Partial Class PV CargaModelos() CargaBCIAjuste() - GvRecepcionUsados.DataSource = DtTamanios + DdlRecepcionUsados.DataSource = DtTamanios GvRecepcionUsadosModal.DataSource = DtTamanios + TxtFechaVigencia.Text = Now.ToString("dd/MM/yyyy") + DdlTipoUso.DataBind() DdlTipoDefecto.DataBind() DdlFacturas.DataBind() - GvRecepcionUsados.DataBind() + DdlRecepcionUsados.DataBind() + + DdlRecepcionUsados.Items.Insert(0, New ListItem("Sin usado recibido", "-1")) + DdlBCIUsado.Items.Insert(0, New ListItem("Seleccione", "-1")) + GvRecepcionUsadosModal.DataBind() CreaDTmpDTAjustes() @@ -6300,12 +6383,12 @@ Partial Class PV DdlModeloAuto.DataBind() End Sub - Protected Sub GvRecepcionUsados_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvRecepcionUsados.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.FCDropDownList("DdlBCIUsado").DataSource = DTBCIUsados.FiltraParametros(String.Format("CveTamaño = {0}", e.Row.DataKey("CveTamaño"))) - e.Row.FCDropDownList("DdlBCIUsado").DataBind() - End If - End Sub + 'Protected Sub GvRecepcionUsados_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvRecepcionUsados.RowDataBound + ' If e.Row.RowType = DataControlRowType.DataRow Then + ' e.Row.FCDropDownList("DdlBCIUsado").DataSource = DTBCIUsados.FiltraParametros(String.Format("CveTamaño = {0}", e.Row.DataKey("CveTamaño"))) + ' e.Row.FCDropDownList("DdlBCIUsado").DataBind() + ' End If + 'End Sub Private Sub CargaPSAjuste() 'DdlPSAjuste.Items.Clear() @@ -6790,12 +6873,17 @@ Partial Class PV Protected Sub ChkAjuste_CheckedChanged(sender As Object, e As EventArgs) If ChkAjuste.Checked Then - For Each Gvr As GridViewRow In GvRecepcionUsados.Rows - If Gvr.RowType = DataControlRowType.DataRow Then - Gvr.FCTextBox("TxtCantidad").Text = "" - Gvr.FCTextBox("TxtCantidad").Enabled = False - End If - Next + 'For Each Gvr As GridViewRow In GvRecepcionUsados.Rows + ' If Gvr.RowType = DataControlRowType.DataRow Then + ' Gvr.FCTextBox("TxtCantidad").Text = "" + ' Gvr.FCTextBox("TxtCantidad").Enabled = False + ' End If + 'Next + + DdlRecepcionUsados.SelectedValueExist("-1") + DdlRecepcionUsados.Enabled = False + DdlBCIUsado.SelectedValueExist("-1") + DdlBCIUsado.Enabled = False DivAjuste.Visible = True TxtCantidad.Text = "1" @@ -6810,12 +6898,17 @@ Partial Class PV TxtPrecio.Text = TxtPrecio.Text TxtObsPS.Text = "Descuento por garantía" Else - For Each Gvr As GridViewRow In GvRecepcionUsados.Rows - If Gvr.RowType = DataControlRowType.DataRow Then - Gvr.FCTextBox("TxtCantidad").Text = "" - Gvr.FCTextBox("TxtCantidad").Enabled = True - End If - Next + 'For Each Gvr As GridViewRow In GvRecepcionUsados.Rows + ' If Gvr.RowType = DataControlRowType.DataRow Then + ' Gvr.FCTextBox("TxtCantidad").Text = "" + ' Gvr.FCTextBox("TxtCantidad").Enabled = True + ' End If + 'Next + + DdlRecepcionUsados.SelectedValueExist("-1") + DdlRecepcionUsados.Enabled = True + DdlBCIUsado.SelectedValueExist("-1") + DdlBCIUsado.Enabled = True DivAjuste.Visible = False TxtCantidad.Enabled = True @@ -6877,6 +6970,7 @@ Partial Class PV TmpDTPolizaVirtual.Columns.Add("FechaUsado", GetType(DateTime)) TmpDTPolizaVirtual.Columns.Add("CvePSUsado", GetType(Integer)) TmpDTPolizaVirtual.Columns.Add("CveBCIUsado", GetType(Integer)) + TmpDTPolizaVirtual.Columns.Add("CveMarcaUsado", GetType(Integer)) End Sub Private Function AddPolizaVirtual(CvePS As Integer) As Boolean Dim Retorno As Boolean = True @@ -6916,7 +7010,7 @@ Partial Class PV Dim Total As Decimal = ((Cantidad * PU) - Descuento).RoundSQL(2) Dim TipoServicio As Integer = DdlTipoServicio.SelectedValue.ToEntero() - Dim FechaUsado As DateTime = If(TxtFechaAjuste.Text.ToDateTime() < MinFecha, Now, TxtFechaAjuste.Text.ToDateTime()) + Dim FechaUsado As DateTime = If(TxtFechaVigencia.Text.ToDateTime() < MinFecha, Now, TxtFechaVigencia.Text.ToDateTime()) Dim CveModeloAuto As Integer = DdlModeloAuto.SelectedValue.ToEntero() Dim AnioVehiculo As Integer = TxtAnioVehiculo.Text.ToEntero() Dim TipoPoliza As Integer = 1 'VENTA @@ -6929,21 +7023,25 @@ Partial Class PV End If End If - Dim TieneUsado As Boolean = GvRecepcionUsados.Rows.Cast(Of GridViewRow).Any(Function(GvRow) GvRow.RowType = DataControlRowType.DataRow AndAlso GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() > 0) + Dim TieneUsado As Boolean = (DdlRecepcionUsados.SelectedValue.ToEntero() > 0) 'GvRecepcionUsados.Rows.Cast(Of GridViewRow).Any(Function(GvRow) GvRow.RowType = DataControlRowType.DataRow AndAlso GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() > 0) Dim CvePSUsado As Integer = -1 Dim CveBCIUsado As Integer = -1 If TieneUsado Then - For Each GvRow As GridViewRow In GvRecepcionUsados.Rows - If GvRow.RowType = DataControlRowType.DataRow Then - If GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() > 0 Then - CvePSUsado = GvRow.DataKey("CvePSCargo").ToEntero() - CveBCIUsado = GvRow.FCDropDownList("DdlBCIUsado").SelectedValue.ToEntero() + 'For Each GvRow As GridViewRow In GvRecepcionUsados.Rows + ' If GvRow.RowType = DataControlRowType.DataRow Then + ' If GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() > 0 Then + ' CvePSUsado = GvRow.DataKey("CvePSCargo").ToEntero() + ' CveBCIUsado = GvRow.FCDropDownList("DdlBCIUsado").SelectedValue.ToEntero() + + ' Exit For + ' End If + ' End If + 'Next + + CvePSUsado = DdlRecepcionUsados.SelectedValue.ToEntero() + CveBCIUsado = DdlBCIUsado.SelectedValue.ToEntero() - Exit For - End If - End If - Next End If Dim Row As DataRow = TmpDTPolizaVirtual.NewRow() @@ -6961,6 +7059,7 @@ Partial Class PV Row("FechaUsado") = FechaUsado Row("CvePSUsado") = CvePSUsado Row("CveBCIUsado") = CveBCIUsado + Row("CveMarcaUsado") = DdlMarcaUsado.SelectedValue.ToEntero() TmpDTPolizaVirtual.Rows.Add(Row) @@ -6992,7 +7091,7 @@ Partial Class PV EmitirImprimirNew() End Sub - Private Sub CalculaRecepcionUsados(Gv As GridView, CvePS As Integer, ListaPSCargo As List(Of Integer)) + Private Sub CalculaRecepcionUsados(CvePS As Integer, ListaPSCargo As List(Of Integer)) If Modalidad = "U" Then If TmpDTRecepcionUsados.Rows.Count > 0 Then @@ -7014,28 +7113,48 @@ Partial Class PV Dim StrTamanios As New StringBuilder() StrTamanios.Append("Se recibierón los siguientes usados:") - For Each Gvr As GridViewRow In Gv.Rows - If Gvr.RowType = DataControlRowType.DataRow Then + 'For Each Gvr As GridViewRow In Gv.Rows + ' If Gvr.RowType = DataControlRowType.DataRow Then - If Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 Then - TotalCargos += Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal * Gvr.DataKey("Cargo").ToDecimal - TotalCantidad += Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal - StrTamanios.AppendFormat("{0},", Gvr.DataKey("CodigoPS")) + ' If Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 Then + ' TotalCargos += Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal * Gvr.DataKey("Cargo").ToDecimal + ' TotalCantidad += Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal + ' StrTamanios.AppendFormat("{0},", Gvr.DataKey("CodigoPS")) - Dim Row As DataRow = TmpDTRecepcionUsados.NewRow() - Row("CvePS") = Gvr.DataKey("CvePSCargo").ToEntero - Row("CvePSRelacionado") = CvePS - Row("Cantidad") = Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal - Row("CveUM") = Gvr.DataKey("CveUM").ToEntero - Row("CveVentaDetalle") = -1 - Row("PU") = Gvr.DataKey("Cargo").ToDouble - Row("CveBCIUsado") = Gvr.FCDropDownList("DdlBCIUsado").SelectedValue.ToEntero - Row("CveModeloAuto") = DdlModeloAuto.SelectedValue.ToEntero - TmpDTRecepcionUsados.Rows.Add(Row) + ' Dim Row As DataRow = TmpDTRecepcionUsados.NewRow() + ' Row("CvePS") = Gvr.DataKey("CvePSCargo").ToEntero + ' Row("CvePSRelacionado") = CvePS + ' Row("Cantidad") = Gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal + ' Row("CveUM") = Gvr.DataKey("CveUM").ToEntero + ' Row("CveVentaDetalle") = -1 + ' Row("PU") = Gvr.DataKey("Cargo").ToDouble + ' Row("CveBCIUsado") = Gvr.FCDropDownList("DdlBCIUsado").SelectedValue.ToEntero + ' Row("CveModeloAuto") = DdlModeloAuto.SelectedValue.ToEntero + ' TmpDTRecepcionUsados.Rows.Add(Row) - End If - End If - Next + ' End If + ' End If + 'Next + + Dim DrTamanio As DataRow = GlobalDTAcumTamaños.FiltroPrimero($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CvePSCargo = {DdlRecepcionUsados.SelectedValue}") + + If DdlRecepcionUsados.SelectedValue.ToEntero() > 0 Then + TotalCargos += 1D * DrTamanio("Cargo").ToString().ToDecimal + TotalCantidad += 1D + StrTamanios.AppendFormat("{0},", DrTamanio("CodigoPS")) + + Dim Row As DataRow = TmpDTRecepcionUsados.NewRow() + Row("CvePS") = DrTamanio("CvePSCargo").ToString().ToEntero + Row("CvePSRelacionado") = CvePS + Row("Cantidad") = 1D + Row("CveUM") = DrTamanio("CveUM").ToString().ToEntero + Row("CveVentaDetalle") = -1 + Row("PU") = DrTamanio("Cargo").ToString().ToDecimal + Row("CveBCIUsado") = DdlBCIUsado.SelectedValue.ToEntero + Row("CveModeloAuto") = DdlModeloAuto.SelectedValue.ToEntero + TmpDTRecepcionUsados.Rows.Add(Row) + + End If If TotalCargos > 0 Then StrTamanios.Remove(StrTamanios.Length - 1, 1) @@ -7587,4 +7706,12 @@ Partial Class PV Response.Redirect($"~/Ventas/PV.aspx") End Sub + Protected Sub DdlRecepcionUsados_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim DrTamanio As DataRow = GlobalDTAcumTamaños.FiltroPrimero($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CvePSCargo = {DdlRecepcionUsados.SelectedValue}") + + DdlBCIUsado.DataSource = DTBCIUsados.FiltraParametros(String.Format("CveTamaño = {0}", DrTamanio("CveTamaño"))) + DdlBCIUsado.DataBind() + + UpModalVenta.Update() + End Sub End Class diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 9a9fffbe4..298cbe993 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -3635,15 +3635,17 @@
    - + - + - +
    {ObjGPS.DtResultados.FiltroPrimeroValor("Vehiculo", $"CveDispositivo = {Cve}")}: {ObjGPS.DtResultados.FiltroPrimeroValor("Visitas", $"CveDispositivo = {Cve}")} visitas
    {ObjGPS.DtResultados.FiltroPrimeroValor("Vehiculo", $"CveDispositivo = {Cve}")}: {ObjGPS.DtResultados.FiltroPrimeroValor("Visitas", $"CveDispositivo = {Cve}")} visitas
    Última Visita: {ObjGPS.DtResultados.FiltroPrimeroValor("UltimaVisita", $"CveDispositivo = {Cve}")}
    Próxima Rotación y Balanceo: 
    +
    Próxima Alineación: 
    +
    @@ -6627,7 +6629,7 @@ - + @@ -7030,7 +7032,7 @@
    - + <%----%> @@ -7110,7 +7112,7 @@ - + @@ -7201,7 +7203,7 @@
    -
    + <%--
    @@ -7213,13 +7215,11 @@
    -
    +
    --%>
    - - + + + + + + + <%-- MODAL SUCURSAL --%>