Option Explicit On Option Strict On Imports System.Data Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class Compras_ReembolsosComprobaciones Inherits ClsPaginas #Region "Propiedades" Private ReadOnly Property CveCajaChica As Integer Get Return ViewState("CveCajaChica").ToString.ToEntero End Get End Property Private ReadOnly Property CvePersonal As Integer Get Return ViewState("CvePersonal").ToString.ToEntero End Get End Property Private Property CveMoneda As Integer Get Return ViewState("CveMoneda").ToString.ToEntero End Get Set(value As Integer) ViewState("CveMoneda") = value End Set End Property Private Property CveMonedaPago As Integer Get Return ViewState("CveMonedaPago").ToString.ToEntero End Get Set(value As Integer) ViewState("CveMonedaPago") = value End Set End Property Private Property TipoCambioPago As Decimal Get Return ViewState("TipoCambioPago").ToString.ToDecimal End Get Set(value As Decimal) ViewState("TipoCambioPago") = value End Set End Property Private Property CvePrePolizaComprobacion As Integer Get Return ViewState("CvePrePolizaComprobacion").ToString.ToEntero End Get Set(value As Integer) ViewState("CvePrePolizaComprobacion") = value End Set End Property Private Property NumeroReembolso As String Get NumeroReembolso = ViewState("NumeroReembolso").ToString End Get Set(value As String) ViewState("NumeroReembolso") = value End Set End Property Private Property DtDatos As DataTable Get DtDatos = DirectCast(ViewState("DtDatos"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtDatos") = value End Set End Property Private Property DtCheques As DataTable Get Return CType(ViewState("DtCheques"), DataTable) End Get Set(value As DataTable) ViewState("DtCheques") = value End Set End Property Private Property Folio As String Get Folio = ViewState("Folio").ToString End Get Set(value As String) ViewState("Folio") = 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 TxtImporte.Attributes.Add("disabled", "disabled") TxtAboneA.Enabled = False ViewState("CveMoneda") = 1 CveMonedaPago = 1 TipoCambioPago = 1 Folio = "" 'Cargar Filtros Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) dt = dt.FiltraParametros(String.Format("CveTipoCuenta = 1")) 'caja chica = 1 DdlCajaChica.DataSource = dt DdlCajaChica.DataBind() If UsuarioActual.CveEmpresa.Contiene(119, 158) Then DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) Else DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltraParametros("CveEstatusPersonal = 1") End If DdlPersonal.DataBind() CargaTipoTransaccion() If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then 'acumuladores ChkMesSiguiente.Visible = True End If If UsuarioActual.Empresa.Funcionalidad(506) = "1" Then CbPermitirExcedente.Visible = True Else CbPermitirExcedente.Visible = False End If If UsuarioActual.CveEmpresa = 119 Then ChkReembolsarSinBancos.Visible = True TxtFechaPrePoliza.Text = NowADS().ToShortDateString End If End Sub #Region " FILTROS " Protected Sub DdlTipoPago_SelectedIndexChanged(sender As Object, e As EventArgs) PnlCheques.Visible = False PnlChequeInfo.Visible = False TableExpedirCheque.Visible = False ViewState("CveCajaChica") = -2 ViewState("CvePersonal") = -2 LtTituloPago.Text = "" If DdlTipoPago.SelectedValue = "1" Then DdlPersonal.Visible = True DdlPersonal.SelectedValue = "-2" If UsuarioActual.CveRol = 1 Then ChkAplicaViatico.Visible = True LtTituloPago.Text = "Viáticos:" 'Valida Proceso 120 para ROL Administrador de obra - para FyE solo puede ver los del UsuarioActual If UsuarioActual.TienePermisoProceso(120) Then If UsuarioActual.CvePersonal > 0 Then DdlPersonal.SelectedValue = UsuarioActual.CvePersonal.ToString ViewState("CvePersonal") = UsuarioActual.CvePersonal End If DdlPersonal.Enabled = False End If Else DdlPersonal.Visible = False DdlPersonal.SelectedValue = "-2" ChkAplicaViatico.Visible = False DdlPersonal.Enabled = True End If If DdlTipoPago.SelectedValue = "2" Then DdlCajaChica.Visible = True DdlCajaChica.SelectedValue = "-2" LtTituloPago.Text = "Caja Chica:" Else DdlCajaChica.Visible = False DdlCajaChica.SelectedValue = "-2" End If LimpiaDatos() GvChequesFYE.Visible = False UpChequesFYE.Update() GvCxP.Visible = False UPCompras.Update() 'CargaCxP() End Sub Protected Sub DdlPersonal_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonal.SelectedIndexChanged ViewState("CvePersonal") = DdlPersonal.SelectedValue End Sub Protected Sub DdlCajaChica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCajaChica.SelectedIndexChanged ViewState("CveCajaChica") = DdlCajaChica.SelectedValue End Sub #End Region #Region " CARGA DATOS " Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click LimpiaDatos() CargaCxP() If UsuarioActual.TienePermisoProceso(113) Then CargaReporteChequesFYE() End Sub Private Sub CargaDatos(tCveIE As Integer) Dim ObjIE As New ClsBancos() If ObjIE.GetBancosIE(tCveIE, UsuarioActual.CveEmpresa) Then If ObjIE.DtResultados.Rows.Count > 0 Then LtChequeFecha.Text = ObjIE.FechaDocumento.ToShortDateString TxtFechaPrePoliza.Text = ObjIE.FechaDocumento.ToShortDateString HlCheque.Text = ObjIE.Folio HlCheque.NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", tCveIE) HdnCheque.Value = tCveIE.ToString LtChequeImporte.Text = ObjIE.Importe.FormatoNumero CveMonedaPago = ObjIE.CveMoneda TipoCambioPago = ObjIE.TipoCambio Dim IndexCheque As Integer = If(UsuarioActual.TienePermisoProceso(113), DDlCheques.SelectedIndex - 1, DDlCheques.SelectedIndex) TxtChequeSaldo.Text = DtCheques.Rows(DDlCheques.SelectedIndex - 1)("Saldo").ToString.FormatoNumero Else Alert("El Documento solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) End If End If ObjIE.Dispose() End Sub Private Sub CargaTipoTransaccion() DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'") 'Ing DdlTipoTransaccion.DataBind() DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) 'DdlTipoTransaccionDiferencia.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'") 'Ing 'DdlTipoTransaccionDiferencia.DataBind() 'DdlTipoTransaccionDiferencia.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1")) End Sub Private Sub CargaCuentas() DdlCuenta.Items.Clear() DdlCuenta.SelectedIndex = -1 Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa, CveTipoCuenta:=2) 'solo cuentas "bancarias" dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1)) If DdlTipoTransaccion.SelectedValue.ToEntero = 3 Then dt = dt.FiltraParametros("CveTipoCuenta = 7") End If 'cuando es layout If DdlTipoTransaccion.SelectedValue.ToEntero = 9 Then dt = dt.FiltraParametros("UsaLayout = 1") End If If DdlTipoTransaccion.SelectedValue.ToEntero = 17 Then dt = dt.FiltraParametros("UsaLayoutGrupos = 1") End If DdlCuenta.DataSource = dt DdlCuenta.DataBind() DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1")) End Sub Protected Sub ChkAjusteOI_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ChkAjusteOI.CheckedChanged If ChkAjusteOI.Checked Then TxtOtrosImportes.Visible = True TxtTotal.Visible = True GvCxP.Columns(12).Visible = True Else TxtOtrosImportes.Visible = False TxtTotal.Visible = False GvCxP.Columns(12).Visible = False TxtOtrosImportes.Text = "" TxtTotal.Text = "" RegistraScript("$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);") End If UpDatos.Update() UPCompras.Update() End Sub Protected Sub ChkOtrosIngresosCheque_CheckedChanged(sender As Object, e As EventArgs) If ChkOtrosIngresosCheque.Checked Then TxtOtrosImportes.Visible = True TxtTotal.Visible = True GvCxP.Columns(14).Visible = True Else TxtOtrosImportes.Visible = False TxtTotal.Visible = False GvCxP.Columns(14).Visible = False TxtOtrosImportes.Text = "" TxtTotal.Text = "" RegistraScript("$get('TxtImporte').value = FormatoNumero(SumaValores(), 2);") End If UpDatos.Update() UPCompras.Update() End Sub #End Region #Region " SELECTED INDEX CHANGED " Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged 'recargo la moneda con la que se va a pagar Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) If dr IsNot Nothing Then CveMonedaPago = dr("CveMoneda").ToString.ToEntero End If If HdnTipoTransaccion.Value = "Egs" Then Dim Folio As Long Dim Banco As New ClsBancos Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero) Banco.Dispose() TxtFolio.Text = Folio.ToString Else TxtFolio.Text = "" End If End Sub Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) If dr IsNot Nothing Then HdnTipoTransaccion.Value = dr("Tipo").ToString End If CargaCuentas() End Sub Protected Sub DDlCheques_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDlCheques.SelectedIndexChanged If DDlCheques.SelectedValue.ToEntero > 0 Then TxtAboneA.Enabled = False PnlChequeInfo.Visible = True ChkOtrosIngresosCheque.Visible = True 'If UsuarioActual.TienePermisoProceso(113) Then TrChequeExcedente.Visible = True CargaDatos(DDlCheques.SelectedValue.ToEntero) LimpiaDatos() TableExpedirCheque.Visible = False Else HlCheque.Text = "" HlCheque.NavigateUrl = "" TxtAboneA.Enabled = True HdnCheque.Value = "-1" ChkOtrosIngresosCheque.Visible = False 'If UsuarioActual.TienePermisoProceso(113) Then TableExpedirCheque.Visible = True LimpiaDatos() ChkChequeExcedente.Checked = False PnlChequeInfo.Visible = False 'DdlTipoTransaccion.Enabled = True 'DdlCuenta.Enabled = True 'TxtChequeSaldo.Text = "" 'LimpiaDatos() End If End Sub #End Region #Region " BTN GUARDAR " Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click Dim ValFechaDocumento As Boolean = False Dim FoliosFechasValFechaDocumentoAnio As New StringBuilder Dim FoliosFechasValFechaDocumentoPagoMesSuperior As New StringBuilder Dim FoliosFechasValFechaDocumentoMesInferior As New StringBuilder Dim SaldoAntesPago As Decimal = TxtChequeSaldo.Text.ToDecimal For Each gvRowVal As GridViewRow In GvCxP.Rows If gvRowVal.FCCheckBox("Chk").Checked Then Dim FechaFactura As Date = gvRowVal.DataKey("FechaCompra").ToDate Dim FechaDocumento As Date If DDlCheques.SelectedValue.ToEntero = -1 And Not ChkReembolsarSinBancos.Checked Then FechaDocumento = TxtFechaDocumento.Text.ToDate Else FechaDocumento = TxtFechaPrePoliza.Text.ToDate End If Dim AnioFactura As Integer = FechaFactura.Year Dim MesFactura As Integer = FechaFactura.Month Dim AnioDocumento As Integer = FechaDocumento.Year Dim MesDocumento As Integer = FechaDocumento.Month If AnioFactura > AnioDocumento Then FoliosFechasValFechaDocumentoAnio.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("FechaCompra").ToDate.ToString("dd/MM/yyyy") }
") ValFechaDocumento = True ElseIf AnioFactura = AnioDocumento And MesFactura > MesDocumento Then FoliosFechasValFechaDocumentoMesInferior.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("FechaCompra").ToDate.ToString("dd/MM/yyyy") }
") ValFechaDocumento = True ElseIf AnioFactura = AnioDocumento And MesDocumento > MesFactura Then 'FoliosFechasValFechaDocumentoPagoMesSuperior.AppendLine($"Folio: { gvRowVal.DataKey("SerieFolio") } fecha: {gvRowVal.DataKey("FechaCompra").ToDate.ToString("dd/MM/yyyy") }
") 'ValFechaDocumento = True End If End If Next 'rmf. codigo temporal If UsuarioActual.CveEmpresa.Contiene(13, 83) OrElse ChkMesSiguiente.Checked Then ValFechaDocumento = False End If If ValFechaDocumento Then Dim strMensajeValFechas As String = "" strMensajeValFechas = $"{strMensajeValFechas}{If(FoliosFechasValFechaDocumentoAnio.Length > 0, "Se seleccionarón facturas con fecha de año superior al año del pago:
" & FoliosFechasValFechaDocumentoAnio.ToString, "")}" strMensajeValFechas = $"{strMensajeValFechas}{If(FoliosFechasValFechaDocumentoPagoMesSuperior.Length > 0, "Se seleccionarón facturas con fecha de mes inferior al mes del pago:
" & FoliosFechasValFechaDocumentoPagoMesSuperior.ToString, "")}" strMensajeValFechas = $"{strMensajeValFechas}{If(FoliosFechasValFechaDocumentoMesInferior.Length > 0, "Se seleccionarón facturas con fecha de mes superior al mes del pago:
" & FoliosFechasValFechaDocumentoMesInferior.ToString, "")}" Alert(strMensajeValFechas, TipoMensaje.MsgAdvertencia) Exit Sub End If If HdnCheque.Value.ToEntero > 0 And ChkChequeExcedente.Checked And TxtImporte.Text.ToDecimal = 0 Then Alert("El importe del cheque excedente debe ser mayor a cero", TipoMensaje.MsgAdvertencia) Exit Sub End If If TxtImporte.Text.ToDecimal + TxtImporteVinculado.Text.ToDecimal <= 0 Then Alert("El Importe debe de ser mayor a $0.00", TipoMensaje.MsgAdvertencia) Exit Sub End If Dim ObjIE As New ClsBancos() Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL) Dim MsgError As String = "" Dim CveIEExcedente As Integer = -1 Dim CvePrePolizaExcedente As Integer = 0 Dim CveIERegistrado As Integer = 0 Dim CveIECajaChica As Integer = 0 Dim CvePrePolizaIERegistrado As Integer = 0 Dim IdPoliza As Integer = 0 Dim CveIEPago As Integer = 0 Dim CvePrePolizaPago As Integer = 0 Dim CvePrePolizaPagoOriginal As Integer = 0 Dim CvePersonal As Integer = If(DdlPersonal.Visible AndAlso DdlPersonal.SelectedValue.ToEntero > 0, DdlPersonal.SelectedValue.ToEntero, 0) Dim tipoCambio As Decimal = 1 Dim drp As DataRow = DtCheques.FiltroPrimero($"CveIE = {DDlCheques.SelectedValue.ToEntero}") 'AGARRA CONFIGURACIONES If CveMoneda = 2 Then tipoCambio = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString.ToDecimal Else tipoCambio = 1 End If Dim UsaSimplificacionCajaChica As Boolean = False If UsuarioActual.CveEmpresa.Contiene(119, 158) Then UsaSimplificacionCajaChica = True Dim concepto As String = "Compras: " For Each Gvr As GridViewRow In GvCxP.Rows Dim chkPago As CheckBox = Gvr.FCCheckBox("Chk") If chkPago.Checked Then concepto = concepto & $" {Gvr.DataKey("SerieFolio").ToString }" End If Next Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos Dim filemove As String = "" Dim Comprobante As String = "" Dim ComprobanteIE As String = "" For Each fileItem As Archivo In filesgral Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") filemove = fileItem.filename Next If HdnCheque.Value.ToEntero > 0 AndAlso Not ChkReembolsarSinBancos.Checked Then CveIERegistrado = DDlCheques.SelectedValue.ToEntero If UsuarioActual.CveEmpresa.Contiene(119, 158) OrElse ChkMesSiguiente.Checked Then CvePrePolizaIERegistrado = ObjMov.AddPrePolizas("Compras/Comprobaciones1", 9, TxtImporteVinculado.Text.ToDecimal, TxtImporteVinculado.Text.ToDecimal, CveMoneda, TxtFechaPrePoliza.Text.ToDate, If(TxtObservaciones.Text.Trim = "", concepto, TxtObservaciones.Text.Trim), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If CveCajaChica > 0 Then Dim FolioIENew As String = ObjIE.GetNextFolio(If(CveCajaChica > 0, CveCajaChica, CvePersonal), 8).ToString CveIECajaChica = ObjIE.AddBancos_IE(CveCajaChica, 8, If(ChkReembolsarSinBancos.Checked, TxtFechaPrePoliza.Text.ToDate, TxtFechaDocumento.Text.Trim.ToDate), FolioIENew, String.Format("Transferencia Cta: {0}", DdlCajaChica.SelectedItem), TxtImporteVinculado.Text.ToDecimal, CveMoneda, 0, TxtObservaciones.Text.Trim, "", False, False, -1, CvePrePolizaIERegistrado, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked Or CveCajaChica > 0, True, False)) 'AGREGO PREPOLIZA IE BANCOS If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaIERegistrado, True, TxtImporteVinculado.Text.ToDecimal, TxtImporteVinculado.Text.ToDecimal * tipoCambio, 30, String.Format("Transferencia Cta: {0}", DdlCajaChica.SelectedItem), TxtObservaciones.Text, CveIE:=CveIECajaChica, ImporteME:=If(tipoCambio = 1, 0, TxtImporteVinculado.Text.ToDecimal)) Then MsgError = "Error al registrar detalle de concepto bancario" End If Else 'AGREGO PREPOLIZA FyE If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaIERegistrado, True, TxtImporteVinculado.Text.ToDecimal, TxtImporteVinculado.Text.ToDecimal * tipoCambio, 29, TxtObservaciones.Text, TxtObservaciones.Text, CvePersonal:=CvePersonal, CveIE:=CveIERegistrado, ImporteME:=If(tipoCambio = 1, 0, TxtImporteVinculado.Text.ToDecimal)) Then MsgError = "Error al registrar detalle de concepto bancario" End If End If Else If drp IsNot Nothing Then If drp("FolioPoliza").ToString.ToEntero > 0 Then CvePrePolizaIERegistrado = ObjMov.AddPrePolizas("Compras/Comprobaciones2", 9, TxtImporteVinculado.Text.ToDecimal, TxtImporteVinculado.Text.ToDecimal, CveMoneda, TxtFechaPrePoliza.Text.ToDate, If(TxtObservaciones.Text.Trim = "", concepto, TxtObservaciones.Text.Trim), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) IdPoliza = drp("IdPoliza").ToString.ToEntero Else If UsuarioActual.CveEmpresa = 141 AndAlso CvePrePolizaComprobacion > 0 Then CvePrePolizaIERegistrado = CvePrePolizaComprobacion Else CvePrePolizaIERegistrado = drp("CvePrePoliza").ToString.ToEntero End If End If End If End If Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) If dr IsNot Nothing Then CveMonedaPago = dr("CveMoneda").ToString.ToEntero End If If ChkChequeExcedente.Checked Then CvePrePolizaExcedente = ObjMov.AddPrePolizas("Compras/Comprobaciones3", 9, TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal, CveMoneda, TxtFechaDocumento.Text.ToDate, If(TxtObservaciones.Text.Trim = "", concepto, TxtObservaciones.Text.Trim), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) CveIEExcedente = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.ToDate, TxtFolio.Text.Trim, TxtAboneA.Text, TxtImporte.Text.ToDecimal, CveMoneda, 0.0, TxtObservaciones.Text, "", ChkAbonoCuenta.Checked, True, -1, CvePrePolizaExcedente, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked, True, False)) If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaExcedente, True, TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal * tipoCambio, If(CveCajaChica > 0, 30, 29), TxtObservaciones.Text, TxtObservaciones.Text, CveIE:=CveIEExcedente, CvePersonal:=CvePersonal, CveCompra:=-1, CveProveedor:=-1, ImporteME:=If(tipoCambio = 1, 0, TxtImporte.Text.ToDecimal)) Then MsgError = "Error al registrar detalle de concepto bancario" End If If CveIEExcedente > 0 Then If filemove <> "" Then filemove.FilesMove(CveIEExcedente.ToString, String.Format("{0}IE", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False) Anexo.Text = "" End If End If End If ElseIf Not ChkReembolsarSinBancos.Checked Then CvePrePolizaIERegistrado = ObjMov.AddPrePolizas("Compras/Comprobaciones4", 9, TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal, CveMoneda, TxtFechaDocumento.Text.ToDate, If(TxtObservaciones.Text.Trim = "", concepto, TxtObservaciones.Text.Trim), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) CveIERegistrado = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.ToDate, TxtFolio.Text.Trim, TxtAboneA.Text, TxtImporte.Text.ToDecimal, CveMoneda, 0.0, TxtObservaciones.Text, "", ChkAbonoCuenta.Checked, True, -1, CvePrePolizaIERegistrado, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked, True, False)) If CveIERegistrado > 0 Then If filemove <> "" Then filemove.FilesMove(CveIERegistrado.ToString, String.Format("{0}IE", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False) Anexo.Text = "" End If End If 'AGREGO PREPOLIZA IE BANCOS If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaIERegistrado, True, TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal * tipoCambio, 30, TxtObservaciones.Text, TxtObservaciones.Text, CveIE:=CveIERegistrado, CvePersonal:=CvePersonal, ImporteME:=If(tipoCambio = 1, 0, TxtImporte.Text.ToDecimal)) Then MsgError = "Error al registrar detalle de concepto bancario" End If 'SI ES CAJA CHICA REGISTRO IE CAJA CHICA If CveCajaChica > 0 Then Dim FolioIENew As String = ObjIE.GetNextFolio(If(CveCajaChica > 0, CveCajaChica, CvePersonal), 8).ToString CveIECajaChica = ObjIE.AddBancos_IE(CveCajaChica, 8, TxtFechaDocumento.Text.Trim.ToDate, FolioIENew, String.Format("Transferencia Cta: {0}", DdlCajaChica.SelectedItem), TxtImporte.Text.ToDecimal, CveMoneda, 0, TxtObservaciones.Text.Trim, "", False, False, -1, CvePrePolizaIERegistrado, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked Or CveCajaChica > 0, True, False)) 'AGREGO PREPOLIZA IE BANCOS If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaIERegistrado, False, TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal * tipoCambio, 30, String.Format("Transferencia Cta: {0}", DdlCajaChica.SelectedItem), TxtObservaciones.Text, CveIE:=CveIECajaChica, ImporteME:=If(tipoCambio = 1, 0, TxtImporte.Text.ToDecimal), Contabilizable:=Not UsaSimplificacionCajaChica) Then MsgError = "Error al registrar detalle de concepto bancario" End If Else Dim Importe28 As Decimal = TxtImporte.Text.ToDecimal If ChkAjusteOI.Checked Then Importe28 = TxtTotal.Text.ToDecimal End If 'AGREGO PREPOLIZA FyE If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaIERegistrado, False, Importe28, Importe28 * tipoCambio, 28, TxtObservaciones.Text, TxtObservaciones.Text, CvePersonal:=CvePersonal, CveIE:=CveIERegistrado, ImporteME:=If(tipoCambio = 1, 0, TxtImporte.Text.ToDecimal), Contabilizable:=If(CveCajaChica > 0 Or CvePersonal > 0, Not UsaSimplificacionCajaChica, True)) Then MsgError = "Error al registrar detalle de concepto bancario" End If End If Else CvePrePolizaIERegistrado = ObjMov.AddPrePolizas("Compras/Comprobaciones5", 9, TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal, CveMoneda, TxtFechaPrePoliza.Text.ToDate, If(TxtObservaciones.Text.Trim = "", concepto, TxtObservaciones.Text.Trim), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) 'SI ES CAJA CHICA REGISTRO IE CAJA CHICA If CveCajaChica > 0 Then Dim FolioIENew As String = ObjIE.GetNextFolio(If(CveCajaChica > 0, CveCajaChica, CvePersonal), 2).ToString CveIECajaChica = ObjIE.AddBancos_IE(CveCajaChica, 2, If(ChkReembolsarSinBancos.Checked, TxtFechaPrePoliza.Text.ToDate, TxtFechaDocumento.Text.Trim.ToDate), FolioIENew, String.Format("Transferencia Cta: {0}", DdlCajaChica.SelectedItem), TxtImporte.Text.ToDecimal, CveMoneda, 0, TxtObservaciones.Text.Trim, "", False, False, -1, CvePrePolizaIERegistrado, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked Or CveCajaChica > 0, True, False)) '8 'AGREGO PREPOLIZA IE BANCOS If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaIERegistrado, True, TxtImporte.Text.ToDecimal, TxtImporte.Text.ToDecimal * tipoCambio, 30, String.Format("Transferencia Cta: {0}", DdlCajaChica.SelectedItem), TxtObservaciones.Text, CveIE:=CveIECajaChica, ImporteME:=If(tipoCambio = 1, 0, TxtImporte.Text.ToDecimal)) Then MsgError = "Error al registrar detalle de concepto bancario" End If Else 'AGREGO PREPOLIZA FyE If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaIERegistrado, True, TxtImporteVinculado.Text.ToDecimal, TxtImporte.Text.ToDecimal * tipoCambio, 29, TxtObservaciones.Text, TxtObservaciones.Text, CvePersonal:=CvePersonal, CveIE:=CveIERegistrado, ImporteME:=If(tipoCambio = 1, 0, TxtImporte.Text.ToDecimal)) Then MsgError = "Error al registrar detalle de concepto bancario" End If End If End If Dim ImportePagoTotal As Decimal = 0 If CveIERegistrado > 0 Or CveIEExcedente > 0 Or ChkReembolsarSinBancos.Checked Then 'inserto los movimientos de la conta para abonar al saldo If ((TxtImporte.Text.ToDecimal > 0 Or ChkReembolsarSinBancos.Checked) And CvePrePolizaIERegistrado > 0) Or ((TxtImporteVinculado.Text.ToDecimal > 0 And HdnCheque.Value.ToEntero > 0) Or ChkReembolsarSinBancos.Checked) Then Dim SaldoCheque As Decimal = If(HdnCheque.Value.ToEntero > 0, TxtChequeSaldo.Text.ToDecimal, TxtImporte.Text.ToDecimal) Dim PorcentajePago As Decimal = 1 Dim FechaMovimiento As Date = TxtFechaDocumento.Text.ToDate Dim CvePrePolizaUnificar As Integer = 0 Dim SeUnifico As Boolean = False 'inserto las compras que voy a pagar For Each gvr As GridViewRow In GvCxP.Rows If gvr.FCCheckBox("Chk").Checked Then Dim ImporteMovto As Decimal Dim ConceptoMovimiento As String = $"{gvr.DataKey("Proveedor")} F:{gvr.DataKey("SerieFolio")} {If(DdlPersonal.Visible, DdlPersonal.SelectedItem.Text, DdlCajaChica.SelectedItem.Text)}" Dim Referencia As String = gvr.DataKey("SerieFolio").ToString Dim ImportePagar, ImporteOriginal As Decimal Dim CompraActual As New Compra CompraActual.CveCompra = gvr.DataKey("CveCompra").ToEntero CompraActual.CveTipoConceptoProveedor = gvr.DataKey("CveTipoConcepto").ToEntero CompraActual.CveProveedor = gvr.DataKey("CveProveedor").ToEntero CompraActual.CveMoneda = gvr.DataKey("CveMoneda").ToEntero CompraActual.Fecha = gvr.DataKey("FechaCompra").ToDate CompraActual.SerieFolio = gvr.DataKey("SerieFolio").ToString CompraActual.ProveedorNombre = gvr.DataKey("Proveedor") CompraActual.TC = gvr.DataKey("TipoCambio").ToDecimal CompraActual.Total = gvr.DataKey("Total").ToDecimal CompraActual.IVA = gvr.DataKey("IVA").ToDecimal CompraActual.IVADeducible = gvr.DataKey("IVADeducible").ToDecimal CompraActual.IVANoDeducible = gvr.DataKey("IVANoDeducible").ToDecimal CompraActual.IEPS = gvr.DataKey("IEPS").ToDecimal CompraActual.RetIVA = gvr.DataKey("RetIVA").ToDecimal CompraActual.RetISR = gvr.DataKey("RetISR").ToDecimal CompraActual.CveConceptoRetISR = gvr.DataKey("CveRetISRConcepto").ToEntero CompraActual.CveConceptoRetIVA = gvr.DataKey("CveRetIVAConcepto").ToEntero CompraActual.PorcentajeIVA = gvr.DataKey("IVAPorcentaje").ToDecimal CompraActual.UsuarioActual = UsuarioActual CompraActual.CveSubProyecto = gvr.DataKey("CveSubProyecto").ToEntero CompraActual.CompraNoDeducible = gvr.DataKey("NoDeducible").ToEntero ImportePagar = gvr.FCTextBox("TxtAbonar").Text.ToDecimal ImporteOriginal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal If SaldoCheque > 0 Then 'ImporteMovto = If(ImportePagar > SaldoCheque, SaldoCheque, ImportePagar) ImporteMovto = ImportePagar CvePrePolizaPago = CvePrePolizaIERegistrado ''SE USARA PARA PODER ELIMINAR UNA COMPROBACION CvePrePolizaPagoOriginal = -1 'ObjMov.AddPrePolizas("Compras/Comprobaciones6", 9, ImporteMovto, ImporteMovto, CveMoneda, TxtFechaPrePoliza.Text.ToDate, If(TxtObservaciones.Text.Trim = "", $"Compra: { gvr.DataKey("SerieFolio").ToString }", TxtObservaciones.Text.Trim), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) 'registramos el nuevo IE If CveCajaChica > 0 Then Dim ImporIEPago As Decimal = ImporteMovto + gvr.FCTextBox("TxtComision").Text.ToDecimal CveIEPago = 0 Dim FolioIENew As String = ObjIE.GetNextFolio(CveCajaChica, 6).ToString CveIEPago = ObjIE.AddBancos_IE(CveCajaChica, 6, If(ChkReembolsarSinBancos.Checked, TxtFechaPrePoliza.Text.ToDate, TxtFechaDocumento.Text.ToDate), FolioIENew, gvr.DataKey("Proveedor"), ImporIEPago, CveMoneda, 0.0, $"{gvr.DataKey("Proveedor")} F:{gvr.DataKey("SerieFolio")} {If(DdlPersonal.Visible, DdlPersonal.SelectedItem.Text, DdlCajaChica.SelectedItem.Text)}", "", False, True, -1, CvePrePolizaPago, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked Or CveCajaChica > 0, True, False)) TipoCambioPago = 1 Else CveIEPago = CveIERegistrado End If Dim Pago As New CompraPago Pago.Fecha = TxtFechaDocumento.Text.ToDate Pago.ImportePago = ImporteMovto Pago.CveIE = CveIEPago Pago.CveMonedaPago = CveMonedaPago Pago.TCPago = TipoCambioPago Pago.CvePersonal =CvePersonal ImportePagoTotal = ImportePagoTotal + ImporteMovto If UsuarioActual.CveEmpresa.Contiene(7, 11, 12, 122, 145) Then Pago.AplicaAcreditable = False End If 'Otros Ingresos If MsgError = "" AndAlso (ChkAjusteOI.Checked Or ChkOtrosIngresosCheque.Checked) AndAlso gvr.FCTextBox("TxtComision").Text.ToDecimal <> 0 Then Pago.OtroGastoIngreso = gvr.FCTextBox("TxtComision").Text.ToDecimal End If If MsgError = "" Then If AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePolizaPago, ObjMov) Then MsgError = "Detalle" End If If Not ChkReembolsarSinBancos.Checked AndAlso (Not HdnCheque.Value.ToEntero > 0 Or Not UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso Not ChkMesSiguiente.Checked) Then 'Si es caja chica metemos el concepto 30, si es funcionario metemos 29 ImporteMovto += Pago.OtroGastoIngreso ' si ajuste, sedebe de aplicar en su contraparte If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaPago, True, ImporteMovto, ImporteMovto * tipoCambio, If(CveCajaChica > 0, 30, 29), Referencia, ConceptoMovimiento, CveIE:=CveIEPago, CveIEDevolucion:=If(CveCajaChica > 0, If(DDlCheques.SelectedValue.ToEntero = -1, CveIECajaChica, DDlCheques.SelectedValue.ToEntero), -1), CvePersonal:=CvePersonal, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, ImporteME:=If(tipoCambio = 1, 0, ImporteMovto), CvePrePolizaOriginal:=CvePrePolizaPagoOriginal, Contabilizable:=If(CveCajaChica > 0 Or CvePersonal > 0, Not UsaSimplificacionCajaChica, True)) Then MsgError = "Detalle" End If End If End If Dim SaldoExcedente As Decimal = gvr.FCTextBox("TxtSaldoExcedente").Text.ToDecimal If MsgError = "" AndAlso UsuarioActual.Empresa.Funcionalidad(506) = "1" And CbPermitirExcedente.Checked = True And SaldoExcedente > 0 Then If DDlPermitirExcedente.SelectedValue = "1" Then If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaPago, True, SaldoExcedente, SaldoExcedente * tipoCambio, 132, Referencia, ConceptoMovimiento, CveIE:=CveIEPago, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, ImporteME:=If(tipoCambio = 1, 0, SaldoExcedente), CvePersonal:=CvePersonal, CvePrePolizaOriginal:=CvePrePolizaPagoOriginal) Then MsgError = "Detalle Reembolso Personal" End If ElseIf DDlPermitirExcedente.SelectedValue = "2" Then If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaPago, True, SaldoExcedente, SaldoExcedente * tipoCambio, 29, Referencia, ConceptoMovimiento, CveIE:=CveIEPago, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, ImporteME:=If(tipoCambio = 1, 0, SaldoExcedente), CvePersonal:=CvePersonal, CvePrePolizaOriginal:=CvePrePolizaPagoOriginal) Then MsgError = "Detalle Reembolso Personal Excedente" End If End If End If 'Unificamos el cheque y la caja chica con los pagos y facturas If MsgError = "" AndAlso Not IdPoliza > 0 AndAlso Not gvr.DataKey("IdPoliza").ToEntero > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(219) = "1" Then If MsgError = "" Then If Not ObjMov.PrePolizaUnificacion(CvePrePolizaPago, gvr.DataKey("CvePrePoliza").ToEntero) Then MsgError = "No se pudo unificar la prepoliza" Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) Else SeUnifico = True End If End If End If ImportePagar = ImportePagar - ImporteMovto SaldoCheque = SaldoCheque - ImporteMovto End If 'CHEQUE EXCEDENTE - NUEVO If MsgError = "" AndAlso ChkChequeExcedente.Checked And ImportePagar > 0 Then ImporteMovto = ImportePagar If ImportePagar = ImporteOriginal Then CvePrePolizaPago = ObjMov.AddPrePolizas("Compras/Comprobaciones7", 9, ImporteMovto, ImporteMovto, CveMoneda, TxtFechaPrePoliza.Text.ToDate, If(TxtObservaciones.Text.Trim = "", $"Compra: { gvr.DataKey("SerieFolio").ToString }", TxtObservaciones.Text.Trim), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) 'registramos el nuevo IE If CveCajaChica > 0 Then CveIEPago = 0 Dim FolioIENew As String = ObjIE.GetNextFolio(CveCajaChica, 6).ToString CveIEPago = ObjIE.AddBancos_IE(CveCajaChica, 6, TxtFechaPrePoliza.Text.ToDate, FolioIENew, gvr.DataKey("Proveedor"), ImporteMovto, CveMoneda, 0.0, $"{gvr.DataKey("Proveedor")} F:{gvr.DataKey("SerieFolio")} {If(DdlPersonal.Visible, DdlPersonal.SelectedItem.Text, DdlCajaChica.SelectedItem.Text)}", "", False, True, -1, CvePrePolizaPago, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FueConciliado:=If(ChkReembolsarSinBancos.Checked Or CveCajaChica > 0, True, False)) TipoCambioPago = 1 End If End If Dim Pago As New CompraPago Pago.ImportePago = ImporteMovto Pago.CveIE = CveIEExcedente Pago.CveMonedaPago = CveMoneda Pago.CvePersonal = CvePersonal If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaExcedente, True, ImporteMovto, ImporteMovto * tipoCambio, 30, Referencia, ConceptoMovimiento, CveIE:=CveIEExcedente, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, ImporteME:=If(tipoCambio = 1, 0, ImporteMovto)) Then MsgError = "no se pudo insertar el detalle de la poliza" End If If UsuarioActual.CveEmpresa.Contiene(7, 11, 12, 122, 145) Then Pago.AplicaAcreditable = False End If If Not AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePolizaPago, ObjMov) Then MsgError = "Detalle" End If 'Otros Ingresos If ChkAjusteOI.Checked Then If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaExcedente, True, gvr.FCTextBox("TxtComision").Text.ToDecimal, gvr.FCTextBox("TxtComision").Text.ToDecimal * tipoCambio, 78, Referencia, ConceptoMovimiento, CveIE:=CveIERegistrado, CvePersonal:=CvePersonal, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, CveSubProyecto:=gvr.DataKey("CveSubProyecto").ToEntero, ImporteME:=If(tipoCambio = 1, 0, gvr.FCTextBox("TxtComision").Text.ToDecimal)) Then MsgError = "no se pudo insertar el detalle de la poliza de otros ingresos" End If End If If MsgError = "" AndAlso ImportePagar = ImporteOriginal Then 'Unificamos el cheque y la caja chica con los pagos y facturas If gvr.DataKey("IdPoliza").ToEntero = 0 AndAlso UsuarioActual.Empresa.Funcionalidad(219) = "1" Then If Not ObjMov.PrePolizaUnificacion(CvePrePolizaExcedente, CvePrePolizaPago) Then MsgError = "No se pudo unificar la prepoliza" Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) Else SeUnifico = True End If If MsgError = "" Then If Not ObjMov.PrePolizaUnificacion(CvePrePolizaExcedente, gvr.DataKey("CvePrePoliza").ToEntero) Then MsgError = "No se pudo unificar la prepoliza" Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) Else SeUnifico = True End If End If End If End If If MsgError <> "" Then Exit For End If End If Next Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" If MsgError = "" AndAlso ObjMov.ValidacionesPrePoliza(CvePrePolizaPago, UsuarioActual, Opcion:=1, AutoConta:=AutoConta) Then If ObjMov.ValorPolizaDescuadre > 0 Then GuardaLogAD($"Compras/ReembolsosComprobaciones | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePolizaPago}", "LogPrePolizas") MsgError = ObjMov.MensajePolizaDescuadre End If End If If MsgError = "" AndAlso CvePrePolizaExcedente > 0 AndAlso ObjMov.ValidacionesPrePoliza(CvePrePolizaExcedente, UsuarioActual, Opcion:=1, AutoConta:=AutoConta) Then If ObjMov.ValorPolizaDescuadre > 0 Then GuardaLogAD($"Compras/ReembolsosComprobaciones | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePolizaExcedente}", "LogPrePolizas") MsgError = ObjMov.MensajePolizaDescuadre End If End If Else MsgError = "No se pudo insertar el encabezado" End If Else MsgError = "No se pudo insertar la póliza" End If If MsgError.Trim = "" Then ObjIE.Commit() UPCompras.Update() Dim Mensaje As New StringBuilder If CvePrePolizaExcedente > 0 Then Mensaje.AppendFormat("Abono Registrado Correctamente.

