Commit d7b16766120442a56f28d42e7c04e69863bb499c

Authored by r-ujihara
1 parent d66af8d7

製造中登録(3回目)

@@ -108,6 +108,7 @@ @@ -108,6 +108,7 @@
108 this.textBox2.Size = new System.Drawing.Size(100, 19); 108 this.textBox2.Size = new System.Drawing.Size(100, 19);
109 this.textBox2.TabIndex = 3; 109 this.textBox2.TabIndex = 3;
110 this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); 110 this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
  111 + this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
111 // 112 //
112 // label4 113 // label4
113 // 114 //
@@ -136,6 +137,7 @@ @@ -136,6 +137,7 @@
136 this.textBox4.Size = new System.Drawing.Size(100, 19); 137 this.textBox4.Size = new System.Drawing.Size(100, 19);
137 this.textBox4.TabIndex = 8; 138 this.textBox4.TabIndex = 8;
138 this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged); 139 this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged);
  140 + this.textBox4.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox4_KeyPress);
139 // 141 //
140 // textBox5 142 // textBox5
141 // 143 //
@@ -146,6 +148,7 @@ @@ -146,6 +148,7 @@
146 this.textBox5.Size = new System.Drawing.Size(100, 19); 148 this.textBox5.Size = new System.Drawing.Size(100, 19);
147 this.textBox5.TabIndex = 9; 149 this.textBox5.TabIndex = 9;
148 this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged); 150 this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged);
  151 + this.textBox5.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox5_KeyPress);
149 // 152 //
150 // label6 153 // label6
151 // 154 //
@@ -175,6 +178,7 @@ @@ -175,6 +178,7 @@
175 this.textBox6.Size = new System.Drawing.Size(31, 19); 178 this.textBox6.Size = new System.Drawing.Size(31, 19);
176 this.textBox6.TabIndex = 12; 179 this.textBox6.TabIndex = 12;
177 this.textBox6.TextChanged += new System.EventHandler(this.textBox6_TextChanged); 180 this.textBox6.TextChanged += new System.EventHandler(this.textBox6_TextChanged);
  181 + this.textBox6.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox6_KeyPress);
178 // 182 //
179 // label8 183 // label8
180 // 184 //
@@ -194,6 +198,7 @@ @@ -194,6 +198,7 @@
194 this.textBox7.Size = new System.Drawing.Size(31, 19); 198 this.textBox7.Size = new System.Drawing.Size(31, 19);
195 this.textBox7.TabIndex = 14; 199 this.textBox7.TabIndex = 14;
196 this.textBox7.TextChanged += new System.EventHandler(this.textBox7_TextChanged); 200 this.textBox7.TextChanged += new System.EventHandler(this.textBox7_TextChanged);
  201 + this.textBox7.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox7_KeyPress);
197 // 202 //
198 // label9 203 // label9
199 // 204 //
@@ -267,6 +272,7 @@ @@ -267,6 +272,7 @@
267 this.textBox8.Size = new System.Drawing.Size(31, 19); 272 this.textBox8.Size = new System.Drawing.Size(31, 19);
268 this.textBox8.TabIndex = 22; 273 this.textBox8.TabIndex = 22;
269 this.textBox8.TextChanged += new System.EventHandler(this.textBox8_TextChanged); 274 this.textBox8.TextChanged += new System.EventHandler(this.textBox8_TextChanged);
  275 + this.textBox8.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox8_KeyPress);
270 // 276 //
271 // textBox9 277 // textBox9
272 // 278 //
@@ -277,6 +283,7 @@ @@ -277,6 +283,7 @@
277 this.textBox9.Size = new System.Drawing.Size(31, 19); 283 this.textBox9.Size = new System.Drawing.Size(31, 19);
278 this.textBox9.TabIndex = 23; 284 this.textBox9.TabIndex = 23;
279 this.textBox9.TextChanged += new System.EventHandler(this.textBox9_TextChanged); 285 this.textBox9.TextChanged += new System.EventHandler(this.textBox9_TextChanged);
  286 + this.textBox9.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox9_KeyPress);
280 // 287 //
281 // textBox10 288 // textBox10
282 // 289 //
@@ -287,6 +294,7 @@ @@ -287,6 +294,7 @@
287 this.textBox10.Size = new System.Drawing.Size(31, 19); 294 this.textBox10.Size = new System.Drawing.Size(31, 19);
288 this.textBox10.TabIndex = 24; 295 this.textBox10.TabIndex = 24;
289 this.textBox10.TextChanged += new System.EventHandler(this.textBox10_TextChanged); 296 this.textBox10.TextChanged += new System.EventHandler(this.textBox10_TextChanged);
  297 + this.textBox10.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox10_KeyPress);
290 // 298 //
291 // textBox11 299 // textBox11
292 // 300 //
@@ -297,6 +305,7 @@ @@ -297,6 +305,7 @@
297 this.textBox11.Size = new System.Drawing.Size(31, 19); 305 this.textBox11.Size = new System.Drawing.Size(31, 19);
298 this.textBox11.TabIndex = 25; 306 this.textBox11.TabIndex = 25;
299 this.textBox11.TextChanged += new System.EventHandler(this.textBox11_TextChanged); 307 this.textBox11.TextChanged += new System.EventHandler(this.textBox11_TextChanged);
  308 + this.textBox11.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox11_KeyPress);
300 // 309 //
301 // textBox12 310 // textBox12
302 // 311 //
@@ -307,6 +316,7 @@ @@ -307,6 +316,7 @@
307 this.textBox12.Size = new System.Drawing.Size(31, 19); 316 this.textBox12.Size = new System.Drawing.Size(31, 19);
308 this.textBox12.TabIndex = 26; 317 this.textBox12.TabIndex = 26;
309 this.textBox12.TextChanged += new System.EventHandler(this.textBox12_TextChanged); 318 this.textBox12.TextChanged += new System.EventHandler(this.textBox12_TextChanged);
  319 + this.textBox12.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox12_KeyPress);
