Exemplo n.º 1
0
        //検索ボタン
        private void m_selectBtn_Click(object sender, EventArgs e)
        {
            m_Site_List.Clear();
            DISP_dataSet dset = new DISP_dataSet();
            Dictionary <string, string> param_dict = new Dictionary <string, string>();
            Class_Detaget dg = new Class_Detaget();

            if (m_selecttext.Text != "")
            {
                if (this.m_selectKoumoku.SelectedIndex.ToString() != "")
                {
                    switch (this.m_selectKoumoku.SelectedIndex)
                    {
                    //拠点通番
                    case 0:
                        param_dict["siteno"] = m_selecttext.Text;
                        break;

                    //拠点名
                    case 1:
                        param_dict["sitename"] = m_selecttext.Text;
                        break;

                    //郵便番号
                    case 2:
                        param_dict["address1"] = m_selecttext.Text;
                        break;

                    //住所
                    case 3:
                        param_dict["address2"] = m_selecttext.Text;
                        break;

                    //TEL/FAX
                    case 4:
                        param_dict["telno"] = m_selecttext.Text;
                        break;

                    //ステータス
                    case 5:
                        if (m_selecttext.Text == "無効")
                        {
                            param_dict["status"] = "0";
                        }
                        else if (m_selecttext.Text == "有効")
                        {
                            param_dict["status"] = "1";
                        }

                        break;

                    //備考
                    case 6:
                        param_dict["biko"] = m_selecttext.Text;
                        break;

                    //カスタマ通番
                    case 7:
                        param_dict["userno"] = m_selecttext.Text;
                        break;

                    //システム通番
                    case 8:
                        param_dict["systemno"] = m_selecttext.Text;
                        break;

                    //更新日時
                    case 9:

                        DateTime dt;
                        String   str = m_selecttext.Text;

                        //入力された日付の形式の確認
                        if (DateTime.TryParse(str, out dt))
                        {
                            param_dict["chk_date"] = str;
                        }
                        else
                        {
                            MessageBox.Show("日付の形式が正しくありません。", "拠点検索");
                            return;
                        }
                        break;

                    //更新者
                    case 10:
                        param_dict["chk_name_id"] = m_selecttext.Text;
                        break;

                    default:
                        break;
                    }
                }
            }

            //まず件数を取得する
            Int64 count = dg.getSelectSiteCount(param_dict, con, dset, true);

            if (MessageBox.Show(count.ToString() + "件ヒットしました。表示しますか?", "拠点", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            //拠点一覧を取得する
            dset = dg.getSelectSite(param_dict, con, dset, true);

            this.splitContainer1.SplitterDistance = 227;
            this.m_Site_List.VirtualMode          = true;
            // 1行全体選択
            this.m_Site_List.FullRowSelect = true;
            this.m_Site_List.HideSelection = false;
            this.m_Site_List.HeaderStyle   = ColumnHeaderStyle.Clickable;
            //Hook up handlers for VirtualMode events.
            this.m_Site_List.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(Site_RetrieveVirtualItem);
            this.m_Site_List.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            this.m_Site_List.Scrollable = true;


            this.m_Site_List.Columns.Insert(0, "No", 30, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(1, "拠点名", 120, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(2, "郵便番号", 120, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(3, "住所", 90, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(4, "TEL/FAX", 80, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(5, "ステータス", 50, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(6, "カスタマ番号", 50, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(7, "カスタマ名", 120, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(8, "システム番号", 120, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(9, "システム名", 120, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(10, "更新日時", 50, HorizontalAlignment.Left);
            this.m_Site_List.Columns.Insert(11, "更新者", 50, HorizontalAlignment.Left);

            //リストビューを初期化する
            site_list = new DataTable("table1");
            site_list.Columns.Add("No", Type.GetType("System.Int32"));
            site_list.Columns.Add("拠点名", Type.GetType("System.String"));
            site_list.Columns.Add("郵便番号", Type.GetType("System.String"));
            site_list.Columns.Add("住所", Type.GetType("System.String"));
            site_list.Columns.Add("TEL/FAX", Type.GetType("System.String"));
            site_list.Columns.Add("ステータス", Type.GetType("System.String"));
            site_list.Columns.Add("カスタマ番号", Type.GetType("System.String"));
            site_list.Columns.Add("カスタマ名", Type.GetType("System.String"));
            site_list.Columns.Add("システム番号", Type.GetType("System.String"));
            site_list.Columns.Add("システム名", Type.GetType("System.String"));
            site_list.Columns.Add("更新日時", Type.GetType("System.String"));
            site_list.Columns.Add("更新者", Type.GetType("System.String"));

            //リストに表示
            if (dset.site_L != null)
            {
                m_Site_List.BeginUpdate();

                foreach (siteDS s_ds in dset.site_L)
                {
                    DataRow urow = site_list.NewRow();

                    urow["No"]      = s_ds.siteno;
                    urow["拠点名"]     = s_ds.sitename;
                    urow["郵便番号"]    = s_ds.address1;
                    urow["住所"]      = s_ds.address2;
                    urow["TEL/FAX"] = s_ds.telno;
                    urow["ステータス"]   = s_ds.status;
                    urow["カスタマ番号"]  = s_ds.userno;
                    urow["カスタマ名"]   = s_ds.username;
                    urow["システム番号"]  = s_ds.systemno;
                    urow["システム名"]   = s_ds.systemname;
                    urow["更新日時"]    = s_ds.chk_date;
                    urow["更新者"]     = s_ds.chk_name_id;
                    site_list.Rows.Add(urow);
                }
                this.m_Site_List.VirtualListSize = site_list.Rows.Count;
                this.m_Site_List.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

                m_Site_List.EndUpdate();
            }
        }