protected void Page_Load(object sender, EventArgs e)
        {
            bool isSearchQueryString = false;

            if (!Page.IsPostBack)
            {
                StaffUserList.Items.AddRange(GetStaffUserList());
                SubmitterUserList.Items.AddRange(GetSubmitterUserList());
                CategoryList.DataSource = SettingsManager.CategoriesList;
                CategoryList.DataBind();
                BuildPriorityList();
                TypeList.DataSource = SettingsManager.TicketTypesList;
                TypeList.DataBind();
                isSearchQueryString = ProcessSearchQuery();
            }


            if (!Page.IsPostBack && !isSearchQueryString)
            {
                SearchTitleCheckBox.Checked = true;
            }
            if (Page.IsPostBack || isSearchQueryString)
            {
                List <string> terms    = new List <string>();
                List <string> andTerms = new List <string>();
                if (!string.IsNullOrEmpty(SearchTerms.Text))
                {
                    string[] words = SearchTerms.Text.Split(' ');

                    foreach (string word in words)
                    {
                        if (SearchTagsCheckBox.Checked)
                        {
                            terms.Add(string.Format("TagList.Contains(\"{0}\")", word));
                        }
                        if (SearchTitleCheckBox.Checked)
                        {
                            terms.Add(string.Format("Title.Contains(\"{0}\")", word));
                        }
                        if (SearchDetailsCheckBox.Checked)
                        {
                            terms.Add(string.Format("Details.Contains(\"{0}\")", word));
                        }
                    }
                }
                switch (StatusList.SelectedValue)
                {
                case "Open":
                    andTerms.Add("CurrentStatus != \"Closed\"");
                    break;

                case "Active":
                    andTerms.Add("CurrentStatus == \"Active\"");
                    break;

                case "More Info":
                    andTerms.Add("CurrentStatus == \"More Info\"");
                    break;

                case "Resolved":
                    andTerms.Add("CurrentStatus == \"Resolved\"");
                    break;

                case "Closed":
                    andTerms.Add("CurrentStatus == \"Closed\"");
                    break;

                default:
                    //status DDL = any
                    //do nothing
                    break;
                }

                if (StaffUserList.SelectedValue != "any")
                {
                    andTerms.Add(string.Format("AssignedTo == \"{0}\"", StaffUserList.SelectedValue));
                }
                if (SubmitterUserList.SelectedValue != "any")
                {
                    andTerms.Add(string.Format("Owner == \"{0}\"", SubmitterUserList.SelectedValue));
                }
                if (CategoryList.SelectedValue != "any")
                {
                    andTerms.Add(string.Format("Category == \"{0}\"", CategoryList.SelectedValue));
                }
                if (TypeList.SelectedValue != "any")
                {
                    andTerms.Add(string.Format("Type == \"{0}\"", TypeList.SelectedValue));
                }

                if (PriorityList.SelectedValue != "any")
                {
                    andTerms.Add(string.Format("Priority == \"{0}\"", PriorityList.SelectedValue));
                }



                ListViewControl.Visible = true;

                string s = string.Empty;
                if (terms.Count > 0)
                {
                    s = string.Format("({0})", string.Join(" || ", terms.ToArray()));
                }
                string a = string.Empty;
                if (andTerms.Count > 0)
                {
                    string seperator = ((terms.Count > 0) ? " && " : string.Empty);
                    a = string.Format("{1}({0})", string.Join(" && ", andTerms.ToArray()), seperator);
                }
                if (!string.IsNullOrEmpty(s) || !string.IsNullOrEmpty(a))
                {
                    ListViewControl.Where = s + a;
                }
            }
        }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AdminPopedom.IsHoldModel("10");

        DataTable sd1  = new DataTable();
        string    sql1 = "select TypeID,TypeName from Web_NewsType order by Typeid desc";

        sd1 = DbSession.Default.FromSql(sql1).ToDataTable();           //sqlconn.sqlReader(sql1);
        if (sd1.Rows.Count > 0)
        {
            TypeList.DataSource = sd1;
            TypeList.DataBind();
        }
        sd1.Clear();

        Cids = CommonManager.Web.Request("cid", "");                         //Limit.editCharacter(Limit.getFormValue("cid"));
        sqlrecommendation = CommonManager.Web.Request("recommendation", ""); //Limit.editCharacter(Limit.getFormValue("recommendation"));
        sqlIstop          = CommonManager.Web.Request("Istop", "");          //Limit.editCharacter(Limit.getFormValue("Istop"));
        sqlthrough        = CommonManager.Web.Request("through", "");        //Limit.editCharacter(Limit.getFormValue("through"));

        if (sqlrecommendation.ToString() == "1")
        {
            SqlW = " and recommendation=1";
            para = "recommendation=1";
        }
        else if (sqlIstop.ToString() == "1")
        {
            SqlW = " and Istop=1";
            para = "Istop=1";
        }
        else if (sqlthrough.ToString() == "1")
        {
            SqlW = " and through=0";
            para = "through=0";
        }
        else if (Cids.ToString() != "")
        {
            SqlW = " and News_Type =" + Cids + "";
            para = "Cid=" + Cids + "";
        }
        else
        {
            SqlW = "";
            para = "";
        }

        DataSet ds = DbSession.Default.FromProc("Web_pGetDataPager")
                     .AddInputParameter("@PageSize", DbType.Int32, anpPageIndex.PageSize)
                     .AddInputParameter("@CurrentPage", DbType.Int32, PageIndex)
                     .AddInputParameter("@Columns", DbType.String, "*")
                     .AddInputParameter("@TableName", DbType.String, "Web_NewsData")
                     .AddInputParameter("@Wheres", DbType.String, SqlW)
                     .AddInputParameter("@KeyName", DbType.String, "News_ID")
                     .AddInputParameter("@OrderBy", DbType.String, "News_ID desc")
                     .ToDataSet();

        if (ds.Tables.Count > 0 && ds.Tables[1].Rows.Count > 0)
        {
            anpPageIndex.RecordCount      = (int)ds.Tables[0].Rows[0][0];
            anpPageIndex.CurrentPageIndex = PageIndex;

            NewsList.DataSource = ds.Tables[1];
            NewsList.DataBind();
            NewsList.Visible   = true;
            NoNewsList.Visible = false;
        }
        else
        {
            NewsList.Visible   = false;
            NoNewsList.Visible = true;
        }

        /*
         * DataTable sd = new DataTable();
         * string[] sql = new string[2];
         * sql[0] = "select * from Web_NewsData " + SqlW + " order by News_ID desc";
         * //Response.Write(sql[0] + "<br>");
         * sql[1] = "select count(*) from Web_NewsData " + SqlW + "";
         * //Response.Write(sql[1]);
         * string url = "News.aspx";
         * PageLink page_set = new PageLink(url, 20, 10, para, sql);
         * page_set.paraLinkType = paraLinkShow.middling.ToString();
         * sd = page_set.get_table();
         * if (sd.Rows.Count > 0)
         * {
         * Repeater Vlist = (Repeater)Page.FindControl("NewsList");
         * Vlist.DataSource = sd;
         * Vlist.DataBind();
         * this.pageList.Text = page_set.pageList();
         * }
         * else
         * this.NoNewsList.Visible = true;
         * sd.Clear();*/
    }