310 // 320 //
311 // textBox13 321 // textBox13
312 // 322 //
@@ -317,6 +327,7 @@ @@ -317,6 +327,7 @@
317 this.textBox13.Size = new System.Drawing.Size(31, 19); 327 this.textBox13.Size = new System.Drawing.Size(31, 19);
318 this.textBox13.TabIndex = 27; 328 this.textBox13.TabIndex = 27;
319 this.textBox13.TextChanged += new System.EventHandler(this.textBox13_TextChanged); 329 this.textBox13.TextChanged += new System.EventHandler(this.textBox13_TextChanged);
  330 + this.textBox13.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox13_KeyPress);
320 // 331 //
321 // textBox14 332 // textBox14
322 // 333 //
@@ -327,6 +338,7 @@ @@ -327,6 +338,7 @@
327 this.textBox14.Size = new System.Drawing.Size(31, 19); 338 this.textBox14.Size = new System.Drawing.Size(31, 19);
328 this.textBox14.TabIndex = 28; 339 this.textBox14.TabIndex = 28;
329 this.textBox14.TextChanged += new System.EventHandler(this.textBox14_TextChanged); 340 this.textBox14.TextChanged += new System.EventHandler(this.textBox14_TextChanged);
  341 + this.textBox14.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox14_KeyPress);
330 // 342 //
331 // label16 343 // label16
332 // 344 //
@@ -365,6 +377,7 @@ @@ -365,6 +377,7 @@
365 this.textBox15.Size = new System.Drawing.Size(31, 19); 377 this.textBox15.Size = new System.Drawing.Size(31, 19);
366 this.textBox15.TabIndex = 32; 378 this.textBox15.TabIndex = 32;
367 this.textBox15.TextChanged += new System.EventHandler(this.textBox15_TextChanged); 379 this.textBox15.TextChanged += new System.EventHandler(this.textBox15_TextChanged);
  380 + this.textBox15.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox15_KeyPress);
368 // 381 //
369 // textBox16 382 // textBox16
370 // 383 //
@@ -375,6 +388,7 @@ @@ -375,6 +388,7 @@
375 this.textBox16.Size = new System.Drawing.Size(31, 19); 388 this.textBox16.Size = new System.Drawing.Size(31, 19);
376 this.textBox16.TabIndex = 33; 389 this.textBox16.TabIndex = 33;
377 this.textBox16.TextChanged += new System.EventHandler(this.textBox16_TextChanged); 390 this.textBox16.TextChanged += new System.EventHandler(this.textBox16_TextChanged);
  391 + this.textBox16.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox16_KeyPress);
378 // 392 //
379 // button1 393 // button1
380 // 394 //
@@ -487,8 +501,10 @@ @@ -487,8 +501,10 @@
487 this.Controls.Add(this.label2); 501 this.Controls.Add(this.label2);
488 this.Controls.Add(this.label1); 502 this.Controls.Add(this.label1);
489 this.Controls.Add(this.textBox1); 503 this.Controls.Add(this.textBox1);
  504 + this.KeyPreview = true;
490 this.Name = "Form2"; 505 this.Name = "Form2";
491 this.Text = "Form2"; 506 this.Text = "Form2";
  507 + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form2_KeyDown);
492 this.ResumeLayout(false); 508 this.ResumeLayout(false);
493 this.PerformLayout(); 509 this.PerformLayout();
494 510
@@ -18,10 +18,15 @@ namespace MedicalCheckInputTool @@ -18,10 +18,15 @@ namespace MedicalCheckInputTool
18 private const int historyMax = 10; 18 private const int historyMax = 10;
19 private int historyPos = 0; 19 private int historyPos = 0;
20 20
21 - public Form2() 21 + public Form2(string serialNo = null)
22 { 22 {
23 InitializeComponent(); 23 InitializeComponent();
24 24
  25 + if (serialNo != null)
  26 + {
  27 + initDsp(serialNo);
  28 + }
  29 +
25 this.Text = "ロット:" + Global.lotNo + " " + Global.times + " " + "ユーザ:" + Global.inputUser; 30 this.Text = "ロット:" + Global.lotNo + " " + Global.times + " " + "ユーザ:" + Global.inputUser;
26 31
27 label3.Text = "ロット " + Global.lotNo + " 行政区番号 " + Global.adminCode; 32 label3.Text = "ロット " + Global.lotNo + " 行政区番号 " + Global.adminCode;
@@ -31,6 +36,67 @@ namespace MedicalCheckInputTool @@ -31,6 +36,67 @@ namespace MedicalCheckInputTool
31 dspCount(); 36 dspCount();
32 } 37 }
33 38
  39 + //修正から遷移
  40 + private void initDsp(string serialNo)
  41 + {
  42 + MySqlConnection conn;
  43 + string connstr = System.Configuration.ConfigurationManager.AppSettings["Conn"];
  44 + conn = new MySqlConnection(connstr);
  45 + conn.Open();
  46 + string code = serialNo.PadLeft(10, '0');
  47 +
  48 + textBox1.Text = code;
  49 + bool err = false;
  50 + MySqlCommand cmd = new MySqlCommand("select * from `" + Global.times + "` where `ロット番号` = @lotNo and `整理番号` = @serialNo", conn);
  51 + // パラメータ設定
  52 + cmd.Parameters.Add(new MySqlParameter("lotNo", Global.lotNo));
  53 + cmd.Parameters.Add(new MySqlParameter("serialNo", serialNo));
  54 +
  55 + try
  56 + {
  57 + MySqlDataReader reader = cmd.ExecuteReader();
  58 + if (!reader.HasRows)
  59 + {
  60 + //無かった
  61 + reader.Close();
  62 + }
  63 + else
  64 + {
  65 + string[] row = new string[reader.FieldCount];
  66 + while (reader.Read())
  67 + {
  68 + textBox1.Text = isDBNull(reader, "整理番号");
  69 + textBox2.Text = isDBNull(reader, "世帯番号");
  70 + textBox4.Text = isDBNull(reader, "電話番号");
  71 + textBox5.Text = isDBNull(reader, "携帯番号");
  72 + textBox6.Text = isDBNull(reader, "健康診査");
  73 + textBox7.Text = isDBNull(reader, "結核肺がん");
  74 + textBox8.Text = isDBNull(reader, "胃がん");
  75 + textBox9.Text = isDBNull(reader, "大腸がん");
  76 + textBox10.Text = isDBNull(reader, "前立腺がん");
  77 + textBox11.Text = isDBNull(reader, "骨粗鬆症");
  78 + textBox12.Text = isDBNull(reader, "成人歯科");
  79 + textBox13.Text = isDBNull(reader, "子宮頸がん");
  80 + textBox14.Text = isDBNull(reader, "乳がん");
  81 + textBox15.Text = isDBNull(reader, "希望場所");
  82 + textBox16.Text = isDBNull(reader, "身体不自由");
  83 +
  84 + Global.adminCode = isDBNull(reader, "行政区コード");
  85 + Global.adminName = isDBNull(reader, "行政区名称");
  86 + Global.healthArea = isDBNull(reader, "保健区");
  87 + }
  88 + reader.Close();
  89 + }
  90 + }
  91 + catch (SqlException ex)
  92 + {
  93 + }
  94 +
  95 + conn.Close();
  96 + }
  97 +
  98 +
  99 +
