private void btnUpdate_Click(object sender, EventArgs e) { if (tbRoleName.Text.Trim() == "") { WinInfoHelper.ShowInfoWindow(this, "角色名称不能为空!"); return; } if (_selectRow != null && dgvData.Rows.Contains(_selectRow)) { Maticsoft.Model.SMT_ROLE_INFO role = (Maticsoft.Model.SMT_ROLE_INFO)_selectRow.Tag; role.ROLE_NAME = tbRoleName.Text.Trim(); role.ROLE_DESC = tbRoleDesc.Text.Trim(); CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO(); roleBll.Update(role); SmtLog.InfoFormat("用户", "更新角色:ID={0},名称={1}", role.ID, role.ROLE_NAME); this.Invoke(new Action(() => { _selectRow.Cells[0].Value = role.ROLE_NAME; _selectRow.Cells[1].Value = role.ROLE_DESC; })); } catch (Exception ex) { log.Error("更新角色异常:", ex); WinInfoHelper.ShowInfoWindow(this, "更新角色异常:" + ex.Message); } }); waiting.Show(this); } }
private void DoSave() { CtrlWaiting waiting = new CtrlWaiting(() => { decimal?old = _userInfo.ROLE_ID; try { _userInfo.ROLE_ID = SELECT_ROLE.ID; Maticsoft.BLL.SMT_USER_INFO userBll = new Maticsoft.BLL.SMT_USER_INFO(); userBll.Update(_userInfo); SmtLog.InfoFormat("用户", "修改用户:{0},角色:{1}成功.", _userInfo.USER_NAME, _userInfo.ROLE_ID + ":" + SELECT_ROLE.ROLE_NAME); this.Invoke(new Action(() => { _userInfo.ROLE_NAME = SELECT_ROLE.ROLE_NAME + "(点击修改)"; this.DialogResult = DialogResult.OK; this.Close(); })); } catch (Exception ex) { _userInfo.ROLE_ID = old; WinInfoHelper.ShowInfoWindow(this, "保存失败:" + ex.Message); log.Error("保存授权角色失败:", ex); } }); waiting.Show(this); }
private void btnAdd_Click(object sender, EventArgs e) { if (tbRoleName.Text.Trim() == "") { WinInfoHelper.ShowInfoWindow(this, "角色名称不能为空!"); return; } Maticsoft.Model.SMT_ROLE_INFO role = new Maticsoft.Model.SMT_ROLE_INFO(); role.ROLE_NAME = tbRoleName.Text.Trim(); role.ROLE_DESC = tbRoleName.Text.Trim(); CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO(); role.ID = roleBll.Add(role); SmtLog.InfoFormat("用户", "添加角色:ID={0},名称={1}", role.ID, role.ROLE_NAME); this.Invoke(new Action(() => { AddModel(role); })); } catch (Exception ex) { log.Error("添加角色异常:", ex); WinInfoHelper.ShowInfoWindow(this, "添加角色异常:" + ex.Message); } }); waiting.Show(this); }
private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { if (dgvData.Columns[e.ColumnIndex].Name == "ColDelete") { Maticsoft.Model.SMT_WEEKEX_INFO info = (Maticsoft.Model.SMT_WEEKEX_INFO)dgvData.Rows[e.RowIndex].Tag; if (MessageBox.Show("确定删除该假期约束?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_WEEKEX_INFO wbll = new Maticsoft.BLL.SMT_WEEKEX_INFO(); wbll.Delete(info.ID); SmtLog.InfoFormat("设置", "删除假期约束:{0},开始时间:{1},结束时间:{2},描述:{3}", info.WEEKEX_ON_DUTY ? "上班[允许开门]" : "假期[不能开门]", info.WEEKEX_START_DATE, info.WEEKEX_END_DATE, info.WEEKEX_DESC); this.Invoke(new Action(() => { dgvData.Rows.Remove(dgvData.Rows[e.RowIndex]); })); } catch (System.Exception ex) { WinInfoHelper.ShowInfoWindow(this, "删除假期约束异常:" + ex.Message); log.Error("删除假期约束异常:", ex); } }); waiting.Show(this); } } } }
private void btnAdd_Click(object sender, EventArgs e) { string pwd = this.tbPassword.Text.Trim(); if (pwd == "") { WinInfoHelper.ShowInfoWindow(this, "密码为空!"); return; } var doors = doorTree.Tree.GetNodeList(true, typeof(Maticsoft.Model.SMT_DOOR_INFO)); if (doors.Count == 0) { WinInfoHelper.ShowInfoWindow(this, "未选择任何门禁!"); return; } List <decimal> doorIds = new List <decimal>(); foreach (var item in doors) { doorIds.Add(((Maticsoft.Model.SMT_DOOR_INFO)item.Tag).ID); } CtrlWaiting ctrlWaiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_SUPER_PWD pwdBll = new Maticsoft.BLL.SMT_SUPER_PWD(); List <Maticsoft.Model.SMT_SUPER_PWD> models = pwdBll.GetModelList("SUPER_PWD='" + pwd + "'"); List <Maticsoft.Model.SMT_SUPER_PWD> addmodels = new List <Maticsoft.Model.SMT_SUPER_PWD>(); foreach (var item in doorIds) { if (!models.Exists(m => m.DOOR_ID == item)) { Maticsoft.Model.SMT_SUPER_PWD model = new Maticsoft.Model.SMT_SUPER_PWD() { DOOR_ID = item, SUPER_PWD = pwd }; model.ID = pwdBll.Add(model); addmodels.Add(model); SmtLog.InfoFormat("配置", "添加超级通行密码:门禁Id={0}", item); } } if (addmodels.Count > 0) { RefreshDatas(); } } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "添加超级通行密码异常!" + ex.Message); log.Error("添加超级通行密码异常:", ex); } }); ctrlWaiting.Show(this); }
private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow row = dgvData.Rows[e.RowIndex]; _selectRow = row; Maticsoft.Model.SMT_ROLE_INFO role = (Maticsoft.Model.SMT_ROLE_INFO)row.Tag; tbRoleName.Text = role.ROLE_NAME; tbRoleDesc.Text = role.ROLE_DESC; if (e.ColumnIndex >= 0) { if (dgvData.Columns[e.ColumnIndex].Name == "ColPrivate") { DoSetPrivate(); } else if (dgvData.Columns[e.ColumnIndex].Name == "ColDelete") { if (MessageBox.Show("确定删除该角色?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + role.ID); Maticsoft.BLL.SMT_ROLE_INFO roleInfo = new Maticsoft.BLL.SMT_ROLE_INFO(); roleInfo.Delete(role.ID); SmtLog.InfoFormat("用户", "删除角色:ID={0},名称={1}", role.ID, role.ROLE_NAME); this.Invoke(new Action(() => { dgvData.Rows.Remove(row); _selectRow = null; tbRoleName.Text = ""; tbRoleDesc.Text = ""; })); } catch (Exception ex) { log.Error("删除角色异常:", ex); WinInfoHelper.ShowInfoWindow(this, "删除角色异常:" + ex.Message); } }); waiting.Show(this); } } } } }
private void biDelete_Click(object sender, EventArgs e) { if (dgvData.SelectedRows.Count > 0) { if (MessageBox.Show("确定删除选择对象?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { List <Maticsoft.Model.SMT_TIMESCALE_INFO> mscs = new List <Maticsoft.Model.SMT_TIMESCALE_INFO>(); List <DataGridViewRow> rows = new List <DataGridViewRow>(); foreach (DataGridViewRow item in dgvData.SelectedRows) { mscs.Add((Maticsoft.Model.SMT_TIMESCALE_INFO)item.Tag); rows.Add(item); } CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_TIMESCALE_INFO scBll = new Maticsoft.BLL.SMT_TIMESCALE_INFO(); foreach (var item in mscs) { scBll.Delete(item.ID); SmtLog.InfoFormat("配置", "删除定时任务,编号:{0},名称:{1}", item.TIME_NO, item.TIME_NAME); } this.Invoke(new Action(() => { foreach (var item in rows) { dgvData.Rows.Remove(item); } DoUpload(); })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "删除对象异常:" + ex.Message); log.Error("删除对象异常:", ex); } }); waiting.Show(this); } } }
private void btnOk_Click(object sender, EventArgs e) { if (tbOldPwd.Text != UserInfoHelper.OldPwd) { MessageBox.Show("原始密码输入错误!"); tbOldPwd.Focus(); return; } if (tbNewPwd.Text == "") { MessageBox.Show("新密码不能为空!"); tbNewPwd.Focus(); return; } if (tbNewPwd.Text != tbRePwd.Text) { MessageBox.Show("两次输入密码不相同!"); tbRePwd.Focus(); return; } //"USER_NAME='" + tbUserName.Text.Trim() + "' and IS_ENABLE=1 and IS_DELETE=0 and PASS_WORD= substring(sys.fn_sqlvarbasetostr(HashBytes('MD5','" + tbPwd.Text + "')),3,32)" CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("update SMT_USER_INFO set PASS_WORD=substring(sys.fn_sqlvarbasetostr(HashBytes('MD5','" + tbNewPwd.Text + "')),3,32) where ID='" + UserInfoHelper.UserID + "'"); SmtLog.InfoFormat("用户", "修改密码,用户名:{0}", UserInfoHelper.UserInfo.USER_NAME); this.Invoke(new Action(() => { this.Close(); })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "修改用户密码失败:" + ex.Message); } }); waiting.Show(this); }
private void btnAdd_Click(object sender, EventArgs e) { DateTime dtStart = DateTime.Parse(dtpStartDate.Value.ToString("yyyy-MM-dd HH:mm:00")); DateTime dtEnd = DateTime.Parse(dtpEndDate.Value.ToString("yyyy-MM-dd HH:mm:00")); if (dtStart > dtEnd) { WinInfoHelper.ShowInfoWindow(this, "开始时间大于结束时间!"); return; } Maticsoft.Model.SMT_WEEKEX_INFO info = new Maticsoft.Model.SMT_WEEKEX_INFO(); info.WEEKEX_ON_DUTY = cboHolidayType.SelectedIndex == 1; info.WEEKEX_START_DATE = dtStart; info.WEEKEX_END_DATE = dtEnd; info.WEEKEX_DESC = tbDesc.Text.Trim(); CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_WEEKEX_INFO wbll = new Maticsoft.BLL.SMT_WEEKEX_INFO(); info.ID = wbll.Add(info); SmtLog.InfoFormat("设置", "添加假期约束:{0},开始时间:{1},结束时间:{2},描述:{3}", info.WEEKEX_ON_DUTY ? "上班[允许开门]" : "假期[不能开门]", info.WEEKEX_START_DATE, info.WEEKEX_END_DATE, info.WEEKEX_DESC); this.Invoke(new Action(() => { AddToGrid(info); })); } catch (System.Exception ex) { WinInfoHelper.ShowInfoWindow(this, "添加假期约束异常:" + ex.Message); log.Error("添加假期约束异常:", ex); } }); waiting.Show(this); }
private void btnOk_Click(object sender, EventArgs e) { if (tbUserName.Text.Trim() == "") { MessageBox.Show("用户名不能为空!"); return; } if (_userInfo == null) { _userInfo = new Maticsoft.Model.SMT_USER_INFO(); _userInfo.ID = -1; } string oldUser = _userInfo.USER_NAME; _userInfo.USER_NAME = tbUserName.Text.Trim(); _userInfo.PASS_WORD = tbPwd.Text; if (_userInfo.PASS_WORD == "123456") { _userInfo.PASS_WORD = "e10adc3949ba59abbe56e057f20f883e"; } _userInfo.REAL_NAME = tbRealName.Text.Trim(); _userInfo.IS_ENABLE = cbEnable.Checked; _userInfo.TELEPHONE = tbTel.Text.Trim(); _userInfo.ADDRESS = tbAddress.Text.Trim(); _userInfo.EMAIL = tbEmail.Text.Trim(); _userInfo.QQ = tbQQ.Text.Trim(); _userInfo.KEY_VAL = ""; _userInfo.IS_DELETE = false; if (cboRole.SelectedItem != null) { ComboItem cboItem = (ComboItem)cboRole.SelectedItem; Maticsoft.Model.SMT_ROLE_INFO roleInfo = (Maticsoft.Model.SMT_ROLE_INFO)cboItem.Tag; _userInfo.ROLE_ID = roleInfo.ID; _userInfo.ROLE_NAME = roleInfo.ROLE_NAME; } else { _userInfo.ROLE_ID = -1; } if (cbtDept.SelectedNode != null) { Maticsoft.Model.SMT_ORG_INFO orgInfo = (Maticsoft.Model.SMT_ORG_INFO)cbtDept.SelectedNode.Tag; _userInfo.ORG_ID = orgInfo.ID; _userInfo.DEPT_NAME = orgInfo.ORG_NAME; } else { _userInfo.ORG_ID = -1; } CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_USER_INFO userBll = new Maticsoft.BLL.SMT_USER_INFO(); if (_userInfo.ID == -1) { userBll.Add(_userInfo); SmtLog.InfoFormat("用户", "添加用户:用户名={0},状态={1}", _userInfo.USER_NAME, _userInfo.IS_ENABLE); } else { userBll.Update(_userInfo); SmtLog.InfoFormat("用户", "更新用户:用户名={0},状态={1},原始用户名={2}", _userInfo.USER_NAME, _userInfo.IS_ENABLE, oldUser); } this.BeginInvoke(new Action(() => { this.DialogResult = DialogResult.OK; this.Close(); })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "保存用户异常:" + ex.Message); log.Error("保存用户异常:", ex); } }); waiting.Show(this); }
private void btnOk_Click(object sender, EventArgs e) { //读取菜单权限 List <Maticsoft.Model.SMT_FUN_MENUPOINT> funs = GetSelectModels <Maticsoft.Model.SMT_FUN_MENUPOINT>(advPrivate, CheckState.Indeterminate, CheckState.Checked); //读取部门菜单 List <Maticsoft.Model.SMT_ORG_INFO> orgs = null; if (deptTree.IsLoaded) { orgs = GetSelectModels <Maticsoft.Model.SMT_ORG_INFO>(deptTree.Tree, CheckState.Checked); } //读取门参数 List <Maticsoft.Model.SMT_DOOR_INFO> doors = null; if (doorTree.IsLoaded) { doors = GetSelectModels <Maticsoft.Model.SMT_DOOR_INFO>(doorTree.Tree, CheckState.Checked); } //读取人脸参数 List <Maticsoft.Model.SMT_FACERECG_DEVICE> faces = null; if (faceDevTree.IsLoaded) { faces = GetSelectModels <Maticsoft.Model.SMT_FACERECG_DEVICE>(faceDevTree.Tree, CheckState.Checked); } CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_ROLE_FUN rolefunBll = new Maticsoft.BLL.SMT_ROLE_FUN(); Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and (ROLE_TYPE=1 or ROLE_TYPE is null)"); if (funs.Count > 0) { foreach (var item in funs) { Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN(); rf.ROLE_ID = _roleInfo.ID; rf.FUN_ID = item.ID; rf.ROLE_TYPE = 1; rolefunBll.Add(rf); } } SmtLog.InfoFormat("用户", "更新角色:{0}菜单权限,个数:{1}.", _roleInfo.ROLE_NAME, funs.Count); if (orgs != null) { Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=2"); foreach (var item in orgs) { Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN(); rf.ROLE_ID = _roleInfo.ID; rf.FUN_ID = item.ID; rf.ROLE_TYPE = 2; rolefunBll.Add(rf); } SmtLog.InfoFormat("用户", "更新角色:{0}部门权限,个数:{1}.", _roleInfo.ROLE_NAME, orgs.Count); } if (doors != null) { Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=3"); foreach (var item in doors) { Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN(); rf.ROLE_ID = _roleInfo.ID; rf.FUN_ID = item.ID; rf.ROLE_TYPE = 3; rolefunBll.Add(rf); } SmtLog.InfoFormat("用户", "更新角色:{0}门禁权限,个数:{1}.", _roleInfo.ROLE_NAME, doors.Count); } if (faces != null) { Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=4"); foreach (var item in faces) { Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN(); rf.ROLE_ID = _roleInfo.ID; rf.FUN_ID = item.ID; rf.ROLE_TYPE = 4; rolefunBll.Add(rf); } SmtLog.InfoFormat("用户", "更新角色:{0}人脸设备权限,个数:{1}.", _roleInfo.ROLE_NAME, faces.Count); } this.Invoke(new Action(() => { this.DialogResult = DialogResult.OK; this.Close(); })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "更新角色权限失败:" + ex.Message); log.Error("更新角色权限失败:", ex); } }); waiting.Show(this); }