{"id":1949,"date":"2017-10-25T01:18:58","date_gmt":"2017-10-24T16:18:58","guid":{"rendered":"http:\/\/okamurax.com\/?p=1949"},"modified":"2024-05-03T18:57:51","modified_gmt":"2024-05-03T09:57:51","slug":"c-%e5%b7%a5%e6%95%b0%e7%ae%a1%e7%90%86%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=1949","title":{"rendered":"C# \u5de5\u6570\u7ba1\u7406\u30d7\u30ed\u30b0\u30e9\u30e0"},"content":{"rendered":"<p>\u30c6\u30b9\u30c8\u3067\u4f5c\u3063\u3066\u307f\u305f\u304c\u65b9\u5411\u6027\u5909\u66f4\u306e\u305f\u3081\u672a\u4f7f\u7528\u3002\u8907\u6570\u306ePC\u304b\u3089\u30d0\u30fc\u30b3\u30fc\u30c9\u3092\u4f7f\u3044\u88fd\u4f5c\u6642\u9593(\u5de5\u6570)\u3092\u767b\u9332\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3002<\/p>\n<p>\u4eca\u5f8c\u3001\u6642\u9593\u306e\u3042\u308b\u3068\u304d\u7a3c\u50cd\u6642\u9593\u7b97\u51fa\u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3088\u3046\u304b\u306a\u3068\u3002<\/p>\n<p>MySQL\u304c\u5fc5\u8981\u306a\u306e\u3067\u3001XAMPP\u3092\u4f7f\u3046\u306e\u304c\u4e00\u756a\u7c21\u5358\u3067\u3001XAMPP\u306e\u30b7\u30a7\u30eb\u304b\u3089MySQL\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u305f\u3089\u3001\u4ee5\u4e0b\u3092\u30b3\u30d4\u30da\u3067\u5b9f\u884c\u3002<\/p>\n<pre class=\"lang:tsql decode:true\">CREATE DATABASE man_hours CHARSET=sjis;\r\n\r\nUSE man_hours;\r\n\r\nCREATE TABLE items (\r\n  items_id int unsigned NOT NULL AUTO_INCREMENT,\r\n  orders_id int DEFAULT NULL,\r\n  suffix_no int DEFAULT NULL,\r\n  PRIMARY KEY (items_id)\r\n) DEFAULT CHARSET=sjis;\r\n\r\nCREATE TABLE orders (\r\n  orders_id int unsigned NOT NULL AUTO_INCREMENT,\r\n  customer varchar(100) DEFAULT NULL,\r\n  model varchar(100) DEFAULT NULL,\r\n  serial_no varchar(100) DEFAULT NULL,\r\n  quantity smallint unsigned DEFAULT NULL,\r\n  notes varchar(100) DEFAULT NULL,\r\n  visible varchar(2) DEFAULT NULL,\r\n  PRIMARY KEY (orders_id)\r\n) DEFAULT CHARSET=sjis;\r\n\r\nCREATE TABLE tasks_e (\r\n  tasks_id int unsigned NOT NULL AUTO_INCREMENT,\r\n  items_id int DEFAULT NULL,\r\n  workers_id int DEFAULT NULL,\r\n  end_dt datetime DEFAULT NULL,\r\n  PRIMARY KEY (tasks_id),\r\n  UNIQUE KEY (items_id,workers_id)\r\n) DEFAULT CHARSET=sjis;\r\n\r\nCREATE TABLE tasks_p (\r\n  tasks_id int unsigned NOT NULL AUTO_INCREMENT,\r\n  items_id int DEFAULT NULL,\r\n  workers_id int DEFAULT NULL,\r\n  adjust varchar(10) DEFAULT NULL,\r\n  PRIMARY KEY (tasks_id),\r\n  UNIQUE KEY (items_id,workers_id)\r\n) DEFAULT CHARSET=sjis;\r\n\r\nCREATE TABLE tasks_s (\r\n  tasks_id int unsigned NOT NULL AUTO_INCREMENT,\r\n  items_id int DEFAULT NULL,\r\n  workers_id int DEFAULT NULL,\r\n  start_dt datetime DEFAULT NULL,\r\n  PRIMARY KEY (tasks_id),\r\n  UNIQUE KEY (items_id,workers_id)\r\n) DEFAULT CHARSET=sjis;\r\n\r\nCREATE TABLE workers (\r\n  workers_id int unsigned NOT NULL AUTO_INCREMENT,\r\n  worker_name varchar(100) DEFAULT NULL,\r\n  work_type varchar(100) DEFAULT NULL,\r\n  PRIMARY KEY (workers_id)\r\n) DEFAULT CHARSET=sjis;\r\n<\/pre>\n<p>\u8d77\u52d5\u5f8c\u4ee5\u4e0b\u306e\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u63a5\u7d9a\u5148\u306fIP\u30a2\u30c9\u30ec\u30b9\u3001DB\u540d\u306fman_hours\u3001\u30e6\u30fc\u30b6\u30fc\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u306fMySQL\u4f5c\u6210\u6642\u306b\u6307\u5b9a\u3057\u305f\u30e6\u30fc\u30b6\u30fc\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3002<\/p>\n<p>Form1.cs<\/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\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        public Form1()\r\n        {\r\n            Form9 f = new Form9();\r\n            f.ShowDialog();\r\n\r\n            Db.DbHost = f.DbHost;\r\n            Db.DbName = f.DbName;\r\n            Db.DbUser = f.DbUser;\r\n            Db.DbPass = f.DbPass;\r\n\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                foreach (Control c in Controls)\r\n                {\r\n                    c.Enabled = false;\r\n                }\r\n                return;\r\n            } \r\n        }\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            Form2 f = new Form2();\r\n            f.ShowDialog();\r\n        }\r\n        private void button3_Click(object sender, EventArgs e)\r\n        {\r\n            Form3 f = new Form3();\r\n            f.ShowDialog();\r\n        }\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            Form6 f = new Form6();\r\n            f.ShowDialog();\r\n        }\r\n        private void button4_Click(object sender, EventArgs e)\r\n        {\r\n            Form7 f = new Form7();\r\n            f.ShowDialog();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form2.cs<\/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 ZXing;\r\n\r\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form2 : Form\r\n    {\r\n        string default_query = \"select orders_id,customer,model,serial_no,quantity,notes,visible,'\u8868\u793a' from orders where visible = '\u672a'\";\r\n  \r\n        public Form2()\r\n        {\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            dataGridView1.AllowUserToAddRows = false;\r\n            dataGridView1.ReadOnly = true;\r\n            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;\r\n            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;\r\n            dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;\r\n            dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;\r\n            dataGridView1.DefaultCellStyle.Font = new Font(\"Meiryo UI\", 11);\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n\r\n            foreach(string s in d.LoadCustomer())\r\n            {\r\n                comboBox2.Items.Add(s);\r\n            }\r\n            foreach (string s in d.LoadModel())\r\n            {\r\n                comboBox3.Items.Add(s);\r\n            }\r\n            d.ExecuteReader(default_query, \"\", dataGridView1);\r\n        }\r\n        public void CreateBarcode(string code)\r\n        {\r\n            BarcodeWriter br = new BarcodeWriter();\r\n            br.Format = BarcodeFormat.CODE_128;\r\n            br.Options.Height = 79;\r\n            br.Options.Width = 151;\r\n            br.Options.Margin = 10;\r\n            br.Options.PureBarcode = false;\r\n            Bitmap b = br.Write(code);\r\n            pictureBox1.BackgroundImage = b;\r\n        }\r\n        private Boolean CheckTextBox()\r\n        {\r\n            if (comboBox2.Text == \"\" || comboBox3.Text == \"\" || textBox3.Text == \"\" || textBox4.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u5099\u8003\u4ee5\u5916\u306f\u5165\u529b\u5fc5\u9808\u3067\u3059\u3002\");\r\n                return false;\r\n            }\r\n\r\n            try\r\n            {\r\n                int.Parse(textBox4.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            comboBox2.Text = comboBox2.Text.Trim();\r\n            comboBox3.Text = comboBox3.Text.Trim();\r\n            textBox3.Text = textBox3.Text.Trim();\r\n            textBox6.Text = textBox6.Text.Trim();\r\n\r\n            comboBox2.Text = comboBox2.Text.Replace(\"\\'\", \"\u2019\");\r\n            comboBox3.Text = comboBox3.Text.Replace(\"\\'\", \"\u2019\");\r\n            textBox3.Text = textBox3.Text.Replace(\"\\'\", \"\u2019\");\r\n            textBox6.Text = textBox6.Text.Replace(\"\\'\", \"\u2019\");\r\n\r\n            comboBox2.Text = comboBox2.Text.Replace(\"\\\"\", \"\u201d\");\r\n            comboBox3.Text = comboBox3.Text.Replace(\"\\\"\", \"\u201d\");\r\n            textBox3.Text = textBox3.Text.Replace(\"\\\"\", \"\u201d\");\r\n            textBox6.Text = textBox6.Text.Replace(\"\\\"\", \"\u201d\");\r\n\r\n            return true;\r\n        }\r\n        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)\r\n        {\r\n            int r = e.RowIndex; int c = e.ColumnIndex;\r\n            if (r == -1 || c == -1) return;\r\n\r\n            textBox5.Text = dataGridView1.Rows[r].Cells[0].Value.ToString();\r\n            comboBox2.Text = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n            comboBox3.Text = dataGridView1.Rows[r].Cells[2].Value.ToString();\r\n            textBox3.Text = dataGridView1.Rows[r].Cells[3].Value.ToString();\r\n            textBox4.Text = dataGridView1.Rows[r].Cells[4].Value.ToString();\r\n            textBox6.Text = dataGridView1.Rows[r].Cells[5].Value.ToString();\r\n            comboBox1.Text = dataGridView1.Rows[r].Cells[6].Value.ToString();\r\n            CreateBarcode(textBox5.Text);\r\n\r\n            if (c == 7)\r\n            {\r\n                Form4 f = new Form4(textBox5.Text, comboBox2.Text, comboBox3.Text, textBox3.Text, textBox4.Text, textBox6.Text);\r\n                f.ShowDialog();\r\n            }\r\n        }\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            if (!CheckTextBox()) return;\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n\r\n            string q1 = @\"insert into orders (customer,model,serial_no,quantity,notes,visible) \" +\r\n                \"values ('\" + comboBox2.Text + \"','\" + comboBox3.Text + \"','\" + textBox3.Text + \"',\" + textBox4.Text + \",'\" + textBox6.Text + \"','\u672a');\";\r\n\r\n            string lastId = d.ExecuteNonReader(q1, \"\");\r\n\r\n            if(lastId == \"\")\r\n            {\r\n                MessageBox.Show(\"\u679d\u756a\u767b\u9332\u306b\u554f\u984c\u304c\u3042\u308a\u307e\u3059\u3002\u30aa\u30fc\u30c0\u30fc\u3092\u518d\u767b\u9332\u3057\u3066\u304f\u3060\u3055\u3044\u3002\");\r\n                return;\r\n            }\r\n            else\r\n            {\r\n                string q2 = \"insert into items (orders_id,suffix_no) values \";\r\n\r\n                for (int i = 1; i &lt;= int.Parse(textBox4.Text); i++)\r\n                {\r\n                    q2 += \"(\" + lastId + \",\" + i.ToString() + \")\";\r\n\r\n                    if (i == int.Parse(textBox4.Text))\r\n                    {\r\n                        q2 += \";\";\r\n                    }\r\n                    else\r\n                    {\r\n                        q2 += \",\";\r\n                    }\r\n                }\r\n                d.ExecuteNonReader(q2, \"\");\r\n            }\r\n            d.ExecuteReader(default_query, \"\", dataGridView1);\r\n            button2.PerformClick();\r\n            MessageBox.Show(\"\u767b\u9332\u3057\u307e\u3057\u305f\u3002\");\r\n        }\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            comboBox2.Text = \"\";\r\n            comboBox3.Text = \"\";\r\n            textBox3.Text = \"\";\r\n            textBox4.Text = \"\";\r\n            textBox5.Text = \"\";\r\n            textBox6.Text = \"\";\r\n            comboBox1.Text = \"\u672a\";\r\n            pictureBox1.BackgroundImage = null;\r\n        }\r\n        private void button3_Click(object sender, EventArgs e)\/\/\u66f4\u65b0\r\n        {\r\n            if (textBox5.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u5909\u66f4\u5bfe\u8c61\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002\");\r\n                return;\r\n            }\r\n\r\n            if (!CheckTextBox()) return;\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n\r\n            \/\/\u6570\u91cf\u66f4\u65b0\u4e0d\u53ef\r\n            if (!d.QuantityCheck(\"select quantity from orders where orders_id = \" + textBox5.Text + \";\", textBox4.Text))\r\n            {\r\n                MessageBox.Show(\"\u6570\u91cf\u306f\u66f4\u65b0\u3067\u304d\u307e\u305b\u3093\u3002\");\r\n                return;\r\n            }\r\n\r\n            string q = \"update orders set customer = '\" + comboBox2.Text + \"', model = '\" + comboBox3.Text + \"' , serial_no = '\" + textBox3.Text + \"' , quantity = \" + textBox4.Text + \" , notes = '\" + textBox6.Text + \"' , visible = '\" + comboBox1.Text + \"' where orders_id = \" + textBox5.Text + \";\";\r\n            d.ExecuteNonReader(q, \"\");\r\n            d.ExecuteReader(default_query, \"\", dataGridView1);\r\n            button2.PerformClick();\r\n            MessageBox.Show(\"\u66f4\u65b0\u3057\u307e\u3057\u305f\u3002\");\r\n        }\r\n        private void button4_Click(object sender, EventArgs e)\/\/\u524a\u9664\r\n        {\r\n            DialogResult yn = MessageBox.Show(\"\u672c\u5f53\u306b\u524a\u9664\u3057\u307e\u3059\u304b\uff1f\", \"\", MessageBoxButtons.YesNo);\r\n            if (yn == DialogResult.No) return;\r\n\r\n            if (textBox5.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u524a\u9664\u5bfe\u8c61\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002\");\r\n                return;\r\n            }\r\n\r\n            if (!CheckTextBox()) return;\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n\r\n            string q = \"delete from orders where orders_id = \" + textBox5.Text + \";\";\r\n            d.ExecuteNonReader(q, \"\");\r\n\r\n            q = \"delete from items where orders_id = \" + textBox5.Text + \";\";\r\n            d.ExecuteNonReader(q, \"\");\r\n\r\n            d.ExecuteReader(default_query, \"\", dataGridView1);\r\n            button2.PerformClick();\r\n            MessageBox.Show(\"\u524a\u9664\u3057\u307e\u3057\u305f\u3002\");\r\n        }\r\n        private void checkBox1_CheckedChanged(object sender, EventArgs e)\r\n        {\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n\r\n            if (checkBox1.Checked)\r\n            {\r\n                default_query = \"select orders_id,customer,model,serial_no,quantity,notes,visible,'\u8868\u793a' from orders where visible = '\u5b8c'\";\r\n            }\r\n            else\r\n            {\r\n                default_query = \"select orders_id,customer,model,serial_no,quantity,notes,visible,'\u8868\u793a' from orders where visible = '\u672a'\";\r\n            }\r\n            d.ExecuteReader(default_query, \"\", dataGridView1);\r\n            button2.PerformClick();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form3.cs<\/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 MySql.Data.MySqlClient;\r\n\r\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form3 : Form\r\n    {\r\n        public Form3()\r\n        {\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            dataGridView1.AllowUserToAddRows = false;\r\n            dataGridView1.ReadOnly = true;\r\n            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;\r\n            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;\r\n            dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;\r\n            dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;\r\n            dataGridView1.DefaultCellStyle.Font = new Font(\"Meiryo UI\", 11);\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n            d.ExecuteReader(\"select * from workers;\",\"\",dataGridView1);\r\n        }\r\n        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)\r\n        {\r\n            int r = e.RowIndex; int c = e.ColumnIndex;\r\n            if (r == -1 || c == -1) return;\r\n\r\n            textBox1.Text = dataGridView1.Rows[r].Cells[0].Value.ToString();\r\n            textBox2.Text = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n            textBox3.Text = dataGridView1.Rows[r].Cells[2].Value.ToString();\r\n        }\r\n        private void button4_Click(object sender, EventArgs e)\r\n        {\r\n            textBox1.Text = \"\";\r\n            textBox2.Text = \"\";\r\n            textBox3.Text = \"\";\r\n        }\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            if (textBox1.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u5909\u66f4\u5bfe\u8c61\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002\");\r\n                return;\r\n            }\r\n\r\n            if (!CheckTextBox()) return;\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n            string q = @\"update workers set worker_name = '\" + textBox2.Text + \"', work_type = '\" + textBox3.Text + \"' where workers_id = \" + textBox1.Text + \";\";\r\n            d.ExecuteNonReader(q, \"\");\r\n            d.ExecuteReader(\"select * from workers;\", \"\", dataGridView1);\r\n            button4.PerformClick();\r\n            MessageBox.Show(\"\u66f4\u65b0\u3057\u307e\u3057\u305f\");\r\n        }\r\n        private void button3_Click(object sender, EventArgs e)\r\n        {\r\n            DialogResult yn = MessageBox.Show(\"\u672c\u5f53\u306b\u524a\u9664\u3057\u307e\u3059\u304b\uff1f\",\"\",MessageBoxButtons.YesNo);\r\n            if (yn == DialogResult.No) return;\r\n\r\n            if (textBox1.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u524a\u9664\u5bfe\u8c61\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002\");\r\n                return;\r\n            }\r\n\r\n            if (!CheckTextBox()) return;\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n            string q = @\"delete from workers where workers_id = \" + textBox1.Text + \";\";\r\n            d.ExecuteNonReader(q, \"\");\r\n            d.ExecuteReader(\"select * from workers;\", \"\", dataGridView1);\r\n            button4.PerformClick();\r\n            MessageBox.Show(\"\u524a\u9664\u3057\u307e\u3057\u305f\u3002\");\r\n        }\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            if (!CheckTextBox()) return;\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n            string q = @\"insert into workers (worker_name,work_type) values ('\" + textBox2.Text + \"','\" + textBox3.Text + \"');\";\r\n            d.ExecuteNonReader(q, \"\");\r\n            d.ExecuteReader(\"select * from workers;\", \"\", dataGridView1);\r\n            button4.PerformClick();\r\n            MessageBox.Show(\"\u767b\u9332\u3057\u307e\u3057\u305f\u3002\");\r\n        }\r\n        private Boolean CheckTextBox()\r\n        {\r\n            if (textBox2.Text == \"\" || textBox3.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u5168\u3066\u5165\u529b\u5fc5\u9808\u3067\u3059\u3002\");\r\n                return false;\r\n            }\r\n\r\n            textBox2.Text = textBox2.Text.Trim();\r\n            textBox3.Text = textBox3.Text.Trim();\r\n\r\n            textBox2.Text = textBox2.Text.Replace(\"\\'\", \"\u2019\");\r\n            textBox3.Text = textBox3.Text.Replace(\"\\'\", \"\u2019\");\r\n\r\n            textBox2.Text = textBox2.Text.Replace(\"\\\"\", \"\u201d\");\r\n            textBox3.Text = textBox3.Text.Replace(\"\\\"\", \"\u201d\");\r\n\r\n            return true;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form4.cs<\/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 ZXing;\r\n\r\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form4 : Form\r\n    {\r\n        public Form4(string orders_id, string customer, string model, string serial_no, string quantity, string notes)\r\n        {\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            textBox5.Text = orders_id;\r\n            textBox1.Text = customer;\r\n            textBox2.Text = model;\r\n            textBox3.Text = serial_no;\r\n            textBox4.Text = quantity;\r\n            textBox6.Text = notes;\r\n\r\n            CreateBarcode(orders_id);\r\n        }\r\n        public void CreateBarcode(string code)\r\n        {\r\n            BarcodeWriter br = new BarcodeWriter();\r\n            br.Format = BarcodeFormat.CODE_128;\r\n            br.Options.Height = 80;\r\n            br.Options.Width = 245;\r\n            br.Options.Margin = 10;\r\n            br.Options.PureBarcode = false;\r\n            Bitmap b = br.Write(code);\r\n            pictureBox1.BackgroundImage = b;\r\n        }\r\n        public void PanelPrint()\r\n        {\r\n            System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();\r\n\r\n            pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler((object sender, System.Drawing.Printing.PrintPageEventArgs e) =&gt; {\r\n                Bitmap bmp = new Bitmap(panel1.Width, panel1.Height);\r\n                panel1.DrawToBitmap(bmp, new Rectangle(0, 0, panel1.Width, panel1.Height));\r\n                e.Graphics.DrawImage(bmp, e.MarginBounds);\r\n                e.HasMorePages = false;\r\n                bmp.Dispose();\r\n            });\r\n\r\n            PrintDialog pdg = new PrintDialog();\r\n            pdg.Document = pd;\r\n            if (pdg.ShowDialog() == DialogResult.OK) pd.Print();\r\n        }\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            PanelPrint();\r\n        }\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            SaveFileDialog sd = new SaveFileDialog();\r\n            sd.FileName = \"orders.png\";\r\n            sd.InitialDirectory = @\"c:\\\";\r\n            sd.Title = \"\u4fdd\u5b58\u5148\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\";\r\n            if(sd.ShowDialog() == DialogResult.OK)\r\n            {\r\n                Bitmap bmp = new Bitmap(panel1.Width, panel1.Height);\r\n                panel1.DrawToBitmap(bmp, new Rectangle(0, 0, panel1.Width, panel1.Height));\r\n                bmp.Save(sd.FileName);\r\n                bmp.Dispose();\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form5.cs<\/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\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form5 : Form\r\n    {\r\n        public Form5(string worker_name, string wokers_id, string orders_id)\r\n        {\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            timer1.Start();\r\n\r\n            dataGridView1.AllowUserToAddRows = false;\r\n            dataGridView1.Columns[0].ReadOnly = true;\r\n            dataGridView1.Columns[1].ReadOnly = true;\r\n            dataGridView1.Columns[2].ReadOnly = true;\/\/\u679d\u756a\r\n            dataGridView1.Columns[3].ReadOnly = true;\/\/\u958b\u59cb\r\n            dataGridView1.Columns[4].ReadOnly = true;\/\/\u7d42\u4e86\r\n            dataGridView1.Columns[5].ReadOnly = true;\/\/\u8abf\u6574\r\n            dataGridView1.Columns[6].ReadOnly = true;\/\/\u7a3c\u50cd\r\n            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;\r\n            dataGridView1.Columns[2].Width = 50;\r\n            dataGridView1.Columns[3].Width = 200;\r\n            dataGridView1.Columns[4].Width = 200;\r\n            dataGridView1.Columns[5].Width = 110;\r\n            dataGridView1.Columns[6].Width = 110;\r\n            dataGridView1.Columns[7].Width = 50;\r\n            dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;\r\n            dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;\r\n            dataGridView1.DefaultCellStyle.Font = new Font(\"Meiryo UI\", 11);\r\n            dataGridView1.Columns[3].DefaultCellStyle.Font = new Font(\"Meiryo UI\", 16);\r\n            dataGridView1.Columns[4].DefaultCellStyle.Font = new Font(\"Meiryo UI\", 16);\r\n            dataGridView1.Columns[5].DefaultCellStyle.Font = new Font(\"Meiryo UI\", 16);\r\n            dataGridView1.Columns[6].DefaultCellStyle.Font = new Font(\"Meiryo UI\", 16);\r\n\r\n            textBox7.Text = wokers_id;\r\n            label10.Text = \"\" + worker_name + \" \u3055\u3093\u306e\u5165\u529b\u753b\u9762\u3067\u3059\u3002\";\r\n            label10.Tag = worker_name;\r\n            comboBox1.Items.AddRange(new string[]{ \"00:15\" , \"00:30\" , \"01:00\" , \"02:00\" , \"04:00\" , \"08:00\"});\r\n            comboBox1.Text = \"00:15\";\r\n\r\n            \/\/\u4f5c\u696d\u4e2d\u4e00\u89a7\u304b\u3089\u8d77\u52d5\r\n            if(orders_id != \"\")\r\n            {\r\n                textBox5.Text = orders_id;\r\n                button1.PerformClick();\r\n            }\r\n        }\r\n        private void timer1_Tick(object sender, EventArgs e)\r\n        {\r\n            label7.Text = DateTime.Now.ToString(\"yyyy\/MM\/dd (dddd)\");\r\n            label8.Text = DateTime.Now.ToString(\"HH:mm:ss\");\r\n        }\r\n        public string DefaultQuery()\r\n        {\r\n            return \"select items.orders_id , items.items_id , items.suffix_no , \" +\r\n            \"date_format(tasks_s.start_dt, '%y-%m-%d %H:%i') , \" + \r\n            \"date_format(tasks_e.end_dt, '%y-%m-%d %H:%i') , \" +\r\n            \"substring(tasks_p.adjust,1,length(tasks_p.adjust)-3) ,'','False' \" +\r\n            \"from items left outer join tasks_s on items.items_id = tasks_s.items_id and tasks_s.workers_id = \" + textBox7.Text + \" \" +\r\n            \"left outer join tasks_e on items.items_id = tasks_e.items_id and tasks_e.workers_id = \" + textBox7.Text + \" \" +\r\n            \"left outer join tasks_p on items.items_id = tasks_p.items_id and tasks_p.workers_id = \" + textBox7.Text + \" \" + \r\n            \"where items.orders_id = \" + textBox5.Text + \" order by items.items_id;\";\r\n            \/\/items.items_id \u306f primary key\u3002tasks_x.items_id \u3068 tasks_x.workers_id \u3067 \u8907\u5408unique key\u30021\u5bfe1\u306ejoin\u3002\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            if (textBox5.Text == \"\")\r\n            {\r\n                MessageBox.Show(\"\u30aa\u30fc\u30c0\u30fcID\u304c\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\");\r\n                return;\r\n            }\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n            List&lt;TextBox&gt; t = new List&lt;TextBox&gt;() { textBox1, textBox2, textBox3, textBox4, textBox6 };\r\n            if (!d.FormLoadExecuteReader(\"select customer,model,serial_no,quantity,notes from orders where orders_id = \" + textBox5.Text + \";\", t))\r\n            {\r\n                MessageBox.Show(\"\u30aa\u30fc\u30c0\u30fcID\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\r\n                return;\r\n            }\r\n            d.ExecuteReader(DefaultQuery(), \"\", dataGridView1);\r\n            SetWorkTime();\r\n            checkBox1.Checked = false;\r\n        }\r\n        private void SetWorkTime()\r\n        {\r\n            for (int r = 0; r &lt; dataGridView1.Rows.Count; r++)\r\n            {\r\n                string s = dataGridView1.Rows[r].Cells[3].Value.ToString();\r\n                string e = dataGridView1.Rows[r].Cells[4].Value.ToString();\r\n                string a = dataGridView1.Rows[r].Cells[5].Value.ToString();\r\n\r\n                if (s != \"\" &amp;&amp; e != \"\" &amp;&amp; a != \"\")\r\n                {\r\n                    dataGridView1.Rows[r].Cells[6].Value = Db.WorkTime(DateTime.Parse(s), DateTime.Parse(e), TimeSpan.Parse(a));\r\n                }\r\n                if (s != \"\" &amp;&amp; e != \"\" &amp;&amp; a == \"\")\r\n                {\r\n                    dataGridView1.Rows[r].Cells[6].Value = Db.WorkTime(DateTime.Parse(s), DateTime.Parse(e), new TimeSpan(0,0,0));\r\n                }\r\n                if (s == \"\" || e == \"\")\r\n                {\r\n                    dataGridView1.Rows[r].Cells[6].Value = \"-\";\r\n                }\r\n            }\r\n        }\r\n        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)\r\n        {\r\n            int r = e.RowIndex; int c = e.ColumnIndex;\r\n\r\n            if (c == 3 &amp;&amp; r &gt;= 0 &amp;&amp; dataGridView1.Rows[r].Cells[c].Value.ToString() != \"\")\/\/\u958b\u59cb\r\n            {\r\n                Db d = new Db();\r\n                if (!d.DbState)\r\n                {\r\n                    MessageBox.Show(d.DbStateMessage);\r\n                    return;\r\n                }\r\n\r\n                Form10 f = new Form10();\r\n                f.ShowDialog();\r\n                if (f.getDatetime == \"\")\r\n                {\r\n                    DialogResult yn = MessageBox.Show(\"\u524a\u9664\u3057\u307e\u3059\u304b\uff1f(\u7d42\u4e86\u3082\u524a\u9664\u3055\u308c\u307e\u3059)\", \"\", MessageBoxButtons.YesNo);\r\n                    if (yn == DialogResult.No) return;\r\n\r\n                    string items_id = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n                    string workers_id = textBox7.Text;\r\n\r\n                    d.ExecuteNonReader(\"delete from tasks_s where items_id = \" + items_id + \" and workers_id = \" + workers_id + \";\", \"\");\r\n                    d.ExecuteNonReader(\"delete from tasks_e where items_id = \" + items_id + \" and workers_id = \" + workers_id + \";\", \"\");\r\n                    d.ExecuteReader(DefaultQuery(), \"\", dataGridView1);\r\n                    SetWorkTime();\r\n                    checkBox1.Checked = false;\r\n                    MessageBox.Show(\"\u524a\u9664\u3057\u307e\u3057\u305f\u3002\");\r\n                }\r\n                else\r\n                {\r\n                    string items_id = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n                    string workers_id = textBox7.Text;\r\n\r\n                    d.ExecuteNonReader(\"update tasks_s set start_dt = '\" + f.getDatetime + \"' where items_id = \" + items_id + \" and workers_id = \" + workers_id + \";\", \"\");\r\n                    d.ExecuteReader(DefaultQuery(), \"\", dataGridView1);\r\n                    SetWorkTime();\r\n                    checkBox1.Checked = false;\r\n                    MessageBox.Show(\"\u66f4\u65b0\u3057\u307e\u3057\u305f\u3002\");\r\n                }\r\n            }\r\n\r\n            if (c == 4 &amp;&amp; r &gt;= 0 &amp;&amp; dataGridView1.Rows[r].Cells[c].Value.ToString() != \"\")\/\/\u7d42\u4e86\r\n            {\r\n                Db d = new Db();\r\n                if (!d.DbState)\r\n                {\r\n                    MessageBox.Show(d.DbStateMessage);\r\n                    return;\r\n                }\r\n\r\n                Form10 f = new Form10();\r\n                f.ShowDialog();\r\n                if (f.getDatetime == \"\")\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                    string items_id = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n                    string workers_id = textBox7.Text;\r\n\r\n                    d.ExecuteNonReader(\"delete from tasks_e where items_id = \" + items_id + \" and workers_id = \" + workers_id + \";\", \"\");\r\n                    d.ExecuteReader(DefaultQuery(), \"\", dataGridView1);\r\n                    SetWorkTime();\r\n                    checkBox1.Checked = false;\r\n                    MessageBox.Show(\"\u524a\u9664\u3057\u307e\u3057\u305f\u3002\");\r\n                }\r\n                else\r\n                {\r\n                    string items_id = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n                    string workers_id = textBox7.Text;\r\n\r\n                    d.ExecuteNonReader(\"update tasks_e set end_dt = '\" + f.getDatetime + \"' where items_id = \" + items_id + \" and workers_id = \" + workers_id + \";\", \"\");\r\n                    d.ExecuteReader(DefaultQuery(), \"\", dataGridView1);\r\n                    SetWorkTime();\r\n                    checkBox1.Checked = false;\r\n                    MessageBox.Show(\"\u66f4\u65b0\u3057\u307e\u3057\u305f\u3002\");\r\n                }\r\n            }\r\n            if (c == 5 &amp;&amp; r &gt;= 0 &amp;&amp; dataGridView1.Rows[r].Cells[c].Value.ToString() != \"\")\/\/\u8abf\u6574\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                string items_id = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n                string workers_id = textBox7.Text;\r\n\r\n                Db d = new Db();\r\n                if (!d.DbState)\r\n                {\r\n                    MessageBox.Show(d.DbStateMessage);\r\n                    return;\r\n                }\r\n                d.ExecuteNonReader(\"delete from tasks_p where items_id = \" + items_id + \" and workers_id = \" + workers_id + \";\", \"\");\r\n                d.ExecuteReader(DefaultQuery(), \"\", dataGridView1);\r\n                SetWorkTime();\r\n                checkBox1.Checked = false;\r\n                MessageBox.Show(\"\u524a\u9664\u3057\u307e\u3057\u305f\u3002\");\r\n            }\r\n        }\r\n        private void OnOff(object sender, EventArgs e)\r\n        {\r\n            if (button2 == sender) InsertDatetime(\"\u958b\u59cb\", 3, \"tasks_s\", \"start_dt\");\r\n            if (button3 == sender) InsertDatetime(\"\u7d42\u4e86\", 4, \"tasks_e\", \"end_dt\");\r\n        }\r\n        public void InsertDatetime(string cap, int col_no, string tbl,string col_name)\r\n        {\r\n            if (dataGridView1.Rows.Count == 0) return;\r\n\r\n            for (int r = 0; r &lt; dataGridView1.Rows.Count; r++)\r\n            {\r\n                string check = dataGridView1.Rows[r].Cells[7].Value.ToString();\r\n\r\n                if (check == \"True\" &amp;&amp; dataGridView1.Rows[r].Cells[col_no].Value.ToString() != \"\")\r\n                {\r\n                    MessageBox.Show(\"\u65e2\u306b\" + cap + \"\u6642\u523b\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u524a\u9664\u5f8c\u306b\u767b\u9332\u3057\u3066\u304f\u3060\u3055\u3044\u3002\");\r\n                    return;\r\n                }\r\n\r\n                if (check == \"True\" &amp;&amp; col_no == 4 &amp;&amp; dataGridView1.Rows[r].Cells[3].Value.ToString() == \"\")\r\n                {\r\n                    MessageBox.Show(\"\u4f5c\u696d\u958b\u59cb\u306e\u524d\u306b\u4f5c\u696d\u7d42\u4e86\u3092\u767b\u9332\u3067\u304d\u307e\u305b\u3093\u3002\");\r\n                    return;\r\n                }\r\n            }\r\n\r\n            string query = \"insert into \" + tbl + \" (items_id,workers_id,\" + col_name + \") values \";\r\n            Boolean queryExists = false;\r\n\r\n            for (int r = 0; r &lt; dataGridView1.Rows.Count; r++)\r\n            {\r\n                string items_id = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n                string check = dataGridView1.Rows[r].Cells[7].Value.ToString();\r\n\r\n                if (check == \"True\" &amp;&amp; dataGridView1.Rows[r].Cells[col_no].Value.ToString() == \"\")\r\n                {\r\n                    query += \"(\" + items_id + \",\" + textBox7.Text + \",'\" + DateTime.Now.ToString(\"yyyy\/MM\/dd HH:mm:ss\") + \"'),\";\r\n                    queryExists = true;\r\n                }\r\n            }\r\n            if (queryExists)\r\n            {\r\n                query = query.Substring(0, query.Length - 1) + \";\";\r\n\r\n                Db d = new Db();\r\n                if (!d.DbState)\r\n                {\r\n                    MessageBox.Show(d.DbStateMessage);\r\n                    return;\r\n                }\r\n                d.ExecuteNonReader(query, \"\");\r\n                d.ExecuteReader(DefaultQuery(), \"\", dataGridView1);\r\n                SetWorkTime();\r\n                checkBox1.Checked = false;\r\n                MessageBox.Show(\"\u767b\u9332\u3057\u307e\u3057\u305f\u3002\");\r\n            }\r\n        }\r\n        private void UpDown(object sender, EventArgs e)\r\n        {\r\n            if (dataGridView1.Rows.Count == 0) return;\r\n\r\n            Boolean f = false;\r\n            for (int r = 0; r &lt; dataGridView1.Rows.Count; r++)\r\n            {\r\n                if (\"True\" == dataGridView1.Rows[r].Cells[7].Value.ToString()) f = true;\r\n            }\r\n            if (f &amp;&amp; (Button)sender == button4) PauseClick(TimeSpan.Parse(\"\" + comboBox1.Text));\r\n            if (f &amp;&amp; (Button)sender == button5) PauseClick(TimeSpan.Parse(\"-\" + comboBox1.Text));\r\n        }\r\n        public void PauseClick(TimeSpan t)\r\n        {\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n            for (int r = 0; r &lt; dataGridView1.Rows.Count; r++)\r\n            {\r\n                string items_id = dataGridView1.Rows[r].Cells[1].Value.ToString();\r\n                string check = dataGridView1.Rows[r].Cells[7].Value.ToString();\r\n\r\n                if (check == \"True\")\r\n                {\r\n                    string adjust_col = dataGridView1.Rows[r].Cells[5].Value.ToString();\r\n                    TimeSpan ts ;\r\n\r\n                    if(adjust_col == \"\")\r\n                    {\r\n                        ts = t;\r\n                    }\r\n                    else\r\n                    {\r\n                        ts = t + TimeSpan.Parse(adjust_col);\r\n                    }\r\n\r\n                    string q = \"delete from tasks_p where items_id = \" + items_id + \" and workers_id = \" + textBox7.Text + \";\";\r\n                    d.ExecuteNonReader(q, \"\");\r\n\r\n                    if (ts != TimeSpan.Zero)\r\n                    {\r\n                        q = \"insert into tasks_p (items_id,workers_id,adjust) values (\" + items_id + \",\" + textBox7.Text + \",'\" + ts.ToString() + \"');\";\r\n                        d.ExecuteNonReader(q, \"\");\r\n                    }\r\n                }\r\n            }\r\n            d.ExecuteReader(DefaultQuery(), \"\", dataGridView1);\r\n            SetWorkTime();\r\n            checkBox1.Checked = false;\r\n            MessageBox.Show(\"\u767b\u9332\u3057\u307e\u3057\u305f\u3002\");\r\n        }\r\n\r\n        private void button6_Click(object sender, EventArgs e)\r\n        {\r\n            Form8 f = new Form8(textBox7.Text,label10.Tag.ToString());\r\n            f.ShowDialog();\r\n            if(f.ReturnOrders_id != \"\")\r\n            {\r\n                textBox5.Text = f.ReturnOrders_id;\r\n                button1.PerformClick();\r\n            }\r\n        }\r\n\r\n        private void checkBox1_CheckedChanged(object sender, EventArgs e)\r\n        {\r\n            if (dataGridView1.Rows.Count == 0) return;\r\n\r\n            for (int r = 0; r &lt; dataGridView1.Rows.Count; r++)\r\n            {\r\n                dataGridView1.Rows[r].Cells[7].Value = checkBox1.Checked.ToString();\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form6.cs<\/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\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form6 : Form\r\n    {\r\n        public Form6()\r\n        {\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n\r\n            string[][] workers = d.LoadWorkers();\r\n\r\n            int count = workers.Length;\r\n            int pages = 1;\r\n\r\n            tabControl1.ItemSize = new Size(1, 55);\r\n\r\n            if(count &lt;= 24)\r\n            {\r\n                tabControl1.TabPages.Add(\"1\u30da\u30fc\u30b8\");\r\n            }\r\n            else if(count &gt; 24 &amp;&amp; count &lt;= 48)\r\n            {\r\n                tabControl1.TabPages.Add(\"1\u30da\u30fc\u30b8\");\r\n                tabControl1.TabPages.Add(\"2\u30da\u30fc\u30b8\");\r\n                pages = 2;\r\n            }\r\n            else if (count &gt; 48)\r\n            {\r\n                tabControl1.TabPages.Add(\"1\u30da\u30fc\u30b8\");\r\n                tabControl1.TabPages.Add(\"2\u30da\u30fc\u30b8\");\r\n                tabControl1.TabPages.Add(\"3\u30da\u30fc\u30b8\");\r\n                pages = 3;\r\n            }\r\n\r\n            int i = 0;\r\n            for (int p = 0; p &lt; pages; p++)\r\n            {\r\n                int x = 6; int y = 6;\r\n\r\n                for (int r = 0; r &lt; 6; r++)\r\n                {\r\n                    for (int c = 0; c &lt; 4; c++)\r\n                    {\r\n                        if (i == count) break;\r\n\r\n                        Button b = new Button();\r\n                        b.Font = new Font(\"Meiryo UI\", 16);\r\n                        b.Text = workers[i][1].ToString();\r\n                        b.Tag = workers[i][0].ToString();\r\n                        b.Size = new Size(206, 71);\r\n                        b.Location = new Point(y + c * (206 + 6), x + r * (71 + 6));\r\n                        b.Click += new EventHandler(ClickWorker);\r\n                        tabControl1.TabPages[p].Controls.Add(b);\r\n\r\n                        i++;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n        public void ClickWorker(object sender, EventArgs e)\r\n        {\r\n            Form5 f = new Form5(((Button)sender).Text, ((Button)sender).Tag.ToString(),\"\");\r\n            f.ShowDialog();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form7.cs<\/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\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form7 : Form\r\n    {\r\n        public Form7()\r\n        {\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            string[] col = new string[] { \"\u30aa\u30fc\u30c0\u30fcID\", \"\u5f97\u610f\u5148\", \"\u578b\u5f0f\", \"\u5de5\u756a\", \"\u679d\u756a\", \"\u6570\u91cf\" , \"\u540d\u524d\" , \"\u958b\u59cb\u65e5\u6642\" , \"\u7d42\u4e86\u65e5\u6642\" , \"\u8abf\u6574\u6642\u9593\" , \"\u7a3c\u50cd\u6642\u9593\"};\r\n            for (int i = 0; i &lt; col.Length; i++)\r\n            {\r\n                dataGridView1.Columns.Add(new DataGridViewTextBoxColumn());\r\n                dataGridView1.Columns[i].HeaderText = col[i];\r\n            }\r\n\r\n            dataGridView1.AllowUserToAddRows = false;\r\n            dataGridView1.ReadOnly = true;\r\n            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;\r\n            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;\r\n            dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;\r\n            dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;\r\n            dataGridView1.DefaultCellStyle.Font = new Font(\"Meiryo UI\", 11);\r\n\r\n            DbLoad();\r\n        }\r\n        public string QueryWhere()\r\n        {\r\n            string orders_id = textBox5.Text;\r\n            string customer = comboBox2.Text;\r\n            string model = comboBox1.Text;\r\n            string serial_no = textBox6.Text;\r\n            string worker_name = comboBox3.Text;\r\n            string start_dt_1 = textBox1.Text;\r\n            string start_dt_2 = textBox2.Text;\r\n            string end_dt_1 = textBox3.Text;\r\n            string end_dt_2 = textBox4.Text;\r\n\r\n            string q = \"\";\r\n            if (orders_id != \"\")\r\n            {\r\n                q = \"where items.orders_id like '%\" + orders_id + \"%' \";\r\n            }\r\n            if (customer != \"\")\r\n            {\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where customer like '%\" + customer + \"%' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and customer like '%\" + customer + \"%' \";\r\n                }\r\n            }\r\n            if (model != \"\")\r\n            {\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where model like '%\" + model + \"%' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and model like '%\" + model + \"%' \";\r\n                }\r\n            }\r\n            if (serial_no != \"\")\r\n            {\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where serial_no like '%\" + serial_no + \"%' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and serial_no like '%\" + serial_no + \"%' \";\r\n                }\r\n            }\r\n            if (worker_name != \"\")\r\n            {\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where worker_name like '%\" + worker_name + \"%' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and worker_name like '%\" + worker_name + \"%' \";\r\n                }\r\n            }\r\n            if (start_dt_1 != \"\" &amp;&amp; start_dt_2 != \"\")\r\n            {\r\n                string f = DateTime.Parse(start_dt_1).ToString(\"yyyy-MM-dd\");\r\n                string t = DateTime.Parse(start_dt_2).AddDays(1).ToString(\"yyyy-MM-dd\");\r\n\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where tasks_s.start_dt &gt;= '\" + f + \"' and tasks_s.start_dt &lt; '\" + t + \"' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and tasks_s.start_dt &gt;= '\" + f + \"' and tasks_s.start_dt &lt; '\" + t + \"' \";\r\n                }\r\n            }\r\n            if (start_dt_1 != \"\" &amp;&amp; start_dt_2 == \"\")\r\n            {\r\n                string f = DateTime.Parse(start_dt_1).ToString(\"yyyy-MM-dd\");\r\n\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where tasks_s.start_dt &gt;= '\" + f + \"' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and tasks_s.start_dt &gt;= '\" + f + \"' \";\r\n                }\r\n            }\r\n            if (start_dt_1 == \"\" &amp;&amp; start_dt_2 != \"\")\r\n            {\r\n                string t = DateTime.Parse(start_dt_2).AddDays(1).ToString(\"yyyy-MM-dd\");\r\n\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where tasks_s.start_dt &lt; '\" + t + \"' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and tasks_s.start_dt &lt; '\" + t + \"' \";\r\n                }\r\n            }\r\n            if (end_dt_1 != \"\" &amp;&amp; end_dt_2 != \"\")\r\n            {\r\n                string f = DateTime.Parse(end_dt_1).ToString(\"yyyy-MM-dd\");\r\n                string t = DateTime.Parse(end_dt_2).AddDays(1).ToString(\"yyyy-MM-dd\");\r\n\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where tasks_e.end_dt &gt;= '\" + f + \"' and tasks_e.end_dt &lt; '\" + t + \"' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and tasks_e.end_dt &gt;= '\" + f + \"' and tasks_e.end_dt &lt; '\" + t + \"' \";\r\n                }\r\n            }\r\n            if (end_dt_1 != \"\" &amp;&amp; end_dt_2 == \"\")\r\n            {\r\n                string f = DateTime.Parse(end_dt_1).ToString(\"yyyy-MM-dd\");\r\n\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where tasks_e.end_dt &gt;= '\" + f + \"' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and tasks_e.end_dt &gt;= '\" + f + \"' \";\r\n                }\r\n            }\r\n            if (end_dt_1 == \"\" &amp;&amp; end_dt_2 != \"\")\r\n            {\r\n                string t = DateTime.Parse(end_dt_2).AddDays(1).ToString(\"yyyy-MM-dd\");\r\n\r\n                if (q == \"\")\r\n                {\r\n                    q = \"where tasks_e.end_dt &lt; '\" + t + \"' \";\r\n                }\r\n                else\r\n                {\r\n                    q += \"and tasks_e.end_dt &lt; '\" + t + \"' \";\r\n                }\r\n            }\r\n            if (q == \"\")\r\n            {\r\n                q = \"where visible = '\" + comboBox4.Text + \"' and tasks_s.tasks_id is not null \";\r\n            }\r\n            else\r\n            {\r\n                q += \"and visible = '\" + comboBox4.Text + \"' and tasks_s.tasks_id is not null \";\r\n            }\r\n            return q;\r\n        }\r\n\r\n        private void DbLoad()\r\n        {\r\n            string start_dt_1 = textBox1.Text;\r\n            string start_dt_2 = textBox2.Text;\r\n            string end_dt_1 = textBox3.Text;\r\n            string end_dt_2 = textBox4.Text;\r\n\r\n            try\r\n            {\r\n                if (start_dt_1 != \"\") DateTime.Parse(start_dt_1);\r\n                if (start_dt_2 != \"\") DateTime.Parse(start_dt_2);\r\n                if (end_dt_1 != \"\") DateTime.Parse(end_dt_1);\r\n                if (end_dt_2 != \"\") DateTime.Parse(end_dt_2);\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;\r\n            }\r\n\r\n            string q = \"select items.orders_id , orders.customer , orders.model , orders.serial_no , items.suffix_no , orders.quantity , workers.worker_name , \" +\r\n            \"date_format(tasks_s.start_dt, '%y-%m-%d %H:%i') , \" +\r\n            \"date_format(tasks_e.end_dt, '%y-%m-%d %H:%i') , \" +\r\n            \"substring(tasks_p.adjust,1,length(tasks_p.adjust)-3) , '' \" +\r\n            \"from items \" + \r\n            \"left outer join tasks_s on items.items_id = tasks_s.items_id \" +\r\n            \"left outer join tasks_e on items.items_id = tasks_e.items_id and tasks_s.workers_id = tasks_e.workers_id \" +\r\n            \"left outer join tasks_p on items.items_id = tasks_p.items_id and tasks_s.workers_id = tasks_p.workers_id \" +\r\n            \"left outer join workers on tasks_s.workers_id = workers.workers_id \" + \r\n            \"left outer join orders  on items.orders_id = orders.orders_id \" + \r\n            QueryWhere() + \" order by items.orders_id , workers.worker_name , items.suffix_no;\";\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n\r\n            comboBox2.Items.Clear();\r\n            comboBox1.Items.Clear();\r\n            comboBox3.Items.Clear();\r\n            foreach (string s in d.LoadCustomer())\r\n            {\r\n                comboBox2.Items.Add(s);\r\n            }\r\n            foreach (string s in d.LoadModel())\r\n            {\r\n                comboBox1.Items.Add(s);\r\n            }\r\n            foreach (string[] s in d.LoadWorkers())\r\n            {\r\n                comboBox3.Items.Add(s[1]);\r\n            }\r\n\r\n            d.ExecuteReader(q,\"\",dataGridView1);\r\n            SetWorkTime();\r\n        }\r\n        private void SetWorkTime()\r\n        {\r\n            for (int r = 0; r &lt; dataGridView1.Rows.Count; r++)\r\n            {\r\n                string s = dataGridView1.Rows[r].Cells[7].Value.ToString();\r\n                string e = dataGridView1.Rows[r].Cells[8].Value.ToString();\r\n                string a = dataGridView1.Rows[r].Cells[9].Value.ToString();\r\n\r\n                if (s != \"\" &amp;&amp; e != \"\" &amp;&amp; a != \"\")\r\n                {\r\n                    dataGridView1.Rows[r].Cells[10].Value = Db.WorkTime(DateTime.Parse(s), DateTime.Parse(e), TimeSpan.Parse(a));\r\n                }\r\n                if (s != \"\" &amp;&amp; e != \"\" &amp;&amp; a == \"\")\r\n                {\r\n                    dataGridView1.Rows[r].Cells[10].Value = Db.WorkTime(DateTime.Parse(s), DateTime.Parse(e), new TimeSpan(0, 0, 0));\r\n                }\r\n                if (s == \"\" || e == \"\")\r\n                {\r\n                    dataGridView1.Rows[r].Cells[10].Value = \"-\";\r\n                }\r\n            }\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            DbLoad();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form8.cs<\/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\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form8 : Form\r\n    {\r\n        public string ReturnOrders_id = \"\";\r\n\r\n        public Form8(string workers_id,string worker_name)\r\n        {\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            string[] col = new string[] { \"\u540d\u524d\" , \"\u30aa\u30fc\u30c0\u30fcID\" , \"\u5f97\u610f\u5148\", \"\u578b\u5f0f\", \"\u5de5\u756a\", \"\u679d\u756a\", \"\u6570\u91cf\", \"\u958b\u59cb\u65e5\u6642\" };\r\n            for (int i = 0; i &lt; col.Length; i++)\r\n            {\r\n                dataGridView1.Columns.Add(new DataGridViewTextBoxColumn());\r\n                dataGridView1.Columns[i].HeaderText = col[i];\r\n            }\r\n\r\n            dataGridView1.AllowUserToAddRows = false;\r\n            dataGridView1.ReadOnly = true;\r\n            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;\r\n            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;\r\n            dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;\r\n            dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;\r\n            dataGridView1.DefaultCellStyle.Font = new Font(\"Meiryo UI\", 11);\r\n\r\n            string q = \"select '\" + worker_name + \"' , items.orders_id , orders.customer , orders.model , orders.serial_no , items.suffix_no , orders.quantity , \" +\r\n            \"date_format(tasks_s.start_dt, '%y-%m-%d %H:%i') \" +\r\n            \"from items \" + \r\n            \"left outer join tasks_s on items.items_id = tasks_s.items_id and tasks_s.workers_id = \" + workers_id + \" \" +\r\n            \"left outer join tasks_e on items.items_id = tasks_e.items_id and tasks_e.workers_id = \" + workers_id + \" \" +\r\n            \"left outer join tasks_p on items.items_id = tasks_p.items_id and tasks_p.workers_id = \" + workers_id + \" \" +\r\n            \"left outer join orders  on items.orders_id = orders.orders_id \" + \r\n            \"where tasks_s.start_dt is not null and tasks_e.end_dt is null and visible = '\u672a';\";\r\n\r\n            Db d = new Db();\r\n            if (!d.DbState)\r\n            {\r\n                MessageBox.Show(d.DbStateMessage);\r\n                return;\r\n            }\r\n            d.ExecuteReader(q, \"\", dataGridView1);\r\n        }\r\n\r\n        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)\r\n        {\r\n            int r = e.RowIndex; int c = e.ColumnIndex;\r\n\r\n            if (c == 1 &amp;&amp; r &gt;= 0 &amp;&amp; dataGridView1.Rows[r].Cells[c].Value.ToString() != \"\")\r\n            {\r\n                ReturnOrders_id = dataGridView1.Rows[r].Cells[c].Value.ToString();\r\n                this.Close();\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form9.cs<\/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\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form9 : Form\r\n    {\r\n        public string DbHost;\r\n        public string DbName;\r\n        public string DbUser;\r\n        public string DbPass;\r\n\r\n        public Form9()\r\n        {\r\n            InitializeComponent();\r\n            try\r\n            {\r\n                System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(string[]));\r\n                using (System.IO.StreamReader sr = new System.IO.StreamReader(Application.StartupPath + @\"\\path.txt\", new System.Text.UTF8Encoding(false)))\r\n                {\r\n                    string[] s = (string[])xs.Deserialize(sr);\r\n                    textBox5.Text = s[0];\r\n                    textBox1.Text = s[1];\r\n                    textBox2.Text = s[2];\r\n                    textBox3.Text = s[3];\r\n                    sr.Close();\r\n                }\r\n            }\r\n            catch { }\r\n        }\r\n\r\n        private void Form9_FormClosing(object sender, FormClosingEventArgs e)\r\n        {\r\n            DbHost = textBox5.Text;\r\n            DbName = textBox1.Text;\r\n            DbUser = textBox2.Text;\r\n            DbPass = textBox3.Text;\r\n            try\r\n            {\r\n                System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(string[]));\r\n                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(Application.StartupPath + @\"\\path.txt\", false, new System.Text.UTF8Encoding(false)))\r\n                {\r\n                    xs.Serialize(sw, new string[] { DbHost , DbName, DbUser , DbPass});\r\n                    sw.Close();\r\n                }\r\n                    \r\n            }\r\n            catch { }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Form10.cs<\/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\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    public partial class Form10 : Form\r\n    {\r\n        public string getDatetime = \"\";\r\n\r\n        public Form10()\r\n        {\r\n            InitializeComponent();\r\n            ImeMode = ImeMode.Off;\r\n\r\n            for (int i = DateTime.Now.AddYears(-2).Year; i &lt;= DateTime.Now.AddYears(2).Year; i++ )\r\n            {\r\n                comboBox1.Items.Add(i.ToString());\r\n            }\r\n            comboBox1.Text = DateTime.Now.Year.ToString();\r\n\r\n            for (int i = 1; i &lt;= 12; i++)\r\n            {\r\n                comboBox2.Items.Add(i.ToString(\"00\"));\r\n            }\r\n            comboBox2.Text = DateTime.Now.Month.ToString();\r\n\r\n            for (int i = 1; i &lt;= 31; i++)\r\n            {\r\n                comboBox3.Items.Add(i.ToString(\"00\"));\r\n            }\r\n            comboBox3.Text = DateTime.Now.Day.ToString();\r\n\r\n            for (int i = 0; i &lt;= 24; i++)\r\n            {\r\n                comboBox4.Items.Add(i.ToString(\"00\"));\r\n            }\r\n            comboBox4.Text = \"00\";\r\n\r\n            comboBox5.Items.AddRange(new string[] { \"00\", \"15\", \"30\", \"45\" });\r\n            comboBox5.Text = \"00\";\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            DateTime dt = new DateTime();\r\n            try\r\n            {\r\n                dt = DateTime.Parse(comboBox1.Text + \"-\" + comboBox2.Text + \"-\" + comboBox3.Text + \" \" + comboBox4.Text + \":\" + comboBox5.Text + \":01\");\r\n            }\r\n            catch\r\n            {\r\n                MessageBox.Show(\"\u5024\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002\");\r\n                getDatetime = \"\";\r\n                return;\r\n            }\r\n            getDatetime = dt.ToString(\"yyyy-MM-dd HH:mm:ss\");\r\n            this.Close();\r\n        }\r\n\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            getDatetime = \"\";\r\n            this.Close();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Db.cs<\/p>\n<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\n\r\nusing System.Windows.Forms;\r\nusing MySql.Data.MySqlClient;\r\n\r\nnamespace \u88fd\u54c1\u5de5\u6570\u7ba1\u7406\r\n{\r\n    class Db\r\n    {\r\n        public static string DbHost;\r\n        public static string DbName;\r\n        public static string DbUser;\r\n        public static string DbPass;\r\n\r\n        public Boolean DbState = true;\r\n        public string DbStateMessage = \"\";\r\n\r\n        string dsn = \"\";\r\n\r\n        public Db()\r\n        {\r\n            dsn = @\"user=\" + DbUser + \";password=\" + DbPass + \";database=\" + DbName + \";server=\" + DbHost + \";charset=sjis\";\r\n            MySqlConnection con = null;\r\n            try\r\n            {\r\n                using (con = new MySqlConnection(dsn))\r\n                {\r\n                    con.Open();\r\n                }\r\n            }\r\n            catch(Exception e)\r\n            {\r\n                DbStateMessage = e.Message;\r\n                DbState = false;\r\n                return;\r\n            }\r\n            finally\r\n            {\r\n                con.Close();\r\n            }\r\n        }\r\n        public string[] LoadModel()\r\n        {\r\n            MySqlConnection con = null;\r\n            try\r\n            {\r\n                using (con = new MySqlConnection(dsn))\r\n                {\r\n                    con.Open();\r\n                    MySqlCommand cmd = new MySqlCommand(\"select distinct model from orders\", con);\r\n                    using (MySqlDataReader dr = cmd.ExecuteReader())\r\n                    {\r\n                        List&lt;string&gt; tmp = new List&lt;string&gt;();\r\n\r\n                        while (dr.Read())\r\n                        {\r\n                            tmp.Add(dr[0].ToString());\r\n                        }\r\n                        return tmp.ToArray();\r\n                    }\r\n                }\r\n            }\r\n            catch { }\r\n            finally\r\n            {\r\n                con.Close();\r\n            }\r\n            return new string[] { };\r\n        }\r\n        public string[] LoadCustomer()\r\n        {\r\n            MySqlConnection con = null;\r\n            try\r\n            {\r\n                using (con = new MySqlConnection(dsn))\r\n                {\r\n                    con.Open();\r\n                    MySqlCommand cmd = new MySqlCommand(\"select distinct customer from orders\", con);\r\n                    using (MySqlDataReader dr = cmd.ExecuteReader())\r\n                    {\r\n                        List&lt;string&gt; tmp = new List&lt;string&gt;();\r\n\r\n                        while (dr.Read())\r\n                        {\r\n                            tmp.Add(dr[0].ToString());\r\n                        }\r\n                        return tmp.ToArray();\r\n                    }\r\n                }\r\n            }\r\n            catch { }\r\n            finally\r\n            {\r\n                con.Close();\r\n            }\r\n            return new string[] { };\r\n        }\r\n        public string[][] LoadWorkers()\r\n        {\r\n            MySqlConnection con = null;\r\n            try\r\n            {\r\n                using (con = new MySqlConnection(dsn))\r\n                {\r\n                    con.Open();\r\n                    MySqlCommand cmd = new MySqlCommand(\"select workers_id , worker_name from workers\", con);\r\n                    using (MySqlDataReader dr = cmd.ExecuteReader())\r\n                    {\r\n                        List&lt;string[]&gt; tmp = new List&lt;string[]&gt;();\r\n\r\n                        while (dr.Read())\r\n                        {\r\n                            tmp.Add(new string[] { dr[0].ToString(), dr[1].ToString() });\r\n                        }\r\n                        return tmp.ToArray();\r\n                    }\r\n                }\r\n            }\r\n            catch{}\r\n            finally\r\n            {\r\n                con.Close();\r\n            }\r\n            return new string[][] { };\r\n        }\r\n        public string ExecuteNonReader(string q, string cap)\r\n        {\r\n            MySqlConnection con = null;\r\n            try\r\n            {\r\n                using (con = new MySqlConnection(dsn))\r\n                {\r\n                    con.Open();\r\n                    MySqlCommand cmd1 = new MySqlCommand(q,con);\r\n                    cmd1.ExecuteNonQuery();\r\n\r\n                    MySqlCommand cmd2 = new MySqlCommand(\"select last_insert_id()\",con);\r\n                    using (MySqlDataReader dr = cmd2.ExecuteReader())\r\n                    {\r\n                        if (dr.Read() &amp;&amp; dr[0].ToString() != \"\") return dr[0].ToString();\r\n                    }\r\n                }\r\n            }\r\n            catch { }\r\n            finally\r\n            {\r\n                con.Close();\r\n            }\r\n            return \"\";\r\n        }\r\n        public void ExecuteReader(string q, string cap, DataGridView dgv)\r\n        {\r\n            dgv.Rows.Clear();\r\n            MySqlConnection con = null;\r\n            try\r\n            {\r\n                using (con = new MySqlConnection(dsn))\r\n                {\r\n                    con.Open();\r\n                    MySqlCommand cmd = new MySqlCommand(q, con);\r\n                    using (MySqlDataReader dr = cmd.ExecuteReader())\r\n                    {\r\n                        while(dr.Read())\r\n                        {\r\n                            List&lt;string&gt; tmp = new List&lt;string&gt;();\r\n                            for (int c = 0; c &lt; dgv.Columns.Count; c++)\r\n                            {\r\n                                tmp.Add(dr[c].ToString());\r\n                            }\r\n                            dgv.Rows.Add(tmp.ToArray());\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n            catch { }\r\n            finally\r\n            {\r\n                con.Close();\r\n            }\r\n        }\r\n        public Boolean QuantityCheck(string q, string quantity)\r\n        {\r\n            MySqlConnection con = null;\r\n            try\r\n            {\r\n                using (con = new MySqlConnection(dsn))\r\n                {\r\n                    con.Open();\r\n                    MySqlCommand cmd = new MySqlCommand(q, con);\r\n                    using (MySqlDataReader dr = cmd.ExecuteReader())\r\n                    {\r\n                        if(dr.Read() &amp;&amp; dr[0].ToString() == quantity) return true;\r\n                    }\r\n                }\r\n            }\r\n            catch { }\r\n            finally\r\n            {\r\n                con.Close();\r\n            }\r\n            return false;\r\n        }\r\n        public Boolean FormLoadExecuteReader(string q,List&lt;TextBox&gt; t)\r\n        {\r\n            MySqlConnection con = null;\r\n            try\r\n            {\r\n                using (con = new MySqlConnection(dsn))\r\n                {\r\n                    con.Open();\r\n                    MySqlCommand cmd = new MySqlCommand(q, con);\r\n                    using (MySqlDataReader dr = cmd.ExecuteReader())\r\n                    {\r\n                        while (dr.Read())\r\n                        {\r\n                            t[0].Text = dr[0].ToString();\r\n                            t[1].Text = dr[1].ToString();\r\n                            t[2].Text = dr[2].ToString();\r\n                            t[3].Text = dr[3].ToString();\r\n                            t[4].Text = dr[4].ToString();\r\n                            return true;\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n            catch { }\r\n            finally\r\n            {\r\n                con.Close();\r\n            }\r\n            return false;\r\n        }\r\n        private static TimeSpan ActualWork(DateTime s, DateTime e)\r\n        {\r\n            \/\/08:30 - 10:00 = 01:30\r\n            \/\/10:15 - 12:00 = 01:45 = 03:15\r\n            \/\/12:50 - 15:00 = 02:10\r\n            \/\/15:15 - 17:20 = 02:05 = 04:15 = 07:30\r\n\r\n            int y = s.Year;\r\n            int m = s.Month;\r\n            int d = s.Day;\r\n\r\n            DateTime start_dt = new DateTime(y, m, d, s.Hour, s.Minute, 00);\r\n            DateTime end_dt = new DateTime(y, m, d, e.Hour, e.Minute, 00);\r\n\r\n            DateTime dt = start_dt;\r\n            TimeSpan ts = new TimeSpan(0, 0, 0);\r\n\r\n            while (dt &lt; end_dt)\r\n            {\r\n                ts += new TimeSpan(0, 1, 0);\r\n\r\n                if (dt &gt;= new DateTime(y, m, d, 10, 00, 00) &amp;&amp; dt &lt; new DateTime(y, m, d, 10, 15, 00)) ts -= new TimeSpan(0, 1, 0);\r\n                if (dt &gt;= new DateTime(y, m, d, 12, 00, 00) &amp;&amp; dt &lt; new DateTime(y, m, d, 12, 50, 00)) ts -= new TimeSpan(0, 1, 0);\r\n                if (dt &gt;= new DateTime(y, m, d, 15, 00, 00) &amp;&amp; dt &lt; new DateTime(y, m, d, 15, 15, 00)) ts -= new TimeSpan(0, 1, 0);\r\n                if (dt &gt;= new DateTime(y, m, d, 17, 20, 00) &amp;&amp; dt &lt; new DateTime(y, m, d, 17, 30, 00)) ts -= new TimeSpan(0, 1, 0);\r\n\r\n                dt += new TimeSpan(0, 1, 0);\r\n            }\r\n            return ts;\r\n        }\r\n        public static string WorkTime(DateTime s, DateTime e, TimeSpan a)\r\n        {\r\n            if (s &gt; e) return \"-\";\r\n\r\n            DateTime start_day = new DateTime(s.Year,s.Month,s.Day);\r\n            DateTime end_day = new DateTime(e.Year, e.Month, e.Day);\r\n\r\n            \/\/\u958b\u59cb\u3068\u7d42\u4e86\u304c\u540c\r\n            if (start_day == end_day)\r\n            {\r\n                TimeSpan ts = ActualWork(s,e);\r\n                return (ts + a).ToString().Substring(0, (ts + a).ToString().Length - 3);\r\n            }\r\n            else \/\/\u958b\u59cb\u3068\u7d42\u4e86\u304c\u5225\r\n            {\r\n                TimeSpan ts = new TimeSpan(0, 0, 0);\r\n\r\n                int i = 0;\r\n                while (start_day.AddDays(i) &lt;= end_day)\r\n                {\r\n                    DateTime t = start_day.AddDays(i);\r\n                    \r\n                    if (t == start_day &amp;&amp; t != end_day)\/\/\u958b\u59cb\r\n                    {\r\n                        ts += ActualWork(s, new DateTime(s.Year,s.Month,s.Day,17,20,00));\r\n                    }\r\n                    \r\n                    if (t != start_day &amp;&amp; t != end_day)\/\/\u4e2d\u9593\r\n                    {\r\n                        ts += ActualWork(new DateTime(t.Year, t.Month, t.Day, 8, 30, 00), new DateTime(t.Year, t.Month, t.Day, 17, 20, 00));\r\n                    }\r\n                    \r\n                    if (t != start_day &amp;&amp; t == end_day)\/\/\u7d42\u4e86\r\n                    {\r\n                        ts += ActualWork(new DateTime(e.Year, e.Month, e.Day, 8, 30, 00), e);\r\n                    }\r\n                    i++;\r\n                }\r\n                return (ts + a).ToString().Substring(0, (ts + a).ToString().Length - 3);\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30c6\u30b9\u30c8\u3067\u4f5c\u3063\u3066\u307f\u305f\u304c\u65b9\u5411\u6027\u5909\u66f4\u306e\u305f\u3081\u672a\u4f7f\u7528\u3002\u8907\u6570\u306ePC\u304b\u3089\u30d0\u30fc\u30b3\u30fc\u30c9\u3092\u4f7f\u3044\u88fd\u4f5c\u6642\u9593(\u5de5\u6570)\u3092\u767b\u9332\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3002 \u4eca\u5f8c\u3001\u6642\u9593\u306e\u3042\u308b\u3068\u304d\u7a3c\u50cd\u6642\u9593\u7b97\u51fa\u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3088\u3046\u304b\u306a\u3068\u3002 MySQL\u304c\u5fc5\u8981\u306a\u306e\u3067\u3001XA &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=1949\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u5de5\u6570\u7ba1\u7406\u30d7\u30ed\u30b0\u30e9\u30e0&#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-1949","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\/1949","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=1949"}],"version-history":[{"count":13,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/1949\/revisions"}],"predecessor-version":[{"id":6296,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/1949\/revisions\/6296"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}