在庫管理の別バーション。方向性変更のため未使用。
出庫を別表にして視覚的に分かりやすく。
Form1.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
using System; using System.Windows.Forms; using System.Data.OleDb; namespace 預かり在庫管理_1._0 { public partial class Form1 : Form { public Form1() { InitializeComponent(); dataGridView1.AllowUserToAddRows = false; dataGridView1.ReadOnly = true; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False; dataGridView1.CellClick += new DataGridViewCellEventHandler(cell_click); using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand("select * from order_tbl", con); cmd.ExecuteNonQuery(); } catch { MessageBox.Show("データベースに接続できませんでした。"); return; } finally { con.Close(); } } load_Db("select * from order_tbl where 表示 = 0"); } void cell_click(object sener, DataGridViewCellEventArgs e) { int r = e.RowIndex; int c = e.ColumnIndex; string id = dataGridView1.Rows[r].Cells[0].Value.ToString(); string number = dataGridView1.Rows[r].Cells[1].Value.ToString(); string client = dataGridView1.Rows[r].Cells[2].Value.ToString(); string item = dataGridView1.Rows[r].Cells[3].Value.ToString(); string quantity = dataGridView1.Rows[r].Cells[4].Value.ToString(); string v = dataGridView1.Rows[r].Cells[7].Value.ToString(); if (r == -1 || c == -1) return; if (c == 0)//ID { Form f = new Form3(id, number, client, item, quantity); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(); this.button3.PerformClick(); } if (c == 5)//編集 { Form f = new Form2(id, number, client, item, quantity, v); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(); this.button3.PerformClick(); } if (c == 6)//削除 { DialogResult yn = MessageBox.Show("削除します。実行しますか?", "", MessageBoxButtons.YesNo); if (yn == DialogResult.No) return; using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand("delete from order_tbl where ID = " + id + "", con); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } } this.button3.PerformClick(); } } void load_Db(string q) { dataGridView1.Rows.Clear(); using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand(q, con); using (OleDbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { this.dataGridView1.Rows.Add( dr["ID"].ToString(), dr["伝票番号"].ToString(), dr["仕入先"].ToString(), dr["品目名"].ToString(), dr["数量"].ToString(), "編集", "削除", dr["表示"].ToString() ); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } } //初期化 private void button3_Click(object sender, EventArgs e) { load_Db("select * from order_tbl where 表示 = 0"); textBox1.Enabled = true; textBox1.Text = ""; comboBox1.Text = ""; } //検索 private void button2_Click(object sender, EventArgs e) { if(comboBox1.Text == "非表示品") { load_Db("select * from order_tbl where 表示 = 1"); return; } if (textBox1.Text == "" || comboBox1.Text == "") { MessageBox.Show("検索条件が不足です。"); return; } load_Db("select * from order_tbl where 表示 = 0 and " + comboBox1.Text + " like '%" + textBox1.Text + "%'"); } private void button1_Click(object sender, EventArgs e) { Form f = new Form2("","","","","",""); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(); this.button3.PerformClick(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.Text == "非表示品") { textBox1.Text = ""; textBox1.Enabled = false; } else { textBox1.Enabled = true; } } } } |
Form2.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
using System; using System.Windows.Forms; using System.Data.OleDb; namespace 預かり在庫管理_1._0 { public partial class Form2 : Form { public Form2(string id, string number, string client, string item, string quantity, string v) { InitializeComponent(); textBox5.Text = id; textBox1.Text = number; comboBox1.Text = client; textBox3.Text = item; textBox4.Text = quantity; if (textBox5.Text == "") { checkBox1.Enabled = false; } else { checkBox1.Enabled = true; } if (v == "1") checkBox1.Checked = true; using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand("select distinct 仕入先 from order_tbl", con); using (OleDbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { comboBox1.Items.Add(dr["仕入先"].ToString()); } } } finally { con.Close(); } } } private void button1_Click(object sender, EventArgs e) { textBox5.Text = textBox5.Text.Replace("\"", "”"); textBox1.Text = textBox1.Text.Replace("\"", "”"); comboBox1.Text = comboBox1.Text.Replace("\"", "”"); textBox3.Text = textBox3.Text.Replace("\"", "”"); textBox4.Text = textBox4.Text.Replace("\"", "”"); textBox5.Text = textBox5.Text.Replace("\'", "’"); textBox1.Text = textBox1.Text.Replace("\'", "’"); comboBox1.Text = comboBox1.Text.Replace("\'", "’"); textBox3.Text = textBox3.Text.Replace("\'", "’"); textBox4.Text = textBox4.Text.Replace("\'", "’"); try { if (textBox1.Text == "" || comboBox1.Text == "" || textBox3.Text == "") throw new Exception(); short.Parse(textBox4.Text); } catch { MessageBox.Show("入力に不正があります。"); return; } string q = ""; if (textBox5.Text == "") { q = "insert into order_tbl(伝票番号,仕入先,品目名,数量,表示) values('" + textBox1.Text + "','" + comboBox1.Text + "','" + textBox3.Text + "','" + textBox4.Text + "',0)"; } else { string v = "0"; if (checkBox1.Checked) v = "1"; q = "update order_tbl set 伝票番号='" + textBox1.Text + "',仕入先='" + comboBox1.Text + "',品目名='" + textBox3.Text + "',数量=" + textBox4.Text + ",表示=" + v + " where ID = " + textBox5.Text + ""; } using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand(q, con); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } } this.Close(); } } } |
Form3.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
using System; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using System.IO; namespace 預かり在庫管理_1._0 { public partial class Form3 : Form { public Form3(string id, string number, string client, string item, string quantity) { InitializeComponent(); textBox5.Text = id; textBox1.Text = number; textBox2.Text = client; textBox3.Text = item; textBox4.Text = quantity; dataGridView1.AllowUserToAddRows = false; dataGridView1.ReadOnly = true; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False; dataGridView2.AllowUserToAddRows = false; dataGridView2.ReadOnly = true; dataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dataGridView2.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False; dataGridView1.CellClick += new DataGridViewCellEventHandler(cell_click_dvg1); dataGridView2.CellClick += new DataGridViewCellEventHandler(cell_click_dvg2); load_db_dgv(); } void open_Folder(string number) { string path = ""; try { using (StreamReader sr = new StreamReader(Application.StartupPath + @"\setting.txt", Encoding.GetEncoding("shift_jis"))) { path = sr.ReadLine() + @"\" + textBox2.Text + @"\" + number; if (Directory.Exists(path)) { System.Diagnostics.Process.Start(path); } else { DialogResult yn = MessageBox.Show("フォルダを作成します。実行しますか?", "", MessageBoxButtons.YesNo); if (yn == DialogResult.No) return; Directory.CreateDirectory(path); System.Diagnostics.Process.Start(path); } } } catch(Exception e) { MessageBox.Show(e.Message); return; } } void cell_click_dvg2(object sener, DataGridViewCellEventArgs e) { int r = e.RowIndex; int c = e.ColumnIndex; if (r == -1 || c == -1) return; if (c == 7) open_Folder(dataGridView2.Rows[r].Cells[7].Value.ToString());//管理番号 if (c == 9)//戻入 { DialogResult yn = MessageBox.Show("在庫に戻します。実行しますか?", "", MessageBoxButtons.YesNo); if (yn == DialogResult.No) return; using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand("update stock_tbl set 出庫日='',出荷=0,PO='',管理番号='',得意先='' where ID = " + dataGridView2.Rows[r].Cells[0].Value.ToString() + "", con); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } } load_db_dgv(); } } void cell_click_dvg1(object sener, DataGridViewCellEventArgs e) { int r = e.RowIndex; int c = e.ColumnIndex; if (r == -1 || c == -1) return; if(c == 3)//分割 { Form f = new Form4(dataGridView1.Rows[r].Cells[0].Value.ToString(),dataGridView1.Rows[r].Cells[3].Value.ToString()); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(); load_db_dgv(); } if (c == 5)//出荷 { if (textBox8.Text == "" || comboBox2.Text == "" || textBox12.Text == "") { MessageBox.Show("出庫日・得意先・管理番号(INV)は必須です。"); return; } comboBox2.Text = comboBox2.Text.Replace("\"", "”"); comboBox2.Text = comboBox2.Text.Replace("\'", "’"); textBox8.Text = textBox8.Text.Replace("\"", "”"); textBox8.Text = textBox8.Text.Replace("\'", "’"); textBox11.Text = textBox11.Text.Replace("\"", "”"); textBox11.Text = textBox11.Text.Replace("\'", "’"); DialogResult yn = MessageBox.Show("出荷します。実行しますか?", "", MessageBoxButtons.YesNo); if (yn == DialogResult.No) return; using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand("update stock_tbl set 出庫日 = '" + textBox12.Text + "',出荷 = 1,PO = '" + textBox11.Text + "',管理番号='" + textBox8.Text + "',得意先='" + comboBox2.Text + "' where ID = " + dataGridView1.Rows[r].Cells[0].Value.ToString() + "", con); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } } load_db_dgv(); } if (c == 6)//削除 { DialogResult yn = MessageBox.Show("削除します。実行しますか?", "", MessageBoxButtons.YesNo); if (yn == DialogResult.No) return; using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand("delete from stock_tbl where ID = " + dataGridView1.Rows[r].Cells[0].Value.ToString() + "", con); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } } load_db_dgv(); } } void load_db_dgv() { dataGridView1.Rows.Clear(); dataGridView2.Rows.Clear(); comboBox2.Items.Clear(); string id = textBox5.Text; using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd1 = new OleDbCommand("select * from stock_tbl where 受注ID = " + id + " and 出荷 = 0", con); using (OleDbDataReader dr1 = cmd1.ExecuteReader()) { while (dr1.Read()) { this.dataGridView1.Rows.Add( dr1["ID"].ToString(), dr1["受注ID"].ToString(), dr1["日付"].ToString(), dr1["数量"].ToString(), dr1["種類"].ToString(),"出荷", "削除"); } } OleDbCommand cmd2 = new OleDbCommand("select * from stock_tbl where 受注ID = " + id + " and 出荷 = 1", con); using (OleDbDataReader dr2 = cmd2.ExecuteReader()) { while (dr2.Read()) { this.dataGridView2.Rows.Add( dr2["ID"].ToString(), dr2["受注ID"].ToString(), dr2["日付"].ToString(), dr2["出庫日"].ToString(), dr2["数量"].ToString(), dr2["種類"].ToString(), dr2["得意先"].ToString(), dr2["管理番号"].ToString(), dr2["PO"].ToString(), "戻入"); } } OleDbCommand cmd3 = new OleDbCommand("select distinct 得意先 from stock_tbl where 出荷 = 1", con); using (OleDbDataReader dr3 = cmd3.ExecuteReader()) { while (dr3.Read()) { comboBox2.Items.Add(dr3["得意先"].ToString()); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } int ship_qty = 0; int stock_qty = 0; for (int r = 0; r < dataGridView1.Rows.Count; r++) { stock_qty = stock_qty + int.Parse(dataGridView1.Rows[r].Cells[3].Value.ToString()); } for (int r = 0; r < dataGridView2.Rows.Count; r++) { ship_qty = ship_qty + int.Parse(dataGridView2.Rows[r].Cells[4].Value.ToString()); } textBox9.Text = stock_qty.ToString();//在庫数量 textBox10.Text = ship_qty.ToString();//出庫数量 label14.Text = "(" + (stock_qty + ship_qty).ToString() + ")"; textBox6.Text = DateTime.Now.ToString("yyyy/MM/dd");//入庫日 textBox12.Text = DateTime.Now.ToString("yyyy/MM/dd");//出庫日 textBox7.Text = "";//数量 textBox8.Text = "";//管理番号(INV) textBox11.Text = "";//PO comboBox2.Text = "";//得意先 comboBox1.Text = "";//保管方法 } //登録 private void button1_Click(object sender, EventArgs e) { string id = textBox5.Text; try { if (comboBox1.Text == "" || textBox6.Text == "") throw new Exception(); short.Parse(textBox7.Text); } catch { MessageBox.Show("入力に不正があります。"); return; } string q = "insert into stock_tbl (受注ID,日付,数量,種類,出荷) values (" + id + ",'" + textBox6.Text + "'," + textBox7.Text + ",'" + comboBox1.Text + "',0)"; using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand(q, con); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } load_db_dgv(); } } private void button2_Click(object sender, EventArgs e) { Form f = new Form5(); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(); } } } |
Form4.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
using System; using System.Windows.Forms; using System.Data.OleDb; namespace 預かり在庫管理_1._0 { public partial class Form4 : Form { short quantity = 0; int id = 0; public Form4(string i, string q) { InitializeComponent(); quantity = short.Parse(q); id = int.Parse(i); textBox6.Text = "0"; } private void button1_Click(object sender, EventArgs e) { short number = 0; try { if (textBox6.Text == "") throw new Exception(); number = short.Parse(textBox6.Text); if (quantity <= number || number == 0) throw new Exception(); } catch { MessageBox.Show("入力に不正があります。"); return; } DialogResult yn = MessageBox.Show("分割します。実行しますか?", "", MessageBoxButtons.YesNo); if (yn == DialogResult.No) return; using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); string q = "insert into stock_tbl (受注ID,日付,数量,種類,出荷) select 受注ID,日付,'" + number.ToString() + "',種類,'0' from stock_tbl where ID = " + id.ToString() + ""; OleDbCommand cmd1 = new OleDbCommand(q, con); cmd1.ExecuteNonQuery(); q = "update stock_tbl set 数量 = " + (quantity - number).ToString() +" where ID = " + id.ToString() + ""; OleDbCommand cmd2 = new OleDbCommand(q, con); cmd2.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } } this.Close(); } } } |
Form5.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
using System; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using System.IO; namespace 預かり在庫管理_1._0 { public partial class Form5 : Form { public Form5() { InitializeComponent(); dataGridView1.AllowUserToAddRows = false; dataGridView1.ReadOnly = true; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False; dataGridView1.CellClick += new DataGridViewCellEventHandler(cell_click); string q = "select 伝票番号,仕入先,品目名,日付,stock_tbl.数量,種類,管理番号,得意先,PO,出庫日 " + "from stock_tbl left outer join order_tbl " + "on stock_tbl.受注ID = order_tbl.ID where 出荷 = 1"; load_Db(q); } void load_Db(string q) { dataGridView1.Rows.Clear(); using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\dat.mdb")) { try { con.Open(); OleDbCommand cmd = new OleDbCommand(q, con); using (OleDbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { this.dataGridView1.Rows.Add( dr["伝票番号"].ToString(), dr["仕入先"].ToString(), dr["品目名"].ToString(), dr["日付"].ToString(), dr["出庫日"].ToString(), dr["数量"].ToString(), dr["種類"].ToString(), dr["得意先"].ToString(), dr["管理番号"].ToString(), dr["PO"].ToString() ); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } } //初期化 private void button3_Click(object sender, EventArgs e) { string q = "select 伝票番号,仕入先,品目名,日付,stock_tbl.数量,種類,管理番号,得意先,PO,出庫日 " + "from stock_tbl left outer join order_tbl " + "on stock_tbl.受注ID = order_tbl.ID where 出荷 = 1"; load_Db(q); textBox1.Text = ""; comboBox1.Text = ""; } //検索 private void button2_Click(object sender, EventArgs e) { if (textBox1.Text == "" || comboBox1.Text == "") { MessageBox.Show("検索条件が不足です。"); return; } string param = ""; switch (comboBox1.Text) { case "入庫日": param = "日付"; break; case "管理番号(INV)": param = "管理番号"; break; default: param = comboBox1.Text; break; } string q = "select 伝票番号,仕入先,品目名,日付,stock_tbl.数量,種類,管理番号,得意先,PO,出庫日 " + "from stock_tbl left outer join order_tbl " + "on stock_tbl.受注ID = order_tbl.ID where 出荷 = 1 and " + "" + param + " like '%" + textBox1.Text + "%'"; load_Db(q); } void cell_click(object sener, DataGridViewCellEventArgs e) { int r = e.RowIndex; int c = e.ColumnIndex; if (r == -1 || c == -1) return; if (c == 8) { string number = dataGridView1.Rows[r].Cells[8].Value.ToString(); string client = dataGridView1.Rows[r].Cells[1].Value.ToString(); try { using (StreamReader sr = new StreamReader(Application.StartupPath + @"\setting.txt", Encoding.GetEncoding("shift_jis"))) { string path = sr.ReadLine() + @"\" + client + @"\" + number; if (Directory.Exists(path)) { System.Diagnostics.Process.Start(path); } else { DialogResult yn = MessageBox.Show("フォルダを作成します。実行しますか?", "", MessageBoxButtons.YesNo); if (yn == DialogResult.No) return; Directory.CreateDirectory(path); System.Diagnostics.Process.Start(path); } } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } } } |