Showing
4 changed files
with
526 additions
and
39 deletions
| ... | ... | @@ -108,6 +108,7 @@ |
| 108 | 108 | this.textBox2.Size = new System.Drawing.Size(100, 19); |
| 109 | 109 | this.textBox2.TabIndex = 3; |
| 110 | 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 | 113 | // label4 |
| 113 | 114 | // |
| ... | ... | @@ -136,6 +137,7 @@ |
| 136 | 137 | this.textBox4.Size = new System.Drawing.Size(100, 19); |
| 137 | 138 | this.textBox4.TabIndex = 8; |
| 138 | 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 | 142 | // textBox5 |
| 141 | 143 | // |
| ... | ... | @@ -146,6 +148,7 @@ |
| 146 | 148 | this.textBox5.Size = new System.Drawing.Size(100, 19); |
| 147 | 149 | this.textBox5.TabIndex = 9; |
| 148 | 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 | 153 | // label6 |
| 151 | 154 | // |
| ... | ... | @@ -175,6 +178,7 @@ |
| 175 | 178 | this.textBox6.Size = new System.Drawing.Size(31, 19); |
| 176 | 179 | this.textBox6.TabIndex = 12; |
| 177 | 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 | 183 | // label8 |
| 180 | 184 | // |
| ... | ... | @@ -194,6 +198,7 @@ |
| 194 | 198 | this.textBox7.Size = new System.Drawing.Size(31, 19); |
| 195 | 199 | this.textBox7.TabIndex = 14; |
| 196 | 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 | 203 | // label9 |
| 199 | 204 | // |
| ... | ... | @@ -267,6 +272,7 @@ |
| 267 | 272 | this.textBox8.Size = new System.Drawing.Size(31, 19); |
| 268 | 273 | this.textBox8.TabIndex = 22; |
| 269 | 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 | 277 | // textBox9 |
| 272 | 278 | // |
| ... | ... | @@ -277,6 +283,7 @@ |
| 277 | 283 | this.textBox9.Size = new System.Drawing.Size(31, 19); |
| 278 | 284 | this.textBox9.TabIndex = 23; |
| 279 | 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 | 288 | // textBox10 |
| 282 | 289 | // |
| ... | ... | @@ -287,6 +294,7 @@ |
| 287 | 294 | this.textBox10.Size = new System.Drawing.Size(31, 19); |
| 288 | 295 | this.textBox10.TabIndex = 24; |
| 289 | 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 | 299 | // textBox11 |
| 292 | 300 | // |
| ... | ... | @@ -297,6 +305,7 @@ |
| 297 | 305 | this.textBox11.Size = new System.Drawing.Size(31, 19); |
| 298 | 306 | this.textBox11.TabIndex = 25; |
| 299 | 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 | 310 | // textBox12 |
| 302 | 311 | // |
| ... | ... | @@ -307,6 +316,7 @@ |
| 307 | 316 | this.textBox12.Size = new System.Drawing.Size(31, 19); |
| 308 | 317 | this.textBox12.TabIndex = 26; |
| 309 | 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 | 321 | // textBox13 |
| 312 | 322 | // |
| ... | ... | @@ -317,6 +327,7 @@ |
| 317 | 327 | this.textBox13.Size = new System.Drawing.Size(31, 19); |
| 318 | 328 | this.textBox13.TabIndex = 27; |
| 319 | 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 | 332 | // textBox14 |
| 322 | 333 | // |
| ... | ... | @@ -327,6 +338,7 @@ |
| 327 | 338 | this.textBox14.Size = new System.Drawing.Size(31, 19); |
| 328 | 339 | this.textBox14.TabIndex = 28; |
| 329 | 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 | 343 | // label16 |
| 332 | 344 | // |
| ... | ... | @@ -365,6 +377,7 @@ |
| 365 | 377 | this.textBox15.Size = new System.Drawing.Size(31, 19); |
| 366 | 378 | this.textBox15.TabIndex = 32; |
| 367 | 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 | 382 | // textBox16 |
| 370 | 383 | // |
| ... | ... | @@ -375,6 +388,7 @@ |
| 375 | 388 | this.textBox16.Size = new System.Drawing.Size(31, 19); |
| 376 | 389 | this.textBox16.TabIndex = 33; |
| 377 | 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 | 393 | // button1 |
| 380 | 394 | // |
| ... | ... | @@ -487,8 +501,10 @@ |
| 487 | 501 | this.Controls.Add(this.label2); |
| 488 | 502 | this.Controls.Add(this.label1); |
| 489 | 503 | this.Controls.Add(this.textBox1); |
| 504 | + this.KeyPreview = true; | |
| 490 | 505 | this.Name = "Form2"; |
| 491 | 506 | this.Text = "Form2"; |
| 507 | + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form2_KeyDown); | |
| 492 | 508 | this.ResumeLayout(false); |
| 493 | 509 | this.PerformLayout(); |
| 494 | 510 | ... | ... |
| ... | ... | @@ -18,10 +18,15 @@ namespace MedicalCheckInputTool |
| 18 | 18 | private const int historyMax = 10; |
| 19 | 19 | private int historyPos = 0; |
| 20 | 20 | |
| 21 | - public Form2() | |
| 21 | + public Form2(string serialNo = null) | |
| 22 | 22 | { |
| 23 | 23 | InitializeComponent(); |
| 24 | 24 | |
| 25 | + if (serialNo != null) | |
| 26 | + { | |
| 27 | + initDsp(serialNo); | |
| 28 | + } | |
| 29 | + | |
| 25 | 30 | this.Text = "ロット:" + Global.lotNo + " " + Global.times + " " + "ユーザ:" + Global.inputUser; |
| 26 | 31 | |
| 27 | 32 | label3.Text = "ロット " + Global.lotNo + " 行政区番号 " + Global.adminCode; |
| ... | ... | @@ -31,6 +36,67 @@ namespace MedicalCheckInputTool |
| 31 | 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 | 100 | private void dspCount() |
| 35 | 101 | { |
| 36 | 102 | MySqlConnection conn; |
| ... | ... | @@ -148,6 +214,19 @@ namespace MedicalCheckInputTool |
| 148 | 214 | sv.inputUser = Global.inputUser; |
| 149 | 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 | 230 | conn.Close(); |
| 152 | 231 | return err; |
| 153 | 232 | } |
| ... | ... | @@ -295,6 +374,7 @@ namespace MedicalCheckInputTool |
| 295 | 374 | { |
| 296 | 375 | //無かった |
| 297 | 376 | textBox1.BackColor = Color.Pink; |
| 377 | + err = true; | |
| 298 | 378 | reader.Close(); |
| 299 | 379 | } |
| 300 | 380 | else |
| ... | ... | @@ -302,7 +382,7 @@ namespace MedicalCheckInputTool |
| 302 | 382 | string[] row = new string[reader.FieldCount]; |
| 303 | 383 | while (reader.Read()) |
| 304 | 384 | { |
| 305 | - if( !sv.adminCode.Equals(isDBNull(reader, "世帯番号"))) | |
| 385 | + if (!sv.houseNo.Equals(isDBNull(reader, "世帯番号"))) | |
| 306 | 386 | { |
| 307 | 387 | textBox2.BackColor = Color.Pink; |
| 308 | 388 | err = true; |
| ... | ... | @@ -505,7 +585,7 @@ namespace MedicalCheckInputTool |
| 505 | 585 | + "`修正日` = @updateDate," |
| 506 | 586 | + "`修正者` = @updateUser," |
| 507 | 587 | + "`完了` = @done " |
| 508 | - + "where `整理番号` = @serialNo"; | |
| 588 | + + "where `ロット番号` = @lotNo and `整理番号` = @serialNo"; | |
| 509 | 589 | |
| 510 | 590 | // コマンドを作成 |
| 511 | 591 | MySqlCommand cmd = new MySqlCommand(sql, conn); |
| ... | ... | @@ -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 | 663 | private void sendTabKey(TextBox textbox, int length) |
| 554 | 664 | { |
| 555 | 665 | if (textbox.Text.Length == length) |
| ... | ... | @@ -592,6 +702,8 @@ namespace MedicalCheckInputTool |
| 592 | 702 | textBox15.Text = ""; |
| 593 | 703 | textBox16.Text = ""; |
| 594 | 704 | |
| 705 | + label20.Text = ""; | |
| 706 | + | |
| 595 | 707 | textBox1.Focus(); |
| 596 | 708 | } |
| 597 | 709 | |
| ... | ... | @@ -801,30 +913,6 @@ namespace MedicalCheckInputTool |
| 801 | 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 | 917 | private void button3_Click(object sender, EventArgs e) |
| 830 | 918 | { |
| ... | ... | @@ -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 | 116 | this.button2.TabIndex = 3; |
| 117 | 117 | this.button2.Text = "チェック"; |
| 118 | 118 | this.button2.UseVisualStyleBackColor = true; |
| 119 | + this.button2.Click += new System.EventHandler(this.button2_Click); | |
| 119 | 120 | // |
| 120 | 121 | // checkBox1 |
| 121 | 122 | // |
| ... | ... | @@ -126,6 +127,7 @@ |
| 126 | 127 | this.checkBox1.TabIndex = 4; |
| 127 | 128 | this.checkBox1.Text = "未完了データのみ表示"; |
| 128 | 129 | this.checkBox1.UseVisualStyleBackColor = true; |
| 130 | + this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); | |
| 129 | 131 | // |
| 130 | 132 | // dataGridView1 |
| 131 | 133 | // |
| ... | ... | @@ -177,6 +179,7 @@ |
| 177 | 179 | this.dataGridView1.RowTemplate.Height = 21; |
| 178 | 180 | this.dataGridView1.Size = new System.Drawing.Size(1040, 381); |
| 179 | 181 | this.dataGridView1.TabIndex = 5; |
| 182 | + this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); | |
| 180 | 183 | // |
| 181 | 184 | // label2 |
| 182 | 185 | // |
| ... | ... | @@ -216,6 +219,7 @@ |
| 216 | 219 | this.checkBox2.TabIndex = 9; |
| 217 | 220 | this.checkBox2.Text = "1回目を軸"; |
| 218 | 221 | this.checkBox2.UseVisualStyleBackColor = true; |
| 222 | + this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged); | |
| 219 | 223 | // |
| 220 | 224 | // checkBox3 |
| 221 | 225 | // |
| ... | ... | @@ -228,14 +232,16 @@ |
| 228 | 232 | this.checkBox3.TabIndex = 10; |
| 229 | 233 | this.checkBox3.Text = "2回目を軸"; |
| 230 | 234 | this.checkBox3.UseVisualStyleBackColor = true; |
| 235 | + this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged); | |
| 231 | 236 | // |
| 232 | 237 | // comboBox1 |
| 233 | 238 | // |
| 234 | 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 | 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 | 243 | this.comboBox1.TabIndex = 11; |
| 244 | + this.comboBox1.SelectionChangeCommitted += new System.EventHandler(this.comboBox1_SelectionChangeCommitted); | |
| 239 | 245 | // |
| 240 | 246 | // button3 |
| 241 | 247 | // |
| ... | ... | @@ -245,6 +251,7 @@ |
| 245 | 251 | this.button3.TabIndex = 12; |
| 246 | 252 | this.button3.Text = "<"; |
| 247 | 253 | this.button3.UseVisualStyleBackColor = true; |
| 254 | + this.button3.Click += new System.EventHandler(this.button3_Click); | |
| 248 | 255 | // |
| 249 | 256 | // label5 |
| 250 | 257 | // |
| ... | ... | @@ -263,6 +270,7 @@ |
| 263 | 270 | this.button4.TabIndex = 14; |
| 264 | 271 | this.button4.Text = ">"; |
| 265 | 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 | 286 | this.編集1.ReadOnly = true; |
| 279 | 287 | this.編集1.Resizable = System.Windows.Forms.DataGridViewTriState.True; |
| 280 | 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 | 293 | // f_行政区コード |
| 284 | 294 | // |
| 285 | 295 | this.f_行政区コード.HeaderText = "l_行政区コード"; |
| 286 | 296 | this.f_行政区コード.Name = "f_行政区コード"; |
| 287 | 297 | this.f_行政区コード.ReadOnly = true; |
| 298 | + this.f_行政区コード.Width = 50; | |
| 288 | 299 | // |
| 289 | 300 | // f_整理番号 |
| 290 | 301 | // |
| ... | ... | @@ -392,7 +403,9 @@ |
| 392 | 403 | this.編集2.HeaderText = "編集(2)"; |
| 393 | 404 | this.編集2.Name = "編集2"; |
| 394 | 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 | 410 | // s_行政区コード |
| 398 | 411 | // |
| ... | ... | @@ -401,6 +414,7 @@ |
| 401 | 414 | this.s_行政区コード.ReadOnly = true; |
| 402 | 415 | this.s_行政区コード.Resizable = System.Windows.Forms.DataGridViewTriState.True; |
| 403 | 416 | this.s_行政区コード.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; |
| 417 | + this.s_行政区コード.Width = 50; | |
| 404 | 418 | // |
| 405 | 419 | // s_整理番号 |
| 406 | 420 | // | ... | ... |
| ... | ... | @@ -14,7 +14,7 @@ namespace MedicalCheckInputTool |
| 14 | 14 | { |
| 15 | 15 | public partial class Form3 : Form |
| 16 | 16 | { |
| 17 | - private const int PAGEMAX = 100; | |
| 17 | + private const int PAGEMAX = 10; | |
| 18 | 18 | private int currentPageNo = 1; |
| 19 | 19 | private int maxPageNo = 1; |
| 20 | 20 | |
| ... | ... | @@ -23,6 +23,8 @@ namespace MedicalCheckInputTool |
| 23 | 23 | InitializeComponent(); |
| 24 | 24 | |
| 25 | 25 | this.Text = "ロット: " + EditParam.lotNo + " ユーザ: " + EditParam.inputUser; |
| 26 | + | |
| 27 | + this.label2.Text = ""; | |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | 30 | private void setPage() |
| ... | ... | @@ -31,7 +33,7 @@ namespace MedicalCheckInputTool |
| 31 | 33 | MySqlConnection readerCon = new MySqlConnection(connstr); |
| 32 | 34 | readerCon.Open(); |
| 33 | 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 | 39 | countQuery += "(`f_ロット番号` = " + EditParam.lotNo + " or `s_ロット番号` = " + EditParam.lotNo + ") "; |
| ... | ... | @@ -62,7 +64,7 @@ namespace MedicalCheckInputTool |
| 62 | 64 | } |
| 63 | 65 | } |
| 64 | 66 | // 並び順 |
| 65 | - countQuery += orderby; | |
| 67 | +// countQuery += orderby; | |
| 66 | 68 | |
| 67 | 69 | //ページ設定 |
| 68 | 70 | MySqlCommand cntCmd = new MySqlCommand(countQuery, readerCon); |
| ... | ... | @@ -99,7 +101,7 @@ namespace MedicalCheckInputTool |
| 99 | 101 | readerCon.Open(); |
| 100 | 102 | string readQuery = "select * from page_compare where "; |
| 101 | 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 | 107 | readQuery += "(`f_ロット番号` = " + EditParam.lotNo + " or `s_ロット番号` = " + EditParam.lotNo + ") "; |
| ... | ... | @@ -111,7 +113,8 @@ namespace MedicalCheckInputTool |
| 111 | 113 | |
| 112 | 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 | 120 | if (this.checkBox2.Checked && this.checkBox3.Checked) |
| ... | ... | @@ -133,18 +136,17 @@ namespace MedicalCheckInputTool |
| 133 | 136 | readQuery += orderby; |
| 134 | 137 | |
| 135 | 138 | //ページ指定 |
| 136 | - readQuery += pageing; | |
| 139 | + readQuery += paging; | |
| 137 | 140 | |
| 138 | 141 | MySqlCommand readCmd = new MySqlCommand(readQuery, readerCon); |
| 139 | 142 | MySqlDataReader reader = readCmd.ExecuteReader(); |
| 140 | 143 | |
| 141 | 144 | this.dataGridView1.Rows.Clear(); |
| 142 | - //adapter.Fill(ds); | |
| 143 | 145 | while (reader.Read()) |
| 144 | 146 | { |
| 145 | 147 | DataGridViewRow row = new DataGridViewRow(); |
| 146 | 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 | 150 | this.dataGridView1.Rows.Add(row); |
| 149 | 151 | foreach (string prefix in new string[2] { "f_", "s_" }) |
| 150 | 152 | { |
| ... | ... | @@ -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 | 431 | private void button1_Click(object sender, EventArgs e) |
| 274 | 432 | { |
| 275 | 433 | this.setPage(); |
| 434 | + this.check(); | |
| 276 | 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