Beispiel #1
0
        protected void gvPELList_Sorting(object sender, GridViewSortEventArgs e)
        {
            Classes.cUserOption Option = new Classes.cUserOption();
            Option.LoadOptionValue(Master.UserName, HttpContext.Current.Request.Url.AbsolutePath, "gvPELList", "SortField");
            string sSortField = Option.OptionValue;

            Option.LoadOptionValue(Master.UserName, HttpContext.Current.Request.Url.AbsolutePath, "gvPELList", "SortDir");
            string sSortDir = Option.OptionValue;

            if (e.SortExpression == sSortField)
            {
                if (String.IsNullOrEmpty(sSortDir))
                {
                    sSortDir = "DESC";
                }
                else
                {
                    sSortDir = "";
                }
            }
            else
            {
                sSortField = e.SortExpression;
                sSortDir   = "";
            }

            Option = new Classes.cUserOption();
            Option.LoginUsername = Master.UserName;
            Option.PageName      = HttpContext.Current.Request.Url.AbsolutePath;
            Option.ObjectName    = "gvPELList";
            Option.ObjectOption  = "SortField";
            Option.OptionValue   = sSortField;
            Option.SaveOptionValue();

            Option = new Classes.cUserOption();
            Option.LoginUsername = Master.UserName;
            Option.PageName      = HttpContext.Current.Request.Url.AbsolutePath;
            Option.ObjectName    = "gvPELList";
            Option.ObjectOption  = "SortDir";
            Option.OptionValue   = sSortDir;
            Option.SaveOptionValue();
        }
Beispiel #2
0
        protected void BindData()
        {
            SortedList sParams       = new SortedList();
            DataTable  dtCharHistory = new DataTable();

            int iSessionID = 0;

            int.TryParse(Session ["CampaignID"].ToString(), out iSessionID);
            sParams.Add("@CampaignID", iSessionID);

            dtCharHistory = Classes.cUtilities.LoadDataTable("uspGetCampaignCharacterHistory", sParams, "LARPortal", Session ["UserName"].ToString(), "PELApprovalList.Page_PreRender");

            if (!IsPostBack)
            {
                ddlCharacterName.DataSource     = dtCharHistory;
                ddlCharacterName.DataTextField  = "CharacterAKA";
                ddlCharacterName.DataValueField = "CharacterAKA";
                ddlCharacterName.DataBind();

                if (dtCharHistory.Rows.Count > 1)
                {
                    ListItem liNoFilter = new ListItem();
                    liNoFilter.Text  = "No Filter";
                    liNoFilter.Value = "";
                    ddlCharacterName.Items.Insert(0, liNoFilter);
                }
            }

            string sSelectedChar = "";
            string sStatus       = "";
            string sRowFilter    = "";

            Classes.cUserOption Option = new Classes.cUserOption();
            Option.LoadOptionValue(Session["UserName"].ToString(), HttpContext.Current.Request.Url.AbsolutePath, "ddlCharacterName", "SelectedValue");
            sSelectedChar = Option.OptionValue;

            Option.LoadOptionValue(Session["UserName"].ToString(), HttpContext.Current.Request.Url.AbsolutePath, "ddlStatus", "SelectedValue");
            sStatus = Option.OptionValue;

            if (!string.IsNullOrEmpty(sSelectedChar))
            {
                ddlCharacterName.ClearSelection();
                foreach (ListItem lItem in ddlCharacterName.Items)
                {
                    if (lItem.Value == sSelectedChar)
                    {
                        sRowFilter = "(CharacterAKA = '" + lItem.Value.Replace("'", "''") + "')";
                        ddlCharacterName.ClearSelection();
                        lItem.Selected = true;
                    }
                }
                if (ddlCharacterName.SelectedIndex < 0)
                {
                    ddlCharacterName.SelectedIndex = 0;
                }
            }
            else
            {
                if (sStatus.Length > 0)
                {
                    ddlStatus.ClearSelection();
                    foreach (ListItem lItem in ddlStatus.Items)
                    {
                        if (lItem.Value == sStatus)
                        {
                            switch (sStatus)
                            {
                            case "A":
                                sRowFilter = "(DateHistoryApproved is not null)";
                                break;

                            case "S":
                                sRowFilter = "(DateHistoryApproved is null) and (DateHistorySubmitted is not null)";
                                break;

                            default:
                                sRowFilter = "(DateHistorySubmitted is not null)";
                                break;
                            }
                        }
                    }
                    if (ddlStatus.SelectedIndex < 0)
                    {
                        ddlStatus.SelectedIndex = 0;
                    }
                }
            }

            if (dtCharHistory.Columns ["HistoryStatus"] == null)
            {
                dtCharHistory.Columns.Add("HistoryStatus", typeof(string));
            }

            if (dtCharHistory.Columns ["ShortHistory"] == null)
            {
                dtCharHistory.Columns.Add("ShortHistory", typeof(string));
            }

            foreach (DataRow dRow in dtCharHistory.Rows)
            {
                string sRawHistory     = dRow ["CharacterHistory"].ToString();
                string ScrubbedHistory = ScrubHtml(sRawHistory);

                if (ScrubbedHistory.Length > 100)
                {
                    dRow ["ShortHistory"] = ScrubbedHistory.Substring(0, 95) + "...";
                }
                else
                {
                    dRow ["ShortHistory"] = ScrubbedHistory;
                }
                if (dRow ["DateHistoryApproved"] == DBNull.Value)
                {
                    dRow ["HistoryStatus"] = "Submitted";
                }
                else
                {
                    dRow ["HistoryStatus"] = "Approved";
                }
            }

            DataView dvPELs = new DataView(dtCharHistory, sRowFilter, "CharacterAKA", DataViewRowState.CurrentRows);

            gvHistoryList.DataSource = dvPELs;
            gvHistoryList.DataBind();
        }