Form3.cs
12.5 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;
namespace MedicalCheckInputTool
{
public partial class Form3 : Form
{
private const int PAGEMAX = 100;
private int currentPageNo = 1;
private int maxPageNo = 1;
public Form3()
{
InitializeComponent();
this.Text = "ロット: " + EditParam.lotNo + " ユーザ: " + EditParam.inputUser;
}
private void setPage()
{
string connstr = System.Configuration.ConfigurationManager.AppSettings["Conn"];
MySqlConnection readerCon = new MySqlConnection(connstr);
readerCon.Open();
string countQuery = "select count(*) from page_compare where ";
string orderby = " order by `f_行政区コード`, `f_整理番号`";
// ロットの指定は必須
countQuery += "(`f_ロット番号` = " + EditParam.lotNo + " or `s_ロット番号` = " + EditParam.lotNo + ") ";
if (!"".Equals(textBox1.Text))
{
countQuery += " and (`f_整理番号` like '%" + textBox1.Text + "%' or `s_整理番号` like '%" + textBox1.Text + "%')";
}
if (this.checkBox1.Checked)
{
countQuery += " and (`f_完了` <> 1 or `s_完了` <> 1)";
}
if (this.checkBox2.Checked && this.checkBox3.Checked)
{
}
else
{
if (this.checkBox2.Checked)
{
countQuery += " and `f_整理番号` is not null";
}
if (this.checkBox3.Checked)
{
countQuery += " and `s_整理番号` is not null";
}
}
// 並び順
countQuery += orderby;
//ページ設定
MySqlCommand cntCmd = new MySqlCommand(countQuery, readerCon);
MySqlDataReader cntreader = cntCmd.ExecuteReader();
int dataCnt = 0;
while (cntreader.Read())
{
dataCnt = cntreader.GetInt32(0);
}
cntreader.Close();
maxPageNo = 1;
if (dataCnt > 0)
{
maxPageNo = (dataCnt / PAGEMAX) + ((dataCnt % PAGEMAX == 0) ? 0 : 1);
}
comboBox1.Items.Clear(); //クリアする
for (int i = 0; i < maxPageNo; i++)
{
comboBox1.Items.Add((i + 1).ToString());
}
// 読み取り専用(テキストボックスは編集不可)にする
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox1.SelectedIndex = 0; // 先頭の項目を選択
currentPageNo = 1;
readerCon.Close();
}
private void search()
{
string connstr = System.Configuration.ConfigurationManager.AppSettings["Conn"];
MySqlConnection readerCon = new MySqlConnection(connstr);
readerCon.Open();
string readQuery = "select * from page_compare where ";
string orderby = " order by `f_行政区コード`, `f_整理番号`";
string pageing = " limit " + PAGEMAX + " offset " + ((currentPageNo - 1) * PAGEMAX);
// ロットの指定は必須
readQuery += "(`f_ロット番号` = " + EditParam.lotNo + " or `s_ロット番号` = " + EditParam.lotNo + ") ";
if (!"".Equals(textBox1.Text))
{
readQuery += " and (`f_整理番号` like '%" + textBox1.Text + "%' or `s_整理番号` like '%" + textBox1.Text + "%')";
}
if (this.checkBox1.Checked)
{
readQuery += " and (`f_完了` <> 1 or `s_完了` <> 1)";
}
if (this.checkBox2.Checked && this.checkBox3.Checked)
{
}
else
{
if (this.checkBox2.Checked)
{
readQuery += " and `f_整理番号` is not null";
}
if (this.checkBox3.Checked)
{
readQuery += " and `s_整理番号` is not null";
}
}
// 並び順
readQuery += orderby;
//ページ指定
readQuery += pageing;
MySqlCommand readCmd = new MySqlCommand(readQuery, readerCon);
MySqlDataReader reader = readCmd.ExecuteReader();
this.dataGridView1.Rows.Clear();
//adapter.Fill(ds);
while (reader.Read())
{
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(this.dataGridView1);
row.Cells[0].Value = (this.isDBNull(reader, "s_完了") == "1") ? "一致" : "不一致"; ;
this.dataGridView1.Rows.Add(row);
foreach (string prefix in new string[2] { "f_", "s_" })
{
row.Cells[prefix + "行政区コード"].Value = this.isDBNull(reader, prefix + "行政区コード");
row.Cells[prefix + "整理番号"].Value = this.isDBNull(reader, prefix + "整理番号");
row.Cells[prefix + "世帯番号"].Value = this.isDBNull(reader, prefix + "世帯番号");
row.Cells[prefix + "電話番号"].Value = this.isDBNull(reader, prefix + "電話番号");
row.Cells[prefix + "携帯番号"].Value = this.isDBNull(reader, prefix + "携帯番号");
row.Cells[prefix + "健康診査"].Value = this.isDBNull(reader, prefix + "健康診査");
row.Cells[prefix + "結核肺がん"].Value = this.isDBNull(reader, prefix + "結核肺がん");
row.Cells[prefix + "胃がん"].Value = this.isDBNull(reader, prefix + "胃がん");
row.Cells[prefix + "大腸がん"].Value = this.isDBNull(reader, prefix + "大腸がん");
row.Cells[prefix + "前立腺がん"].Value = this.isDBNull(reader, prefix + "前立腺がん");
row.Cells[prefix + "骨粗鬆症"].Value = this.isDBNull(reader, prefix + "骨粗鬆症");
row.Cells[prefix + "成人歯科"].Value = this.isDBNull(reader, prefix + "成人歯科");
row.Cells[prefix + "子宮頸がん"].Value = this.isDBNull(reader, prefix + "子宮頸がん");
row.Cells[prefix + "乳がん"].Value = this.isDBNull(reader, prefix + "乳がん");
row.Cells[prefix + "希望場所"].Value = this.isDBNull(reader, prefix + "希望場所");
row.Cells[prefix + "身体不自由"].Value = this.isDBNull(reader, prefix + "身体不自由");
}
if (!row.Cells["f_整理番号"].Value.ToString().Equals(row.Cells["s_整理番号"].Value.ToString()))
{
row.Cells["f_整理番号"].Style.BackColor = Color.Pink;
row.Cells["s_整理番号"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_世帯番号"].Value.ToString().Equals(row.Cells["s_世帯番号"].Value.ToString()))
{
row.Cells["f_世帯番号"].Style.BackColor = Color.Pink;
row.Cells["s_世帯番号"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_電話番号"].Value.ToString().Equals(row.Cells["s_電話番号"].Value.ToString()))
{
row.Cells["f_電話番号"].Style.BackColor = Color.Pink;
row.Cells["s_電話番号"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_携帯番号"].Value.ToString().Equals(row.Cells["s_携帯番号"].Value.ToString()))
{
row.Cells["f_携帯番号"].Style.BackColor = Color.Pink;
row.Cells["s_携帯番号"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_健康診査"].Value.ToString().Equals(row.Cells["s_健康診査"].Value.ToString()))
{
row.Cells["f_健康診査"].Style.BackColor = Color.Pink;
row.Cells["s_健康診査"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_結核肺がん"].Value.ToString().Equals(row.Cells["s_結核肺がん"].Value.ToString()))
{
row.Cells["f_結核肺がん"].Style.BackColor = Color.Pink;
row.Cells["s_結核肺がん"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_胃がん"].Value.ToString().Equals(row.Cells["s_胃がん"].Value.ToString()))
{
row.Cells["f_胃がん"].Style.BackColor = Color.Pink;
row.Cells["s_胃がん"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_大腸がん"].Value.ToString().Equals(row.Cells["s_大腸がん"].Value.ToString()))
{
row.Cells["f_大腸がん"].Style.BackColor = Color.Pink;
row.Cells["s_大腸がん"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_前立腺がん"].Value.ToString().Equals(row.Cells["s_前立腺がん"].Value.ToString()))
{
row.Cells["f_前立腺がん"].Style.BackColor = Color.Pink;
row.Cells["s_前立腺がん"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_骨粗鬆症"].Value.ToString().Equals(row.Cells["s_骨粗鬆症"].Value.ToString()))
{
row.Cells["f_骨粗鬆症"].Style.BackColor = Color.Pink;
row.Cells["s_骨粗鬆症"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_成人歯科"].Value.ToString().Equals(row.Cells["s_成人歯科"].Value.ToString()))
{
row.Cells["f_成人歯科"].Style.BackColor = Color.Pink;
row.Cells["s_成人歯科"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_子宮頸がん"].Value.ToString().Equals(row.Cells["s_子宮頸がん"].Value.ToString()))
{
row.Cells["f_子宮頸がん"].Style.BackColor = Color.Pink;
row.Cells["s_子宮頸がん"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_乳がん"].Value.ToString().Equals(row.Cells["s_乳がん"].Value.ToString()))
{
row.Cells["f_乳がん"].Style.BackColor = Color.Pink;
row.Cells["s_乳がん"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_希望場所"].Value.ToString().Equals(row.Cells["s_希望場所"].Value.ToString()))
{
row.Cells["f_希望場所"].Style.BackColor = Color.Pink;
row.Cells["s_希望場所"].Style.BackColor = Color.Pink;
}
if (!row.Cells["f_身体不自由"].Value.ToString().Equals(row.Cells["s_身体不自由"].Value.ToString()))
{
row.Cells["f_身体不自由"].Style.BackColor = Color.Pink;
row.Cells["s_身体不自由"].Style.BackColor = Color.Pink;
}
}
readerCon.Close();
readerCon.Open();
MySqlCommand countCmd = new MySqlCommand("select count(`完了`) as cnt from `2回目` where `完了` = 1 and `ロット番号` = " + EditParam.lotNo, readerCon);
MySqlDataReader countReader = countCmd.ExecuteReader();
while (countReader.Read())
{
this.label2.Text = countReader.GetString("cnt");
}
countReader.Close();
readerCon.Close();
}
private string isDBNull(MySqlDataReader reader, string column)
{
int index = reader.GetOrdinal(column);
if (reader.IsDBNull(index))
{
return "";
}
else
{
return reader.GetString(column);
}
}
//検索
private void button1_Click(object sender, EventArgs e)
{
this.setPage();
this.search();
}
}
}