FrmCanVoteVoterGroup.cs
11.7 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
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeneralLib;
namespace SunVoteARSPPT
{
public partial class FrmCanVoteVoterGroup : Form
{
private TagSet tagSet = null;
private bool SaveOK = true;
public FrmCanVoteVoterGroup()
{
InitializeComponent();
}
//public FrmCanVoteSet(int type)
//{
// InitializeComponent();
// switch (type)
// {
// case 1:
// this.Text = "授权设置-指定名单分组";
// lvwItem.Items[0].Text = "1/A";
// btnSelectCorrect.Visible = false;
// break;
// default:
// this.Text = "授权设置-指定题目选项";
// break;
// }
//}
private void btnOK_Click(object sender, EventArgs e)
{
//2012-11-22 赵丽 没有勾选认为设置无效 日本要求
if(IsChecked())
SaveAuthorInfo();
SaveOK = true;
this.Close();
}
/// <summary>
/// 是否有选择项
/// 2012-11-22 赵丽
/// </summary>
/// <returns></returns>
private bool IsChecked()
{
if (GlobalInfo.OEMLogo != OEMLogos.oem3eAnalyzer) return true;
bool bResult = false;
for (int i = 0; i < lvwGroup.Items.Count; i++)
{
if (lvwGroup.Items[i].Checked == true)
{
bResult = true;
break;
}
}
return bResult;
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
SaveOK = true;
this.Close();
}
private void FrmCanVoteSet_Load(object sender, EventArgs e)
{
GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
chkSelectAllSlide.Top = lvwGroup.Top + 5;
chkSelectAllSlide.Left = lvwGroup.Left + 3;
lvwGroup.Columns[0].Text = " " + lvwGroup.Columns[0].Text;
tagSet = new TagSet();
tagSet.Tags = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.Tags;
ControlOper.SetPosCheckBoxToListViewHead(lvwGroup, chkSelectAllSlide);//杨斌 2012-11-16
LoadVoterInfo();
SaveOK = true;
}
private void btnSelectAll_Click(object sender, EventArgs e)
{
}
/// <summary>
/// 加载授权信息
/// </summary>
private void LoadAuthorInfo(int groupID)
{
try
{
int CurrentID = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.SlideID;
if (groupID == tagSet.LoadValue(TagKey.ResponsePara_CanVoteGroup, 0).ToInt)
{
//if (chkValue[groupIndex.ToString()] == null) { chkValue[groupIndex.ToString()] = new bool[lvwGroup.Items.Count]; }
for (int i = 0; i < lvwGroup.Items.Count; i++)
{
lvwGroup.Items[i].Checked = tagSet.LoadValue(TagKey.ResponsePara_CanVoteList_,
CurrentID.ToString() + "_" + lvwGroup.Items[i].Text, 0).ToInt == 1 ? true : false;
//chkValue[groupIndex.ToString()][i] = lvwGroup.Items[i].Checked;
}
}
}
catch (Exception ex)
{
}
}
/// <summary>
/// 获得投票人分组
/// </summary>
private void LoadVoterInfo()
{
try
{
lvwSlide.Items.Clear();
DataSet ds = null;
string sSql = "select * from ST_RosterColumn order by RC_Index";
ds = GlobalInfo.DBOperation.OpenDataSet(sSql);
string groupID;
string groupIndex;
if (ds.Tables[0].Rows.Count == 0) { return; }
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
bool[] chk = null;
groupIndex = ds.Tables[0].Rows[i]["RC_Index"].ToString();
lvwSlide.Items.Add(groupIndex);
lvwSlide.Items[i].SubItems.Add(ds.Tables[0].Rows[i]["RC_Name"].ToString());
lvwSlide.Items[i].SubItems.Add(ds.Tables[0].Rows[i]["RC_ID"].ToString());
}
groupID = tagSet.LoadValue(TagKey.ResponsePara_CanVoteGroup, 0).ToInt.ToString();
if (groupID != "0")
{
//杨斌 2012-03-22
int index = GetVoterIndex(groupID);
if (index >= 0)
{
lvwSlide.Items[GetVoterIndex(groupID)].Selected = true;
LoadCanChooseVoter(ConvertOper.Convert(groupID).ToInt);
}
else
{
lvwSlide.Items[0].Selected = true;
LoadCanChooseVoter(ConvertOper.Convert(lvwSlide.Items[0].SubItems[2].Text).ToInt);
}
}
else
{
lvwSlide.Items[0].Selected = true;
LoadCanChooseVoter(ConvertOper.Convert(lvwSlide.Items[0].SubItems[2].Text).ToInt);
}
}
catch (Exception ex)
{
}
}
/// <summary>
/// 加载可选投票人列表
/// </summary>
private void LoadCanChooseVoter(int GroupID)
{
try
{
lvwGroup.Items.Clear();
DataSet ds = null;
string sSql = "select distinct RV_Text from ST_RosterValue where RC_ID=" + GroupID.ToString();
ds = GlobalInfo.DBOperation.OpenDataSet(sSql);
if (ds.Tables[0].Rows.Count == 0) { return; }
if (lvwSlide.SelectedItems[0].Index == 0)//键盘编号为数字,应按数字排序,杨斌 2012-03-01
{
List<string> lstKeypad = new List<string>();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
//lstKeypad.Add(ConvertOper.Convert(ds.Tables[0].Rows[i]["RV_Text"].ToString()).ToInt);
lstKeypad.Add(ds.Tables[0].Rows[i]["RV_Text"].ToString());//杨斌 2015-01-14
}
lstKeypad.Sort();
for (int i = 0; i < lstKeypad.Count; i++)
{
lvwGroup.Items.Add(lstKeypad[i].ToString(), 0);
}
}
else
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
lvwGroup.Items.Add(ds.Tables[0].Rows[i]["RV_Text"].ToString(), 0);
//lvwGroup.Items[i].SubItems.Add(ds.Tables[0].Rows[i]["RO_ID"].ToString());
}
}
LoadAuthorInfo(GroupID);
}
catch (Exception ex)
{
}
}
/// <summary>
/// 保存授权信息
/// </summary>
private void SaveAuthorInfo()
{
string topicID = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.SlideID.ToString();
string sSql = "select * from ST_Response where T_ID='" + topicID + "'";
if (GlobalInfo.DBOperation.RecordIsExist(sSql))
{
if (MessageBox.Show(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "UpdatePrompt",
"更改键盘授权信息,将清空该题目所有反馈信息,是否继续?"), GlobalInfo.GetAppName(), MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.No)
{
this.DialogResult = DialogResult.Cancel;
return;
}
else
{
GlobalInfo.response.ClearResponseDB(topicID);
}
}
try
{
// if (lvwSlide.sel == null) { return; }
int CurrnetID = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.SlideID;
//删除之前的数据,人员名单授权和幻灯片授权
PPTOper.RemoveTags(tagSet, "ResponsePara_CanVoteList_" + CurrnetID.ToString());
PPTOper.RemoveTags(tagSet, "ResponsePara_CanVoteOption_" + CurrnetID.ToString());
tagSet.SetValue(TagKey.ResponsePara_CanVoteGroup, lvwSlide.SelectedItems[0].SubItems[2].Text);
for (int i = 0; i < lvwGroup.Items.Count; i++)
{
tagSet.SetValue(TagKey.ResponsePara_CanVoteList_, CurrnetID.ToString() + "_" + lvwGroup.Items[i].Text,
lvwGroup.Items[i].Checked == true ? 1 : 0);
}
//tagSet.SetValue(TagKey.ResponsePara_CanVote, CanVoteIndex);
this.DialogResult = DialogResult.OK;
}
catch (Exception ex)
{ }
}
private void lvwSlide_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
chkSelectAllSlide.Checked = false;
SaveOK = true;
if (lvwSlide.FocusedItem == null) { return; }
if (lvwSlide.FocusedItem != null)
{
int groupID = 0;
groupID = ConvertOper.Convert(lvwSlide.SelectedItems[0].SubItems[2].Text).ToInt;
LoadCanChooseVoter(groupID);
}
}
catch
{
//未选中列表
}
}
private void FrmCanVoteVoterGroup_FormClosing(object sender, FormClosingEventArgs e)
{
if (SaveOK != true)
{
if (MessageBox.Show(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "UpdateSave",
"键盘授权已修改,是否保存?"), GlobalInfo.GetAppName(), MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
SaveOK = false;
}
else
SaveOK = true;
}
}
private void lvwGroup_ItemChecked(object sender, ItemCheckedEventArgs e)
{
}
private void lvwGroup_ItemCheck(object sender, ItemCheckEventArgs e)
{
SaveOK = false;
}
private void FrmCanVoteVoterGroup_FormClosed(object sender, FormClosedEventArgs e)
{
if (!SaveOK)
{
SaveAuthorInfo();
SaveOK = true;
}
}
private int GetVoterIndex(string groupID)
{
//杨斌 2012-03-22
int voteIndex = -1;
for (int i = 0; i < lvwSlide.Items.Count; i++)
{
if (lvwSlide.Items[i].SubItems[2].Text.ToString() == groupID)
{
//voteIndex = ConvertOper.Convert(lvwSlide.Items[i].Text.ToString()).ToInt ;
voteIndex = i;
break;
}
}
return voteIndex;
}
private void chkSelectAllSlide_Click(object sender, EventArgs e)
{
for (int i = 0; i < lvwGroup.Items.Count; i++)
{
lvwGroup.Items[i].Checked = chkSelectAllSlide.Checked;
}
SaveOK = false;
}
}
}