193 lines
9.3 KiB
C#
193 lines
9.3 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 Microsoft.Reporting.WebForms;
|
|
|
|
public partial class Compras_RepAnt_NC_EXC : ClsPaginas
|
|
{
|
|
#region PROPIEDADES
|
|
private DataTable DtDatos
|
|
{
|
|
get { return DtDatos = (DataTable)ViewState["DtDatos"]; }
|
|
set { ViewState["DtDatos"] = value; }
|
|
}
|
|
|
|
private double TCEspecifico
|
|
{
|
|
get { return TCEspecifico = (double)ViewState["TCEspecifico"]; }
|
|
set { ViewState["TCEspecifico"] = value; }
|
|
}
|
|
|
|
private int TipoCambio
|
|
{
|
|
get { return TipoCambio = (int)ViewState["TipoCambio"]; }
|
|
set { ViewState["TipoCambio"] = value; }
|
|
}
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
InicializaValores();
|
|
}
|
|
}
|
|
|
|
private void InicializaValores()
|
|
{
|
|
txtFechaI.Text = "01/01/2000";
|
|
txtFechaF.Text = DateTime.Today.ToString();
|
|
TxtFechaFCorte.Text = DateTime.Today.ToString();
|
|
TipoCambio = 1;
|
|
TCEspecifico = -1;
|
|
CargaSucursales();
|
|
CargaProveedores();
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void CargaSucursales()
|
|
{
|
|
DdlSucursal.DataSource = get_GlobalDTSubProyectos( UsuarioActual.CveEmpresa);
|
|
DdlSucursal.DataBind();
|
|
DdlSucursal.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
}
|
|
|
|
protected void CargaProveedores()
|
|
{
|
|
DdlProveedor.DataSource = get_GlobalDTCompProveedores(UsuarioActual.CveEmpresa);
|
|
DdlProveedor.DataBind();
|
|
DdlProveedor.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
}
|
|
|
|
protected void CargaDatos()
|
|
{
|
|
if (TipoCambio == 3 && TxtEspecifico.Text != "") { TCEspecifico = TxtEspecifico.Text.ToDouble(); } else { TCEspecifico = -1; }
|
|
DateTime FechaICorte = TxtFechaICorte.Text != "" ? TxtFechaICorte.Text.ToDate() : DateTime.MinValue;
|
|
DateTime FechaFCorte = TxtFechaFCorte.Text != "" ? TxtFechaFCorte.Text.ToDate() : DateTime.MaxValue;
|
|
ClsCompras ObjCompra = new ClsCompras();
|
|
if (ObjCompra.GetRepAnticiposNCEXC(DdlProveedor.SelectedValue.ToEntero(), DdlSucursal.SelectedValue.ToEntero(), txtFechaI.Text.ToDate(),
|
|
txtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa, FechaICorte, FechaFCorte, TipoCambio, TCEspecifico))
|
|
{
|
|
GvDatos.DataSource = ObjCompra.DtResultados;
|
|
DtDatos = ObjCompra.DtResultados;
|
|
}
|
|
ObjCompra.Dispose();
|
|
GvDatos.DataBind();
|
|
UpDatos.Update();
|
|
}
|
|
|
|
protected void BtnConsultar_Click(object sender, EventArgs e)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void LnkExcel_Click(object sender, EventArgs e)
|
|
{
|
|
GenerarPDF("EXCEL");
|
|
}
|
|
|
|
protected void LnkPdf_Click(object sender, EventArgs e)
|
|
{
|
|
GenerarPDF("PDF");
|
|
}
|
|
|
|
protected void GenerarPDF(String Opcion)
|
|
{
|
|
String FechaI;
|
|
if (txtFechaI.Text == "" || txtFechaI.Text == "__/__/____") { FechaI = ""; } else { FechaI = $" <b>Fecha Inicial:</b> {txtFechaI.Text}"; }
|
|
String FechaF;
|
|
if (txtFechaF.Text == "" || txtFechaF.Text == "__/__/____") { FechaF = ""; } else { FechaF = $" <b>Fecha Final:</b> {txtFechaF.Text}"; }
|
|
String FechaICorte;
|
|
if (TxtFechaICorte.Text == "" || TxtFechaICorte.Text == "__/__/____") { FechaICorte = ""; } else { FechaICorte = $" <b>Fecha Inicial Corte:</b> {TxtFechaICorte.Text}"; }
|
|
String FechaFCorte;
|
|
if (TxtFechaFCorte.Text == "" || TxtFechaFCorte.Text == "__/__/____") { FechaFCorte = ""; } else { FechaFCorte = $" <b>Fecha Final Corte:</b> {TxtFechaFCorte.Text}"; }
|
|
String Sucursal;
|
|
if (DdlSucursal.SelectedValue != "-1") { Sucursal = $" <b>Sucursal:</b> {DdlSucursal.SelectedItem.Text}"; } else { Sucursal = ""; }
|
|
String Proveedor;
|
|
if (DdlProveedor.SelectedValue != "-1") { Proveedor = $" <b>Proveedor:</b> {DdlProveedor.SelectedItem.Text}"; } else { Proveedor = ""; }
|
|
if (DtDatos.Rows.Count > 0)
|
|
{
|
|
System.IO.FileInfo Imagen = new System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png");
|
|
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", NowADS().ToString()));
|
|
para.Add(new ReportParameter("AgrupadoPor", $"<b>Agrupado Por:</b> {Proveedor}{Sucursal}{FechaI}{FechaF}{FechaICorte}{FechaFCorte}"));
|
|
if (Imagen.Exists)
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", logouri));
|
|
}
|
|
else
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", ""));
|
|
}
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepAnt-NC-EXC.rdlc", DtDatos, para, "Reporte de Anticipos - NCXAplicar - EXC", Opcion);
|
|
}
|
|
else
|
|
{
|
|
Alert("No hay datos consultados", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
|
|
if (e.Row.DBCampo("CveProveedor").ToEntero() < 1)
|
|
{
|
|
e.Row.CssClass = "Totales";
|
|
if (e.Row.DBCampo("CveMoneda").ToEntero() == 1)
|
|
{
|
|
e.Row.Cells[0].Text = "Total Pesos";
|
|
}
|
|
else if (e.Row.DBCampo("CveMoneda").ToEntero() == 2)
|
|
{
|
|
e.Row.Cells[0].Text = "Total Dolares";
|
|
}
|
|
}
|
|
|
|
String Css = "Texto";
|
|
String Liga = "";
|
|
|
|
Liga = $"/Compras/RepAnt-NC-EXCDetalle.aspx?&CveProveedor={e.Row.DataKey("CveProveedor")}&CveMoneda={e.Row.DataKey("CveMoneda")}&Tipo=-1&CveSubProyecto={e.Row.DataKey("CveSubProyecto")}&FechaI={e.Row.DataKey("FechaI").ToDate().ToShortDateString()}&FechaF={e.Row.DataKey("FechaF").ToDate().ToShortDateString()}&FechaICorte={e.Row.DataKey("FechaICorte").ToDate().ToShortDateString()}&FechaFCorte={e.Row.DataKey("FechaFCorte").ToDate().ToShortDateString()}&TipoCambio={e.Row.DataKey("TipoCambio")}&TCEspecifico={e.Row.DataKey("TCEspecifico")}";
|
|
e.Row.Cells[0].Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.Cells[0].Text + "</a>";
|
|
|
|
Liga = $"/Compras/RepAnt-NC-EXCDetalle.aspx?&CveProveedor={e.Row.DataKey("CveProveedor")}&CveMoneda={e.Row.DataKey("CveMoneda")}&Tipo=1&CveSubProyecto={e.Row.DataKey("CveSubProyecto")}&FechaI={e.Row.DataKey("FechaI").ToDate().ToShortDateString()}&FechaF={e.Row.DataKey("FechaF").ToDate().ToShortDateString()}&FechaICorte={e.Row.DataKey("FechaICorte").ToDate().ToShortDateString()}&FechaFCorte={e.Row.DataKey("FechaFCorte").ToDate().ToShortDateString()}&TipoCambio={e.Row.DataKey("TipoCambio")}&TCEspecifico={e.Row.DataKey("TCEspecifico")}";
|
|
e.Row.Cells[3].Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.Cells[3].Text + "</a>";
|
|
|
|
Liga = $"/Compras/RepAnt-NC-EXCDetalle.aspx?&CveProveedor={e.Row.DataKey("CveProveedor")}&CveMoneda={e.Row.DataKey("CveMoneda")}&Tipo=2&CveSubProyecto={e.Row.DataKey("CveSubProyecto")}&FechaI={e.Row.DataKey("FechaI").ToDate().ToShortDateString()}&FechaF={e.Row.DataKey("FechaF").ToDate().ToShortDateString()}&FechaICorte={e.Row.DataKey("FechaICorte").ToDate().ToShortDateString()}&FechaFCorte={e.Row.DataKey("FechaFCorte").ToDate().ToShortDateString()}&TipoCambio={e.Row.DataKey("TipoCambio")}&TCEspecifico={e.Row.DataKey("TCEspecifico")}";
|
|
e.Row.Cells[6].Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.Cells[6].Text + "</a>";
|
|
|
|
Liga = $"/Compras/RepAnt-NC-EXCDetalle.aspx?&CveProveedor={e.Row.DataKey("CveProveedor")}&CveMoneda={e.Row.DataKey("CveMoneda")}&Tipo=3&CveSubProyecto={e.Row.DataKey("CveSubProyecto")}&FechaI={e.Row.DataKey("FechaI").ToDate().ToShortDateString()}&FechaF={e.Row.DataKey("FechaF").ToDate().ToShortDateString()}&FechaICorte={e.Row.DataKey("FechaICorte").ToDate().ToShortDateString()}&FechaFCorte={e.Row.DataKey("FechaFCorte").ToDate().ToShortDateString()}&TipoCambio={e.Row.DataKey("TipoCambio")}&TCEspecifico={e.Row.DataKey("TCEspecifico")}";
|
|
e.Row.Cells[9].Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.Cells[9].Text + "</a>";
|
|
|
|
}
|
|
}
|
|
|
|
protected void BtnTipoCambio_Click(object sender, EventArgs e)
|
|
{
|
|
CargaDatos();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivTipoCambio"));
|
|
}
|
|
|
|
protected void RblTipoCambio_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
TipoCambio = RblTipoCambio.SelectedValue.ToEntero();
|
|
if (TipoCambio == 3)
|
|
{
|
|
LiEspecifico.Visible = true;
|
|
TCEspecifico = get_GlobalTipoCambio(NowADS()).ToString().ToDouble();
|
|
TxtEspecifico.Text = TCEspecifico.ToString();
|
|
}
|
|
else
|
|
{
|
|
LiEspecifico.Visible = false;
|
|
}
|
|
UpBodyTipoCambio.Update();
|
|
}
|
|
} |