1035 lines
45 KiB
C#
1035 lines
45 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
using static Extensiones.ModExtensiones;
|
|
|
|
public partial class Bancos_PagoDeudor : ClsPaginas
|
|
{
|
|
#region "PROPIEDADES"
|
|
private int IDCtaContableDeudor
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableDeudor"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableDeudor"] = value;
|
|
}
|
|
}
|
|
private int IDCtaContableDeudorExtranjera
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableDeudorExtranjera"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableDeudorExtranjera"] = value;
|
|
}
|
|
}
|
|
private int IDCtaContableDeudorComplementaria
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableDeudorComplementaria"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableDeudorComplementaria"] = value;
|
|
}
|
|
}
|
|
private bool UsaComplementaria
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToBoolean(ViewState["UsaComplementaria"]);
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["UsaComplementaria"] = value;
|
|
}
|
|
}
|
|
private int IDCtaContableBancos
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableBancos"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableBancos"] = value;
|
|
}
|
|
}
|
|
private int IDCtaContableBancosComplementario
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableBancosComplementario"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableBancosComplementario"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private int IDCtaContableBancosPrestamo
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableBancosPrestamo"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableBancosPrestamo"] = value;
|
|
}
|
|
}
|
|
private int IDCtaContableBancosComplementariaPrestamo
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableBancosComplementariaPrestamo"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableBancosComplementariaPrestamo"] = value;
|
|
}
|
|
}
|
|
|
|
private int IDCtaContableDeudorPrestamo
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableDeudorPrestamo"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableDeudorPrestamo"] = value;
|
|
}
|
|
}
|
|
private int IDCtaContableDeudorCompPrestamo
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableDeudorCompPrestamo"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableDeudorCompPrestamo"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveMonedaPrestamo
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveMonedaPrestamo"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveMonedaPrestamo"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
|
|
CargaTipoTransaccion();
|
|
CargaCuentas();
|
|
CargaProveedores();
|
|
CargaReporte();
|
|
CargaSubproyectos();
|
|
CveMonedaPrestamo = 1;
|
|
UsaComplementaria = false;
|
|
if (UsuarioActual.CveEmpresa.Contiene(1, 119)) { UsaComplementaria = true; }
|
|
TxtFechaDocumento.Text = DateTime.Now.ToShortDateString();
|
|
TxtFechaPrestamo.Text = DateTime.Now.ToShortDateString();
|
|
txtFechaI.Text = DateTime.Now.FirstDayOfMonth().ToShortDateString();
|
|
txtFechaF.Text = DateTime.Now.ToShortDateString();
|
|
TxtTCDolaresPrestamo.Text = get_GlobalTipoCambio(TxtFechaPrestamo.Text.ToDateTime()).FormatoNumero(4);
|
|
TxtTCDolaresPago.Text = get_GlobalTipoCambio(TxtFechaDocumento.Text.ToDateTime()).FormatoNumero(4);
|
|
TxtImporte.Attributes.Add("disabled", "disabled");
|
|
}
|
|
}
|
|
|
|
private void CargaSubproyectos()
|
|
{
|
|
|
|
DdlSubProyecto.DataSource = get_GlobalDTSubProyectos(-1, CveEmpresa: UsuarioActual.CveEmpresa);
|
|
DdlSubProyecto.DataBind();
|
|
|
|
DdlSubProyecto.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
|
|
DdlSubProyectoPago.DataSource = get_GlobalDTSubProyectos(-1, CveEmpresa: UsuarioActual.CveEmpresa);
|
|
DdlSubProyectoPago.DataBind();
|
|
|
|
DdlSubProyectoPago.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
|
|
|
|
|
|
}
|
|
|
|
#region"INFORMACION GENERAL"
|
|
protected void CargaTipoTransaccion()
|
|
{
|
|
DdlTipoTransaccion.Items.Clear();
|
|
DdlTipoTransaccionPrestamo.Items.Clear();
|
|
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing'");
|
|
DdlTipoTransaccionPrestamo.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Egs'");
|
|
|
|
DdlTipoTransaccion.DataBind();
|
|
DdlTipoTransaccionPrestamo.DataBind();
|
|
|
|
DdlTipoTransaccion.Items.Insert(0, new ListItem("Seleccione Tipo Movimiento", "-1"));
|
|
DdlTipoTransaccionPrestamo.Items.Insert(0, new ListItem("Seleccione Tipo Movimiento", "-1"));
|
|
}
|
|
|
|
protected void CargaCuentas()
|
|
{
|
|
DdlCuenta.Items.Clear();
|
|
DdlCuentaPrestamo.Items.Clear();
|
|
|
|
DdlCuenta.DataSource = get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros("CveTipoCuenta <> 1"); //quito las cajas chicas
|
|
DdlCuentaPrestamo.DataSource = get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros("CveTipoCuenta <> 1");
|
|
|
|
DdlCuenta.DataBind();
|
|
DdlCuentaPrestamo.DataBind();
|
|
|
|
DdlCuenta.Items.Insert(0, new ListItem("Seleccione Cuenta", "-1"));
|
|
DdlCuentaPrestamo.Items.Insert(0, new ListItem("Seleccione Cuenta", "-1"));
|
|
}
|
|
|
|
protected void CargaProveedores()
|
|
{
|
|
DdlProveedores.setEsWebService(true);
|
|
DdlProveedorPrestamo.setEsWebService(true);
|
|
DdlProveedorAuxiliar.setEsWebService(true);
|
|
|
|
DdlProveedores.Attributes.Add("data-metodo", "getproveedores");
|
|
DdlProveedorPrestamo.Attributes.Add("data-metodo", "getproveedores");
|
|
DdlProveedorAuxiliar.Attributes.Add("data-metodo", "getproveedores");
|
|
}
|
|
|
|
protected void CambiaTipoMoneda()
|
|
{
|
|
if (DivTCDolaresPrestamo1.Visible)
|
|
{
|
|
TxtTCDolaresPrestamo.Text = get_GlobalTipoCambio(TxtFechaPrestamo.Text.ToDateTime()).FormatoNumero(4);
|
|
}
|
|
UpPrestamo.Update();
|
|
}
|
|
|
|
protected void CambiaTipoMonedaP()
|
|
{
|
|
if (DivTCDolaresPago.Visible)
|
|
{
|
|
TxtTCDolaresPago.Text = get_GlobalTipoCambio(TxtFechaDocumento.Text.ToDateTime()).FormatoNumero(4);
|
|
RegistraScript(String.Format("FnCambia({0},this,{1},2,'{2}',{3});", 0, 0, "", HdnMonPago.Value));
|
|
}
|
|
UpDatos.Update();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region "PRESTAMO DEUDORES"
|
|
protected void BtnCambiaTipoMoneda_Click(object sender, EventArgs e)
|
|
{
|
|
CambiaTipoMoneda();
|
|
}
|
|
|
|
protected void DdlCuentaPrestamo_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
int idcuenta, idcuentaComp;
|
|
Int32.TryParse(get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("IdCtaContable", String.Format("CveCuenta = {0}", DdlCuentaPrestamo.SelectedValue)), out idcuenta);
|
|
Int32.TryParse(get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("IdCtaContableComplementaria", String.Format("CveCuenta = {0}", DdlCuentaPrestamo.SelectedValue)), out idcuentaComp);
|
|
IDCtaContableBancosPrestamo = idcuenta;
|
|
IDCtaContableBancosComplementariaPrestamo = idcuentaComp;
|
|
|
|
long Folio;
|
|
ClsBancos bancos = new ClsBancos();
|
|
Folio = bancos.GetNextFolio(DdlCuentaPrestamo.SelectedValue.ToEntero(), DdlTipoTransaccionPrestamo.SelectedValue.ToEntero());
|
|
bancos.Dispose();
|
|
TxtFolioPrestamo.Text = Folio.ToString();
|
|
|
|
|
|
CveMonedaPrestamo = get_GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuentaPrestamo.SelectedValue.ToEntero()}").ToEntero();
|
|
|
|
if (CveMonedaPrestamo == 2)
|
|
{
|
|
TxtFechaPrestamo.Attributes.Add("onchange", "CambiaTC(this);");
|
|
DivTCDolaresPrestamo1.Visible = true;
|
|
DivTCDolaresPrestamo2.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
TxtFechaPrestamo.Attributes.Remove("onchange");
|
|
DivTCDolaresPrestamo1.Visible = false;
|
|
DivTCDolaresPrestamo2.Visible = false;
|
|
|
|
}
|
|
|
|
UpPrestamo.Update();
|
|
}
|
|
|
|
protected void DdlProveedorPrestamo_selectedindexchange(object sender, EventArgs e)
|
|
{
|
|
ClsCompProveedores proveedores = new ClsCompProveedores();
|
|
|
|
if (DdlProveedorPrestamo.SelectedValue.ToEntero() > 0)
|
|
{
|
|
if (proveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, DdlProveedorPrestamo.SelectedValue.ToEntero(), "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, UsuarioActual.CveEmpresa))
|
|
{
|
|
IDCtaContableDeudorPrestamo = proveedores.IdCtaContDeudor;
|
|
IDCtaContableDeudorCompPrestamo = proveedores.IdCtaContDeudorComplementaria;
|
|
}
|
|
}
|
|
proveedores.Dispose();
|
|
}
|
|
|
|
protected void BtnGuardarPrestamo_Click(object sender, EventArgs e)
|
|
{
|
|
ClsBancos ObjIE = new ClsBancos();
|
|
ClsContabilidad ObjMov = new ClsContabilidad(ObjIE.IniciaTransacSQL());
|
|
ClsCompras ObjComp = new ClsCompras(ObjIE.IniciaTransacSQL());
|
|
|
|
string MsgError = "";
|
|
int CveIE = 0;
|
|
int CveConceptoContableBanco = 30;
|
|
int CveConceptoContablePrestamo = 43;
|
|
int CvePlantillaPoliza = 45;
|
|
int CvePrePoliza = 0;
|
|
int FolioFijo = 0;
|
|
int IDPoliza = 0;
|
|
decimal tipoCambio = (CveMonedaPrestamo == 2) ? TxtTCDolaresPrestamo.Text.ToDecimal() : 1;
|
|
StringBuilder Msg = new StringBuilder();
|
|
|
|
//OBTIENE COMPROBANTE !!
|
|
string Comprobante = "";
|
|
List<Archivo> filesgral = AnexoPrestamo.getfiles().Archivos;
|
|
string filemove = "";
|
|
|
|
foreach (Archivo fileItem in filesgral)
|
|
{
|
|
Comprobante = System.IO.Path.GetExtension(string.Format(@"{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "");
|
|
filemove = fileItem.filename;
|
|
}
|
|
|
|
// DATOS PREPOLIZA
|
|
if ((DdlTipoTransaccionPrestamo.SelectedValue == "1"))
|
|
FolioFijo = TxtFolioPrestamo.Text.ToEntero();
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Bancos/IE PRESTAMO DEUDORES", CvePlantillaPoliza, TxtImportePrestamo.Text.Trim().ToDouble(), TxtImportePrestamo.Text.Trim().ToDouble(), CveMonedaPrestamo, TxtFechaPrestamo.Text.ToDate(), DdlProveedorPrestamo.SelectedText.ToString(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransaccionPrestamo.SelectedValue, "-1", UsuarioActual.CveEmpresa));
|
|
|
|
if (CvePrePoliza > 0)
|
|
{
|
|
string Conc = TxtObservacionesPrestamo.Text == "" ? TxtFolioPrestamo.Text : TxtObservacionesPrestamo.Text;
|
|
string Ref = TxtObservacionesPrestamo.Text == "" ? TxtFolioPrestamo.Text : TxtObservacionesPrestamo.Text;
|
|
|
|
CveIE = ObjIE.AddBancos_IE(DdlCuentaPrestamo.SelectedValue.ToEntero(), DdlTipoTransaccionPrestamo.SelectedValue.ToEntero(), TxtFechaPrestamo.Text.Trim().ToDate(), TxtFolioPrestamo.Text.Trim(), DdlProveedorPrestamo.SelectedText.ToString(),
|
|
TxtImportePrestamo.Text.Trim().ToDouble(), CveMonedaPrestamo, tipoCambio.ToString().ToDouble(), TxtObservacionesPrestamo.Text.Trim(), "", false, false, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
|
|
|
|
if (CveIE > 0)
|
|
{
|
|
//GUARDA COMPROBANTE
|
|
if (!filemove.Equals(""))
|
|
{
|
|
filemove.FilesMove(CveIE.ToString(), string.Format(@"Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta));
|
|
}
|
|
|
|
// SI ES DOLARES
|
|
if(CveMonedaPrestamo == 2)
|
|
{
|
|
// BANCOS - BANCOS COMPLEMENTARIA
|
|
if (UsaComplementaria)
|
|
{
|
|
// BANCOS - COMPLEMENTARIA
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true,0, Ref, 204, Conc, DateTime.Now, IDCtaContableBancosComplementariaPrestamo, -1, CveIE, CveProveedor: DdlProveedorPrestamo.SelectedValue.ToEntero(), ImporteMX: (TxtImportePrestamo.Text.ToDecimal() * tipoCambio) - TxtImportePrestamo.Text.ToDecimal(), ImporteME: TxtImportePrestamo.Text.ToDecimal(), TipoCambio:tipoCambio, CveSubProyecto:DdlSubProyecto.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de bancos complementaria";
|
|
}
|
|
|
|
// BANCOS
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true, TxtImportePrestamo.Text.ToDecimal(), Ref, CveConceptoContableBanco, Conc, DateTime.Now, IDCtaContableBancosPrestamo, -1, CveIE, CveProveedor: DdlProveedorPrestamo.SelectedValue.ToEntero(), ImporteMX: TxtImportePrestamo.Text.ToDecimal(), ImporteME: TxtImportePrestamo.Text.ToDecimal(), TipoCambio: tipoCambio, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de bancos";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// BANCOS
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true, TxtImportePrestamo.Text.ToDecimal(), Ref, CveConceptoContableBanco, Conc, DateTime.Now, IDCtaContableBancosPrestamo, -1, CveIE, CveProveedor: DdlProveedorPrestamo.SelectedValue.ToEntero(), ImporteMX: TxtImportePrestamo.Text.ToDecimal() * tipoCambio, ImporteME: TxtImportePrestamo.Text.ToDecimal(), TipoCambio: tipoCambio, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de bancos";
|
|
}
|
|
}
|
|
|
|
// DEUDORES - DEUDORES COMPLEMENTARIA
|
|
if (UsaComplementaria) //(IDCtaContableDeudorCompPrestamo > 0)
|
|
{
|
|
// DEUDOR COMPLEMENTARIA
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, false,0, Ref, 256, Conc, DateTime.Now, IDCtaContableDeudorCompPrestamo, -1, CveIE, CveProveedor: DdlProveedorPrestamo.SelectedValue.ToEntero(), ImporteMX: (TxtImportePrestamo.Text.ToDecimal() * tipoCambio) - TxtImportePrestamo.Text.ToDecimal(), ImporteME: TxtImportePrestamo.Text.ToDecimal(),TipoCambio:tipoCambio, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de deudor complementaria";
|
|
}
|
|
|
|
// DEUDOR
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, false, TxtImportePrestamo.Text.ToDecimal(), Ref, CveConceptoContablePrestamo, Conc, DateTime.Now, IDCtaContableDeudorPrestamo, -1, CveIE, CveProveedor: DdlProveedorPrestamo.SelectedValue.ToEntero(), ImporteMX: TxtImportePrestamo.Text.ToDecimal(), ImporteME: TxtImportePrestamo.Text.ToDecimal(), TipoCambio: tipoCambio, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de deudor";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// DEUDOR
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, false, TxtImportePrestamo.Text.ToDecimal(), Ref, CveConceptoContablePrestamo, Conc, DateTime.Now, IDCtaContableDeudorPrestamo, -1, CveIE, CveProveedor: DdlProveedorPrestamo.SelectedValue.ToEntero(), ImporteMX: TxtImportePrestamo.Text.ToDecimal() * tipoCambio, ImporteME: TxtImportePrestamo.Text.ToDecimal(), TipoCambio: tipoCambio, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de deudor";
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
// BANCOS
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true, TxtImportePrestamo.Text.ToDecimal(), Ref, CveConceptoContableBanco, Conc, DateTime.Now, IDCtaContableBancosPrestamo, -1, CveIE, CveProveedor: DdlProveedorPrestamo.SelectedValue.ToEntero(), ImporteMX: TxtImportePrestamo.Text.ToDecimal(), TipoCambio: tipoCambio, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de bancos";
|
|
}
|
|
|
|
// DEUDOR
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, false, TxtImportePrestamo.Text.ToDecimal(), Ref, CveConceptoContablePrestamo, Conc, DateTime.Now, IDCtaContableDeudorPrestamo, -1, CveIE, CveProveedor: DdlProveedorPrestamo.SelectedValue.ToEntero(), ImporteMX: TxtImportePrestamo.Text.ToDecimal(), TipoCambio: tipoCambio, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de deudor";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MsgError = "No se insertó el encabezado";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MsgError = "No se pudo insertar la póliza";
|
|
}
|
|
|
|
if (ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1))
|
|
{
|
|
if (ObjMov.ValorPolizaDescuadre > 0)
|
|
{
|
|
$"Bancos/IE PAGO Deudor | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}".GuardaLogAD( "LogPrePolizas");
|
|
}
|
|
}
|
|
|
|
bool AutoConta = UsuarioActual.Empresa.Funcionalidad(200).Equals("1");
|
|
// if (UsuarioActual.CveEmpresa == 119) AutoConta = false;
|
|
|
|
if (AutoConta && MsgError.Equals(""))
|
|
{
|
|
//JJMQ:20190103: Cambio la siguiente linea porque esta validando siempre una complementaria aunque el movto sea dlls
|
|
//if (IDCtaContableDeudorPrestamo > 0 && IDCtaContableBancosPrestamo > 0 && IDCtaContableBancosComplementariaPrestamo > 0 && IDCtaContableDeudorCompPrestamo > 0)
|
|
//Y se valida la moneda con el siguiente IF
|
|
|
|
bool ValidoComplementaria = false;
|
|
if ((CveMonedaPrestamo == 2 && IDCtaContableBancosComplementariaPrestamo > 0 && IDCtaContableDeudorCompPrestamo > 0) || CveMonedaPrestamo == 1)
|
|
{ ValidoComplementaria = true; }
|
|
|
|
if (IDCtaContableDeudorPrestamo > 0 && IDCtaContableBancosPrestamo > 0 && ValidoComplementaria)
|
|
{
|
|
if (ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa))
|
|
{
|
|
IDPoliza = ObjMov.ContaIdPoliza;
|
|
}
|
|
else
|
|
{
|
|
Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IDCtaContableDeudorPrestamo < 1)
|
|
{
|
|
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta de Deudor es invalida", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
if (IDCtaContableDeudorCompPrestamo < 1)
|
|
{
|
|
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta de Deudor complementaria es invalida", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
if (IDCtaContableBancosPrestamo < 1)
|
|
{
|
|
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta bancaria es invalida", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
if (IDCtaContableBancosComplementariaPrestamo < 1)
|
|
{
|
|
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta bancaria complementaria es invalida", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (MsgError.Equals(""))
|
|
{
|
|
if (Msg.ToString().Equals(""))
|
|
{
|
|
Msg.Append("El Documento se guardo correctamente");
|
|
}
|
|
System.IO.FileInfo archivo = null;
|
|
|
|
if (DdlTipoTransaccionPrestamo.SelectedValue.ToEntero().Contiene(2, 8, 9))
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format("{0}Formatos/Transferencia.rdlc", UsuarioActual.Empresa.Ruta));
|
|
}
|
|
else if (DdlTipoTransaccionPrestamo.SelectedValue.ToEntero().Contiene(1))
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format("{0}Formatos/CHQ-{1}.rdlc", UsuarioActual.Empresa.Ruta, DdlCuentaPrestamo.SelectedValue.ToEntero()));
|
|
|
|
if (!archivo.Exists)
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format(@"{0}\Empresas\Grales\Formatos\CHQ.rdlc", AppDomain.CurrentDomain.BaseDirectory));
|
|
}
|
|
}
|
|
else if (DdlTipoTransaccionPrestamo.SelectedValue.ToEntero().Contiene(6) && UsuarioActual.CveEmpresa == 72)
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format("{0}Formatos/ComprobanteEgreso.rdlc", UsuarioActual.Empresa.Ruta, DdlCuentaPrestamo.SelectedValue.ToEntero()));
|
|
}
|
|
|
|
//if (archivo.Length > 0)
|
|
//{
|
|
// if (archivo.Exists)
|
|
// {
|
|
// Msg.AppendFormat(@"<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">{1}</a> ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE)), String.Format("Imprimir {0}", DdlTipoTransaccion.SelectedItem));
|
|
// }
|
|
//}
|
|
|
|
if (IDPoliza > 0)
|
|
{
|
|
Msg.AppendFormat(@"<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza);
|
|
}
|
|
ObjIE.Commit();
|
|
}
|
|
else
|
|
{
|
|
ObjIE.RollBack();
|
|
}
|
|
|
|
if (!Msg.ToString().Equals(""))
|
|
{
|
|
string AccionJS = String.Format(@"document.location.href=""{0}"";", HttpContext.Current.Request.Url.PathAndQuery);
|
|
Alert(Msg.ToString(), TipoMensaje.MsgInformacion, String.Format(@"document.location.href=""{0}"";", HttpContext.Current.Request.Url.PathAndQuery));
|
|
}
|
|
|
|
ObjIE.Dispose();
|
|
ObjMov.Dispose();
|
|
|
|
if (ObjComp != null)
|
|
ObjComp.Dispose();
|
|
}
|
|
#endregion
|
|
|
|
#region "PAGO DEUDORES"
|
|
protected void DdlCuenta_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
int idcuenta, idcuentacomplementaria;
|
|
Int32.TryParse(get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("IdCtaContable", String.Format("CveCuenta = {0}", DdlCuenta.SelectedValue)), out idcuenta);
|
|
Int32.TryParse(get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("IdCtaContableComplementaria", String.Format("CveCuenta = {0}", DdlCuenta.SelectedValue)), out idcuentacomplementaria);
|
|
IDCtaContableBancos = idcuenta;
|
|
IDCtaContableBancosComplementario = idcuentacomplementaria;
|
|
|
|
long Folio;
|
|
ClsBancos bancos = new ClsBancos();
|
|
Folio = bancos.GetNextFolio(DdlCuenta.SelectedValue.ToEntero(), DdlTipoTransaccion.SelectedValue.ToEntero());
|
|
bancos.Dispose();
|
|
TxtFolio.Text = Folio.ToString();
|
|
|
|
int CveMoneda = get_GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero()}").ToEntero();
|
|
HdnMonPago.Value = CveMoneda.ToString();
|
|
if (CveMoneda == 2)
|
|
{
|
|
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTCP(this);");
|
|
DivTCDolaresPago.Visible = true;
|
|
DivImporteMN.Visible = true;
|
|
TxtTCDolaresPago.Attributes.Add("onkeyup", String.Format("FnCambia({0},this,{1},2,'{2}',{3});", 0, 0, "", HdnMonPago.Value));
|
|
}
|
|
else
|
|
{
|
|
TxtFechaDocumento.Attributes.Remove("onchange");
|
|
TxtTCDolaresPago.Attributes.Remove("onkeyup");
|
|
DivTCDolaresPago.Visible = false;
|
|
DivImporteMN.Visible = false;
|
|
}
|
|
|
|
if (DdlProveedores.SelectedValue.ToEntero() > 0)
|
|
{
|
|
DdlProveedores_selectedindexchange(DdlProveedores, null);
|
|
}
|
|
|
|
UpDatos.Update();
|
|
}
|
|
|
|
protected void BtnCambiaTipoMonedaP_Click(object sender, EventArgs e)
|
|
{
|
|
CambiaTipoMonedaP();
|
|
}
|
|
|
|
protected void DdlProveedores_selectedindexchange(object sender, EventArgs e)
|
|
{
|
|
ClsMovimientos ObjMov = new ClsMovimientos();
|
|
ClsCompProveedores proveedores = new ClsCompProveedores();
|
|
|
|
|
|
if (DdlProveedores.SelectedValue.ToEntero() > 0)
|
|
{
|
|
if (ObjMov.GetDeudoresrXSaldar(DdlProveedores.SelectedValue.ToEntero(), -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvMovDeudor.DataSource = ObjMov.DtResultados.FiltraParametros("CveIE > 0 AND Saldo > 0 ", "");
|
|
}
|
|
|
|
if (proveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, DdlProveedores.SelectedValue.ToEntero(), "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, UsuarioActual.CveEmpresa))
|
|
{
|
|
IDCtaContableDeudor = proveedores.IdCtaContDeudor;
|
|
IDCtaContableDeudorExtranjera = proveedores.IdCtaContDeudorExtranjera;
|
|
IDCtaContableDeudorComplementaria = proveedores.IdCtaContDeudorComplementaria;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GvMovDeudor.DataSource = null;
|
|
}
|
|
TxtImporte.Text = "0.00";
|
|
|
|
GvMovDeudor.DataBind();
|
|
ObjMov.Dispose();
|
|
proveedores.Dispose();
|
|
UpMovDeudor.Update();
|
|
}
|
|
|
|
protected void GvMovDeudor_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (DdlCuenta.SelectedValue == "-1")
|
|
{
|
|
e.Row.FCCheckBox("Chk").Enabled = false;
|
|
e.Row.FCTextBox("TxtAbonar").Enabled = false;
|
|
}
|
|
|
|
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1},{2});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), HdnMonPago.Value));
|
|
e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,'{2}',{3});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo", HdnMonPago.Value));
|
|
}
|
|
}
|
|
|
|
protected void BtnIEGuardar_Click(object sender, EventArgs e)
|
|
{
|
|
ClsBancos ObjIE = new ClsBancos();
|
|
ClsContabilidad ObjMov = new ClsContabilidad(ObjIE.IniciaTransacSQL());
|
|
ClsCompras ObjComp = new ClsCompras(ObjIE.IniciaTransacSQL());
|
|
|
|
string MsgError = "";
|
|
int CveIE = 0;
|
|
int CveConceptoContableBanco = 30;
|
|
int CveConceptoContableBancoComplementario = 204;
|
|
int CveConceptoContablePago = 37;
|
|
int CveConceptoContablePagoComplementaria = 256;
|
|
int CvePlantillaPoliza = 39;
|
|
int CvePrePoliza = 0;
|
|
int CveMoneda = get_GlobalDTBancosCuentas(-1).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero()}").ToEntero();
|
|
int FolioFijo = 0;
|
|
int IDPoliza = 0;
|
|
decimal tipoCambio = (TxtTCDolaresPago.Visible == true) ? TxtTCDolaresPago.Text.ToDecimal() : 1;
|
|
decimal importeMN = HdnImporteMN.Value.ToDecimal();
|
|
StringBuilder Msg = new StringBuilder();
|
|
|
|
|
|
//OBTIENE COMPROBANTE !!
|
|
string Comprobante = "";
|
|
List<Archivo> filesgral = Anexo.getfiles().Archivos;
|
|
string filemove = "";
|
|
|
|
foreach (Archivo fileItem in filesgral)
|
|
{
|
|
Comprobante = System.IO.Path.GetExtension(string.Format(@"{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "");
|
|
filemove = fileItem.filename;
|
|
}
|
|
|
|
// DATOS PREPOLIZA
|
|
if ((DdlTipoTransaccion.SelectedValue == "1"))
|
|
FolioFijo = TxtFolio.Text.ToEntero();
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Bancos/IE PAGO DEUDORES", CvePlantillaPoliza, TxtImporte.Text.Trim().ToDouble(), TxtImporte.Text.Trim().ToDouble(), CveMoneda, TxtFechaDocumento.Text.ToDate(), DdlProveedores.SelectedText.ToString(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa));
|
|
|
|
if (CvePrePoliza > 0)
|
|
{
|
|
string Conc = TxtObservaciones.Text == "" ? TxtFolio.Text : TxtObservaciones.Text;
|
|
string Ref = TxtObservaciones.Text == "" ? TxtFolio.Text : TxtObservaciones.Text;
|
|
decimal ImporteBanco = TxtImporte.Text.ToDecimal();
|
|
decimal ImporteMNBanco = ImporteBanco;
|
|
decimal ImporteComplementaria = 0;
|
|
decimal TC = TxtTCDolaresPago.Text.ToDecimal();
|
|
|
|
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero(), DdlTipoTransaccion.SelectedValue.ToEntero(), TxtFechaDocumento.Text.Trim().ToDate(), TxtFolio.Text.Trim(), DdlProveedores.SelectedText.ToString(), ImporteBanco.ToString().ToDouble(), CveMoneda,
|
|
(Double)tipoCambio, TxtObservaciones.Text.Trim(), "", false, false, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
|
|
|
|
|
|
|
|
if (CveIE > 0)
|
|
{
|
|
decimal Importe;
|
|
decimal ImporteMN;
|
|
|
|
//GUARDA COMPROBANTE
|
|
if (!filemove.Equals(""))
|
|
{
|
|
filemove.FilesMove(CveIE.ToString(), string.Format(@"Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta));
|
|
}
|
|
|
|
//GUARDA PREPOLIZAS DETALLE
|
|
foreach (GridViewRow gvr in GvMovDeudor.Rows)
|
|
{
|
|
if (gvr.FCCheckBox("Chk").Checked)
|
|
{
|
|
|
|
Decimal TCDoc = gvr.DataKey("TipoCambio").ToDecimal(); // tipo de cambio de IE
|
|
if (gvr.DataKey("FechaDocumento").ToDate() < TxtFechaDocumento.Text.ToDate().FirstDayOfMonth())
|
|
{
|
|
// si la fecha del documento a pagar es menor al primer dia del mes del pago, toma el TC del mes anterior
|
|
TCDoc = get_GlobalTipoCambio(TxtFechaDocumento.Text.ToDate().AddMonths(-1).LastDayOfMonth()).ToDecimal();
|
|
}
|
|
|
|
Importe = gvr.FCTextBox("TxtAbonar").Text.ToDecimal();
|
|
ImporteMN = Importe;
|
|
ImporteComplementaria = 0;
|
|
|
|
int tCveMoneda = gvr.DataKey("CveMoneda").ToEntero();
|
|
if (CveMoneda == 1 && tCveMoneda == 1)
|
|
{
|
|
ImporteMN = Importe;
|
|
}
|
|
else if (CveMoneda == 1 && tCveMoneda == 2)
|
|
{
|
|
if (UsaComplementaria)
|
|
{
|
|
ImporteMN = Importe;
|
|
ImporteComplementaria = Importe * TCDoc - Importe;
|
|
}
|
|
else
|
|
{
|
|
ImporteMN = Importe * TCDoc;
|
|
ImporteComplementaria = 0;
|
|
}
|
|
}
|
|
else if (CveMoneda == 2 && tCveMoneda == 1)
|
|
{
|
|
|
|
ImporteMN = Importe;
|
|
}
|
|
else if (CveMoneda == 2 && tCveMoneda == 2)
|
|
{
|
|
if (UsaComplementaria)
|
|
{
|
|
ImporteMN = Importe;
|
|
ImporteComplementaria = Importe * TCDoc - Importe;
|
|
}
|
|
else
|
|
{
|
|
ImporteMN = Importe * TCDoc;
|
|
ImporteComplementaria = 0;
|
|
}
|
|
}
|
|
|
|
ImporteMN = Math.Round(ImporteMN, 2, MidpointRounding.AwayFromZero);
|
|
ImporteComplementaria = Math.Round(ImporteComplementaria, 2, MidpointRounding.AwayFromZero);
|
|
|
|
if (tCveMoneda != 1)
|
|
{
|
|
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true, Importe, Ref, CveConceptoContablePago, Conc, DateTime.Now, IDCtaContableDeudor, -1, CveIE, CveProveedor: DdlProveedores.SelectedValue.ToEntero(), ImporteMX: ImporteMN, CveIEDevolucion: gvr.DataKey("CveIE").ToEntero(), TipoCambio: TCDoc, TipoCambioPago: TC,CveSubProyecto:DdlSubProyectoPago.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de pago deudor";
|
|
break;
|
|
}
|
|
if (UsaComplementaria)
|
|
{
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true, Importe, Ref, CveConceptoContablePagoComplementaria, Conc, DateTime.Now, IDCtaContableDeudorComplementaria, -1, CveIE, CveProveedor: DdlProveedores.SelectedValue.ToEntero(), ImporteMX: ImporteComplementaria, CveIEDevolucion: gvr.DataKey("CveIE").ToEntero(), ImporteME: Importe, TipoCambio: TCDoc, TipoCambioPago: TC, CveSubProyecto: DdlSubProyectoPago.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de deudor complementaria";
|
|
}
|
|
}
|
|
|
|
if (TC != TCDoc)
|
|
{
|
|
int CveConceptoDiferenciaCambiaria = 0;
|
|
bool TipoMovto = false;
|
|
int IdCtaContableDiferenciaCambiaria = 0;
|
|
if (TC < TCDoc)
|
|
{
|
|
CveConceptoDiferenciaCambiaria = 65;
|
|
IdCtaContableDiferenciaCambiaria = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria;
|
|
TipoMovto = false;
|
|
Importe = (Importe * gvr.DataKey("TipoCambio").ToDecimal()) - (Importe * TC);
|
|
}
|
|
else if (TC > TCDoc)
|
|
{
|
|
CveConceptoDiferenciaCambiaria = 64;
|
|
IdCtaContableDiferenciaCambiaria = UsuarioActual.Empresa.IdCuentaGananciaCambiaria;
|
|
TipoMovto = true;
|
|
|
|
Importe = (Importe * TC) - (Importe * gvr.DataKey("TipoCambio").ToDecimal());
|
|
}
|
|
ImporteMN = Importe;
|
|
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, Ref, CveConceptoDiferenciaCambiaria, Conc, DateTime.Now, IdCtaContableDiferenciaCambiaria, -1, CveIE, CveProveedor: DdlProveedores.SelectedValue.ToEntero(), ImporteMX: ImporteMN, CveIEDevolucion: gvr.DataKey("CveIE").ToEntero(), ImporteME: Importe, TipoCambio: gvr.DataKey("TipoCambio").ToDecimal(), TipoCambioPago: TC, CveSubProyecto: DdlSubProyectoPago.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de diferencia cambiaria";
|
|
}
|
|
}
|
|
|
|
}else
|
|
{
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true, Importe, Ref, CveConceptoContablePago, Conc, DateTime.Now, IDCtaContableDeudor, -1, CveIE, CveProveedor: DdlProveedores.SelectedValue.ToEntero(), ImporteMX: ImporteMN, CveIEDevolucion: gvr.DataKey("CveIE").ToEntero(), TipoCambio: gvr.DataKey("TipoCambio").ToDecimal(), TipoCambioPago: TC, CveSubProyecto: DdlSubProyectoPago.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de pago deudor";
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CveMoneda != 1)
|
|
{
|
|
if (UsaComplementaria)
|
|
{
|
|
ImporteMNBanco = ImporteBanco;
|
|
ImporteComplementaria = (ImporteBanco * TC - ImporteBanco).RoundSQL();
|
|
}
|
|
else
|
|
{
|
|
ImporteMNBanco = ImporteBanco * TC;
|
|
ImporteComplementaria = 0;
|
|
}
|
|
}
|
|
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, false, ImporteBanco, Ref, CveConceptoContableBanco, Conc, DateTime.Now, IDCtaContableBancos, -1, CveIE, CveProveedor: DdlProveedores.SelectedValue.ToEntero(), ImporteMX: ImporteMNBanco, ImporteME: ImporteBanco, TipoCambio: TC, TipoCambioPago: TC, CveSubProyecto: DdlSubProyectoPago.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de bancos";
|
|
}
|
|
|
|
if (CveMoneda != 1 && UsaComplementaria)
|
|
{
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, false, ImporteBanco, Ref, CveConceptoContableBancoComplementario, Conc, DateTime.Now, IDCtaContableBancosComplementario, -1, CveIE, CveProveedor: DdlProveedores.SelectedValue.ToEntero(), ImporteMX: ImporteComplementaria, ImporteME: ImporteBanco, TipoCambio: TC, TipoCambioPago: TC, CveSubProyecto: DdlSubProyectoPago.SelectedValue.ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de bancos complementaria";
|
|
}
|
|
}
|
|
bool AutoConta = UsuarioActual.Empresa.Funcionalidad(200).Equals("1");
|
|
//if (UsuarioActual.CveEmpresa == 119) AutoConta = false;
|
|
|
|
if (AutoConta && MsgError.Equals(""))
|
|
{
|
|
if (IDCtaContableDeudor > 0 && IDCtaContableBancos > 0)
|
|
{
|
|
if (ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa))
|
|
{
|
|
IDPoliza = ObjMov.ContaIdPoliza;
|
|
}
|
|
else
|
|
{
|
|
Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IDCtaContableDeudor < 1)
|
|
{
|
|
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta de Deudor es invalida", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
if (IDCtaContableBancos < 1)
|
|
{
|
|
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta bancaria es invalida", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MsgError = "No se insertó el encabezado";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MsgError = "No se pudo insertar la póliza";
|
|
}
|
|
|
|
if (ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 10))
|
|
{
|
|
if (ObjMov.ValorPolizaDescuadre > 0)
|
|
{
|
|
MsgError = ObjMov.MensajePolizaDescuadre;
|
|
$"Bancos/IE PAGO Deudor | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}".GuardaLogAD("LogPrePolizas");
|
|
}
|
|
}
|
|
|
|
if (MsgError.Equals(""))
|
|
{
|
|
if (Msg.ToString().Equals(""))
|
|
{
|
|
Msg.Append("El Documento se guardo correctamente");
|
|
}
|
|
System.IO.FileInfo archivo = null;
|
|
|
|
if (DdlTipoTransaccion.SelectedValue.ToEntero().Contiene(2, 8, 9))
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format("{0}Formatos/Transferencia.rdlc", UsuarioActual.Empresa.Ruta));
|
|
}
|
|
else if (DdlTipoTransaccion.SelectedValue.ToEntero().Contiene(1))
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format("{0}Formatos/CHQ-{1}.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero()));
|
|
|
|
if (!archivo.Exists)
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format(@"{0}\Empresas\Grales\Formatos\CHQ.rdlc", AppDomain.CurrentDomain.BaseDirectory));
|
|
}
|
|
}
|
|
else if (DdlTipoTransaccion.SelectedValue.ToEntero().Contiene(6) && UsuarioActual.CveEmpresa == 72)
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format("{0}Formatos/ComprobanteEgreso.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero()));
|
|
}
|
|
|
|
//if (archivo.Length > 0)
|
|
//{
|
|
// if (archivo.Exists)
|
|
// {
|
|
// Msg.AppendFormat(@"<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">{1}</a> ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE)), String.Format("Imprimir {0}", DdlTipoTransaccion.SelectedItem));
|
|
// }
|
|
//}
|
|
|
|
if (IDPoliza > 0)
|
|
{
|
|
Msg.AppendFormat(@"<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza);
|
|
}
|
|
ObjIE.Commit();
|
|
}
|
|
else
|
|
{
|
|
Alert(MsgError.ToString(), TipoMensaje.MsgError);
|
|
ObjIE.RollBack();
|
|
}
|
|
|
|
if (!Msg.ToString().Equals(""))
|
|
{
|
|
string AccionJS = String.Format(@"document.location.href=""{0}"";", HttpContext.Current.Request.Url.PathAndQuery);
|
|
Alert(Msg.ToString(), TipoMensaje.MsgInformacion, String.Format(@"document.location.href=""{0}"";", HttpContext.Current.Request.Url.PathAndQuery));
|
|
}
|
|
|
|
ObjIE.Dispose();
|
|
ObjMov.Dispose();
|
|
|
|
if (ObjComp != null)
|
|
ObjComp.Dispose();
|
|
}
|
|
#endregion
|
|
|
|
#region"REPORTE"
|
|
protected void CargaReporte()
|
|
{
|
|
ClsBancos bancos = new ClsBancos();
|
|
if (bancos.GetDeudoresReporte(UsuarioActual.CveEmpresa))
|
|
{
|
|
GvReporte.DataSource = bancos.DtResultados;
|
|
|
|
}
|
|
bancos.Dispose();
|
|
GvReporte.DataBind();
|
|
UpReporte.Update();
|
|
}
|
|
|
|
|
|
protected void GvReporte_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DBCampo("CveProveedor") == "") e.Row.CssClass = "SubTotales";
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region"AUXILIAR"
|
|
protected void CargaAuxiliar()
|
|
{
|
|
string FechaI, FechaF;
|
|
|
|
if (txtFechaI.Text != "")
|
|
FechaI = txtFechaI.Text;
|
|
else
|
|
FechaI = "-1";
|
|
if (txtFechaF.Text != "")
|
|
FechaF = txtFechaF.Text;
|
|
else
|
|
FechaF = "-1";
|
|
int CveProveedor = -1;
|
|
if (DdlProveedorAuxiliar.SelectedValue.ToEntero() > 0) CveProveedor = DdlProveedorAuxiliar.SelectedValue.ToEntero();
|
|
|
|
ClsBancos bancos = new ClsBancos();
|
|
if (bancos.GetDeudoresAuxiliar(CveProveedor, FechaI, FechaF, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvAuxiliar.DataSource = bancos.DtResultados;
|
|
}
|
|
bancos.Dispose();
|
|
GvAuxiliar.DataBind();
|
|
UpAuxiliar.Update();
|
|
}
|
|
protected void BtnConsultarAuxiliar_Click(object sender, EventArgs e)
|
|
{
|
|
CargaAuxiliar();
|
|
}
|
|
protected void GvAuxiliar_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
protected void BtnMostrarTC_Click(object sender, EventArgs e)
|
|
{
|
|
DivTCDolaresPago.Visible = true;
|
|
TxtTCDolaresPago.Attributes.Add("onkeyup", String.Format("FnCambia({0},this,{1},2,'{2}',{3});", 0, 0, "", HdnMonPago.Value));
|
|
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTCP(this);");
|
|
DivImporteME.Visible = true;
|
|
LbImporteME.Text = HdnImporteME.Value;
|
|
}
|
|
|
|
protected void BtnOcultarTC_Click(object sender, EventArgs e)
|
|
{
|
|
DivTCDolaresPago.Visible = false;
|
|
TxtTCDolaresPago.Attributes.Remove("onkeyup");
|
|
TxtFechaDocumento.Attributes.Remove("onchange");
|
|
DivImporteME.Visible = false;
|
|
}
|
|
} |