34 private void dspCount() 100 private void dspCount()
35 { 101 {
36 MySqlConnection conn; 102 MySqlConnection conn;
@@ -148,6 +214,19 @@ namespace MedicalCheckInputTool @@ -148,6 +214,19 @@ namespace MedicalCheckInputTool
148 sv.inputUser = Global.inputUser; 214 sv.inputUser = Global.inputUser;
149 err = insertData(sv, Global.times, conn); 215 err = insertData(sv, Global.times, conn);
150 } 216 }
  217 +
  218 + if ("2回目".Equals(Global.times))
  219 + {
  220 + if ("1".Equals(sv.done)) //保存したデータの完了フラグが立っていたら
  221 + {
  222 + SaveData sv1 = new SaveData();
  223 + sv1.lotNo = int.Parse(Global.lotNo);
  224 + sv1.serialNo = sv.serialNo;
  225 + sv1.done = "1";
  226 + updateDoneFlag(sv1, "1回目", conn);//1回目の完了フラグも立てる
  227 + }
  228 + }
  229 +
151 conn.Close(); 230 conn.Close();
152 return err; 231 return err;
153 } 232 }
@@ -295,6 +374,7 @@ namespace MedicalCheckInputTool @@ -295,6 +374,7 @@ namespace MedicalCheckInputTool
295 { 374 {
296 //無かった 375 //無かった
297 textBox1.BackColor = Color.Pink; 376 textBox1.BackColor = Color.Pink;
  377 + err = true;
298 reader.Close(); 378 reader.Close();
299 } 379 }
300 else 380 else
@@ -302,7 +382,7 @@ namespace MedicalCheckInputTool @@ -302,7 +382,7 @@ namespace MedicalCheckInputTool
302 string[] row = new string[reader.FieldCount]; 382 string[] row = new string[reader.FieldCount];
303 while (reader.Read()) 383 while (reader.Read())
304 { 384 {
305 - if( !sv.adminCode.Equals(isDBNull(reader, "世帯番号"))) 385 + if (!sv.houseNo.Equals(isDBNull(reader, "世帯番号")))
306 { 386 {
307 textBox2.BackColor = Color.Pink; 387 textBox2.BackColor = Color.Pink;
308 err = true; 388 err = true;
@@ -505,7 +585,7 @@ namespace MedicalCheckInputTool @@ -505,7 +585,7 @@ namespace MedicalCheckInputTool
505 + "`修正日` = @updateDate," 585 + "`修正日` = @updateDate,"
506 + "`修正者` = @updateUser," 586 + "`修正者` = @updateUser,"
507 + "`完了` = @done " 587 + "`完了` = @done "
508 - + "where `整理番号` = @serialNo"; 588 + + "where `ロット番号` = @lotNo and `整理番号` = @serialNo";
509 589
510 // コマンドを作成 590 // コマンドを作成
511 MySqlCommand cmd = new MySqlCommand(sql, conn); 591 MySqlCommand cmd = new MySqlCommand(sql, conn);
@@ -550,6 +630,36 @@ namespace MedicalCheckInputTool @@ -550,6 +630,36 @@ namespace MedicalCheckInputTool
550 630
551 } 631 }
552 632
  633 + private bool updateDoneFlag(SaveData sv, string tableName, MySqlConnection conn)
  634 + {
  635 + bool err = false;
  636 +
  637 + string sql = "update `" + tableName + "` set `完了` = @done "
  638 + + "where `ロット番号` = @lotNo and `整理番号` = @serialNo";
  639 +
  640 + // コマンドを作成
  641 + MySqlCommand cmd = new MySqlCommand(sql, conn);
  642 +
  643 + // パラメータ設定
  644 + cmd.Parameters.Add(new MySqlParameter("lotNo", sv.lotNo));
  645 + cmd.Parameters.Add(new MySqlParameter("serialNo", sv.serialNo));
  646 + cmd.Parameters.Add(new MySqlParameter("done", sv.done));
  647 +
  648 + try
  649 + {
  650 + // 実行
  651 + cmd.ExecuteNonQuery();
  652 + }
  653 + catch (SqlException ex)
  654 + {
  655 + // 例外処理
  656 + MessageBox.Show("例外発生:" + ex.Message);
  657 + return true;
  658 + }
  659 +
  660 + return err;
  661 + }
  662 +
553 private void sendTabKey(TextBox textbox, int length) 663 private void sendTabKey(TextBox textbox, int length)
554 { 664 {
555 if (textbox.Text.Length == length) 665 if (textbox.Text.Length == length)
@@ -592,6 +702,8 @@ namespace MedicalCheckInputTool @@ -592,6 +702,8 @@ namespace MedicalCheckInputTool
592 textBox15.Text = ""; 702 textBox15.Text = "";
593 textBox16.Text = ""; 703 textBox16.Text = "";
594 704
  705 + label20.Text = "";
  706 +
595 textBox1.Focus(); 707 textBox1.Focus();
596 } 708 }
597 709
@@ -801,30 +913,6 @@ namespace MedicalCheckInputTool @@ -801,30 +913,6 @@ namespace MedicalCheckInputTool
801 dspCount(); 913 dspCount();
802 } 914 }
803 915
804 - private void textBox1_KeyPress(object sender, KeyPressEventArgs e)  
805 - {  
806 -// if (e.KeyChar == Keys.NumLock) // 「NumLock」タブ  
807 -// {  
808 -// SendKeys.Send("{Tab}");  
809 -// e.Handled = true;  
810 -// }  
811 - if (e.KeyChar == '/') // 「/」BackSpace  
812 - {  
813 - SendKeys.Send("{BS}");  
814 - e.Handled = true;  
815 - }  
816 - if (e.KeyChar == '+') // 「+」次へ  
817 - {  
818 - button2.Focus();  
819 - button2.PerformClick();  
820 - e.Handled = true;  
821 - }  
822 - if (e.KeyChar == '*') // 「*」無効  
823 - {  
824 - e.Handled = true;  
825 - }  
826 - }  
827 -  
828 //復元 916 //復元
829 private void button3_Click(object sender, EventArgs e) 917 private void button3_Click(object sender, EventArgs e)
830 { 918 {
@@ -939,5 +1027,123 @@ namespace MedicalCheckInputTool @@ -939,5 +1027,123 @@ namespace MedicalCheckInputTool
939 } 1027 }
940 } 1028 }
941 1029
  1030 + private void shortcutKey(object sender, KeyPressEventArgs e)
  1031 + {
  1032 + if (e.KeyChar == '/') // 「/」BackSpace
  1033 + {
  1034 + SendKeys.Send("{BS}");
  1035 + e.Handled = true;
  1036 + }
  1037 + if (e.KeyChar == '+') // 「+」次へ
  1038 + {
  1039 +// button2.Focus();
  1040 +// button2.PerformClick();
  1041 + e.Handled = true;
  1042 + }
  1043 + if (e.KeyChar == '*') // 「*」Tab
  1044 + {
  1045 +// SendKeys.Send("{Tab}");
  1046 + e.Handled = true;
  1047 + }
  1048 + }
  1049 +
  1050 + private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  1051 + {
  1052 + shortcutKey(sender, e);
  1053 + }
  1054 +
  1055 + private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  1056 + {
  1057 + shortcutKey(sender, e);
  1058 + }
  1059 +
  1060 + private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
  1061 + {
  1062 + shortcutKey(sender, e);
  1063 + }
  1064 +
  1065 + private void textBox5_KeyPress(object sender, KeyPressEventArgs e)
  1066 + {
  1067 + shortcutKey(sender, e);
  1068 + }
  1069 +
  1070 + private void textBox6_KeyPress(object sender, KeyPressEventArgs e)
  1071 + {
  1072 + shortcutKey(sender, e);
  1073 + }
  1074 +
  1075 + private void textBox7_KeyPress(object sender, KeyPressEventArgs e)
  1076 + {
  1077 + shortcutKey(sender, e);
  1078 + }
  1079 +
  1080 + private void textBox8_KeyPress(object sender, KeyPressEventArgs e)
  1081 + {
  1082 + shortcutKey(sender, e);
  1083 + }
  1084 +
  1085 + private void textBox9_KeyPress(object sender, KeyPressEventArgs e)
  1086 + {
  1087 + shortcutKey(sender, e);
  1088 + }
  1089 +
  1090 + private void textBox10_KeyPress(object sender, KeyPressEventArgs e)
  1091 + {
  1092 + shortcutKey(sender, e);
  1093 + }
  1094 +
  1095 + private void textBox11_KeyPress(object sender, KeyPressEventArgs e)
  1096 + {
  1097 + shortcutKey(sender, e);
  1098 + }
  1099 +
  1100 + private void textBox12_KeyPress(object sender, KeyPressEventArgs e)
  1101 + {
  1102 + shortcutKey(sender, e);
  1103 + }
  1104 +
  1105 + private void textBox13_KeyPress(object sender, KeyPressEventArgs e)
  1106 + {
  1107 + shortcutKey(sender, e);
  1108 + }
  1109 +
  1110 + private void textBox14_KeyPress(object sender, KeyPressEventArgs e)
  1111 + {
  1112 + shortcutKey(sender, e);
  1113 + }
  1114 +
  1115 + private void textBox15_KeyPress(object sender, KeyPressEventArgs e)
  1116 + {
  1117 + shortcutKey(sender, e);
  1118 + }
  1119 +
  1120 + private void textBox16_KeyPress(object sender, KeyPressEventArgs e)
  1121 + {
  1122 + shortcutKey(sender, e);
  1123 + }
  1124 +
  1125 + private void Form2_KeyDown(object sender, KeyEventArgs e)
  1126 + {
  1127 + if(e.KeyCode == Keys.Multiply)
  1128 + {
  1129 + SendKeys.Send("{Tab}");
  1130 + e.Handled = true;
  1131 + }
  1132 +
  1133 + if(e.KeyCode == Keys.Add)
  1134 + {
  1135 + button2.Focus();
  1136 + button2.PerformClick();
  1137 + e.Handled = true;
  1138 + }
  1139 +
  1140 + if(e.KeyCode == Keys.Enter)
  1141 + {
  1142 +// button1.Focus();
  1143 + button1.PerformClick();
  1144 + e.Handled = true;
  1145 + }
  1146 + }
  1147 +
