예제 #1
0
    protected void SortUpdateHistory(string sortExpression, params string[] sortExpr)
    {
        DataTable dataTable = Session["registerstockupdatehistory_data"] as DataTable;

        if (dataTable != null)
        {
            if (Session["registerstockupdatehistory_sortexpression"] == null)
            {
                Session["registerstockupdatehistory_sortexpression"] = "";
            }

            DataView dataView = new DataView(dataTable);
            string[] sortData = Session["registerstockupdatehistory_sortexpression"].ToString().Trim().Split(' ');

            string newSortExpr = (sortExpr.Length == 0) ?
                                 (sortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC" :
                                 sortExpr[0];

            dataView.Sort = sortExpression + " " + newSortExpr;
            Session["registerstockupdatehistory_sortexpression"] = sortExpression + " " + newSortExpr;

            GrdUpdateHistory.DataSource = dataView;
            GrdUpdateHistory.DataBind();
        }
    }
예제 #2
0
    protected void FillGridUpdateHistory()
    {
        Organisation org = null;

        if (IsValidFormID())
        {
            org = OrganisationDB.GetByID(GetFormID());
        }

        DataTable dt = org == null?StockUpdateHistoryDB.GetDataTable() : StockUpdateHistoryDB.GetDataTable_ByOrg(org.OrganisationID);

        Session["registerstockupdatehistory_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["registerstockupdatehistory_sortexpression"] != null && Session["registerstockupdatehistory_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort = Session["registerstockupdatehistory_sortexpression"].ToString();
                GrdUpdateHistory.DataSource = dataView;
            }
            else
            {
                GrdUpdateHistory.DataSource = dt;
            }


            try
            {
                GrdUpdateHistory.DataBind();
                GrdUpdateHistory.PagerSettings.FirstPageText = "1";
                GrdUpdateHistory.PagerSettings.LastPageText  = GrdUpdateHistory.PageCount.ToString();
                GrdUpdateHistory.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdUpdateHistory.DataSource = dt;
            GrdUpdateHistory.DataBind();

            int TotalColumns = GrdUpdateHistory.Rows[0].Cells.Count;
            GrdUpdateHistory.Rows[0].Cells.Clear();
            GrdUpdateHistory.Rows[0].Cells.Add(new TableCell());
            GrdUpdateHistory.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdUpdateHistory.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }