FrmKeypadReplace.cs
8.99 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
using GeneralLib;
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;
namespace SunVoteARSPPT
{
public partial class FrmKeypadReplace : Form
{
/// <summary>
/// 键盘管理类
/// </summary>
private SunVote.KeypadManage keypadManage;
public FrmKeypadReplace()
{
InitializeComponent();
}
/// <summary>
/// 修改:杨斌 2012-05-16
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOK_Click(object sender, EventArgs e)
{
//if (nudKeypadIDOld.Value == nudKeypadIDNew.Value)
if (txtKeypadIDOld.Text.Trim() == txtKeypadIDNew.Text.Trim())//杨斌 2017-08-18
{
MessageBox.Show(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "ReplaceMassage0", "替换的键盘和原始键盘编号不允许相同"), GlobalInfo.GetAppName());
nudKeypadIDNew.Focus();
return;
}
if (!GlobalInfo.response.EnableList)
{
if (!GlobalInfo.hardwareManage.JudgeKeyStatus(nudKeypadIDNew.Value.ToString()))
{
MessageBox.Show(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "ReplaceMassage1", "替换的键盘无效"), GlobalInfo.GetAppName());
nudKeypadIDNew.Focus();
return;
}
}
//if (IsUsed(Convert.ToInt64(nudKeypadIDNew.Value)))
if (IsUsed(txtKeypadIDNew.Text))//杨斌 2018-08-07
{
MessageBox.Show(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "ReplaceMassage2", "该键盘已存在反馈信息,不允许替换"), GlobalInfo.GetAppName());
nudKeypadIDNew.Focus();
return;
}
//杨斌 2017-08-18
GlobalInfo.hardwareManage.OriginalKeyID = txtKeypadIDOld.Text.Trim();
GlobalInfo.hardwareManage.NewKeyID = txtKeypadIDNew.Text.Trim();
//GlobalInfo.hardwareManage.OriginalKeyID = Convert.ToInt64(nudKeypadIDOld.Value);
//GlobalInfo.hardwareManage.NewKeyID = Convert.ToInt64(nudKeypadIDNew.Value);
//更新键盘
//杨斌 2017-08-18
UpdateKeypad(txtKeypadIDOld.Text.Trim(), txtKeypadIDNew.Text.Trim());
//UpdateKeypad(nudKeypadIDOld.Value.ToString(), nudKeypadIDNew.Value.ToString());
MessageBox.Show(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "ReplaceSuccess", "键盘替换成功"),
GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "prompt", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// 更新键盘
/// </summary>
/// <param name="oldKeyID"></param>
/// <param name="newKeyID"></param>
/// <returns></returns>
private void UpdateKeypad(string oldKeyID, string newKeyID)
{
string sSql = "";
//杨斌 2017-08-18。屏蔽下面格式化。SN是任意字符串
////杨斌 2017-02-07
////需要格式化成SN的
//if (oldKeyID.Length > 5)
// oldKeyID = oldKeyID.PadLeft(12, '0');
//if (newKeyID.Length > 5)
// newKeyID = newKeyID.PadLeft(12, '0');
sSql = "update ST_Response set R_KeypadID='" + newKeyID.ToString() + "'" + " where R_KeypadID='" + oldKeyID.ToString() + "'";
GlobalInfo.DBOperation.ExecuteNonQuery(sSql);
//判断ST_Voter表里面有没有该编号,如果有不做操作
DataSet ds = null;
sSql = "select * from ST_Voter where V_KeypadID='" + newKeyID.ToString() + "'";//杨斌 2015-02-14
ds = GlobalInfo.DBOperation.OpenDataSet(sSql);
if (ds.Tables[0].Rows.Count <= 0)
{
//杨斌 2015-03-18
sSql = "update ST_Voter set V_KeypadID='" + newKeyID.ToString() + "' where V_KeypadID='" + oldKeyID.ToString() + "'";
GlobalInfo.DBOperation.ExecuteNonQuery(sSql);
}
sSql = "update ST_RosterValue set RV_Text='" + newKeyID.ToString()
+ "' where RV_Text='" + oldKeyID.ToString() + "' and RC_ID=(select top 1 RC_ID from ST_RosterColumn where RC_Index=1)";
GlobalInfo.DBOperation.ExecuteNonQuery(sSql);
//修改内存时,禁止收取投票信息
GlobalInfo.response.IsAnOtherOper = true;
if (GlobalInfo.response.ResponseDataList.Contains(oldKeyID.ToString()))
{
ResponsePar r = GlobalInfo.response.ResponseDataList[oldKeyID.ToString()];
GlobalInfo.response.ResponseDataList.Remove(oldKeyID.ToString());
if (!GlobalInfo.response.ResponseDataList.Contains(newKeyID.ToString()))
{
GlobalInfo.response.ResponseDataList.Add(newKeyID.ToString(), r);
GlobalInfo.response.ResponseDataList[newKeyID.ToString()].KeyID = newKeyID;
}
}
if (GlobalInfo.response.AuthorKeypadList.ContainsKey(oldKeyID.ToString()))//授权键盘替换 杨斌 2012-02-15
{
GlobalInfo.response.AuthorKeypadList.Remove(oldKeyID.ToString());
if (!GlobalInfo.response.AuthorKeypadList.ContainsKey(newKeyID.ToString()))
GlobalInfo.response.AuthorKeypadList.Add(newKeyID.ToString(), newKeyID);
}
if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
{
if (Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar != null)
{
if (Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.frmVoteDetail != null)
{
//Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.frmVoteDetail.ReDrawMap();
Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.frmVoteDetail.InitMap();
}
}
}
GlobalInfo.response.IsAnOtherOper = false;
}
/// <summary>
/// 更新键盘。int改成string类型:杨斌 2018-08-07。
/// </summary>
private bool IsUsed(string keyID)
{
bool bResult = false;
//启用名单,键盘已有指定名单
string sSql = "";
DataSet ds;
if (GlobalInfo.response.EnableList)
{
sSql = "select a.* from ST_RosterValue a,ST_RosterColumn b where a.RC_ID=B.RC_ID and b.RC_Index=1 and a.RV_Text='" + keyID.ToString() + "'";
ds = GlobalInfo.DBOperation.OpenDataSet(sSql);
if (ds.Tables[0].Rows.Count > 0)
bResult = true;
}
sSql = "select * from ST_Response where R_KeypadID ='" + keyID.ToString() + "'";
ds = GlobalInfo.DBOperation.OpenDataSet(sSql);
if (ds.Tables[0].Rows.Count > 0)
bResult = true;
//内存里面有该键盘投票信息
if (GlobalInfo.response.ResponseDataList.Contains(keyID.ToString())) { bResult = true; }
//键盘已有反馈信息
return bResult;
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void nudKeypadIDOld_ValueChanged(object sender, EventArgs e)
{
}
private void nudKeypadIDNew_ValueChanged(object sender, EventArgs e)
{
}
private void FrmKeypadReplace_Load(object sender, EventArgs e)
{
GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
//2013-2-25 键盘替换范围增加到最大键盘编号
//nudKeypadIDNew.Maximum = HardWareInfo.KeypadID_Max;
nudKeypadIDOld.Value = 1;
nudKeypadIDNew.Value = 1;
txtKeypadIDOld.Text = "1";
txtKeypadIDNew.Text = "1";
//修改 杨斌 2012-05-09 防止拔出基站重新连接时,当前活动窗体非模式窗体时,PowerPoint停止运行
GlobalInfo.baseConnect.ActiveSlideWindowEvent += new ActiveSlideWindowEventHander(baseConnect_ActiveSlideWindowEvent);
}
/// <summary>
/// //修改 杨斌 2012-05-09
/// 防止拔出基站重新连接时,当前活动窗体非模式窗体时,PowerPoint停止运行
/// 修改:杨斌 2012-06-01,PowerPoint2007激活窗体无效,暂改为模式窗体
/// </summary>
void baseConnect_ActiveSlideWindowEvent()
{
try
{
//Globals.SunVoteARSAddIn.Application.ActivePresentation.Windows[0].Activate();
//Globals.SunVoteARSAddIn.Application.ActivePresentation.Windows[1].Activate();
//Globals.SunVoteARSAddIn.Application.ActiveWindow.Activate();
}
catch
{
}
}
}
}