942 } 1148 }
943 } 1149 }
@@ -116,6 +116,7 @@ @@ -116,6 +116,7 @@
116 this.button2.TabIndex = 3; 116 this.button2.TabIndex = 3;
117 this.button2.Text = "チェック"; 117 this.button2.Text = "チェック";
118 this.button2.UseVisualStyleBackColor = true; 118 this.button2.UseVisualStyleBackColor = true;
  119 + this.button2.Click += new System.EventHandler(this.button2_Click);
119 // 120 //
120 // checkBox1 121 // checkBox1
121 // 122 //
@@ -126,6 +127,7 @@ @@ -126,6 +127,7 @@
126 this.checkBox1.TabIndex = 4; 127 this.checkBox1.TabIndex = 4;
127 this.checkBox1.Text = "未完了データのみ表示"; 128 this.checkBox1.Text = "未完了データのみ表示";
128 this.checkBox1.UseVisualStyleBackColor = true; 129 this.checkBox1.UseVisualStyleBackColor = true;
  130 + this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
129 // 131 //
130 // dataGridView1 132 // dataGridView1
131 // 133 //
@@ -177,6 +179,7 @@ @@ -177,6 +179,7 @@
177 this.dataGridView1.RowTemplate.Height = 21; 179 this.dataGridView1.RowTemplate.Height = 21;
178 this.dataGridView1.Size = new System.Drawing.Size(1040, 381); 180 this.dataGridView1.Size = new System.Drawing.Size(1040, 381);
179 this.dataGridView1.TabIndex = 5; 181 this.dataGridView1.TabIndex = 5;
  182 + this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
