private void sbtnDeleteOk_Click(object sender, EventArgs e) { if (usingWg == DeviceUsing.未启用) { MessageUtil.ShowError("IC门禁控制器未配置,请检查系统设置"); return; } sbtnDeleteOk.Enabled = false; bool bl = true; foreach (DataRow dr in dtDeletePower.Rows) { string str = dr["IcNo"].ToString(); bool blRet = wgControl.DeleteCardPower(str); if (blRet == false) { bl = false; break; } Thread.Sleep(20); } if (bl == true) { foreach (DataRow dr in dtDeletePower.Rows) { string str = dr["IcNo"].ToString(); string strSql = "update tb_DoorUser set IsPower='" + DoorPowerType.未授权.ToString() + "' where IcNo='" + str + "' "; datalogic.SqlComNonQuery(strSql); string strGroup = dr["GroupName"].ToString(); string strName = dr["UserName"].ToString(); string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strSql = "insert into tb_RecordPower (PowerType,GroupName,UserName,OperateTime,People)" + "values ('删除权限','" + strGroup + "','" + strName + "','" + strTime + "','" + frmMain.strUserName + "')"; datalogic.SqlComNonQuery(strSql); } MessageUtil.ShowTips("删除权限成功"); } else { MessageUtil.ShowTips("删除权限失败"); } dtDeletePower.Rows.Clear(); treeView1.Nodes.Clear(); AddTreeView("0", (TreeNode)null); treeView1.ExpandAll(); sbtnDeleteOk.Enabled = true; }
private void sbtnDelete_Click(object sender, EventArgs e) { sbtnAdd.Enabled = false; sbtnDelete.Enabled = false; sbtnDeleteExit.Enabled = false; lblInfo.Visible = true; if (MessageUtil.ShowYesNoAndTips("确定上传?") == DialogResult.Yes) { //所有选中的 工具柜 bool blBox = true; foreach (DataRow dr in dtBoxSelect.Rows) { string strChildId = dr["tvChildId"].ToString(); string strParentId = dr["tvParent"].ToString(); string strBoxName = dr["PlaceName"].ToString(); int iCount = listWg.Count; if (iCount > 0) { for (int iIndex = 0; iIndex < iCount; iIndex++) { if (listWg[iIndex].StrChildId == strChildId) { wgControl.IntSn = listWg[iIndex].IntSn; wgControl.StrIp = listWg[iIndex].StrIp; wgControl.IntPort = listWg[iIndex].IntPort; //MjRegisterCard mjrc = new MjRegisterCard(); bool blUser = true; //所有选中的人 foreach (DataRow row in dtUserSelect.Rows) { string strIcNo = row["IcNo"].ToString(); //string strUserId = row["tvChildId"].ToString(); //string strName = row["UserName"].ToString(); //string strCardNo = row["CardNo"].ToString(); if (wgControl.DeleteCardPower(strIcNo)) { string strSql = "delete from tb_BoxIcPower where BoxChildId='" + strChildId + "' and IcNo='" + strIcNo + "'"; datalogic.SqlComNonQuery(strSql); } else { blUser = false; break; } Thread.Sleep(20); } //人员中有授权错误 if (blUser == false) { blBox = false; } break; } } } // 工具柜 有授权错误 if (blBox == false) { break; } } if (blBox) { MessageUtil.ShowTips("删除权限成功"); } else { MessageUtil.ShowTips("删除权限失败,请检查设备或网络连接"); } } sbtnAdd.Enabled = true; sbtnDelete.Enabled = true; sbtnDeleteExit.Enabled = true; lblInfo.Visible = false; }