262 lines
9.7 KiB
C#
262 lines
9.7 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;
|
|
using ADSNetLibrary.SIGAPI.Models.CGame;
|
|
|
|
public partial class Ventas_RepAnticipo_NC_IXCAplicados : 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; }
|
|
}
|
|
|
|
private int Vendedor
|
|
{
|
|
get { return Vendedor = (int)ViewState["Vendedor"]; }
|
|
set { ViewState["Vendedor"] = 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;
|
|
Vendedor = 0;
|
|
CargaSucursales();
|
|
CargaClientes();
|
|
CargaDatos();
|
|
}
|
|
|
|
protected void CargaSucursales()
|
|
{
|
|
DdlSucursal.DataSource = get_GlobalDTSubProyectos(UsuarioActual.CveEmpresa);
|
|
DdlSucursal.DataBind();
|
|
DdlSucursal.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
}
|
|
|
|
//protected void CargaClientes()
|
|
//{
|
|
// DdlCliente.DataSource = get_GlobalDTCliente(UsuarioActual.CveEmpresa,-1);
|
|
// DdlCliente.DataBind();
|
|
// DdlCliente.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
//}
|
|
protected void CargaClientes()
|
|
{
|
|
DdlCliente.setEsWebService(true);
|
|
DdlCliente.Attributes.Add("data-metodo", "getcliente");
|
|
}
|
|
|
|
protected void CargaDatos()
|
|
{
|
|
if (TipoCambio == 3 && TxtEspecifico.Text != "") { TCEspecifico = TxtEspecifico.Text.ToDouble(); } else { TCEspecifico = -1; }
|
|
DateTime FechaICorte;
|
|
if (TxtFechaICorte.Text != "") { FechaICorte = TxtFechaICorte.Text.ToDate(); } else { FechaICorte = ModExtensiones.MinFecha; }
|
|
DateTime FechaFCorte;
|
|
if (TxtFechaFCorte.Text != "") { FechaFCorte = TxtFechaFCorte.Text.ToDate(); } else { FechaFCorte = ModExtensiones.MaxFecha; }
|
|
ClsVentas ObjVenta = new ClsVentas();
|
|
int CveCliente = -1;
|
|
if (DdlCliente.SelectedValue.ToEntero() != 0)
|
|
{
|
|
CveCliente = DdlCliente.SelectedValue.ToEntero();
|
|
}
|
|
if (ObjVenta.GetRepAnticiposNCIXCAplicados(CveCliente, DdlSucursal.SelectedValue.ToEntero(), ModExtensiones.MinFecha,
|
|
ModExtensiones.MaxFecha, UsuarioActual.CveEmpresa, FechaICorte, FechaFCorte, TipoCambio, TCEspecifico, -1, -1))
|
|
{
|
|
DtDatos = ObjVenta.DtResultados.Copy();
|
|
}
|
|
ObjVenta.Dispose();
|
|
|
|
GvDatos.DataSource = DtDatos;
|
|
|
|
GvDatos.Columns[2].Visible = ChkAnticipos.Checked;
|
|
GvDatos.Columns[3].Visible = ChkNCxAplicar.Checked;
|
|
GvDatos.Columns[4].Visible = ChkIngresosxComprobar.Checked;
|
|
|
|
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:</b> {TxtFechaICorte.Text}"; }
|
|
String FechaFCorte;
|
|
if (TxtFechaFCorte.Text == "" || TxtFechaFCorte.Text == "__/__/____") { FechaFCorte = ""; } else { FechaFCorte = $" <b>Fecha Final:</b> {TxtFechaFCorte.Text}"; }
|
|
String Sucursal;
|
|
if (DdlSucursal.SelectedValue != "-1") { Sucursal = $" <b>Sucursal:</b> {DdlSucursal.SelectedItem.Text}"; } else { Sucursal = ""; }
|
|
String Cliente;
|
|
if (!DdlCliente.SelectedValue.Contiene("-1","")) { Cliente = $" <b>Cliente:</b> {DdlCliente.SelectedText}"; } else { Cliente = ""; }
|
|
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);
|
|
string AgrupadoPor = $"{Cliente}{Sucursal}{FechaICorte}{FechaFCorte}";
|
|
if (Opcion == "PDF")
|
|
{
|
|
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> {AgrupadoPor}"));
|
|
|
|
|
|
|
|
para.Add(new ReportParameter("MostarAnticipos", ChkAnticipos.Checked ? "1" : "0"));
|
|
para.Add(new ReportParameter("MostarNCxAplicar", ChkNCxAplicar.Checked ? "1" : "0"));
|
|
para.Add(new ReportParameter("MostarIngresosxComprobar", ChkIngresosxComprobar.Checked ? "1" : "0"));
|
|
|
|
if (Imagen.Exists)
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", logouri));
|
|
}
|
|
else
|
|
{
|
|
para.Add(new ReportParameter("LogoPath", ""));
|
|
}
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepAnt-NC-IXCAplicados.rdlc", DtDatos, para, "Reporte de aplicaciones de Anticipos - NC - IXC", Opcion);
|
|
}
|
|
else
|
|
{
|
|
var TextoFiltro = AgrupadoPor.Replace(" ", "").Replace("<b>", "").Replace("</b>", "");
|
|
|
|
GvDatos.ExportToExcelGembox("RepAnticiposNCIxCAplicados", UsuarioActual, "Reporte de aplicaciones de Anticipos - NC - Ingresos X Comprobar", DatosFiltros: TextoFiltro, AlturaImagen: 0, AnchoImagen: 0);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert("No hay datos consultados", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
public override void VerifyRenderingInServerForm(System.Web.UI.Control control)
|
|
{
|
|
}
|
|
|
|
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
|
|
if (e.Row.DBCampo("CveCliente").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";
|
|
}
|
|
}
|
|
|
|
if (e.Row.DBCampo("CveCliente").ToEntero() > 0)
|
|
{
|
|
if (e.Row.DBCampo("Tipo").ToEntero() == 0)
|
|
{
|
|
e.Row.CssClass = "SubTotales";
|
|
}
|
|
}
|
|
|
|
if (e.Row.DBCampo("CveCliente").ToEntero() > 0)
|
|
{
|
|
if (e.Row.DBCampo("Tipo").ToEntero() == 0)
|
|
{
|
|
e.Row.CssClass = "SubTotales";
|
|
}
|
|
|
|
switch (e.Row.DBCampo("Tipo"))
|
|
{
|
|
case "0":
|
|
e.Row.FCHyperLink("HLFolio").NavigateUrl = string.Format("/Ventas/Clientes.aspx?CveCliente={0}", e.Row.DBCampo("CveCliente").ToEntero());
|
|
break;
|
|
case "1":
|
|
e.Row.FCHyperLink("HLFolio").NavigateUrl = string.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DBCampo("Id").ToEntero());
|
|
break;
|
|
case "2":
|
|
e.Row.FCHyperLink("HLFolio").NavigateUrl = string.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DBCampo("Id").ToEntero());
|
|
break;
|
|
case "3":
|
|
e.Row.FCHyperLink("HLFolio").NavigateUrl = string.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("Id").ToEntero());
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|