Cheque: {1}

Imprimir", CveIEExcedente, TxtFolio.Text, Encripta(String.Format("OP=ImprimeMov&CveIE={0}&CvePrePoliza={1}", CveIEExcedente, CvePrePolizaIERegistrado))) If UsuarioActual.Empresa.TipoContabilidad = 2 Then Mensaje.AppendFormat("

Póliza: {1}
", ObjMov.ContaIdPoliza, ObjMov.ContaFolio) Else Mensaje.AppendFormat("

Póliza: {1}
", CvePrePolizaExcedente, ObjMov.ContaFolio) End If Alert(Mensaje.ToString, TipoMensaje.MsgInformacion) Else Mensaje.AppendFormat("Abono Registrado Correctamente.

Imprimir", Encripta(String.Format("OP=ImprimeMov&CveIE={0}&ImportePagoTotal={1}&Saldo={2}", CveIERegistrado, ImportePagoTotal, SaldoAntesPago))) If CvePrePolizaIERegistrado > 0 Then If UsuarioActual.Empresa.TipoContabilidad = 2 Then Mensaje.AppendFormat("

Póliza: {1}
", ObjMov.ContaIdPoliza, ObjMov.ContaFolio) Else Mensaje.AppendFormat("

Póliza: {1}
", CvePrePolizaIERegistrado, ObjMov.ContaFolio) End If End If Alert(Mensaje.ToString, TipoMensaje.MsgInformacion) End If LimpiaDatos() CargaCxP() PnlChequeInfo.Visible = False Else Alert($"Ocurrió un error al guardar el movimiento {MsgError.Trim}", TipoMensaje.MsgError) ObjIE.RollBack() End If ObjIE.Dispose() ObjMov.Dispose() End Sub Protected Function UnificacionSimplificacionPrepolizas(ObjMov As ClsContabilidad, CvePrePolizaNueva As Integer, CvePrePolizaVieja As Integer) As String Dim Retorno As String = "" 'Unificacion de PrePolizas If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then If Not ObjMov.PrePolizaUnificacion(CvePrePolizaNueva, CvePrePolizaVieja) Then Retorno = "No se pudo unificar la prepoliza" Alert("No se pudo unificar la prepoliza", TipoMensaje.MsgError) End If End If Return Retorno End Function Protected Sub LimpiaDatos() TxtFolio.Text = "" TxtObservaciones.Text = "" TxtImporte.Text = "" TxtImporteVinculado.Text = "" TxtFechaDocumento.Text = NowADS().ToShortDateString 'DdlCuenta.SelectedValue = "-1" DdlTipoTransaccion.SelectedValue = "-1" DdlTipoTransaccionDiferencia_SelectedIndexChanged(DdlTipoTransaccion, EventArgs.Empty) ChkReembolsarSinBancos.Checked = False UpDatos.Update() For Each gvr As GridViewRow In GvCxP.Rows gvr.FCCheckBox("Chk").Checked = False gvr.FCTextBox("TxtAbonar").Text = "" gvr.FCTextBox("TxtSaldoExcedente").Text = "" Next UPCompras.Update() End Sub #End Region #Region " REPORTE CHEQUES FYE " Private Sub CargaReporteChequesFYE() If DdlPersonal.SelectedIndex > 0 Then GvChequesFYE.Visible = True Dim ObjMovtos As New ClsMovimientos Dim DtChequesFYE As DataTable = Nothing If ObjMovtos.GetChequesFYE(UsuarioActual.CveEmpresa) Then DtChequesFYE = ObjMovtos.DtResultados Else Alert("Ocurrió un error al cargar el reporte de cheques de Funcionarios/Empleados. Por favor vuelva a intentar.", TipoMensaje.MsgError) DtChequesFYE = New DataTable End If ObjMovtos.Dispose() If DtChequesFYE.Rows.Count > 0 Then GvChequesFYE.DataSource = DtChequesFYE GvChequesFYE.DataBind() UpChequesFYE.Update() End If Else GvChequesFYE.Visible = False End If End Sub Protected Sub GvChequesFYE_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then e.Row.FCHyperLink("HLFYE").NavigateUrl = String.Format("/RH/Personal.aspx?CvePersonal={0}", e.Row.DBCampo("CvePersonal")) 'e.Row.FCHyperLink("HLCheque").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")) End If End Sub #End Region #Region " TABLA CxP " Protected Sub CargaCxP() Dim ObjMovtos As New ClsMovimientos GvCxP.Visible = True ObjMovtos.GetCxPPersonalCajaChica(UsuarioActual.CveEmpresa, CvePersonal, CveCajaChica, If(TxtNumeroReembolso.Text.Trim = "", "-1", TxtNumeroReembolso.Text.Trim), OpcionSaldo:=1) DtDatos = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0") GvCxP.DataSource = DtDatos CvePrePolizaComprobacion = DtDatos.MAX("CvePrePolizaComprobacion").ToEntero 'Limpia Ddl Chequesventas DDlCheques.Items.Clear() 'cargo si tiene cheques pendientes sin amortizar If CvePersonal > 0 Then ObjMovtos.GetEgresosSinComprobarPersonalDetalle(CvePersonal, UsuarioActual.CveEmpresa) CargaCuentas() PnlCheques.Visible = True If UsuarioActual.TienePermisoProceso(113) Then TableExpedirCheque.Visible = True End If If CveCajaChica > 0 Then ObjMovtos.GetCajaChicaDetalle(CveCajaChica, UsuarioActual.CveEmpresa) PnlCheques.Visible = True If UsuarioActual.TienePermisoProceso(113) Then TableExpedirCheque.Visible = True DdlCuenta.Items.Clear() DdlCuenta.Items.Add(New ListItem(DdlCajaChica.SelectedItem.Text, DdlCajaChica.SelectedValue)) End If DtCheques = ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha") If DtCheques.Rows.Count > 0 Then DDlCheques.DataSource = DtCheques End If ObjMovtos.Dispose() GvCxP.DataBind() LnkImprimir.Visible = True NumeroReembolso = TxtNumeroReembolso.Text UpAcciones.Update() DDlCheques.DataBind() If UsuarioActual.TienePermisoProceso(113) Then DDlCheques.Items.Insert(0, New ListItem("Expedir Cheque", "-1")) Else DDlCheques.Items.Insert(0, New ListItem("Seleccione", "-1")) End If DDlCheques_SelectedIndexChanged(DDlCheques, EventArgs.Empty) If GvCxP.Rows.Count > 0 Then TxtFechaDocumento.Text = NowADS().ToShortDateString 'Valida Proceso 120 para ROL Administrador de obra - Si tiene el proceso no puede guardar If Not UsuarioActual.TienePermisoProceso(120) Then BtnIEGuardar.Enabled = True End If If Not DdlPersonal.SelectedValue = "-2" Then TxtAboneA.Text = DdlPersonal.SelectedItem.ToString End If If Not DdlCajaChica.SelectedValue = "-2" Then TxtAboneA.Text = DdlCajaChica.SelectedItem.ToString End If Else TxtAboneA.Text = "" BtnIEGuardar.Enabled = False End If UpDatos.Update() UpGuardar.Update() UPCompras.Update() UPPChq.Update() End Sub Protected Sub GvCxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxP.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.BackColor = Drawing.Color.LightGray e.Row.FCTextBox("TxtAbonar").Visible = False e.Row.FCCheckBox("Chk").Visible = False e.Row.FCTextBox("TxtSaldoExcedente").Visible = False e.Row.FCTextBox("TxtComision").Visible = False End If If e.Row.RowIndex = 1 Then e.Row.Cells(0).Width = Unit.Pixel(20) 'e.Row.Cells(1).Width = Unit.Pixel(70) 'e.Row.Cells(2).Width = Unit.Pixel(250) 'e.Row.Cells(3).Width = Unit.Pixel(70) 'e.Row.Cells(4).Width = Unit.Pixel(80) 'e.Row.Cells(5).Width = Unit.Pixel(40) 'e.Row.Cells(6).Width = Unit.Pixel(80) 'e.Row.Cells(7).Width = Unit.Pixel(70) 'e.Row.Cells(8).Width = Unit.Pixel(70) 'e.Row.Cells(9).Width = Unit.Pixel(80) 'e.Row.Cells(15).Width = Unit.Pixel(80) End If e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(8).HorizontalAlign = HorizontalAlign.Right If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(7).ForeColor = Drawing.Color.Red If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxP" Then e.Row.Cells(5).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Total").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldoTotal"), Literal).Text = "" If e.Row.DBCampo("Abonado").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = "" If e.Row.DBCampo("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = "" If TxtNumeroReembolso.Text = "" Then e.Row.FCCheckBox("Chk").Enabled = False e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"))) e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1); FnSumaExcedente({2},{3},{1});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCTextBox("TxtSaldoExcedente").ClientID, e.Row.FCTextBox("TxtAbonar").ClientID)) e.Row.FCTextBox("TxtSaldoExcedente").Attributes.Add("onblur", String.Format("FnSumaExcedente({0},{1},{2});", e.Row.FCTextBox("TxtSaldoExcedente").ClientID, e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"))) e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"))) e.Row.FCRangeValidator("RVComision").MinimumValue = "0" e.Row.FCRangeValidator("RVComision").MaximumValue = e.Row.DBCampo("Saldo") End If End Sub #End Region #Region " APLICA DIFERENCIA " Protected Sub ChkChequeExcedente_CheckedChanged(sender As Object, e As EventArgs) If ChkChequeExcedente.Checked Then If UsuarioActual.TienePermisoProceso(113) Then TableExpedirCheque.Visible = True Else LimpiaDatos() TxtImporteVinculado.Text = "" TableExpedirCheque.Visible = False End If End Sub Protected Sub BtnDiferencia_Click(sender As Object, e As EventArgs) TxtImporteVinculado.Text = HdnSaldo.Value If HdnSaldoDiferencia.Value.ToDouble > 0 AndAlso ChkChequeExcedente.Checked Then TxtImporte.Text = HdnSaldoDiferencia.Value End If End Sub Protected Sub DdlCuentaDiferencia_SelectedIndexChanged(sender As Object, e As EventArgs) 'Handles DdlCuentaDiferencia.SelectedIndexChanged 'recargo la moneda con la que se va a pagar 'Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta = " & DdlCuentaDiferencia.SelectedValue) 'If dr IsNot Nothing Then ' CveMoneda = dr("CveMoneda").ToString.ToEntero 'End If 'If HdnTipoTransaccion.Value = "Egs" Then ' Dim Folio As Long ' Dim Banco As New ClsBancos ' Folio = Banco.GetNextFolio(DdlCuentaDiferencia.SelectedValue.ToEntero, DdlTipoTransaccionDiferencia.SelectedValue.ToEntero) ' Banco.Dispose() ' TxtFolioDiferencia.Text = Folio.ToString 'Else ' TxtFolioDiferencia.Text = "" 'End If End Sub Protected Sub DdlTipoTransaccionDiferencia_SelectedIndexChanged(sender As Object, e As EventArgs) 'Handles DdlTipoTransaccionDiferencia.SelectedIndexChanged 'Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccionDiferencia.SelectedValue)) 'If dr IsNot Nothing Then ' HdnTipoTransaccionDiferencia.Value = dr("Tipo").ToString 'End If 'CargaCuentasDiferencia() End Sub Private Sub CargaCuentasDiferencia() 'DdlCuentaDiferencia.Items.Clear() 'Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario) 'dt = dt.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = {1}", 1, DdlTipoTransaccion.SelectedValue)) 'DdlCuentaDiferencia.DataSource = dt 'DdlCuentaDiferencia.DataBind() 'DdlCuentaDiferencia.Items.Insert(0, New ListItem("Seleccione cuenta", "-1")) End Sub #End Region #Region " EXPORTAR - PDF - EXCEL " Protected Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click 'GvCxP.Columns(0).Visible = False 'GvCxP.Columns(9).Visible = False 'GvCxP.ExportToExcel("Reembolsos - Comprobaciones ") 'GvCxP.Columns(0).Visible = True 'GvCxP.Columns(9).Visible = True Imprimir("EXCEL") End Sub #End Region Protected Sub LnkImprimir_Click(sender As Object, e As EventArgs) Handles LnkImprimir.Click Imprimir("PDF") End Sub Private Sub Imprimir(Formato As String) Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos\Reembolso.rdlc", UsuarioActual.Empresa.Ruta)) Dim Imagen As New System.IO.FileInfo(String.Format("{0}Logo.png", UsuarioActual.Empresa.Ruta)) Dim params As New List(Of ReportParameter) If Archivo.Exists Then If UsuarioActual.CveEmpresa = 72 Then params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToString)) params.Add(New ReportParameter("CveCajaChica", CveCajaChica.ToString)) params.Add(New ReportParameter("CveFyE", CvePersonal.ToString)) params.Add(New ReportParameter("CajaChica", If(DdlCajaChica.SelectedValue.ToEntero > 0, "Caja chica: " & DdlCajaChica.SelectedItem.Text, "Funcionario/Empleado: " & DdlPersonal.SelectedItem.Text))) ImprimirPDF(String.Format("{0}Formatos\Reembolso.rdlc", UsuarioActual.Empresa.Ruta), DtDatos, params, "RepRembolsosComprobaciones", Formato:=Formato) Else params.Add(New ReportParameter("Numero", NumeroReembolso)) params.Add(New ReportParameter("Anio", DtDatos.FiltraParametros("CveCompra > 0").MAX("Fecha").ToDate.Year.ToString)) params.Add(New ReportParameter("Nombre", DtDatos.MAX("SubProyecto"))) params.Add(New ReportParameter("Fecha", NowADS().Date.ToString)) params.Add(New ReportParameter("Elaboro", "")) params.Add(New ReportParameter("Autorizo", "")) params.Add(New ReportParameter("ElaboroPuesto", "")) params.Add(New ReportParameter("AutorizoPuesto", "")) ImprimirPDF(String.Format("{0}Formatos\Reembolso.rdlc", UsuarioActual.Empresa.Ruta), DtDatos.FiltraParametros("CveCompra > 0"), params, "Reembolso", RDSName:="DsCompras") End If Else params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToString)) params.Add(New ReportParameter("CajaChica", If(DdlCajaChica.SelectedValue.ToEntero > 0, "Caja chica: " & DdlCajaChica.SelectedItem.Text, "Funcionario/Empleado: " & DdlPersonal.SelectedItem.Text))) params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) ImprimirPDF("Empresas/Grales/Formatos/RepRembolsosComprobaciones.rdlc", DtDatos, params, "RepRembolsosComprobaciones", Formato:=Formato) End If End Sub Private Sub CbPermitirExcedente_CheckedChanged(sender As Object, e As EventArgs) Handles CbPermitirExcedente.CheckedChanged If CbPermitirExcedente.Checked = True Then HdnExcedente.Value = "1" DDlPermitirExcedente.Visible = True GvCxP.Columns(10).Visible = True Else HdnExcedente.Value = "0" GvCxP.Columns(10).Visible = False DDlPermitirExcedente.Visible = False End If UPCompras.Update() UpDatos.Update() End Sub #Region "VIATICOS" Protected Sub ChkAplicaViatico_CheckedChanged(sender As Object, e As EventArgs) ' If ChkAplicaViatico.Checked Then ' Dim Retorno = TimbrarNomina12(DdlPersonal.SelectedValue.ToEntero) ' If Retorno <> "" Then ' Alert(Retorno, TipoMensaje.MsgError) ' Else ' Dim SerieFolio = $"VIA-{Folio}" ' Dim Msg As New StringBuilder ' Msg.AppendFormat("", Encripta(String.Format("OP=DesXmlVIA&SERIEFOLIO={0}&TIPO={1}", SerieFolio, "Viaticos Comprobados"))) ' Alert(Msg.ToString) ' End If ' End If End Sub #End Region #Region "REEMBOLSAR SIN BANCOS" Protected Sub ChkReembolsarSinBancos_CheckedChanged(sender As Object, e As EventArgs) If ChkReembolsarSinBancos.Checked Then DDlCheques.Enabled = False TableExpedirCheque.Visible = False Else DDlCheques.Enabled = True TableExpedirCheque.Visible = True End If UpDatos.Update() End Sub #End Region Private Sub RVTxtFechaDocumento_Init(sender As Object, e As EventArgs) Handles RVTxtFechaDocumento.Init RVTxtFechaDocumento.MaximumValue = NowADS().ToShortDateString Calendario.EndDate = NowADS() End Sub End Class