180 // 183 //
181 // label2 184 // label2
182 // 185 //
@@ -216,6 +219,7 @@ @@ -216,6 +219,7 @@
216 this.checkBox2.TabIndex = 9; 219 this.checkBox2.TabIndex = 9;
217 this.checkBox2.Text = "1回目を軸"; 220 this.checkBox2.Text = "1回目を軸";
218 this.checkBox2.UseVisualStyleBackColor = true; 221 this.checkBox2.UseVisualStyleBackColor = true;
  222 + this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
219 // 223 //
220 // checkBox3 224 // checkBox3
221 // 225 //
@@ -228,14 +232,16 @@ @@ -228,14 +232,16 @@
228 this.checkBox3.TabIndex = 10; 232 this.checkBox3.TabIndex = 10;
229 this.checkBox3.Text = "2回目を軸"; 233 this.checkBox3.Text = "2回目を軸";
230 this.checkBox3.UseVisualStyleBackColor = true; 234 this.checkBox3.UseVisualStyleBackColor = true;
  235 + this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
231 // 236 //
232 // comboBox1 237 // comboBox1
233 // 238 //
234 this.comboBox1.FormattingEnabled = true; 239 this.comboBox1.FormattingEnabled = true;
235 - this.comboBox1.Location = new System.Drawing.Point(772, 69); 240 + this.comboBox1.Location = new System.Drawing.Point(789, 69);
236 this.comboBox1.Name = "comboBox1"; 241 this.comboBox1.Name = "comboBox1";
237 - this.comboBox1.Size = new System.Drawing.Size(85, 20); 242 + this.comboBox1.Size = new System.Drawing.Size(68, 20);
238 this.comboBox1.TabIndex = 11; 243 this.comboBox1.TabIndex = 11;
  244 + this.comboBox1.SelectionChangeCommitted += new System.EventHandler(this.comboBox1_SelectionChangeCommitted);
239 // 245 //
240 // button3 246 // button3
241 // 247 //
@@ -245,6 +251,7 @@ @@ -245,6 +251,7 @@
245 this.button3.TabIndex = 12; 251 this.button3.TabIndex = 12;
246 this.button3.Text = "<"; 252 this.button3.Text = "<";
247 this.button3.UseVisualStyleBackColor = true; 253 this.button3.UseVisualStyleBackColor = true;
  254 + this.button3.Click += new System.EventHandler(this.button3_Click);
248 // 255 //
249 // label5 256 // label5
250 // 257 //
@@ -263,6 +270,7 @@ @@ -263,6 +270,7 @@
263 this.button4.TabIndex = 14; 270 this.button4.TabIndex = 14;
264 this.button4.Text = ">"; 271 this.button4.Text = ">";
265 this.button4.UseVisualStyleBackColor = true; 272 this.button4.UseVisualStyleBackColor = true;
  273 + this.button4.Click += new System.EventHandler(this.button4_Click);
266 // 274 //
267 // 状況 275 // 状況
268 // 276 //
@@ -278,13 +286,16 @@ @@ -278,13 +286,16 @@
278 this.編集1.ReadOnly = true; 286 this.編集1.ReadOnly = true;
279 this.編集1.Resizable = System.Windows.Forms.DataGridViewTriState.True; 287 this.編集1.Resizable = System.Windows.Forms.DataGridViewTriState.True;
280 this.編集1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; 288 this.編集1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
281 - this.編集1.Width = 30; 289 + this.編集1.Text = "編集";
  290 + this.編集1.UseColumnTextForButtonValue = true;
  291 + this.編集1.Width = 40;
282 // 292 //
283 // f_行政区コード 293 // f_行政区コード
284 // 294 //
285 this.f_行政区コード.HeaderText = "l_行政区コード"; 295 this.f_行政区コード.HeaderText = "l_行政区コード";
286 this.f_行政区コード.Name = "f_行政区コード"; 296 this.f_行政区コード.Name = "f_行政区コード";
287 this.f_行政区コード.ReadOnly = true; 297 this.f_行政区コード.ReadOnly = true;
  298 + this.f_行政区コード.Width = 50;
288 // 299 //
289 // f_整理番号 300 // f_整理番号
290 // 301 //
@@ -392,7 +403,9 @@ @@ -392,7 +403,9 @@
392 this.編集2.HeaderText = "編集(2)"; 403 this.編集2.HeaderText = "編集(2)";
393 this.編集2.Name = "編集2"; 404 this.編集2.Name = "編集2";
394 this.編集2.ReadOnly = true; 405 this.編集2.ReadOnly = true;
395 - this.編集2.Width = 30; 406 + this.編集2.Text = "編集";
  407 + this.編集2.UseColumnTextForButtonValue = true;
  408 + this.編集2.Width = 40;
