private void ShowItemInGridViewRow1(DataGridViewRow row, PREOperatorInfo item) { PREOperatorInfo info = item; row.Tag = info; row.Cells["colOperatorName"].Value = info.OperatorName; }
protected override object GetItemFromInput() { PREOperatorInfo info = null; if (CheckInput()) { if (IsAdding) { info = new PREOperatorInfo(); info.Password = txtPassword.Text.Trim(); } else { info = UpdatingItem as PREOperatorInfo; if (txtPassword.Text.Trim() != _subPwd) { info.Password = txtPassword.Text.Trim(); } } info.OperatorID = txtOperatorID.Text.Trim(); info.OperatorName = txtOperatorName.Text.Trim(); info.Role = comRoleList.Role; info.RoleID = comRoleList.SelectedRoleID; if (this.txtOperatorNum.Visible) { info.OperatorNum = byte.Parse(txtOperatorNum.Text); } } return(info); }
/// <summary> /// 删除操作员 /// </summary> /// <param name="info"></param> /// <returns></returns> /// <exception cref=" "></exception> public CommandResult Delete(PREOperatorInfo info) { if (!info.CanDelete) { throw new InvalidOperationException(string.Format(Resource1.OperatorBll_CannotDelete, info.OperatorID)); } return(provider.Delete(info)); }
/// <summary> /// 清除选择 /// </summary> private void ClearSelection() { foreach (DataGridViewRow row in GridView.Rows) { PREOperatorInfo info = row.Tag as PREOperatorInfo; DataGridViewCheckBoxCell c = row.Cells["colCheck"] as DataGridViewCheckBoxCell; c.Value = false; } }
private string GetItemName(object item) { string name = string.Empty; if (item is PREOperatorInfo) { PREOperatorInfo info = item as PREOperatorInfo; name = info.OperatorName; } return(name); }
protected override CommandResult AddItem(object addingItem) { PREOperatorInfo info = (PREOperatorInfo)addingItem; CommandResult result = bll.Insert(info); if (result.Result == ResultCode.Successful && DataBaseConnectionsManager.Current.StandbyConnected) { PREOperatorBll sobll = new PREOperatorBll(AppSettings.CurrentSetting.CurrentStandbyConnect); sobll.UpdateOrInsert(info); } return(result); }
/// <summary> /// 选择所有 /// </summary> private void SelectAll() { foreach (DataGridViewRow row in GridView.Rows) { if (row.Visible) { PREOperatorInfo info = row.Tag as PREOperatorInfo; DataGridViewCheckBoxCell c = row.Cells["colCheck"] as DataGridViewCheckBoxCell; c.Value = true; } } }
/// <summary> /// 更新操作员,如没有,插入新的操作员记录 /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult UpdateOrInsert(PREOperatorInfo info) { PREOperatorInfo original = provider.GetByID(info.OperatorID).QueryObject; if (original != null) { return(provider.Update(info, original)); } else { return(provider.Insert(info)); } }
protected override void ShowItemInGridViewRow(DataGridViewRow row, object item) { PREOperatorInfo info = item as PREOperatorInfo; row.Tag = info; row.Cells["colOperatorID"].Value = info.OperatorID; row.Cells["colOperatorName"].Value = info.OperatorName; if (info.Role != null) { row.Cells["colRoleID"].Value = info.Role.Name; } row.Cells["colOperatorNum"].Value = info.OperatorNum; }
/// <summary> /// 通过操作员编号获取操作员 /// </summary> /// <param name="optNum"></param> /// <returns></returns> public PREOperatorInfo GetOperatorByOperatorNum(byte optNum) { PREOperatorInfo opt = null; OperatorSearchCondition con = new OperatorSearchCondition(); con.OperatorNum = optNum; List <PREOperatorInfo> opts = GetOperators(con).QueryObjects; if (opts.Count == 1) { opt = opts[0]; } return(opt); }
protected override void ItemShowing() { PREOperatorInfo info = (PREOperatorInfo)UpdatingItem; this.txtOperatorID.Text = info.OperatorID; this.txtOperatorID.Enabled = false; this.txtOperatorID.BackColor = Color.White; this.txtOperatorName.Text = info.OperatorName; this.txtPassword.Text = _subPwd; this.txtPassword.Enabled = false; this.txtPassword.BackColor = Color.White; this.comRoleList.SelectedRoleID = info.RoleID; this.txtOperatorNum.Text = info.OperatorNum.ToString(); this.Text = info.OperatorID; this.comRoleList.Enabled = info.CanEdit; }
/// <summary> /// 用户菜单权限 /// </summary> /// <param name="op"></param> private void ShowOperatorRights(PREOperatorInfo op) { PRERoleInfo role = op.Role; this.mnu_System.Enabled = role.Permit(PREPermission.SystemSetting) || role.Permit(PREPermission.PreferentialCore) || role.Permit(PREPermission.PreferentialCancel); this.mnu_SysOptions.Enabled = role.Permit(PREPermission.SystemSetting); this.mnu_PreferentialInput.Enabled = role.Permit(PREPermission.PreferentialCore); this.mnu_PreferentialCancel.Enabled = role.Permit(PREPermission.PreferentialCancel); this.mnu_Data.Enabled = role.Permit(PREPermission.ReadWorkstations) || role.Permit(PREPermission.EditWorkstations) || role.Permit(PREPermission.ReadBusiness) || role.Permit(PREPermission.EditBusiness); this.mnu_WorkStation.Enabled = role.Permit(PREPermission.ReadWorkstations) || role.Permit(PREPermission.EditWorkstations); this.mnu_Company.Enabled = role.Permit(PREPermission.ReadBusiness) || role.Permit(PREPermission.EditBusiness); //this.mnu_SafeSetting.Enabled = role.Permit(PREPermission.OperatorManager) || role.Permit(PREPermission.RoleManager); this.mnu_Operator.Enabled = role.Permit(PREPermission.OperatorManager); this.mnu_RoleManager.Enabled = role.Permit(PREPermission.RoleManager); this.mnu_Report.Enabled = role.Permit(PREPermission.PreferentialReport); this.mnu_PRERecord.Enabled = role.Permit(PREPermission.PreferentialReport); }
protected override bool DeletingItem(object item) { PREOperatorInfo info = (PREOperatorInfo)item; if (info.OperatorID == "admin") { MessageBox.Show("不能删除管理员!"); return(false); } CommandResult ret = bll.Delete(info); if (ret.Result != ResultCode.Successful) { MessageBox.Show(ret.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(ret.Result == ResultCode.Successful); }
/// <summary> /// 增加操作员,如果操作员编号已被使用,抛出InvalidOperationException /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult Insert(PREOperatorInfo info) { List <PREOperatorInfo> allOpt = GetAllOperators().QueryObjects; if (allOpt.Exists(opt => opt.OperatorID == info.OperatorID)) { throw new InvalidOperationException(string.Format(Resource1.OperatorBll_IDbeUsed, info.OperatorID)); } if (allOpt.Exists(opt => opt.OperatorName == info.OperatorName)) { throw new InvalidOperationException(string.Format(Resource1.OperatorBll_NamebeUsed, info.OperatorName)); } if (info.OperatorNum > 0 && allOpt.Exists(opt => opt.OperatorNum == info.OperatorNum)) { throw new InvalidOperationException(string.Format(Resource1.OperatorBll_NumbeUsed, info.OperatorNum)); } CommandResult ret = provider.Insert(info); return(ret); }
/// <summary> /// 登录验证 /// </summary> public bool Authentication(string logName, string pwd) { PREOperatorInfo info = GetByID(logName).QueryObject; if (info != null) { if (info.OperatorID == logName && info.Password == pwd) { PREOperatorInfo.CurrentOperator = info; return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// 修改操作员,如果操作员编号已被使用,抛出InvalidOperationException /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult Update(PREOperatorInfo info) { List <PREOperatorInfo> allOpt = GetAllOperators().QueryObjects; if (allOpt.Exists(opt => opt.OperatorID != info.OperatorID && opt.OperatorName == info.OperatorName)) { throw new InvalidOperationException(string.Format(Resource1.OperatorBll_NamebeUsed, info.OperatorName)); } if (info.OperatorNum > 0 && allOpt.Exists(opt => opt.OperatorID != info.OperatorID && opt.OperatorNum == info.OperatorNum)) { throw new InvalidOperationException(string.Format(Resource1.OperatorBll_NumbeUsed, info.OperatorNum)); } PREOperatorInfo original = GetByID(info.OperatorID).QueryObject; if (original != null) { return(provider.Update(info, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }