using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI.WebControls; using System.Data; using static Extensiones.ModExtensiones; using Microsoft.Reporting.WebForms; public partial class Ventas_RepPedidos2 : ClsPaginas { #region PROPIEDADES private DataTable DtDatos { get { return DtDatos = (DataTable)ViewState["DtDatos"]; } set { ViewState["DtDatos"] = value; } } #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { InicializaValores(); } } private void InicializaValores() { DdlClientes.setEsWebService(true); DdlClientes.Attributes.Add("data-metodo", "getcliente"); DdlClientes.SelectedText = "Todos"; DdlClientes.SelectedValue = "-1"; DdlSubProyectos.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1); DdlSubProyectos.DataBind(); DdlVendedor.DataSource = get_GlobalDTVendedores(UsuarioActual.CveEmpresa); DdlVendedor.DataBind(); if (UsuarioActual.CveVendedor > 0) { DdlVendedor.SelectedValuesIfExistM(UsuarioActual.CveVendedor.ToString()); } txtFechaI.Text = NowADS().AddMonths(-12).ToShortDateString(); txtFechaF.Text = NowADS().AddMonths(6).ToShortDateString(); //TxtFechaVencimiento.Text = NowADS().ToShortDateString(); } protected void GenerarPDF(String Opcion) { String FechaF; if (txtFechaF.Text == "" || txtFechaF.Text == "__/__/____") { FechaF = "-1"; } else { FechaF = $" Fecha Final: {txtFechaF.Text}"; } String FechaI; if (txtFechaI.Text == "" || txtFechaI.Text == "__/__/____") { FechaI = "-1"; } else { FechaI = $" Fecha Inicial: {txtFechaI.Text}"; } String FechaV; if (TxtFechaVencimiento.Text == "" || TxtFechaVencimiento.Text == "__/__/____") { FechaV = "-1"; } else { FechaV = $" Fecha Vencimiento: {TxtFechaVencimiento.Text}"; } String Cliente; if (DdlClientes.SelectedValue != "-1") { Cliente = $" Cliente: {DdlClientes.SelectedText}"; } else { Cliente = ""; } String SubProyectos; if (DdlSubProyectos.GetSelectedText() != "") { SubProyectos = $" SubProyecto: {DdlSubProyectos.GetSelectedText()}"; } else { SubProyectos = ""; } String Vendedores; if (DdlVendedor.GetSelectedText() != "") { Vendedores = $" Vendedor: {DdlVendedor.GetSelectedText()}"; } else { Vendedores = ""; } 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 para = new List(); 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("Filtros", $"Filtros: {FechaI}{FechaF}{FechaV}{Cliente}{SubProyectos}{Vendedores}")); if (Imagen.Exists) { para.Add(new ReportParameter("LogoPath", logouri)); } else { para.Add(new ReportParameter("LogoPath", "")); } ImprimirPDF("Empresas/Grales/Formatos/RepPedidos2.rdlc", DtDatos, para, "Reporte de Pedidos2", Opcion); } else { Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia); } } protected void LnkPdf_Click(object sender, EventArgs e) { GenerarPDF("PDF"); } protected void LnkExcel_Click(object sender, EventArgs e) { GenerarPDF("EXCEL"); } protected void BtnConsultar_Click(object sender, EventArgs e) { string SubProyectos = ""; string Vendedores = ""; if (DdlSubProyectos.GetSelectedText() != "") { SubProyectos = DdlSubProyectos.GetSelectedValuesM(); } else { SubProyectos = "-1"; } if (DdlVendedor.GetSelectedText() != "") { Vendedores = DdlVendedor.GetSelectedValuesM(); } else { Vendedores = "-1"; } DateTime FechaV = MaxFecha; if (TxtFechaVencimiento.Text != "") { FechaV = TxtFechaVencimiento.Text.ToDate(); } ClsVentas ObjVentas = new ClsVentas(); if (ObjVentas.GetRepPedidos2SinFacturar(txtFechaI.Text.ToDate(),txtFechaF.Text.ToDate(), FechaV, SubProyectos, DdlClientes.SelectedValue.ToEntero(), Vendedores, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario)) { GvDatos.DataSource = ObjVentas.DtResultados; DtDatos= ObjVentas.DtResultados; } ObjVentas.Dispose(); GvDatos.DataBind(); UpDatos.Update(); } protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.DBCampo("FechaVencimiento").ToDate() < NowADS()) { e.Row.Cells[2].ForeColor = System.Drawing.Color.Red; } e.Row.Cells[4].Text = e.Row.Cells[4].Text + "%"; } } }