396 // 409 //
397 // s_行政区コード 410 // s_行政区コード
398 // 411 //
@@ -401,6 +414,7 @@ @@ -401,6 +414,7 @@
401 this.s_行政区コード.ReadOnly = true; 414 this.s_行政区コード.ReadOnly = true;
402 this.s_行政区コード.Resizable = System.Windows.Forms.DataGridViewTriState.True; 415 this.s_行政区コード.Resizable = System.Windows.Forms.DataGridViewTriState.True;
403 this.s_行政区コード.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; 416 this.s_行政区コード.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
  417 + this.s_行政区コード.Width = 50;
404 // 418 //
405 // s_整理番号 419 // s_整理番号
406 // 420 //
@@ -14,7 +14,7 @@ namespace MedicalCheckInputTool @@ -14,7 +14,7 @@ namespace MedicalCheckInputTool
14 { 14 {
15 public partial class Form3 : Form 15 public partial class Form3 : Form
16 { 16 {
17 - private const int PAGEMAX = 100; 17 + private const int PAGEMAX = 10;
18 private int currentPageNo = 1; 18 private int currentPageNo = 1;
19 private int maxPageNo = 1; 19 private int maxPageNo = 1;
20 20
@@ -23,6 +23,8 @@ namespace MedicalCheckInputTool @@ -23,6 +23,8 @@ namespace MedicalCheckInputTool
23 InitializeComponent(); 23 InitializeComponent();
24 24
25 this.Text = "ロット: " + EditParam.lotNo + " ユーザ: " + EditParam.inputUser; 25 this.Text = "ロット: " + EditParam.lotNo + " ユーザ: " + EditParam.inputUser;
  26 +
  27 + this.label2.Text = "";
26 } 28 }
27 29
28 private void setPage() 30 private void setPage()
@@ -31,7 +33,7 @@ namespace MedicalCheckInputTool @@ -31,7 +33,7 @@ namespace MedicalCheckInputTool
31 MySqlConnection readerCon = new MySqlConnection(connstr); 33 MySqlConnection readerCon = new MySqlConnection(connstr);
32 readerCon.Open(); 34 readerCon.Open();
33 string countQuery = "select count(*) from page_compare where "; 35 string countQuery = "select count(*) from page_compare where ";
34 - string orderby = " order by `f_行政区コード`, `f_整理番号`"; 36 +// string orderby = " order by `f_行政区コード`, `f_整理番号`";
35 37
36 // ロットの指定は必須 38 // ロットの指定は必須
37 countQuery += "(`f_ロット番号` = " + EditParam.lotNo + " or `s_ロット番号` = " + EditParam.lotNo + ") "; 39 countQuery += "(`f_ロット番号` = " + EditParam.lotNo + " or `s_ロット番号` = " + EditParam.lotNo + ") ";
@@ -62,7 +64,7 @@ namespace MedicalCheckInputTool @@ -62,7 +64,7 @@ namespace MedicalCheckInputTool
62 } 64 }
63 } 65 }
64 // 並び順 66 // 並び順
65 - countQuery += orderby; 67 +// countQuery += orderby;
66 68
67 //ページ設定 69 //ページ設定
68 MySqlCommand cntCmd = new MySqlCommand(countQuery, readerCon); 70 MySqlCommand cntCmd = new MySqlCommand(countQuery, readerCon);
@@ -99,7 +101,7 @@ namespace MedicalCheckInputTool @@ -99,7 +101,7 @@ namespace MedicalCheckInputTool
99 readerCon.Open(); 101 readerCon.Open();
100 string readQuery = "select * from page_compare where "; 102 string readQuery = "select * from page_compare where ";
101 string orderby = " order by `f_行政区コード`, `f_整理番号`"; 103 string orderby = " order by `f_行政区コード`, `f_整理番号`";
102 - string pageing = " limit " + PAGEMAX + " offset " + ((currentPageNo - 1) * PAGEMAX); 104 + string paging = " limit " + PAGEMAX + " offset " + ((currentPageNo - 1) * PAGEMAX);
103 105
104 // ロットの指定は必須 106 // ロットの指定は必須
105 readQuery += "(`f_ロット番号` = " + EditParam.lotNo + " or `s_ロット番号` = " + EditParam.lotNo + ") "; 107 readQuery += "(`f_ロット番号` = " + EditParam.lotNo + " or `s_ロット番号` = " + EditParam.lotNo + ") ";
@@ -111,7 +113,8 @@ namespace MedicalCheckInputTool @@ -111,7 +113,8 @@ namespace MedicalCheckInputTool
111 113
112 if (this.checkBox1.Checked) 114 if (this.checkBox1.Checked)
113 { 115 {
114 - readQuery += " and (`f_完了` <> 1 or `s_完了` <> 1)"; 116 +// readQuery += " and (`f_完了` <> 1 or `s_完了` <> 1)";
  117 + readQuery += " and (`f_完了` is null or `s_完了` is null)";
115 } 118 }
116 119
117 if (this.checkBox2.Checked && this.checkBox3.Checked) 120 if (this.checkBox2.Checked && this.checkBox3.Checked)
@@ -133,18 +136,17 @@ namespace MedicalCheckInputTool @@ -133,18 +136,17 @@ namespace MedicalCheckInputTool
133 readQuery += orderby; 136 readQuery += orderby;
134 137
135 //ページ指定 138 //ページ指定
136 - readQuery += pageing; 139 + readQuery += paging;
137 140
138 MySqlCommand readCmd = new MySqlCommand(readQuery, readerCon); 141 MySqlCommand readCmd = new MySqlCommand(readQuery, readerCon);
139 MySqlDataReader reader = readCmd.ExecuteReader(); 142 MySqlDataReader reader = readCmd.ExecuteReader();
140 143
141 this.dataGridView1.Rows.Clear(); 144 this.dataGridView1.Rows.Clear();
142 - //adapter.Fill(ds);  
143 while (reader.Read()) 145 while (reader.Read())
144 { 146 {
145 DataGridViewRow row = new DataGridViewRow(); 147 DataGridViewRow row = new DataGridViewRow();
146 row.CreateCells(this.dataGridView1); 148 row.CreateCells(this.dataGridView1);
147 - row.Cells[0].Value = (this.isDBNull(reader, "s_完了") == "1") ? "一致" : "不一致"; ; 149 + row.Cells[0].Value = (this.isDBNull(reader, "f_完了") == "1") ? "一致" : "不一致";
148 this.dataGridView1.Rows.Add(row); 150 this.dataGridView1.Rows.Add(row);
149 foreach (string prefix in new string[2] { "f_", "s_" }) 151 foreach (string prefix in new string[2] { "f_", "s_" })
150 { 152 {
@@ -269,12 +271,261 @@ namespace MedicalCheckInputTool @@ -269,12 +271,261 @@ namespace MedicalCheckInputTool
269 } 271 }
270 } 272 }
271 273
  274 + // 行マッチ判定
  275 + private void check()
  276 + {
  277 + // 行マッチングデータを取得
  278 + string connstr = System.Configuration.ConfigurationManager.AppSettings["Conn"];
  279 +
  280 + // 更新用Connection
  281 + MySqlConnection updateCon = new MySqlConnection(connstr);
  282 + updateCon.Open();
  283 +
  284 + /*
  285 + // 一度フラグを落とす
  286 + string resetFsql = "update `1回目` set `完了` = 0 where `ロット番号` = @lot";
  287 + if (!"".Equals(textBox1.Text))
  288 + {
  289 + resetFsql += " and `整理番号` like '%" + textBox1.Text + "%'";
  290 + }
  291 + MySqlCommand resetFirst = new MySqlCommand(resetFsql, updateCon);
  292 + resetFirst.Parameters.AddWithValue("lot", EditParam.lotNo);
  293 + resetFirst.ExecuteNonQuery();
  294 +
  295 + string resetSsql = "update `2回目` set `完了` = 0 where `ロット番号` = @lot";
  296 + if (!"".Equals(textBox1.Text))
  297 + {
  298 + resetSsql += " and `整理番号` like '%" + textBox1.Text + "%'";
  299 + }
  300 + MySqlCommand resetSecond = new MySqlCommand(resetSsql, updateCon);
  301 + resetSecond.Parameters.AddWithValue("lot", EditParam.lotNo);
  302 + resetSecond.ExecuteNonQuery();
  303 + */
  304 +
  305 + // フラグ更新用コマンド
  306 + MySqlCommand updateFirst = new MySqlCommand("update `1回目` set `完了` = 1 where " +
  307 + "`ロット番号` = @lot and " +
  308 + "`整理番号` = @serialCode", updateCon);
  309 + // フラグ更新用コマンド
  310 + MySqlCommand updateSecond = new MySqlCommand("update `2回目` set `完了` = 1 where " +
  311 + "`ロット番号` = @lot and " +
  312 + "`整理番号` = @serialCode", updateCon);
  313 +
  314 + // 行突合データを取得する
  315 + // 参照用Connection
  316 + MySqlConnection readerCon = new MySqlConnection(connstr);
  317 + readerCon.Open();
  318 + string readQuery = "select * from page_compare where (`f_ロット番号` = @f_lot or `s_ロット番号` = @s_lot) and (`f_完了` <> 1 or `s_完了` <> 1)";
  319 + string orderby = " order by `f_行政区コード`, `f_整理番号`, `s_行政区コード`, `s_整理番号`";
  320 + if (!"".Equals(textBox1.Text))
  321 + {
  322 + readQuery += " and (`f_整理番号` like '%" + textBox1.Text + "%' or `s_整理番号` like '%" + textBox1.Text + "%')";
  323 + }
  324 + readQuery += orderby;
  325 + MySqlCommand readCmd = new MySqlCommand(readQuery, readerCon);
  326 + readCmd.Parameters.AddWithValue("f_lot", EditParam.lotNo);
  327 + readCmd.Parameters.AddWithValue("s_lot", EditParam.lotNo);
  328 + MySqlDataReader reader = readCmd.ExecuteReader();
  329 +
  330 + while (reader.Read())
  331 + {
  332 + // 各種値のチェック
  333 + bool IsMatch = true;
  334 + // 各項目の一致をチェックする
  335 + // 整理番号
  336 + if (!this.isDBNull(reader, "f_整理番号").Equals(this.isDBNull(reader, "s_整理番号")))
  337 + {
  338 + IsMatch = false;
  339 + }
  340 + // 世帯番号
  341 + if (!this.isDBNull(reader, "f_世帯番号").Equals(this.isDBNull(reader, "s_世帯番号")))
  342 + {
  343 + IsMatch = false;
  344 + }
  345 + // 健康診査
  346 + if (!this.isDBNull(reader, "f_健康診査").Equals(this.isDBNull(reader, "s_健康診査")))
  347 + {
  348 + IsMatch = false;
  349 + }
  350 + // 結核肺がん
  351 + if (!this.isDBNull(reader, "f_結核肺がん").Equals(this.isDBNull(reader, "s_結核肺がん")))
  352 + {
  353 + IsMatch = false;
  354 + }
  355 + // 胃がん
  356 + if (!this.isDBNull(reader, "f_胃がん").Equals(this.isDBNull(reader, "s_胃がん")))
  357 + {
  358 + IsMatch = false;
  359 + }
  360 + // 大腸がん
  361 + if (!this.isDBNull(reader, "f_大腸がん").Equals(this.isDBNull(reader, "s_大腸がん")))
  362 + {
  363 + IsMatch = false;
  364 + }
  365 + // 前立腺がん
  366 + if (!this.isDBNull(reader, "f_前立腺がん").Equals(this.isDBNull(reader, "s_前立腺がん")))
  367 + {
  368 + IsMatch = false;
  369 + }
  370 + // 骨粗鬆症
  371 + if (!this.isDBNull(reader, "f_骨粗鬆症").Equals(this.isDBNull(reader, "s_骨粗鬆症")))
  372 + {
  373 + IsMatch = false;
  374 + }
  375 + // 成人歯科
  376 + if (!this.isDBNull(reader, "f_成人歯科").Equals(this.isDBNull(reader, "s_成人歯科")))
  377 + {
  378 + IsMatch = false;
  379 + }
  380 + // 子宮頸がん
  381 + if (!this.isDBNull(reader, "f_子宮頸がん").Equals(this.isDBNull(reader, "s_子宮頸がん")))
  382 + {
  383 + IsMatch = false;
  384 + }
  385 + // 乳がん
  386 + if (!this.isDBNull(reader, "f_乳がん").Equals(this.isDBNull(reader, "s_乳がん")))
  387 + {
  388 + IsMatch = false;
  389 + }
  390 + // 希望場所
  391 + if (!this.isDBNull(reader, "f_希望場所").Equals(this.isDBNull(reader, "s_希望場所")))
  392 + {
  393 + IsMatch = false;
  394 + }
  395 + // 身体不自由
  396 + if (!this.isDBNull(reader, "f_身体不自由").Equals(this.isDBNull(reader, "s_身体不自由")))
  397 + {
  398 + IsMatch = false;
  399 + }
  400 + // 電話番号
  401 + if (!this.isDBNull(reader, "f_電話番号").Equals(this.isDBNull(reader, "s_電話番号")))
  402 + {
  403 + IsMatch = false;
  404 + }
  405 + // 携帯番号
  406 + if (!this.isDBNull(reader, "f_携帯番号").Equals(this.isDBNull(reader, "s_携帯番号")))
  407 + {
  408 + IsMatch = false;
  409 + }
  410 +
  411 + // マッチはフラグを更新する
  412 + if (IsMatch)
  413 + {
  414 + updateFirst.Parameters.Clear();
  415 + updateFirst.Parameters.AddWithValue("lot", EditParam.lotNo);
  416 + updateFirst.Parameters.AddWithValue("serialCode", this.isDBNull(reader, "f_整理番号"));
  417 + updateFirst.ExecuteNonQuery();
  418 +
  419 + updateSecond.Parameters.Clear();
  420 + updateSecond.Parameters.AddWithValue("lot", EditParam.lotNo);
  421 + updateSecond.Parameters.AddWithValue("serialCode", this.isDBNull(reader, "f_整理番号"));
  422 + updateSecond.ExecuteNonQuery();
  423 + }
  424 + }
  425 +
  426 + updateCon.Close();
  427 + readerCon.Close();
  428 + }
  429 +
