559 lines
24 KiB
C#
559 lines
24 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_Devoluciones : ClsPaginas
|
|
{
|
|
#region "PROPIEDADES"
|
|
private int IDCtaContableBancos
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableBancos"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableBancos"] = value;
|
|
}
|
|
}
|
|
private int IDCtaContableDevolucion
|
|
{
|
|
get
|
|
{
|
|
return ViewState["IDCtaContableDevolucion"].ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["IDCtaContableDevolucion"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaTipoTransaccion("");
|
|
CargaCuentas();
|
|
CargaSubProyectos();
|
|
CargaCliente();
|
|
CargaProveedor();
|
|
CargaPersonal();
|
|
TxtImporte.Attributes.Add("disabled", "disabled");
|
|
TxtComisiones.Attributes.Add("disabled", "disabled");
|
|
TxtTotal.Attributes.Add("disabled", "disabled");
|
|
}
|
|
}
|
|
|
|
#region"INFORMACION GENERAL"
|
|
protected void OpcionDevolucion_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
string tipo = "";
|
|
switch (OpcionDevolucion.SelectedValue)
|
|
{
|
|
case "1":
|
|
tipo = "Egs";
|
|
OpcionDev.Text = "Cliente:";
|
|
DdlCliente.Visible = true;
|
|
DdlProveedores.Visible = false;
|
|
DdlPersonal.Visible = false;
|
|
LimpiarGV();
|
|
LimpiarDDL();
|
|
GvDevoluciones.Columns[7].Visible = true;
|
|
break;
|
|
case "2":
|
|
tipo = "Ing";
|
|
OpcionDev.Text = "Proveedor:";
|
|
DdlProveedores.Visible = true;
|
|
DdlCliente.Visible = false;
|
|
DdlPersonal.Visible = false;
|
|
LimpiarGV();
|
|
LimpiarDDL();
|
|
GvDevoluciones.Columns[7].Visible = false;
|
|
break;
|
|
case "3":
|
|
tipo = "Ing";
|
|
OpcionDev.Text = "Viaticos:";
|
|
DdlPersonal.Visible = true;
|
|
DdlProveedores.Visible = false;
|
|
DdlCliente.Visible = false;
|
|
LimpiarGV();
|
|
LimpiarDDL();
|
|
GvDevoluciones.Columns[7].Visible = false;
|
|
break;
|
|
case "4":
|
|
tipo = "Ing";
|
|
OpcionDev.Text = "Personal:";
|
|
DdlPersonal.Visible = true;
|
|
DdlProveedores.Visible = false;
|
|
DdlCliente.Visible = false;
|
|
LimpiarGV();
|
|
LimpiarDDL();
|
|
GvDevoluciones.Columns[7].Visible = false;
|
|
break;
|
|
}
|
|
CargaTipoTransaccion(tipo);
|
|
}
|
|
protected void CargaTipoTransaccion(string tipo)
|
|
{
|
|
DdlTipoTransanccion.Items.Clear();
|
|
DdlTipoTransanccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros($"Tipo='{tipo}'");
|
|
DdlTipoTransanccion.DataBind();
|
|
DdlTipoTransanccion.Items.Insert(0, new ListItem("Seleccione Tipo Movimiento", "-1"));
|
|
|
|
}
|
|
protected void CargaCuentas()
|
|
{
|
|
DdlCuenta.DataSource = get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa: UsuarioActual.CveEmpresa).FiltraParametros("CveTipoCuenta <> 1");
|
|
DdlCuenta.DataBind();
|
|
DdlCuenta.Items.Insert(0, new ListItem("Seleccione Cuenta", "-1"));
|
|
}
|
|
protected void CargaSubProyectos()
|
|
{
|
|
DdlSubProyecto.DataSource = get_GlobalDTSubProyectos(-1, CveEmpresa:UsuarioActual.CveEmpresa);
|
|
DdlSubProyecto.DataBind();
|
|
DdlSubProyecto.Items.Insert(0, new ListItem("Seleccione SubProyecto", "-1"));
|
|
}
|
|
protected void CargaCliente()
|
|
{
|
|
DdlCliente.setEsWebService(true);
|
|
DdlCliente.Attributes.Add("data-metodo", "getcliente");
|
|
}
|
|
protected void CargaProveedor()
|
|
{
|
|
DdlProveedores.setEsWebService(true);
|
|
DdlProveedores.Attributes.Add("data-metodo", "getproveedores");
|
|
}
|
|
protected void CargaPersonal()
|
|
{
|
|
DdlPersonal.DataSource = get_GlobalDTRHPersonal(UsuarioActual.CveEmpresa);
|
|
DdlPersonal.DataBind();
|
|
DdlPersonal.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
}
|
|
protected void DdlTipoTransanccion_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (DdlTipoTransanccion.SelectedValue.ToEntero() > 0)
|
|
{
|
|
DdlCuenta.Enabled = true;
|
|
DdlCuenta_SelectedIndexChanged(DdlCuenta, e);
|
|
}
|
|
else
|
|
{
|
|
DdlCuenta.SelectedValue = "-1";
|
|
DdlCuenta.Enabled = false;
|
|
DdlCuenta_SelectedIndexChanged(DdlCuenta, e);
|
|
}
|
|
UpDatos.Update();
|
|
}
|
|
protected void DdlCuenta_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
int idcuenta;
|
|
Int32.TryParse(get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa: UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveCuenta = {0}", DdlCuenta.SelectedValue)), out idcuenta);
|
|
IDCtaContableBancos = idcuenta;
|
|
|
|
long Folio;
|
|
ClsBancos bancos = new ClsBancos();
|
|
Folio = bancos.GetNextFolio(DdlCuenta.SelectedValue.ToEntero(), DdlTipoTransanccion.SelectedValue.ToEntero());
|
|
bancos.Dispose();
|
|
TxtFolio.Text = Folio.ToString();
|
|
}
|
|
protected void DdlOtrosPagos_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
bool EsOtrosEgresos = (DdlOtrosPagos.SelectedValue.Equals("2"));
|
|
|
|
DivComisiones.Visible = EsOtrosEgresos;
|
|
DivTotal.Visible = EsOtrosEgresos;
|
|
TxtComisiones.Text = "0.00";
|
|
TxtTotal.Text = TxtImporte.Text;
|
|
GvDevoluciones.Columns[8].Visible = EsOtrosEgresos;
|
|
UpDevoluciones.Update();
|
|
}
|
|
#endregion
|
|
|
|
#region"CLIENTE"
|
|
protected void DdlCliente_selectedindexchange(object sender, EventArgs e)
|
|
{
|
|
CargaDevolucionesCliente(DdlCliente.SelectedValue.ToEntero());
|
|
}
|
|
protected void CargaDevolucionesCliente(int CveCliente)
|
|
{
|
|
ClsMovimientos ObjMov = new ClsMovimientos();
|
|
ClsClientes clsClientes = new ClsClientes();
|
|
|
|
if (ObjMov.GetMovimientosIE(1, CveCliente, DdlCuenta.SelectedValue.ToEntero(), MinFecha, DateTime.Now, 1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvDevoluciones.DataSource = ObjMov.DtResultados.FiltraParametros("Saldo > 0 ");
|
|
GvDevoluciones.DataBind();
|
|
|
|
}
|
|
|
|
if (clsClientes.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
IDCtaContableDevolucion = clsClientes.IdCtaContClientes;
|
|
}
|
|
|
|
ObjMov.Dispose();
|
|
clsClientes.Dispose();
|
|
UpDevoluciones.Update();
|
|
}
|
|
#endregion
|
|
|
|
#region"PROVEEDOR"
|
|
protected void DdlProveedores_selectedindexchange(object sender, EventArgs e)
|
|
{
|
|
CargaDevolucionesProveedor(DdlProveedores.SelectedValue.ToEntero());
|
|
}
|
|
protected void CargaDevolucionesProveedor(int CveProveedor)
|
|
{
|
|
ClsMovimientos ObjMov = new ClsMovimientos();
|
|
ClsCompProveedores clsCompProveedores = new ClsCompProveedores();
|
|
|
|
if (ObjMov.GetEgresosSinComprobar("-1", "-1", CveProveedor, -1, -1, -1, -1, 1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
string[] columnas = new string[7] { "CveIE", "IEDevolucion", "Saldo", "Importe", "Pagado", "Folio", "FechaDocumento" };
|
|
GvDevoluciones.DataSource = ObjMov.DtResultados.FiltraParametros("CveIE > 0 AND Saldo > 0 AND CveConceptoContable = 10", "", columnas);
|
|
GvDevoluciones.DataBind();
|
|
}
|
|
if (clsCompProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, UsuarioActual.CveEmpresa))
|
|
{
|
|
IDCtaContableDevolucion = clsCompProveedores.IdCtaContAnticipos;
|
|
}
|
|
|
|
ObjMov.Dispose();
|
|
clsCompProveedores.Dispose();
|
|
UpDevoluciones.Update();
|
|
}
|
|
#endregion
|
|
|
|
#region"PERSONAL"
|
|
protected void DdlPersonal_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
CargaDevolucionesPersonal(DdlPersonal.SelectedValue.ToEntero());
|
|
}
|
|
protected void CargaDevolucionesPersonal(int CvePersonal)
|
|
{
|
|
ClsMovimientos ObjMov = new ClsMovimientos();
|
|
ClsRH clsRH = new ClsRH();
|
|
|
|
switch (OpcionDevolucion.SelectedValue)
|
|
{
|
|
case "3":
|
|
if (ObjMov.GetEgresosSinComprobar("-1", "-1", -1, CvePersonal, -1, -1, -1, 1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
string[] columnas = new string[7] { "CveIE", "IEDevolucion", "Saldo", "Importe", "Pagado", "Folio", "FechaDocumento" };
|
|
GvDevoluciones.DataSource = ObjMov.DtResultados.FiltraParametros("CveIE > 0 AND Saldo > 0 ", "", columnas);
|
|
GvDevoluciones.DataBind();
|
|
}
|
|
break;
|
|
case "4":
|
|
if (ObjMov.GetPrestamosPersonalXSaldar(CvePersonal, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
string[] columnas = new string[7] { "CveIE", "IEDevolucion", "Saldo", "Importe", "Pagado", "Folio", "FechaDocumento" };
|
|
GvDevoluciones.DataSource = ObjMov.DtResultados.FiltraParametros("CveIE > 0 AND Saldo > 0 ", "", columnas);
|
|
GvDevoluciones.DataBind();
|
|
}
|
|
break;
|
|
}
|
|
|
|
|
|
if (clsRH.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa))
|
|
{
|
|
switch (OpcionDevolucion.SelectedValue)
|
|
{
|
|
case "3":
|
|
IDCtaContableDevolucion = clsRH.IdCtaContPersonal;
|
|
break;
|
|
case "4":
|
|
IDCtaContableDevolucion = clsRH.IdCtaContPrestamos;
|
|
break;
|
|
}
|
|
}
|
|
|
|
ObjMov.Dispose();
|
|
clsRH.Dispose();
|
|
UpDevoluciones.Update();
|
|
}
|
|
#endregion
|
|
|
|
#region"GV ROW"
|
|
protected void GvDevoluciones_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,'{3}');", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, "El Importe no debe de exceder el saldo"));
|
|
e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,'{2}');", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo"));
|
|
e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2,'{2}');", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo"));
|
|
}
|
|
}
|
|
protected void LimpiarGV()
|
|
{
|
|
GvDevoluciones.DataSource = null;
|
|
GvDevoluciones.DataBind();
|
|
TxtObservaciones.Text = "";
|
|
TxtImporte.Text = "";
|
|
UpDevoluciones.Update();
|
|
}
|
|
protected void LimpiarDDL()
|
|
{
|
|
DdlCliente.SelectedValue = "";
|
|
DdlProveedores.SelectedValue = "";
|
|
DdlPersonal.SelectedValue = "-1";
|
|
IDCtaContableDevolucion = 0;
|
|
}
|
|
#endregion
|
|
|
|
#region"GUARDAR"
|
|
protected void BtnGuardar_Click(object sender, EventArgs e)
|
|
{
|
|
if (TxtImporte.Text == "")
|
|
{
|
|
Alert("Debe ingresar un importe", TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
ClsBancos ObjIE = new ClsBancos();
|
|
ClsContabilidad ObjMov = new ClsContabilidad(ObjIE.IniciaTransacSQL());
|
|
ClsCompras ObjComp = new ClsCompras(ObjIE.IniciaTransacSQL());
|
|
|
|
string MsgError = "";
|
|
string PagueseA = "";
|
|
int CveIE = 0;
|
|
int CveConceptoContableBanco = 30;
|
|
int CveConceptoContableDevolucion = 0;
|
|
int CvePlantillaPoliza = 0;
|
|
int CvePrePoliza = 0;
|
|
int CveMoneda = get_GlobalDTBancosCuentas(-1, CveEmpresa: UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero()}").ToEntero();
|
|
int FolioFijo = 0;
|
|
int IDPoliza = 0;
|
|
int cveProveedor = (DdlProveedores.SelectedValue.ToEntero() > 0) ? DdlProveedores.SelectedValue.ToEntero() : -1;
|
|
int cvePersonal = (DdlPersonal.SelectedValue.ToEntero() > 0) ? DdlPersonal.SelectedValue.ToEntero() : -1;
|
|
int cveCliente = (DdlCliente.SelectedValue.ToEntero() > 0) ? DdlCliente.SelectedValue.ToEntero() : -1;
|
|
bool TipoMovoDevolucion = false;
|
|
double TC = 1;
|
|
StringBuilder Msg = new StringBuilder();
|
|
|
|
switch (OpcionDevolucion.SelectedValue)
|
|
{
|
|
case "1":
|
|
PagueseA = DdlCliente.SelectedText.ToString();
|
|
CveConceptoContableDevolucion = 92;
|
|
CvePlantillaPoliza = 7;
|
|
TipoMovoDevolucion = false;
|
|
break;
|
|
case "2":
|
|
PagueseA = DdlProveedores.SelectedText.ToString();
|
|
CveConceptoContableDevolucion = 21;
|
|
CvePlantillaPoliza = 7;
|
|
TipoMovoDevolucion = true;
|
|
break;
|
|
case "3":
|
|
PagueseA = DdlPersonal.SelectedItem.ToString();
|
|
CveConceptoContableDevolucion = 250;
|
|
CvePlantillaPoliza = 100;
|
|
TipoMovoDevolucion = true;
|
|
break;
|
|
case "4":
|
|
PagueseA = DdlPersonal.SelectedItem.ToString();
|
|
CveConceptoContableDevolucion = 273;
|
|
CvePlantillaPoliza = 100;
|
|
TipoMovoDevolucion = true;
|
|
break;
|
|
}
|
|
|
|
if (CveMoneda != 1)
|
|
{
|
|
TC = get_GlobalTipoCambio(TxtFechaDocumento.Text.ToDate());
|
|
}
|
|
|
|
// DATOS PREPOLIZA
|
|
if ( DdlTipoTransanccion.SelectedValue == "1" && UsuarioActual.CveEmpresa != 119) FolioFijo = TxtFolio.Text.ToEntero();
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Bancos/IE Devoluciones", CvePlantillaPoliza, TxtImporte.Text.Trim().ToDouble(), TxtImporte.Text.Trim().ToDouble(), CveMoneda, TxtFechaDocumento.Text.ToDate(), TxtObservaciones.Text.Trim(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo: FolioFijo, ReglaFolioPoliza: ObjComp.ObtenerReglaFolio(DdlTipoTransanccion.SelectedValue, null, UsuarioActual.CveEmpresa), CveTipoPoliza: ObjMov.ObtenerTipoPoliza(DdlTipoTransanccion.SelectedValue, "-1", UsuarioActual.CveEmpresa));
|
|
|
|
if (CvePrePoliza > 0)
|
|
{
|
|
string Conc = TxtObservaciones.Text == "" ? TxtFolio.Text : TxtObservaciones.Text;
|
|
string Ref = TxtObservaciones.Text == "" ? TxtFolio.Text : TxtObservaciones.Text;
|
|
|
|
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero(), DdlTipoTransanccion.SelectedValue.ToEntero(), TxtFechaDocumento.Text.Trim().ToDate(), TxtFolio.Text.Trim(), PagueseA, TxtImporte.Text.Trim().ToDouble(), CveMoneda,
|
|
TC, TxtObservaciones.Text.Trim(), "", false, false, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
|
|
if (CveIE > 0)
|
|
{
|
|
//GUARDA PREPOLIZAS DETALLE DEVOLUCION
|
|
foreach (GridViewRow gvr in GvDevoluciones.Rows)
|
|
{
|
|
if (gvr.FCCheckBox("Chk").Checked)
|
|
{
|
|
|
|
if (OpcionDevolucion.SelectedValue.ToEntero() == 1)
|
|
{
|
|
if (gvr.FCTextBox("TxtIVA").Text.ToDecimal() > 0)
|
|
{
|
|
//INGxC
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true, gvr.FCTextBox("TxtAbonar").Text.ToDecimal(), Ref, CveConceptoContableDevolucion, Conc, DateTime.Now, IDCtaContableDevolucion, -1, CveIE: gvr.DataKey("CveIE").ToEntero(), CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero(), CveCliente: DdlCliente.SelectedValue.ToEntero(), ImporteMX: gvr.FCTextBox("TxtAbonar").Text.ToDecimal(), CveIEDevolucion: CveIE))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de devolución";
|
|
}
|
|
|
|
//IVA
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, false, -gvr.FCTextBox("TxtIVA").Text.ToDecimal(), Ref, 13, Conc, DateTime.Now, UsuarioActual.Empresa.IdCuentaIVAxTrasladar, -1, CveIE, CveIEDevolucion: gvr.DataKey("CveIE").ToEntero(), CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero(), CveCliente: DdlCliente.SelectedValue.ToEntero(), ImporteMX: -gvr.FCTextBox("TxtIVA").Text.ToDecimal()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de IVA";
|
|
}
|
|
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, true, -gvr.FCTextBox("TxtIVA").Text.ToDecimal(), Ref, 61, Conc, DateTime.Now, UsuarioActual.Empresa.IdCuentaIVAxTrasladar, -1, CveIE, CveIEDevolucion: gvr.DataKey("CveIE").ToEntero(), CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero(), CveCliente: DdlCliente.SelectedValue.ToEntero(), ImporteMX: -gvr.FCTextBox("TxtIVA").Text.ToDecimal()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de IVA";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//INGxC
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovoDevolucion, gvr.FCTextBox("TxtAbonar").Text.ToDecimal(), Ref, CveConceptoContableDevolucion, Conc, DateTime.Now, IDCtaContableDevolucion, -1, CveIE: CveIE, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero(), CveCliente: DdlCliente.SelectedValue.ToEntero(), ImporteMX: gvr.FCTextBox("TxtAbonar").Text.ToDecimal(), CveIEDevolucion: gvr.DataKey("CveIE").ToEntero()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de bancos";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovoDevolucion, gvr.FCTextBox("TxtAbonar").Text.ToDecimal(), Ref, CveConceptoContableDevolucion, Conc, DateTime.Now, IDCtaContableDevolucion, -1, CveIE: gvr.DataKey("CveIE").ToEntero(), CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero(), CveProveedor: cveProveedor, CvePersonal: cvePersonal, ImporteMX: gvr.FCTextBox("TxtAbonar").Text.ToDecimal(), CveIEDevolucion: CveIE))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de Devolución";
|
|
break;
|
|
}
|
|
|
|
// OTROS INGRESOS
|
|
if (gvr.FCTextBox("TxtComision").Text.ToDecimal() != 0)
|
|
{
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovoDevolucion, gvr.FCTextBox("TxtComision").Text.ToDecimal(), Ref, 78, Conc, DateTime.Now, UsuarioActual.Empresa.IdCuentaOtrosIngresos, -1, CveIE: gvr.DataKey("CveIE").ToEntero(), CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero(), CveProveedor: cveProveedor, CvePersonal: cvePersonal, ImporteMX: gvr.FCTextBox("TxtComision").Text.ToDecimal(), CveIEDevolucion: CveIE))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de Devolución";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//GUARDA PREPOLIZAS DETALLE Bancos
|
|
if (!ObjMov.AddPrePolizasDetalle(CvePrePoliza, !TipoMovoDevolucion, TxtImporte.Text.ToDecimal(), Ref, CveConceptoContableBanco, Conc, DateTime.Now, IDCtaContableBancos, -1, CveIE, CveSubProyecto: DdlSubProyecto.SelectedValue.ToEntero(), CveCliente: cveCliente, CveProveedor: cveProveedor, CvePersonal: cvePersonal, ImporteMX: TxtImporte.Text.ToDecimal()))
|
|
{
|
|
MsgError = "No se pudo insertar concepto de bancos";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MsgError = "No se insertó movimiento bancario";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MsgError = "No se pudo insertar la póliza";
|
|
}
|
|
|
|
//VALIDA QUE CUADRE LA PREPOLIZA
|
|
if (ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1))
|
|
{
|
|
if (ObjMov.ValorPolizaDescuadre > 0)
|
|
{
|
|
MsgError = ObjMov.MensajePolizaDescuadre;
|
|
ModExtensiones.GuardaLogAD($"Bancos/IE PAGO ACREEDOR | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas");
|
|
}
|
|
}
|
|
|
|
//CONTABILIZA
|
|
if (UsuarioActual.Empresa.Funcionalidad(200).Equals("1") && MsgError.Equals(""))
|
|
{
|
|
if (IDCtaContableDevolucion > 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 (IDCtaContableDevolucion < 1)
|
|
{
|
|
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta de devolucion es invalida", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
if (IDCtaContableBancos < 1)
|
|
{
|
|
Alert("No se puede contabilizar la Prepoliza debido a que la cuenta bancaria es invalida", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (MsgError.Equals(""))
|
|
{
|
|
if (Msg.ToString().Equals(""))
|
|
{
|
|
Msg.Append("El Documento se guardo correctamente");
|
|
}
|
|
System.IO.FileInfo archivo = null;
|
|
|
|
if (DdlTipoTransanccion.SelectedValue.ToEntero().Contiene(2, 8, 9))
|
|
{
|
|
archivo = new System.IO.FileInfo(String.Format("{0}Formatos/Transferencia.rdlc", UsuarioActual.Empresa.Ruta));
|
|
}
|
|
else if (DdlTipoTransanccion.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", ModExtensiones.DirectorioBaseEmpresas));
|
|
}
|
|
}
|
|
else if (DdlTipoTransanccion.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
|
|
{
|
|
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
|
|
} |