{"id":2055,"date":"2017-11-10T08:56:57","date_gmt":"2017-11-09T23:56:57","guid":{"rendered":"http:\/\/okamurax.com\/?p=2055"},"modified":"2024-05-03T19:00:30","modified_gmt":"2024-05-03T10:00:30","slug":"c-%e5%9c%a8%e5%ba%ab%e7%ae%a1%e7%90%86ver2","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2055","title":{"rendered":"C# \u5728\u5eab\u7ba1\u7406"},"content":{"rendered":"<p>\u4ee5\u524d\u306b\u3082\u6570\u56de\u540c\u3058\u3088\u3046\u306a\u30bd\u30d5\u30c8\u3092\u4f5c\u3063\u3066\u3044\u308b\u304c\u3001\u4eca\u56de\u306f<br \/>\n\u8868\u3092\u4e26\u3079\u3066\u8868\u793a\u3059\u308b\u30bf\u30a4\u30d7\u3002<\/p>\n<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing System.Windows.Forms;\r\n\r\nusing System.Data.OleDb;\r\nusing System.IO;\r\n\r\nnamespace \u9810\u304b\u308a\u5728\u5eab\u7ba1\u7406ver2\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        public void dgv1_setup()\r\n        {\r\n            string[] header = new string[] {\r\n                \"ID\",\r\n                \"\u767b\u9332\u65e5\",\r\n                \"\u4f1d\u7968\u756a\u53f7\",\r\n                \"\u5f97\u610f\u5148\",\r\n                \"\u4ed5\u5165\u5148\",\r\n                \"\u54c1\u76ee\u540d\",\r\n                \"PO\",\r\n                \"INV\",\r\n                \"\u6570\u91cf\",\r\n                \"\u5099\u8003\"\r\n            };\r\n\r\n            foreach (string h in header)\r\n            {\r\n                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();\r\n                col.HeaderText = h;\r\n                dataGridView1.Columns.Add(col);\r\n            }\r\n\r\n            for (int i = 1; i &lt;= 2; i++)\r\n            {\r\n                DataGridViewButtonColumn col_btn = new DataGridViewButtonColumn();\r\n                col_btn.HeaderText = \"\u3000\u3000\u3000\u3000\u3000\u3000\";\r\n                dataGridView1.Columns.Add(col_btn);\r\n            }\r\n\r\n            dataGridView1.Columns[0].Visible = false;\r\n            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;\r\n            dataGridView1.ReadOnly = true;\r\n            dataGridView1.AllowUserToAddRows = false;\r\n            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;\r\n            dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;\r\n            dataGridView1.RowTemplate.Height = 28;\r\n            dataGridView1.Font = new Font(\"Meiryo UI\", 9);\r\n            dataGridView1.MultiSelect = false;\r\n\r\n            dataGridView1.CellClick += new DataGridViewCellEventHandler(cell_click);\r\n        }\r\n\r\n        public void dgv2_setup()\r\n        {\r\n            string[] header = new string[] {\r\n                \"ID\",\r\n                \"\u51fa\u5eab\u65e5\",\r\n                \"\u51fa\u5eab\u6570\"\r\n            };\r\n\r\n            foreach (string h in header)\r\n            {\r\n                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();\r\n                col.Name = h;\r\n                col.HeaderText = h;\r\n                dataGridView2.Columns.Add(col);\r\n            }\r\n\r\n            DataGridViewButtonColumn col_btn = new DataGridViewButtonColumn();\r\n            col_btn.HeaderText = \"\u3000\u3000\u3000\u3000\u3000\u3000\";\r\n            dataGridView2.Columns.Add(col_btn);\r\n\r\n            dataGridView2.Columns[0].Visible = false;\r\n            dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;\r\n            dataGridView2.ReadOnly = true;\r\n            dataGridView2.AllowUserToAddRows = false;\r\n            dataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect;\r\n            dataGridView2.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;\r\n            dataGridView2.RowTemplate.Height = 28;\r\n            dataGridView2.Font = new Font(\"Meiryo UI\", 9);\r\n            dataGridView2.MultiSelect = false;\r\n\r\n            dataGridView2.CellClick += new DataGridViewCellEventHandler(sub_cell_click);\r\n        }\r\n\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n\r\n            using (OleDbConnection con = new OleDbConnection(@\"provider=microsoft.jet.oledb.4.0; data source=\" + Application.StartupPath + @\"\\dat.mdb\"))\r\n            {\r\n                try\r\n                {\r\n                    con.Open();\r\n\r\n                    OleDbCommand cmd1 = new OleDbCommand(\"select distinct customer_name from orders;\", con);\r\n                    using (OleDbDataReader dr = cmd1.ExecuteReader())\r\n                    {\r\n                        while (dr.Read())\r\n                        {\r\n                            comboBox1.Items.Add(dr[\"customer_name\"].ToString());\r\n                        }\r\n                    }\r\n\r\n                    OleDbCommand cmd2 = new OleDbCommand(\"select distinct supplier_name from orders;\", con);\r\n                    using (OleDbDataReader dr = cmd2.ExecuteReader())\r\n                    {\r\n                        while (dr.Read())\r\n                        {\r\n                            comboBox2.Items.Add(dr[\"supplier_name\"].ToString());\r\n                        }\r\n                    }\r\n\r\n                    OleDbCommand cmd3 = new OleDbCommand(\"select distinct item_name from orders;\", con);\r\n                    using (OleDbDataReader dr = cmd3.ExecuteReader())\r\n                    {\r\n                        while (dr.Read())\r\n                        {\r\n                            comboBox3.Items.Add(dr[\"item_name\"].ToString());\r\n                        }\r\n                    }\r\n\r\n                }\r\n                catch (OleDbException e)\r\n                {\r\n                    foreach (Control c in this.Controls)\r\n                    {\r\n                        c.Enabled = false;\r\n                    }\r\n\r\n                    MessageBox.Show(e.Message);\r\n                    return;\r\n                }\r\n                finally\r\n                {\r\n                    con.Close();\r\n                }\r\n            }\r\n\r\n            textBox1.TextChanged += new EventHandler((object sender, EventArgs e) =&gt; {\r\n                button1.Text = textBox1.Text == \"\" ? \"\u767b\u9332\" : \"\u66f4\u65b0\";\r\n            });\r\n\r\n            dgv1_setup();\r\n            dgv2_setup();\r\n\r\n            dgv_load(\"select * from orders where visible &lt;&gt; 'hide';\", \"\u5b8c\u4e86\");\r\n            form_clear();\r\n        }\r\n\r\n        private string rp(string s)\r\n        {\r\n            s = s.Replace(\"\\'\", \"\u2019\");\r\n            s = s.Replace(\"\\\"\", \"\u201d\");\r\n            return s;\r\n        }\r\n\r\n        private void sub_cell_click(object sender, DataGridViewCellEventArgs e)\r\n        {\r\n            int btn_ci = 3;\r\n\r\n            int ri = e.RowIndex;\r\n            int ci = e.ColumnIndex;\r\n\r\n            if (ri == -1 || ci == -1) return;\r\n\r\n            string id = dataGridView2.Rows[ri].Cells[0].Value.ToString();\r\n\r\n            if (ci == btn_ci)\r\n            {\r\n                DialogResult yn = MessageBox.Show(\"\u524a\u9664\u3057\u307e\u3059\u304b\uff1f\", \"\", MessageBoxButtons.YesNo);\r\n                if (yn == DialogResult.No) return;\r\n\r\n                using (OleDbConnection con = new OleDbConnection(@\"provider=microsoft.jet.oledb.4.0; data source=\" + Application.StartupPath + @\"\\dat.mdb\"))\r\n                {\r\n                    try\r\n                    {\r\n                        con.Open();\r\n                        OleDbCommand cmd = new OleDbCommand(\"delete from shipments where shipments_id = \" + id + \";\", con);\r\n                        cmd.ExecuteNonQuery();\r\n                    }\r\n                    catch (OleDbException ex)\r\n                    {\r\n                        MessageBox.Show(ex.Message);\r\n                    }\r\n                    finally\r\n                    {\r\n                        con.Close();\r\n                    }\r\n                }\r\n                sub_dgv_load(textBox1.Text);\r\n            }\r\n        }\r\n\r\n        private void cell_click(object sender, DataGridViewCellEventArgs e)\r\n        {\r\n            int btn1_ci = 10;\r\n            int btn2_ci = 11;\r\n            int btn3_ci = 6;\r\n\r\n            int ri = e.RowIndex;\r\n            int ci = e.ColumnIndex;\r\n\r\n            if (ri == -1 || ci == -1) return;\r\n\r\n            string id = dataGridView1.Rows[ri].Cells[0].Value.ToString();\r\n            string po = dataGridView1.Rows[ri].Cells[6].Value.ToString();\r\n            string btn_cap = dataGridView1.Rows[ri].Cells[btn1_ci].Value.ToString();\r\n\r\n            if (ci == btn1_ci)\r\n            {\r\n                rows_change(id, btn_cap);\r\n\r\n                dgv_load(\"select * from orders where visible &lt;&gt; 'hide';\", \"\u5b8c\u4e86\");\r\n                form_clear();\r\n                return;\r\n            }\r\n            else if (ci == btn2_ci)\r\n            {\r\n                DialogResult yn = MessageBox.Show(\"\u524a\u9664\u3057\u307e\u3059\u304b\uff1f\", \"\", MessageBoxButtons.YesNo);\r\n                if (yn == DialogResult.No) return;\r\n\r\n                using (OleDbConnection con = new OleDbConnection(@\"provider=microsoft.jet.oledb.4.0; data source=\" + Application.StartupPath + @\"\\dat.mdb\"))\r\n                {\r\n                    try\r\n                    {\r\n                        con.Open();\r\n                        OleDbCommand cmd = new OleDbCommand(\"delete from orders where orders_id = \" + id + \";\", con);\r\n                        cmd.ExecuteNonQuery();\r\n                    }\r\n                    catch (OleDbException ex)\r\n                    {\r\n                        MessageBox.Show(ex.Message);\r\n                    }\r\n                    finally\r\n                    {\r\n                        con.Close();\r\n                    }\r\n                }\r\n\r\n                dgv_load(\"select * from orders where visible &lt;&gt; 'hide';\", \"\u5b8c\u4e86\");\r\n                form_clear();\r\n                return;\r\n            }\r\n            else if (ci == btn3_ci)\r\n            {\r\n                open_Folder(po);\r\n                return;\r\n            }\r\n\r\n            textBox1.Text = dataGridView1.Rows[ri].Cells[0].Value.ToString();\r\n            textBox8.Text = dataGridView1.Rows[ri].Cells[1].Value.ToString();\r\n            textBox2.Text = dataGridView1.Rows[ri].Cells[2].Value.ToString();\r\n            comboBox1.Text = dataGridView1.Rows[ri].Cells[3].Value.ToString();\r\n            comboBox2.Text = dataGridView1.Rows[ri].Cells[4].Value.ToString();\r\n            comboBox3.Text = dataGridView1.Rows[ri].Cells[5].Value.ToString();\r\n            textBox5.Text = dataGridView1.Rows[ri].Cells[6].Value.ToString();\r\n            textBox6.Text = dataGridView1.Rows[ri].Cells[7].Value.ToString();\r\n            textBox9.Text = dataGridView1.Rows[ri].Cells[8].Value.ToString();\r\n            textBox7.Text = dataGridView1.Rows[ri].Cells[9].Value.ToString();\r\n\r\n            sub_dgv_load(id);\r\n        }\r\n\r\n        private void sub_dgv_load(string id)\r\n        {\r\n            dataGridView2.Rows.Clear();\r\n\r\n            using (OleDbConnection con = new OleDbConnection(@\"provider=microsoft.jet.oledb.4.0; data source=\" + Application.StartupPath + @\"\\dat.mdb\"))\r\n            {\r\n                try\r\n                {\r\n                    con.Open();\r\n                    OleDbCommand cmd = new OleDbCommand(\"select * from shipments where orders_id = \" + id + \";\", con);\r\n                    using (OleDbDataReader dr = cmd.ExecuteReader())\r\n                    {\r\n                        while (dr.Read())\r\n                        {\r\n                            dataGridView2.Rows.Add(\r\n                                dr[\"shipments_id\"].ToString(),\r\n                                DateTime.Parse(dr[\"ship_date\"].ToString()).ToString(\"yyyy\/MM\/dd\"),\r\n                                dr[\"quantity\"].ToString(),\r\n                                \"\u524a\u9664\");\r\n                        }\r\n                    }\r\n                }\r\n                catch (OleDbException e)\r\n                {\r\n                    MessageBox.Show(e.Message);\r\n                }\r\n                finally\r\n                {\r\n                    con.Close();\r\n                }\r\n            }\r\n\r\n            int stock_count = 0;\r\n            for (int r = 0; r &lt; dataGridView2.Rows.Count; r++)\r\n            {\r\n                stock_count += int.Parse(dataGridView2.Rows[r].Cells[2].Value.ToString());\r\n            }\r\n            textBox12.Text = stock_count.ToString();\r\n        }\r\n\r\n        private void rows_change(string id,string btn_cap)\r\n        {\r\n            string tmp = (btn_cap == \"\u5b8c\u4e86\") ? \"hide\" : \"show\";\r\n            using (OleDbConnection con = new OleDbConnection(@\"provider=microsoft.jet.oledb.4.0; data source=\" + Application.StartupPath + @\"\\dat.mdb\"))\r\n            {\r\n                try\r\n                {\r\n                    con.Open();\r\n                    OleDbCommand cmd = new OleDbCommand(\"update orders set visible = '\" + tmp + \"' where orders_id = \" + id + \";\", con);\r\n                    cmd.ExecuteNonQuery();\r\n                }\r\n                catch (OleDbException e)\r\n                {\r\n                    MessageBox.Show(e.Message);\r\n                }\r\n                finally\r\n                {\r\n                    con.Close();\r\n                }\r\n            }\r\n        }\r\n\r\n        private void form_clear()\r\n        {\r\n\r\n            textBox1.Text = \"\";\r\n            textBox8.Text = DateTime.Now.ToString(\"yyyy\/MM\/dd\");\r\n            textBox2.Text = \"\";\r\n            comboBox1.Text = \"\";\r\n            comboBox2.Text = \"\";\r\n            comboBox3.Text = \"\";\r\n            textBox5.Text = \"\";\r\n            textBox6.Text = \"\";\r\n            textBox9.Text = \"\";\r\n            textBox7.Text = \"\";\r\n\r\n            textBox14.Text = DateTime.Now.ToString(\"yyyy\/MM\/dd\");\r\n            textBox12.Text = \"\";\r\n\r\n            textBox10.Text = \"\";\r\n\r\n            dataGridView2.Rows.Clear();\r\n        }\r\n\r\n        private bool form_validate()\r\n        {\r\n            if (textBox8.Text == \"\" | textBox2.Text == \"\" | comboBox1.Text == \"\" | comboBox2.Text == \"\" | \r\n                comboBox3.Text == \"\" | textBox5.Text == \"\" | textBox6.Text == \"\" | textBox9.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u5165\u529b\u304c\u4e0d\u8db3\u3057\u3066\u3044\u307e\u3059\u3002\");\r\n                return false;\r\n            }\r\n            \r\n            try\r\n            {\r\n                DateTime.Parse(textBox8.Text);\r\n            }\r\n            catch\r\n            {\r\n                MessageBox.Show(\"\u65e5\u4ed8\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002\");\r\n                return false;\r\n            }\r\n\r\n            try\r\n            {\r\n                int.Parse(textBox9.Text);\r\n            }\r\n            catch\r\n            {\r\n                MessageBox.Show(\"\u6570\u91cf\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002\");\r\n                return false;\r\n            }\r\n\r\n            textBox2.Text = rp(textBox2.Text);\r\n            comboBox1.Text = rp(comboBox1.Text);\r\n            comboBox2.Text = rp(comboBox2.Text);\r\n            comboBox3.Text = rp(comboBox3.Text);\r\n            textBox5.Text = rp(textBox5.Text);\r\n            textBox6.Text = rp(textBox6.Text);\r\n            textBox7.Text = rp(textBox7.Text);\r\n\r\n            return true;\r\n        }\r\n\r\n        private bool change_tbl()\r\n        {\r\n            string query;\r\n            if (button1.Text == \"\u767b\u9332\")\r\n            {\r\n                query = \"insert into orders (register_date,order_no,customer_name,supplier_name,item_name,po_no,inv_no,quantity,notes,visible) values (\" +\r\n                   \"'\" + textBox8.Text + \"',\" +\r\n                   \"'\" + textBox2.Text + \"',\" +\r\n                   \"'\" + comboBox1.Text + \"',\" +\r\n                   \"'\" + comboBox2.Text + \"',\" +\r\n                   \"'\" + comboBox3.Text + \"',\" +\r\n                   \"'\" + textBox5.Text + \"',\" +\r\n                   \"'\" + textBox6.Text + \"',\" +\r\n                   \"\" + textBox9.Text + \",\" +\r\n                   \"'\" + textBox7.Text + \"','show');\";\r\n            }\r\n            else\r\n            {\r\n                query = \"update orders set \" +\r\n                    \"register_date='\" + textBox8.Text + \"',\" +\r\n                    \"order_no='\" + textBox2.Text + \"',\" +\r\n                    \"customer_name='\" + comboBox1.Text + \"',\" +\r\n                    \"supplier_name='\" + comboBox2.Text + \"',\" +\r\n                    \"item_name='\" + comboBox3.Text + \"',\" +\r\n                    \"po_no='\" + textBox5.Text + \"',\" +\r\n                    \"inv_no='\" + textBox6.Text + \"',\" +\r\n                    \"quantity=\" + textBox9.Text + \",\" +\r\n                    \"notes='\" + textBox7.Text + \"'\" +\r\n                    \"where orders_id = \" + textBox1.Text + \";\";\r\n            }\r\n\r\n            using (OleDbConnection con = new OleDbConnection(@\"provider=microsoft.jet.oledb.4.0; data source=\" + Application.StartupPath + @\"\\dat.mdb\"))\r\n            {\r\n                try\r\n                {\r\n                    con.Open();\r\n                    OleDbCommand cmd = new OleDbCommand(query, con);\r\n                    cmd.ExecuteNonQuery();\r\n                }\r\n                catch (OleDbException e)\r\n                {\r\n                    MessageBox.Show(e.Message);\r\n                    return false;\r\n                }\r\n                finally\r\n                {\r\n                    con.Close();\r\n                }\r\n            }\r\n            return true;\r\n        }\r\n\r\n        private void dgv_load(string query,string btn_cap)\r\n        {\r\n            dataGridView1.Rows.Clear();\r\n\r\n            using (OleDbConnection con = new OleDbConnection(@\"provider=microsoft.jet.oledb.4.0; data source=\" + Application.StartupPath + @\"\\dat.mdb\"))\r\n            {\r\n                try\r\n                {\r\n                    con.Open();\r\n                    OleDbCommand cmd = new OleDbCommand(query,con);\r\n                    using (OleDbDataReader dr = cmd.ExecuteReader())\r\n                    {\r\n                        while (dr.Read())\r\n                        {\r\n                            dataGridView1.Rows.Add(\r\n                                dr[\"orders_id\"].ToString(),\r\n                                DateTime.Parse( dr[\"register_date\"].ToString()).ToString(\"yyyy\/MM\/dd\"),\r\n                                dr[\"order_no\"].ToString(),\r\n                                dr[\"customer_name\"].ToString(),\r\n                                dr[\"supplier_name\"].ToString(),\r\n                                dr[\"item_name\"].ToString(),\r\n                                dr[\"po_no\"].ToString(),\r\n                                dr[\"inv_no\"].ToString(),\r\n                                dr[\"quantity\"].ToString(),\r\n                                dr[\"notes\"].ToString(),\r\n                                btn_cap,\"\u524a\u9664\");\r\n                        }\r\n                    }\r\n                }\r\n                catch (OleDbException e)\r\n                {\r\n                    MessageBox.Show(e.Message);\r\n                }\r\n                finally\r\n                {\r\n                    con.Close();\r\n                }\r\n            }\r\n\r\n            if (btn_cap == \"\u5b8c\u4e86\")\r\n            {\r\n                button6.Enabled = false;\r\n                button5.Enabled = true;\r\n            }\r\n            \r\n            if (btn_cap == \"\u623b\u5165\")\r\n            {\r\n                button6.Enabled = true;\r\n                button5.Enabled = false;\r\n            }\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            if (!form_validate()) return;\r\n            if (!change_tbl()) return;\r\n\r\n            if (button1.Text == \"\u767b\u9332\")\r\n            {\r\n                dgv_load(\"select * from orders where visible &lt;&gt; 'hide';\", \"\u5b8c\u4e86\");\r\n            }\r\n            else if (button1.Text == \"\u66f4\u65b0\" &amp;&amp; button5.Enabled == true)\r\n            {\r\n                dgv_load(\"select * from orders where visible &lt;&gt; 'hide';\", \"\u5b8c\u4e86\");\r\n            }\r\n            else if (button1.Text == \"\u66f4\u65b0\" &amp;&amp; button5.Enabled == false)\r\n            {\r\n                dgv_load(\"select * from orders where visible = 'hide';\", \"\u623b\u5165\");\r\n            }\r\n\r\n            form_clear();\r\n            MessageBox.Show(\"\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\");\r\n        }\r\n\r\n        private void button3_Click(object sender, EventArgs e)\r\n        {\r\n            form_clear();\r\n        }\r\n\r\n        private bool sub_form_validate()\r\n        {\r\n            if (textBox14.Text == \"\" | textBox13.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u5165\u529b\u304c\u4e0d\u8db3\u3057\u3066\u3044\u307e\u3059\u3002\");\r\n                return false;\r\n            }\r\n\r\n            try\r\n            {\r\n                DateTime.Parse(textBox14.Text);\r\n            }\r\n            catch\r\n            {\r\n                MessageBox.Show(\"\u65e5\u4ed8\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002\");\r\n                return false;\r\n            }\r\n\r\n            try\r\n            {\r\n                int.Parse(textBox13.Text);\r\n            }\r\n            catch\r\n            {\r\n                MessageBox.Show(\"\u6570\u91cf\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002\");\r\n                return false;\r\n            }\r\n            return true;\r\n        }\r\n\r\n        private void button4_Click(object sender, EventArgs e)\r\n        {\r\n            if (!form_validate()) return;\r\n            if (!sub_form_validate()) return;\r\n            if (textBox1.Text == \"\") return;\r\n\r\n            string query = \"insert into shipments (orders_id,ship_date,quantity) values \" + \r\n                \"(\" + textBox1.Text + \",'\" + textBox14.Text + \"',\" + textBox13.Text + \");\";\r\n\r\n            using (OleDbConnection con = new OleDbConnection(@\"provider=microsoft.jet.oledb.4.0; data source=\" + Application.StartupPath + @\"\\dat.mdb\"))\r\n            {\r\n                try\r\n                {\r\n                    con.Open();\r\n                    OleDbCommand cmd = new OleDbCommand(query, con);\r\n                    cmd.ExecuteNonQuery();\r\n                }\r\n                catch (OleDbException ex)\r\n                {\r\n                    MessageBox.Show(ex.Message);\r\n                }\r\n                finally\r\n                {\r\n                    con.Close();\r\n                }\r\n            }\r\n            sub_dgv_load(textBox1.Text);\r\n            textBox14.Text = DateTime.Now.ToString(\"yyyy\/MM\/dd\");\r\n            textBox13.Text = \"\";\r\n        }\r\n\r\n        private void button6_Click(object sender, EventArgs e)\r\n        {\r\n            dgv_load(\"select * from orders where visible &lt;&gt; 'hide';\",\"\u5b8c\u4e86\");\r\n            form_clear();\r\n        }\r\n\r\n        private void button5_Click_1(object sender, EventArgs e)\r\n        {\r\n            dgv_load(\"select * from orders where visible = 'hide';\",\"\u623b\u5165\");\r\n            form_clear();\r\n        }\r\n\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            string q = \"\";\r\n            textBox10.Text = rp(textBox10.Text);\r\n\r\n            if (textBox10.Text == \"\" &amp;&amp; button5.Enabled == true)\r\n            {\r\n                dgv_load(\"select * from orders where visible &lt;&gt; 'hide';\", \"\u5b8c\u4e86\");\r\n            }\r\n            else if (textBox10.Text == \"\" &amp;&amp; button5.Enabled == false)\r\n            {\r\n                dgv_load(\"select * from orders where visible = 'hide';\", \"\u623b\u5165\");\r\n            }\r\n            else if (textBox10.Text != \"\" &amp;&amp; button5.Enabled == true)\r\n            {\r\n                q = \"select * from orders where visible &lt;&gt; 'hide' and \" +\r\n                    \"(order_no like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"customer_name like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"supplier_name like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"item_name like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"po_no like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"inv_no like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"notes like '%\" + textBox10.Text + \"%')\";\r\n                dgv_load(q, \"\u5b8c\u4e86\");\r\n            }\r\n            else if (textBox10.Text != \"\" &amp;&amp; button5.Enabled == false)\r\n            {\r\n                q = \"select * from orders where visible = 'hide' and \" +\r\n                    \"(order_no like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"customer_name like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"supplier_name like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"item_name like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"po_no like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"inv_no like '%\" + textBox10.Text + \"%' or \" +\r\n                    \"notes like '%\" + textBox10.Text + \"%')\";\r\n                dgv_load(q, \"\u623b\u5165\");\r\n            }\r\n\r\n        }\r\n        void open_Folder(string po)\r\n        {\r\n            string path = \"\";\r\n\r\n            try\r\n            {\r\n                using (StreamReader sr = new StreamReader(Application.StartupPath + @\"\\setting.txt\", Encoding.GetEncoding(\"shift_jis\")))\r\n                {\r\n                    path = sr.ReadLine() + @\"\\\" + po;\r\n\r\n                    if (Directory.Exists(path))\r\n                    {\r\n                        System.Diagnostics.Process.Start(path);\r\n                    }\r\n                    else\r\n                    {\r\n                        DialogResult yn = MessageBox.Show(\"\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u5b9f\u884c\u3057\u307e\u3059\u304b\uff1f\", \"\", MessageBoxButtons.YesNo);\r\n                        if (yn == DialogResult.No) return;\r\n\r\n                        Directory.CreateDirectory(path);\r\n                        System.Diagnostics.Process.Start(path);\r\n                    }\r\n                }\r\n            }\r\n            catch (Exception e)\r\n            {\r\n                MessageBox.Show(e.Message);\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u306b\u3082\u6570\u56de\u540c\u3058\u3088\u3046\u306a\u30bd\u30d5\u30c8\u3092\u4f5c\u3063\u3066\u3044\u308b\u304c\u3001\u4eca\u56de\u306f \u8868\u3092\u4e26\u3079\u3066\u8868\u793a\u3059\u308b\u30bf\u30a4\u30d7\u3002 using System; using System.Collections.Generic; using System.Component &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2055\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u5728\u5eab\u7ba1\u7406&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9],"class_list":["post-2055","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2055"}],"version-history":[{"count":7,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2055\/revisions"}],"predecessor-version":[{"id":6302,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2055\/revisions\/6302"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}