using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Extensiones; public partial class Ventas_RepConciliacionSat : ClsPaginas { const string rqFechaInicio = "FechaInicio"; const string rqFechaFin = "FechaFin"; public string RfechaI { get { return ViewState["RfechaI"].ToString(); } set { ViewState["RfechaI"] = value; } } public string RfechaF { get { return ViewState["RfechaF"].ToString(); } set { ViewState["RfechaF"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DateTime fecha; DateTime fechaInicio = DateTime.Now; DateTime fechaFin = DateTime.Now; if (fechaInicio.Day < 5) { fechaInicio = fechaInicio.AddMonths(-1); } fechaInicio = fechaInicio.AddDays(1 - fechaInicio.DayOfYear); fechaFin = fechaInicio.AddYears(1).AddDays(-1); if (Request[rqFechaInicio] != null) { DateTime.TryParse(Request[rqFechaInicio], out fecha); fechaInicio = fecha.Year > 1900 ? fecha : fechaInicio; } if (Request[rqFechaFin] != null) { DateTime.TryParse(Request[rqFechaFin], out fecha); fechaFin = fecha.Year > 1900 ? fecha : fechaFin; } txtFechaI.Text = string.Format("{0:dd/MM/yyyy}", fechaInicio); txtFechaF.Text = string.Format("{0:dd/MM/yyyy}", fechaFin); } CargaRepConciliacionSatGET(); } protected void CargaRepConciliacionSatGET() { string RtipoDocto; RtipoDocto = "I"; RfechaI = txtFechaI.Text.Length > 0 ? txtFechaI.Text.ToDateTime().ToString("yyyy/MM/dd") : ""; RfechaF = txtFechaF.Text.Length > 0 ? txtFechaF.Text.ToDateTime().ToString("yyyy/MM/dd") : ""; using (ClsGenerales ObjRepC = new ClsGenerales()) { ObjRepC.RepConciliacionSATGet(UsuarioActual.CveEmpresa, RtipoDocto, RfechaI, RfechaF); GVRepConciliacionSatGET.DataSource = ObjRepC.DtResultados; ObjRepC.Dispose(); } GVRepConciliacionSatGET.DataBind(); upDatosRepC.Update(); } protected void BtnConsultar_Click(object sender, EventArgs e) { CargaRepConciliacionSatGET(); } protected void GVRepConciliacionSatGET_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string fechaI = RfechaI; string fechaF = RfechaF; DateTime danio; DateTime danioF; int GRUPOCve = e.Row.DBCampo("GRUPOCve").ToString().ToEntero(); e.Row.CssClass = string.Format("Grupo{0}", GRUPOCve); e.Row.Attributes.Add("ganio", string.Format("{0}", e.Row.DBCampo("anio"))); e.Row.Attributes.Add("gMes", string.Format("{0}", e.Row.DBCampo("Mes"))); string navigateurl = ""; switch (GRUPOCve) { case 0: break; case 1: danio = string.Format("{0}/01/01", e.Row.DBCampo("anio")).ToDateTime(); danioF = danio.AddYears(1).AddSeconds(-1); if (RfechaI.ToDateTime() < danio) { fechaI = danio.ToString("yyyy/MM/dd"); } if (RfechaF.ToDateTime() > danioF || RfechaF.Length == 0) { fechaF = danioF.ToString("yyyy/MM/dd HH:mm:ss"); } break; case 2: danio = string.Format("{0}/{1}/01", e.Row.DBCampo("anio"), e.Row.DBCampo("Mes").Substring(4)).ToDateTime(); danioF = danio.AddMonths(1).AddSeconds(-1); if (RfechaI.ToDateTime() < danio) { fechaI = danio.ToString("yyyy/MM/dd"); } if (RfechaF.ToDateTime() > danioF || RfechaF.Length == 0) { fechaF = danioF.ToString("yyyy/MM/dd HH:mm:ss"); } break; case 3: danio = string.Format("{0:yyyy/MM/dd}", e.Row.DBCampo("dia")).ToDateTime(); danioF = danio.AddDays(1).AddSeconds(-1); if (RfechaI.ToDateTime() < danio) { fechaI = danio.ToString("yyyy/MM/dd"); } if (RfechaF.ToDateTime() > danioF || RfechaF.Length == 0) { fechaF = danioF.ToString("yyyy/MM/dd HH:mm:ss"); } break; default: break; } navigateurl = string.Format("{0}&{3}={1}&{4}={2}", navigateurl, fechaI, fechaF, rqFechaInicio, rqFechaFin); e.Row.FCHyperLink("HypSIG").NavigateUrl = string.Format("/Ventas/RepConciliacionEmitidosSat.aspx?RegistroEn=1{0}", navigateurl); e.Row.FCHyperLink("HypSAT").NavigateUrl = string.Format("/Ventas/RepConciliacionEmitidosSat.aspx?RegistroEn=2{0}", navigateurl); e.Row.FCHyperLink("HypSIGnoSAT").NavigateUrl = string.Format("/Ventas/RepConciliacionEmitidosSat.aspx?RegistroEn=3{0}", navigateurl); e.Row.FCHyperLink("HypSatnoSIG").NavigateUrl = string.Format("/Ventas/RepConciliacionEmitidosSat.aspx?RegistroEn=4{0}", navigateurl); } } }