107 lines
3.8 KiB
C#
107 lines
3.8 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;
|
|
|
|
|
|
public partial class CGame_RepCorte : ClsPaginas
|
|
{
|
|
#region PROPIEDADES
|
|
private DataTable DtCorte
|
|
{
|
|
get { return DtCorte = (DataTable)ViewState["DtCorte"]; }
|
|
set { ViewState["DtCorte"] = value; }
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
InicializaValores();
|
|
DdlHuerta.SelectedValueExist(Request["CveHuerta"] == null ? "-1" : Request["CveHuerta"].ToString());
|
|
txtFechaI.Text = Request["FechaI"] == null ? DateTime.Now.ToString() : Request["FechaI"].ToString();
|
|
txtFechaF.Text = Request["FechaF"] == null ? DateTime.Now.ToString() : Request["FechaF"].ToString();
|
|
if (DdlHuerta.SelectedValue.ToEntero() > 0) { Consulta(); }
|
|
}
|
|
}
|
|
|
|
private void InicializaValores()
|
|
{
|
|
CargaHuerta();
|
|
txtFechaI.Text = DateTime.Now.FirstDayOfMonth().ToShortDateString();
|
|
txtFechaF.Text = DateTime.Now.ToShortDateString();
|
|
UPFiltros.Update();
|
|
}
|
|
|
|
private void CargaHuerta()
|
|
{
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetHuerta(UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlHuerta.DataSource = ObjCGame.DtResultados;
|
|
DdlHuerta.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
}
|
|
ObjCGame.Dispose();
|
|
DdlHuerta.DataBind();
|
|
}
|
|
|
|
private void Consulta()
|
|
{
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetRepCorte(DdlHuerta.SelectedValue.ToEntero(), txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa))
|
|
{
|
|
DtCorte = ObjCGame.DtResultados.Copy();
|
|
int NumColumna = 1, ColTotales = 0;
|
|
ColTotales = DtCorte.Columns.Count;
|
|
for (int i = 0; i < ColTotales; i++)
|
|
{
|
|
if (i >= 2)
|
|
{
|
|
if (DtCorte.Rows[0][DtCorte.Columns[i].ColumnName].ToString().ToDouble() < 1)
|
|
{
|
|
DtCorte.Columns.Remove(DtCorte.Columns[i]);
|
|
i--;
|
|
ColTotales--;
|
|
}
|
|
else
|
|
{
|
|
GvDatos.Columns[NumColumna].HeaderText = DtCorte.Columns[i].ColumnName;
|
|
GvDatos.Columns[NumColumna].Visible = true;
|
|
DtCorte.Columns.Add("Nom" + NumColumna);
|
|
DtCorte.Rows[0]["Nom" + NumColumna] = DtCorte.Columns[i].ColumnName;
|
|
DtCorte.Columns[i].ColumnName = "Col" + NumColumna;
|
|
NumColumna++;
|
|
}
|
|
}
|
|
}
|
|
for (int i = NumColumna; i <= 20; i++)
|
|
{
|
|
DtCorte.Columns.Add("Nom" + i);
|
|
DtCorte.Rows[0]["Nom" + i] = "";
|
|
DtCorte.Columns.Add("Col" + i);
|
|
DtCorte.Rows[0]["Col" + i] = "";
|
|
}
|
|
|
|
GvDatos.DataSource = DtCorte;
|
|
}
|
|
ObjCGame.Dispose();
|
|
GvDatos.DataBind();
|
|
UPDatos.Update();
|
|
}
|
|
|
|
protected void BtnConsultar_Click(object sender, EventArgs e)
|
|
{
|
|
Consulta();
|
|
}
|
|
|
|
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.RowIndex == 0)
|
|
{
|
|
e.Row.Cells[0].Text = "Total";
|
|
e.Row.CssClass = "Totales";
|
|
}
|
|
}
|
|
}
|
|
} |