コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: vatcharaj/smspipeline
        private void bindAllgroup()
        {
            OracleQuery2 cc2      = new OracleQuery2();
            DataTable    _dtgroup = cc2.LoadAllGroups();
            DataTable    dtgroup  = _dtgroup.Select("GROUP_LEVEL >2").Length > 0 ? _dtgroup.Select("GROUP_LEVEL >2").CopyToDataTable() : _dtgroup.Clone();

            dtgroup.Columns.Add("text");
            dtgroup.Columns.Add("text_grp");
            foreach (DataRow r in dtgroup.Rows)
            {
                r["text"]     = r["DEPARTMENT"] + " - " + r["GROUP_NAME"];
                r["text_grp"] = r["GROUP_NAME"];
            }
            DataView  view           = new DataView(dtgroup.Select("MASTER_GROUP_ID <> GROUP_ID ").CopyToDataTable());
            DataTable distinctValues = view.ToTable(true, "text_grp");

            GroupList.DataSource     = distinctValues;
            GroupList.DataTextField  = "text_grp";
            GroupList.DataValueField = "text_grp";
            GroupList.DataBind();



            GroupList.Items.Insert(0, new ListItem("--ทั้งหมด--", "-1"));
            GroupList.SelectedIndex            = 0;
            GroupList_selectall.DataSource     = dtgroup;
            GroupList_selectall.DataTextField  = "text";
            GroupList_selectall.DataValueField = "GROUP_ID";
            GroupList_selectall.DataBind();
            GroupList_selectall.Items.Insert(0, new ListItem("--กรุณาเลือกกลุ่ม--", "-11"));
            //GroupList_selectall.Items.Insert(1, new ListItem("--ทั้งหมด--", "0"));
            GroupList_selectall.SelectedIndex = 0;
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: vatcharaj/smspipeline
        private void group2sendSch()
        {
            updateProgress.Visible = false;
            try
            {
                string shtext   = GroupTosend.Text.TrimEnd().ToUpper();
                string group_id = GroupList.SelectedValue;

                if (GroupList.Items.FindByText(shtext) != null)
                {
                    group_id = GroupList.Items.FindByText(shtext).Value;
                }
                else
                {
                    group_id = GroupList.Items[0].Value;
                }


                DataTable dt     = new DataTable();
                int       ismain = 0;
                if (shtext == "" && group_id == "-1")
                {
                    return;
                }

                OracleQuery2 cc2    = new OracleQuery2();
                DataTable    dttemp = cc2.LoadAllGroups();
                if (shtext == "" && group_id != "-1")
                {
                    dt = dttemp.Select("GROUP_NAME = '" + group_id + "'").CopyToDataTable();
                }
                else if (shtext != "" && group_id != "-1")
                {
                    dt = dttemp.Select("GROUP_NAME = '" + group_id + "' and " + "Keyword like '%" + shtext + "%'").CopyToDataTable();
                }
                else if (shtext != "" && group_id == "-1")
                {
                    dt = dttemp.Select("Keyword like '%" + shtext + "%'").CopyToDataTable();
                }



                if (dt != null && dt.Rows.Count > 0)
                {
                    dt.Columns.Add("ISselect");
                    foreach (DataRow r in dt.Rows)
                    {
                        r["ISselect"] = 0;
                    }
                    #region
                    //if (ismain == 0)
                    //{
                    //    string group_name = "";
                    //    if (GroupList.Items.FindByText(GroupTosend.Text) != null)
                    //        group_name = GroupTosend.Text;
                    //    else
                    //        group_name = "";
                    //    DataRow newRow = dt.NewRow();
                    //    newRow["GROUP_ID"] = GroupList.SelectedValue == "-1" ? dt.Rows[dt.Rows.Count - 1]["GROUP_ID"] : GroupList.SelectedValue;
                    //    newRow["GROUP_NAME"] = GroupList.SelectedValue == "-1" ? group_name : GroupList.SelectedItem.Text;
                    //    newRow["DEPARTMENT"] = dt.Rows[dt.Rows.Count - 1]["DEPARTMENT"];
                    //    //newRow["DESCR"] = "";
                    //    //newRow["NAME"] = "";
                    //    newRow["ISselect"] = 0;
                    //    dt.Rows.InsertAt(newRow, 0);
                    //}
                    #endregion
                }
                else
                {
                    return;
                }
                DataView dv = dt.DefaultView;
                dv.Sort = "GROUP_NAME,GROUP_ID asc";
                dt      = dv.ToTable();
                ViewState["SCHTable"]      = dt;
                GroupResultGrid.DataSource = dt;
                GroupResultGrid.DataBind();
                grpPanel.Visible    = true;
                DetailPanel.Visible = true;
            }
            catch
            {
                return;
            }
        }