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_RepCorteGasto : ClsPaginas { #region PROPIEDADES private int CveHuerta { get { return (ViewState["CveHuerta"] == null) ? 0 : Convert.ToInt32(ViewState["CveHuerta"]); } set { ViewState["CveHuerta"] = value; } } private int Modalidad { get { return (ViewState["Modalidad"] == null) ? 0 : Convert.ToInt32(ViewState["Modalidad"]); } set { ViewState["Modalidad"] = value; } } #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { InicializaValores(); } } private void InicializaValores() { CargaConceptos(); CargaHuerta(); txtFechaI.Text = DateTime.Now.ToShortDateString(); txtFechaF.Text = DateTime.Now.ToShortDateString(); CveHuerta = Request["CveHuerta"] == null ? 0 : Request["CveHuerta"].ToString().ToEntero(); Modalidad = Request["Modalidad"] == null ? 0 : Request["Modalidad"].ToString().ToEntero(); if (CveHuerta > 0) { DdlHuerta.SelectedValueExist(CveHuerta); DdlGrupo.SelectedValue = "2"; DdlModalidad.SelectedValueExist(Modalidad); txtFechaI.Text = MinFecha.ToShortDateString(); txtFechaF.Text = MaxFecha.ToShortDateString(); if (Modalidad == 2) { DivGastos.Visible = false; DivOtrosGastos.Visible = true; } } Consultar(); } private void CargaConceptos() { ClsCGame ObjCGame = new ClsCGame(); if (ObjCGame.GetConceptoGastoCorte(UsuarioActual.CveEmpresa, Estatus: 1)) { DdlConcepto.DataSource = ObjCGame.DtResultados; DdlConcepto.Items.Insert(0, new ListItem("Todos", "-1")); ObjCGame.Dispose(); } DdlConcepto.DataBind(); UPFiltros.Update(); } private void CargaHuerta() { ClsCGame ObjCGame = new ClsCGame(); if (ObjCGame.GetHuerta(UsuarioActual.CveEmpresa, Estatus: 1)) { DdlHuerta.DataSource = ObjCGame.DtResultados; DdlHuerta.Items.Insert(0, new ListItem("Todos", "-1")); ObjCGame.Dispose(); } DdlHuerta.DataBind(); UPFiltros.Update(); } protected void BtnConsultar_Click(object sender, EventArgs e) { Consultar(); } private void Consultar() { ClsCGame ObjCGame = new ClsCGame(); if (ObjCGame.GetRepCorteGasto(UsuarioActual.CveEmpresa, DdlHuerta.SelectedValue.ToEntero(), DdlConcepto.SelectedValue.ToEntero(), txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), DdlGrupo.SelectedValue.ToEntero(),DdlModalidad.SelectedValue.ToEntero())) { if (DdlModalidad.SelectedValue.ToEntero() == 2) { GvOtrosGastos.DataSource = ObjCGame.DtResultados; } else { GvGastos.DataSource = ObjCGame.DtResultados; } ObjCGame.Dispose(); } if (DdlModalidad.SelectedValue.ToEntero() == 2) { GvOtrosGastos.DataBind(); } else { GvGastos.DataBind(); } UpDatos.Update(); UpOtrosGastos.Update(); } protected void GvGastos_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowIndex == 0) { e.Row.CssClass = "Totales"; e.Row.Cells[0].Text = "Total"; } if (e.Row.RowIndex > 0 && DdlGrupo.SelectedValue.ToEntero() == 1) { if (e.Row.DBCampo("ConceptoGastoCorte").ToString() == "") { e.Row.CssClass = "SubTotales"; e.Row.Cells[0].Text = e.Row.DBCampo("Gpo").ToString(); } } else if (e.Row.RowIndex > 0 && DdlGrupo.SelectedValue.ToEntero() == 2) { if (e.Row.DBCampo("ConceptoGastoCorte").ToString() == "" && e.Row.DBCampo("Gpo").ToString() == e.Row.DBCampo("Huerta").ToString()) { e.Row.CssClass = "SubTotales"; e.Row.Cells[0].Text = e.Row.DBCampo("Huerta").ToString(); } else if (e.Row.DBCampo("ConceptoGastoCorte").ToString() == "") { e.Row.CssClass = "SubTotales2"; e.Row.Cells[0].Text = e.Row.DBCampo("Gpo").ToString(); } } } } protected void GvOtrosGastos_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowIndex == 0) { e.Row.CssClass = "Totales"; e.Row.Cells[0].Text = "Total"; } if (e.Row.RowIndex > 0 && DdlGrupo.SelectedValue.ToEntero() == 1) { if (e.Row.DBCampo("RazonSocial").ToString() == "") { e.Row.CssClass = "SubTotales"; e.Row.Cells[0].Text = e.Row.DBCampo("Gpo").ToString(); } } else if (e.Row.RowIndex > 0 && DdlGrupo.SelectedValue.ToEntero() == 2) { if (e.Row.DBCampo("RazonSocial").ToString() == "" && e.Row.DBCampo("Gpo").ToString() == e.Row.DBCampo("Huerta").ToString()) { e.Row.CssClass = "SubTotales"; e.Row.Cells[0].Text = e.Row.DBCampo("Huerta").ToString(); } else if (e.Row.DBCampo("RazonSocial").ToString() == "") { e.Row.CssClass = "SubTotales2"; e.Row.Cells[0].Text = e.Row.DBCampo("Gpo").ToString(); } } } } protected void DdlModalidad_SelectedIndexChanged(object sender, EventArgs e) { if (DdlModalidad.SelectedValue.ToEntero() == 1) { DivGastos.Visible = true; DivOtrosGastos.Visible = false; } else { DivGastos.Visible = false; DivOtrosGastos.Visible = true; } UpOtrosGastos.Update(); UpDatos.Update(); } }