Commit inicial Ventas Productivo
This commit is contained in:
330
Bancos/CreditosPagoMultiple.aspx.vb
Normal file
330
Bancos/CreditosPagoMultiple.aspx.vb
Normal file
@@ -0,0 +1,330 @@
|
||||
Imports Extensiones
|
||||
Imports System.Data
|
||||
|
||||
Partial Class Bancos_CreditosPagoMultiple
|
||||
Inherits ClsPaginas
|
||||
|
||||
Private Property CveProveedor As Integer
|
||||
Get
|
||||
Return ViewState("CveProveedor").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveProveedor") = value
|
||||
End Set
|
||||
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
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
|
||||
If Not Page.IsPostBack Then
|
||||
CveMoneda = 1
|
||||
CargaTipoTransaccion()
|
||||
CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
|
||||
TxtFechaDocumento.Text = Now.ToShortDateString
|
||||
CargaProveedores() ' CveProveedor = 19994
|
||||
|
||||
TxtPagueseA.Enabled = False
|
||||
|
||||
TxtImporte.Attributes.Add("disabled", "disabled")
|
||||
If DdlTipoTransaccion.SelectedValue = "1" Then RFVFolio.Enabled = True Else RFVFolio.Enabled = False
|
||||
'TxtNotificarA.Text = ObjProveedor.NotificarA.Trim
|
||||
|
||||
|
||||
CargaDatos()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargaProveedores()
|
||||
|
||||
DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
||||
DdlProveedor.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
|
||||
|
||||
Dim Bancos As New ClsBancos
|
||||
|
||||
If Bancos.GetCreditosVencimiento(UsuarioActual.CveEmpresa, DdlProveedor.SelectedValue.ToEntero) Then
|
||||
|
||||
GvV.DataSource = Bancos.DtResultados
|
||||
|
||||
TxtPagueseA.Text = DdlProveedor.SelectedItem.Text
|
||||
|
||||
End If
|
||||
|
||||
Bancos.Dispose()
|
||||
GvV.DataBind()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CargaCuentas(tTipoTransaccion As Integer)
|
||||
DdlCuenta.Items.Clear()
|
||||
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario)
|
||||
If CveMoneda > 0 Then
|
||||
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda))
|
||||
|
||||
End If
|
||||
|
||||
|
||||
'cuando es layout
|
||||
If tTipoTransaccion = 9 Then
|
||||
dt = dt.FiltraParametros("UsaLayout = 1")
|
||||
End If
|
||||
|
||||
|
||||
DdlCuenta.DataSource = dt
|
||||
DdlCuenta.DataBind()
|
||||
DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1"))
|
||||
End Sub
|
||||
|
||||
Private Sub CargaTipoTransaccion()
|
||||
|
||||
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs'")
|
||||
DdlTipoTransaccion.DataBind()
|
||||
|
||||
|
||||
If DdlTipoTransaccion.Items.Count > 1 Then DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCuentasDepositos()
|
||||
DdlCuentaDeposito.Items.Clear()
|
||||
If DdlTipoTransaccion.SelectedValue.Contiene("2", "9") Then ' transferencias y layout
|
||||
trCuentaDeposito.Visible = False
|
||||
|
||||
Dim Dep As New ClsGenerales
|
||||
If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor) Then
|
||||
DdlCuentaDeposito.DataSource = Dep.DtResultados
|
||||
'GVCuentasPago.DataSource = Dep.DtResultados
|
||||
If Dep.DtResultados.Rows.Count > 1 Then
|
||||
trCuentaDeposito.Visible = True
|
||||
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
||||
|
||||
|
||||
'Si tiene seleccionado Tipo Mov: Layout y no tiene cuenta deposito
|
||||
ElseIf DdlTipoTransaccion.SelectedValue = "9" AndAlso Not Dep.DtResultados.Rows.Count > 0 Then
|
||||
BtnIEGuardar.Enabled = False
|
||||
UpGuardar.Update()
|
||||
Alert("El proveedor no tiene cuenta deposito", TipoMensaje.MsgError)
|
||||
End If
|
||||
End If
|
||||
Dep.Dispose()
|
||||
|
||||
'If DdlTipoTransaccion.SelectedValue = "9" AndAlso DdlCuentaDeposito.Items.Count = 0 Then
|
||||
' BtnIEGuardar.Enabled = False
|
||||
'End If
|
||||
|
||||
'GVCuentasPago.DataBind()
|
||||
DdlCuentaDeposito.DataBind()
|
||||
|
||||
Else
|
||||
trCuentaDeposito.Visible = False
|
||||
DdlCuentaDeposito.Items.Clear()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
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).FiltroPrimero("CveCuenta = " & DdlCuenta.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(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
|
||||
'cuando es cheque
|
||||
If DdlTipoTransaccion.SelectedValue = "1" Then
|
||||
ChkAbonoCuenta.Visible = True
|
||||
Else
|
||||
ChkAbonoCuenta.Visible = False
|
||||
End If
|
||||
|
||||
|
||||
|
||||
CargaCuentas(DdlTipoTransaccion.SelectedValue.ToEntero)
|
||||
RecargaCuentasDepositos()
|
||||
End Sub
|
||||
|
||||
Private Sub RecargaCuentasDepositos()
|
||||
|
||||
Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
|
||||
If dr IsNot Nothing Then
|
||||
HdnTipoTransaccion.Value = dr("Tipo").ToString
|
||||
End If
|
||||
'cuando es transferencia bancaria, debe de solicitar a que cuenta se va a depositar
|
||||
CargaCuentasDepositos()
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
|
||||
Dim Total As Double = 0
|
||||
For Each gvr As GridViewRow In GvV.Rows
|
||||
If gvr.FCCheckBox("Chk").Checked Then
|
||||
Total += gvr.DataKey("Total").ToDouble
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
If Total <= 0 Then
|
||||
Alert("Debe ingresar un importe", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
Dim ObjIE As New ClsBancos()
|
||||
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
||||
|
||||
|
||||
Dim MsgError As String = ""
|
||||
Dim CveConceptoContable As Integer = 30
|
||||
Dim CveConceptoCompra As Integer = 48
|
||||
' Dim CveCreditoDetalle As Integer = -1
|
||||
Dim CIF As Double = 0
|
||||
Dim CvePlantillaPoliza As Integer = 5
|
||||
Dim TC As Double = 1.0
|
||||
Dim Estatus As Integer = 2
|
||||
Dim CveCreditoDetalle As Integer
|
||||
|
||||
|
||||
Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
|
||||
Dim filemove As String = ""
|
||||
Dim Comprobante 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
|
||||
|
||||
|
||||
Dim CveIE As Integer = -1
|
||||
|
||||
If CveIE = -1 Then
|
||||
|
||||
Dim CveCuentaDeposito As Integer = 0
|
||||
|
||||
If DdlCuentaDeposito.Items.Count > 0 Then
|
||||
CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero
|
||||
End If
|
||||
|
||||
|
||||
Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Banc", CvePlantillaPoliza, Total, Total, CveMoneda, TxtFechaDocumento.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
|
||||
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, Total, CveMoneda,
|
||||
TC, TxtObservaciones.Text.Trim, TxtNotificarA.Text.Trim, ChkAbonoCuenta.Checked, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaDeposito:=CveCuentaDeposito)
|
||||
|
||||
|
||||
If CveIE > 0 Then
|
||||
|
||||
If CvePrePoliza > 0 Then
|
||||
|
||||
'inserto el moviminto de banco
|
||||
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Total, TxtObservaciones.Text, CveConceptoContable, TxtObservaciones.Text, Now, 0, -1, CveIE, CveProveedor:=CveProveedor) Then
|
||||
|
||||
|
||||
For Each gvr As GridViewRow In GvV.Rows
|
||||
If gvr.FCCheckBox("Chk").Checked Then
|
||||
|
||||
CveCreditoDetalle = gvr.DataKey("CveCreditoDetalle").ToEntero()
|
||||
|
||||
If gvr.DataKey("CveTipoCredito") = "1" Then
|
||||
Estatus = 103
|
||||
'cuando es crediproveedores es, pago a documentos por pagar
|
||||
CveConceptoCompra = 57
|
||||
End If
|
||||
ObjIE.UpdateCreditosDetalle(Estatus, CveCreditoDetalle)
|
||||
|
||||
|
||||
Dim IVA As Double = 0 ' TxtImporte.Text.ToDouble * HdnProvPorIVA.Value.ToDouble
|
||||
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, gvr.DataKey("Total").ToDouble - IVA - CIF, TxtObservaciones.Text, CveConceptoCompra, TxtObservaciones.Text, Now, 0, -1, CveIE, CveProveedor:=CveProveedor, CveCreditoDetalle:=CveCreditoDetalle) Then
|
||||
If IVA > 0 AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, IVA, TxtObservaciones.Text, 19, TxtObservaciones.Text, Now, 0, -1, CveIE, CveProveedor:=CveProveedor, CveCreditoDetalle:=CveCreditoDetalle) Then
|
||||
MsgError = "Detalle"
|
||||
End If
|
||||
|
||||
'intereses pagados
|
||||
If CIF > 0 AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, CIF, TxtObservaciones.Text, 46, TxtObservaciones.Text, Now, 0, -1, CveIE, CveProveedor:=CveProveedor, CveCreditoDetalle:=CveCreditoDetalle) Then
|
||||
MsgError = "Detalle"
|
||||
End If
|
||||
|
||||
Else
|
||||
MsgError = "no se pudo insertar el detalle de la póliza2"
|
||||
End If
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
Else
|
||||
MsgError = "no se pudo insertar el detalle de la póliza"
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
MsgError = "No se insertó el encabezado"
|
||||
End If
|
||||
|
||||
Else
|
||||
'If ObjIE.UpdateBancos_IE(DdlTipo.SelectedItem.ToString, DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, TxtImporte.Text.Trim.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtTipoCambio.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, ChkEsAbonoEnCuenta.Checked, ChkAplicaImpuestos.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
Alert("El Documento se guardó correctamente. ", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/CreditosPagoMultiple.aspx"";")
|
||||
'End If
|
||||
' 'CargaDatos()
|
||||
' UpDatos.Update()
|
||||
' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
||||
'End If
|
||||
End If
|
||||
|
||||
If MsgError = "" Then
|
||||
Alert("El Documento se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/CreditosPagoMultiple.aspx"";")
|
||||
|
||||
If filemove <> "" Then
|
||||
filemove.FilesMove(CveIE.ToString, String.Format("Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta))
|
||||
End If
|
||||
ObjIE.Commit()
|
||||
GeneraChequePDF(CveIE, UsuarioActual.Empresa)
|
||||
Else
|
||||
ObjIE.RollBack()
|
||||
End If
|
||||
ObjIE.Dispose()
|
||||
ObjMov.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub GvV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvV.RowDataBound
|
||||
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0});", e.Row.DBCampo("Total")))
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlProveedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedor.SelectedIndexChanged
|
||||
CargaDatos()
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user