281 lines
13 KiB
C#
281 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
using System.Data;
|
|
using static Extensiones.ModExtensiones;
|
|
using Microsoft.Reporting.WebForms;
|
|
using System.Web.UI.HtmlControls;
|
|
using System.Text;
|
|
|
|
public partial class Bancos_RepSaldosPeriodo : ClsPaginas
|
|
{
|
|
#region PROPIEDADES
|
|
|
|
private DataTable DtDatos
|
|
{
|
|
get { return DtDatos = (DataTable)ViewState["DtDatos"]; }
|
|
set { ViewState["DtDatos"] = value; }
|
|
}
|
|
private int TipoCambio
|
|
{
|
|
get { return (ViewState["TipoCambio"] == null) ? -1 : Convert.ToInt32(ViewState["TipoCambio"]); }
|
|
set { ViewState["TipoCambio"] = value; }
|
|
}
|
|
private double TCEspecifico
|
|
{
|
|
get { return (ViewState["TCEspecifico"] == null) ? 0 : Convert.ToDouble(ViewState["TCEspecifico"]); }
|
|
set { ViewState["TCEspecifico"] = value; }
|
|
}
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
InicializaValores();
|
|
}
|
|
}
|
|
|
|
private void InicializaValores()
|
|
{
|
|
TipoCambio = 1;
|
|
TCEspecifico = -1;
|
|
|
|
txtFechaF.Text = DateTime.Now.LastDayOfMonth().ToShortDateString();
|
|
|
|
DdlCuenta.DataSource = get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:UsuarioActual.CveEmpresa);
|
|
DdlCuenta.DataBind();
|
|
DdlCuenta.Items.Insert(0, new ListItem("Todas", "-1"));
|
|
|
|
DdlMoneda.DataSource = GlobalDTMonedas;
|
|
DdlMoneda.DataBind();
|
|
DdlMoneda.Items.Insert(0, new ListItem("Todas", "-1"));
|
|
|
|
}
|
|
|
|
private void Consultar()
|
|
{
|
|
ClsBancos ObjBancos = new ClsBancos();
|
|
StringBuilder Str = new StringBuilder();
|
|
if (ChkCheques.Checked) { Str.AppendFormat("{0},", 2); }
|
|
if (ChkInversion.Checked) { Str.AppendFormat("{0},", 3); }
|
|
if (ChkTC.Checked) { Str.AppendFormat("{0},", 4); }
|
|
if (ChkCajaChica.Checked) { Str.AppendFormat("{0},", 1); }
|
|
if (ChkVirtual.Checked) { Str.AppendFormat("{0},", 5); }
|
|
if (ChkCadenasProductivas.Checked) { Str.AppendFormat("{0},", 7); }
|
|
if (ChkCreditoRevolvente.Checked) { Str.AppendFormat("{0},", 6); }
|
|
Str.Append("-1");
|
|
|
|
if (RblTipoCambio.SelectedValue.ToEntero() == 3 && TxtEspecifico.Text != "") { TCEspecifico = TxtEspecifico.Text.ToDouble(); } else { TCEspecifico = -1; }
|
|
if (ObjBancos.GetBancosSaldosPeriodo(DdlCuenta.SelectedValue.ToEntero(), DdlMoneda.SelectedValue.ToEntero(), txtFechaF.Text.ToDate(), DdlOpcion.SelectedValue.ToEntero(),
|
|
Str.ToString(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TipoCambio, TCEspecifico))
|
|
{
|
|
GvDatos.DataSource = ObjBancos.DtResultados;
|
|
DtDatos = ObjBancos.DtResultados;
|
|
}
|
|
ObjBancos.Dispose();
|
|
GvDatos.DataBind();
|
|
UpDatos.Update();
|
|
}
|
|
|
|
protected void BtnConsultar_Click(object sender, EventArgs e)
|
|
{
|
|
Consultar();
|
|
}
|
|
|
|
protected void LnkPdf_Click(object sender, EventArgs e)
|
|
{
|
|
GenerarPDF("PDF");
|
|
}
|
|
|
|
protected void LnkExcel_Click(object sender, EventArgs e)
|
|
{
|
|
GenerarPDF("EXCEL");
|
|
}
|
|
|
|
private void GenerarPDF(string Opcion)
|
|
{
|
|
string Moneda, FechaCorte, NoCuenta, Agrupador;
|
|
if (DdlMoneda.SelectedValue == "-1") { Moneda = ""; } else { Moneda = $" <b>Moneda:</b> {DdlMoneda.SelectedItem.Text}"; }
|
|
if (DdlCuenta.SelectedValue == "-1") { NoCuenta = ""; } else { NoCuenta = $" <b>No. Cuenta:</b> {DdlCuenta.SelectedItem.Text}"; }
|
|
if (DdlOpcion.SelectedValue == "-1") { Agrupador = ""; } else { Agrupador = $" <b>Agrupador:</b> {DdlOpcion.SelectedItem.Text}"; }
|
|
if (txtFechaF.Text == "") { FechaCorte = ""; } else { FechaCorte = $" <b>Fecha Corte:</b> {txtFechaF.Text}"; }
|
|
|
|
if (DtDatos.Rows.Count > 0)
|
|
{
|
|
System.IO.FileInfo Imagen = new System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta));
|
|
string logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa);
|
|
List<ReportParameter> para = new List<ReportParameter>();
|
|
para.Add(new ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa));
|
|
para.Add(new ReportParameter("UsuarioImprimio", UsuarioActual.Nombre));
|
|
para.Add(new ReportParameter("FechaImpresion", DateTime.Now.ToString()));
|
|
para.Add(new ReportParameter("Filtros", $"<b>Filtros:</b> {NoCuenta}{Moneda}{FechaCorte}{Agrupador}"));
|
|
if (Imagen.Exists)
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", logouri));
|
|
}
|
|
else
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", ""));
|
|
}
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepSaldoPeriodo.rdlc", DtDatos, para, "RepSaldoPeriodo", Opcion);
|
|
}
|
|
else
|
|
{
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
protected void BtnPersonalizar_Click(object sender, EventArgs e)
|
|
{
|
|
Consultar();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivPersonalizar"));
|
|
}
|
|
|
|
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DBCampo("CveCuenta").ToEntero() < 1)
|
|
{
|
|
e.Row.Cells[0].Text = e.Row.DBCampo("Moneda").ToString();
|
|
e.Row.CssClass = "Totales";
|
|
}
|
|
|
|
if (e.Row.Cells[2].Text.ToDouble() == 0) { e.Row.Cells[2].Text = ""; }
|
|
if (e.Row.Cells[3].Text.ToDouble() == 0) { e.Row.Cells[3].Text = ""; }
|
|
if (e.Row.Cells[4].Text.ToDouble() == 0) { e.Row.Cells[4].Text = ""; }
|
|
if (e.Row.Cells[5].Text.ToDouble() == 0) { e.Row.Cells[5].Text = ""; }
|
|
if (e.Row.Cells[6].Text.ToDouble() == 0) { e.Row.Cells[6].Text = ""; }
|
|
if (e.Row.Cells[7].Text.ToDouble() == 0) { e.Row.Cells[7].Text = ""; }
|
|
if (e.Row.Cells[8].Text.ToDouble() == 0) { e.Row.Cells[8].Text = ""; }
|
|
if (e.Row.Cells[9].Text.ToDouble() == 0) { e.Row.Cells[9].Text = ""; }
|
|
if (e.Row.Cells[10].Text.ToDouble() == 0) { e.Row.Cells[10].Text = ""; }
|
|
if (e.Row.Cells[11].Text.ToDouble() == 0) { e.Row.Cells[11].Text = ""; }
|
|
if (e.Row.Cells[12].Text.ToDouble() == 0) { e.Row.Cells[12].Text = ""; }
|
|
if (e.Row.Cells[13].Text.ToDouble() == 0) { e.Row.Cells[13].Text = ""; }
|
|
if (e.Row.Cells[14].Text.ToDouble() == 0) { e.Row.Cells[14].Text = ""; }
|
|
}
|
|
}
|
|
|
|
protected void RblTipoCambio_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
TipoCambio = RblTipoCambio.SelectedValue.ToEntero();
|
|
if (TipoCambio == 3)
|
|
{
|
|
LiEspecifico.Visible = true;
|
|
TCEspecifico = get_GlobalTipoCambio(DateTime.Now).ToString().ToDouble();
|
|
TxtEspecifico.Text = TCEspecifico.ToString();
|
|
}
|
|
else
|
|
{
|
|
LiEspecifico.Visible = false;
|
|
}
|
|
UpBodyTipoCambio.Update();
|
|
}
|
|
|
|
protected void BtnTipoCambio_Click(object sender, EventArgs e)
|
|
{
|
|
Consultar();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivTipoCambio"));
|
|
}
|
|
|
|
protected void LnkVerGrafica_Click(object sender, EventArgs e)
|
|
{
|
|
if (DtDatos != null)
|
|
{
|
|
if (DtDatos.Rows.Count > 0)
|
|
{
|
|
DataTable Dt = new DataTable();
|
|
Dt.Columns.Add("mes");
|
|
|
|
DataTable Dt2 = new DataTable();
|
|
Dt2.Columns.Add("balloonText");
|
|
Dt2.Columns.Add("bullet");
|
|
Dt2.Columns.Add("title");
|
|
Dt2.Columns.Add("valueField");
|
|
Dt2.Columns.Add("fillAlphas");
|
|
|
|
foreach (DataRow Row in DtDatos.Rows)
|
|
{
|
|
if (Row["CveCuenta"].ToString().ToEntero() > 0)
|
|
{
|
|
Dt.Columns.Add($"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}");
|
|
DataRow Row2 = Dt2.NewRow();
|
|
Row2["balloonText"] = "Saldo [[category]]: [[value]]";
|
|
Row2["bullet"] = "round";
|
|
Row2["title"] = $"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}";
|
|
Row2["valueField"] = $"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}";
|
|
Row2["fillAlphas"] = 0;
|
|
Dt2.Rows.Add(Row2);
|
|
}
|
|
}
|
|
|
|
DataRow RowEnero = Dt.NewRow();
|
|
DataRow RowFebrero = Dt.NewRow();
|
|
DataRow RowMarzo = Dt.NewRow();
|
|
DataRow RowAbril = Dt.NewRow();
|
|
DataRow RowMayo = Dt.NewRow();
|
|
DataRow RowJunio = Dt.NewRow();
|
|
DataRow RowJulio = Dt.NewRow();
|
|
DataRow RowAgosto = Dt.NewRow();
|
|
DataRow RowSeptiembre = Dt.NewRow();
|
|
DataRow RowOctubre = Dt.NewRow();
|
|
DataRow RowNoviembre = Dt.NewRow();
|
|
DataRow RowDiciembre = Dt.NewRow();
|
|
|
|
foreach (DataRow Row in DtDatos.Rows)
|
|
{
|
|
if (Row["CveCuenta"].ToString().ToEntero() > 0)
|
|
{
|
|
RowEnero[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Enero"].ToString();
|
|
RowEnero["mes"] = "Enero";
|
|
RowFebrero[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Febrero"].ToString();
|
|
RowFebrero["mes"] = "Febrero";
|
|
RowMarzo[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Marzo"].ToString();
|
|
RowMarzo["mes"] = "Marzo";
|
|
RowAbril[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"]= Row["Abril"].ToString();
|
|
RowAbril["mes"] = "Abril";
|
|
RowMayo[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Mayo"].ToString();
|
|
RowMayo["mes"] = "Mayo";
|
|
RowJunio[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Junio"].ToString();
|
|
RowJunio["mes"] = "Junio";
|
|
RowJulio[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"]= Row["Julio"].ToString();
|
|
RowJulio["mes"] = "Julio";
|
|
RowAgosto[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Agosto"].ToString();
|
|
RowAgosto["mes"] = "Agosto";
|
|
RowSeptiembre[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"]= Row["Septiembre"].ToString();
|
|
RowSeptiembre["mes"] = "Septiembre";
|
|
RowOctubre[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Octubre"].ToString();
|
|
RowOctubre["mes"] = "Octubre";
|
|
RowNoviembre[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"]= Row["Noviembre"].ToString();
|
|
RowNoviembre["mes"] = "Noviembre";
|
|
RowDiciembre[$"{Row["Banco"].ToString()} - {Row["NumCuenta"].ToString()} {Row["Abreviatura"].ToString()}"] = Row["Diciembre"].ToString();
|
|
RowDiciembre["mes"] = "Diciembre";
|
|
}
|
|
}
|
|
|
|
Dt.Rows.Add(RowEnero);
|
|
Dt.Rows.Add(RowFebrero);
|
|
Dt.Rows.Add(RowMarzo);
|
|
Dt.Rows.Add(RowAbril);
|
|
Dt.Rows.Add(RowMayo);
|
|
Dt.Rows.Add(RowJunio);
|
|
Dt.Rows.Add(RowJulio);
|
|
Dt.Rows.Add(RowAgosto);
|
|
Dt.Rows.Add(RowSeptiembre);
|
|
Dt.Rows.Add(RowOctubre);
|
|
Dt.Rows.Add(RowNoviembre);
|
|
Dt.Rows.Add(RowDiciembre);
|
|
|
|
RegistraScript($"CargaGraficaLineas({Dt.ToJson()},{Dt2.ToJson()})", "11");
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivModalGrafica"),"22");
|
|
UpGrafica.Update();
|
|
}
|
|
else
|
|
{
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
}
|