272 //検索 430 //検索
273 private void button1_Click(object sender, EventArgs e) 431 private void button1_Click(object sender, EventArgs e)
274 { 432 {
275 this.setPage(); 433 this.setPage();
  434 + this.check();
276 this.search(); 435 this.search();
277 } 436 }
278 437
  438 + //チェック
  439 + private void button2_Click(object sender, EventArgs e)
  440 + {
  441 + this.check();
  442 + this.search();
  443 + }
  444 +
  445 + private void checkBox1_CheckedChanged(object sender, EventArgs e)
  446 + {
  447 + this.setPage();
  448 + this.search();
  449 + }
  450 +
  451 + private void checkBox2_CheckedChanged(object sender, EventArgs e)
  452 + {
  453 + this.setPage();
  454 + this.search();
  455 + }
  456 +
  457 + private void checkBox3_CheckedChanged(object sender, EventArgs e)
  458 + {
  459 + this.setPage();
  460 + this.search();
  461 + }
  462 +
  463 + //前へ
  464 + private void button3_Click(object sender, EventArgs e)
  465 + {
  466 + if (currentPageNo <= 1)
  467 + {
  468 + return;
  469 + }
  470 + currentPageNo--;
  471 + comboBox1.SelectedIndex = currentPageNo - 1;
  472 +
  473 + this.search();
  474 + }
  475 +
  476 + //次へ
  477 + private void button4_Click(object sender, EventArgs e)
  478 + {
  479 + if (currentPageNo >= maxPageNo)
  480 + {
  481 + return;
  482 + }
  483 + currentPageNo++;
  484 + comboBox1.SelectedIndex = currentPageNo - 1;
  485 +
  486 + this.search();
  487 + }
  488 +
  489 + //ページジャンプ
  490 + private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
  491 + {
  492 + currentPageNo = int.Parse(comboBox1.SelectedItem.ToString());
  493 + this.search();
  494 + }
  495 +
  496 + private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  497 + {
  498 + DataGridView dgv = (DataGridView)sender;
  499 + if (dgv.Columns[e.ColumnIndex].Name == "編集1")
  500 + {
  501 + // 整理番号を取得
  502 + string serialNo = dgv.Rows[e.RowIndex].Cells["f_整理番号"].Value.ToString();
  503 + Global.lotNo = EditParam.lotNo;
  504 + Global.times = "1回目";
  505 + Global.inputUser = EditParam.inputUser;
  506 + if (serialNo != "")
  507 + {
  508 + Form form2 = new Form2(serialNo);
  509 + form2.ShowDialog();
  510 + form2.Dispose();
  511 + }
  512 + }
  513 + if (dgv.Columns[e.ColumnIndex].Name == "編集2")
  514 + {
  515 + // 整理番号を取得
  516 + string serialNo = dgv.Rows[e.RowIndex].Cells["f_整理番号"].Value.ToString();
  517 + Global.lotNo = EditParam.lotNo;
  518 + Global.times = "2回目";
  519 + Global.inputUser = EditParam.inputUser;
  520 + if (serialNo != "")
  521 + {
  522 + Form form2 = new Form2(serialNo);
  523 + form2.ShowDialog();
  524 + form2.Dispose();
  525 + }
  526 + }
  527 +
  528 + }
  529 +
279 } 530 }
280 } 531 }
Please register or login to post a comment