Beispiel #1
0
        private void CarregarTela(string SortExpression)
        {
            if (IsPostBack)
            {
                ExtratoUtilizacaoBLL CredReeBLL = new ExtratoUtilizacaoBLL();
                int iRepresentante = 0;
                int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante);

                var dadosGrid = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, " ", DateTime.Parse(txtDtIni.Text), DateTime.Parse(txtDtFim.Text));

                DataTable dt1        = dadosGrid;
                DataTable tblOrdered = new DataTable();
                DataView  view       = new DataView();

                var vsSort = ViewState["SortDirection"];

                if (String.IsNullOrEmpty(SortExpression))
                {
                    grdExtratoUtilizacao.DataSource = dt1;
                    grdExtratoUtilizacao.DataBind();
                    return;
                }

                if (dt1.Rows.Count > 0)
                {
                    if (vsSort == null)
                    {
                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending;
                    }


                    System.Web.UI.WebControls.SortDirection lastDirection = (System.Web.UI.WebControls.SortDirection)ViewState["SortDirection"];

                    if (lastDirection != System.Web.UI.WebControls.SortDirection.Ascending)
                    {
                        EnumerableRowCollection <DataRow> query = from row in dt1.AsEnumerable()
                                                                  orderby DateTime.Parse(row.Field <string>(SortExpression)) descending
                                                                  select row;

                        tblOrdered = query.AsDataView().ToTable();

                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending;
                    }
                    else
                    {
                        EnumerableRowCollection <DataRow> query = from row in dt1.AsEnumerable()
                                                                  orderby DateTime.Parse(row.Field <string>(SortExpression)) ascending
                                                                  select row;

                        tblOrdered = query.AsDataView().ToTable();

                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending;
                    }

                    grdExtratoUtilizacao.DataSource = tblOrdered;
                    grdExtratoUtilizacao.DataBind();
                }
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string detalhado         = Request.QueryString["hidDetalhado"] ?? "false";
            string visualizar        = Request.QueryString["hidVisualizar"] ?? "false";
            string COD_EMPRS         = Request.QueryString["nempr"];
            string NUM_RGTRO_EMPRG   = Request.QueryString["nreg"];
            string PARTICIPANTEEMAIL = Request.QueryString["ParticipanteEmail"];

            NUM_IDNTF_RPTANT = Util.String2Int32(Request.QueryString["nrepr"]);

            ScriptManager.RegisterStartupScript(UpdatePanel,
                                                UpdatePanel.GetType(),
                                                "script",
                                                "_client_side_script()",
                                                true);

            Page.Form.DefaultButton = btnPesquisar.UniqueID;

            if (!IsPostBack)
            {
                if (!String.IsNullOrEmpty(COD_EMPRS) && !String.IsNullOrEmpty(NUM_RGTRO_EMPRG))
                {
                    //ReportCrystal.Visible = false;
                    txtCodEmpresa.Text   = COD_EMPRS;
                    txtCodMatricula.Text = NUM_RGTRO_EMPRG;
                    if (!String.IsNullOrEmpty(PARTICIPANTEEMAIL) && PARTICIPANTEEMAIL != "undefined")
                    {
                        txtEMail.Text = PARTICIPANTEEMAIL;
                    }
                    //txtDtIni.Text = DateTime.Now.AddMonths(-12).ToString("dd/MM/yyyy");
                    //txtDtFim.Text = DateTime.Now.ToString("dd/MM/yyyy");
                    CarregarDropDown();
                    //if (ValidarCampos())
                    //{
                    ExtratoUtilizacaoBLL CredReeBLL = new ExtratoUtilizacaoBLL();
                    int iRepresentante = 0;
                    int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante);
                    DataTable dadosGrid = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, " ", DateTime.Now.AddMonths(-2), DateTime.Now);
                    grdExtratoUtilizacao.DataSource = dadosGrid;
                    grdExtratoUtilizacao.DataBind();
                    grdExtratoUtilizacao.Visible   = true;
                    ifExtratoUtilSysDocs_0.Visible = false;
                    ifExtratoUtilSysDocs_1.Visible = false;
                    txtEMail.Enabled = true;
                    btnEmail.Enabled = true;



                    //}
                }
            }
        }