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 { /// /// 键盘管理类 /// private SunVote.KeypadManage keypadManage; public FrmKeypadReplace() { InitializeComponent(); } /// /// 修改:杨斌 2012-05-16 /// /// /// 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); } /// /// 更新键盘 /// /// /// /// 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; } /// /// 更新键盘。int改成string类型:杨斌 2018-08-07。 /// 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); } /// /// //修改 杨斌 2012-05-09 /// 防止拔出基站重新连接时,当前活动窗体非模式窗体时,PowerPoint停止运行 /// 修改:杨斌 2012-06-01,PowerPoint2007激活窗体无效,暂改为模式窗体 /// void baseConnect_ActiveSlideWindowEvent() { try { //Globals.SunVoteARSAddIn.Application.ActivePresentation.Windows[0].Activate(); //Globals.SunVoteARSAddIn.Application.ActivePresentation.Windows[1].Activate(); //Globals.SunVoteARSAddIn.Application.ActiveWindow.Activate(); } catch { } } } }