private void Dgv_ManageList_SelectionChanged(object sender, EventArgs e) { if (dgv_ManageList.SelectedRows.Count == 0) { return; } int index = 0; CbManageInfo mManageInfo = FormComm.GetDataSourceToClass <CbManageInfo>(dgv_ManageList, ref index); if (mManageInfo.ManageType == 0) { btn_Del.Enabled = false; btn_Edit.Enabled = false; btn_ChangePassword.Enabled = Dal_ManageInfo.ManageInfo.ManageType == 0; btn_Jurisdiction.Enabled = false; } else if (mManageInfo.ID == Dal_ManageInfo.ManageInfo.ID) { btn_Del.Enabled = false; btn_ChangePassword.Enabled = true; btn_Edit.Enabled = true; btn_Jurisdiction.Enabled = false; } else { btn_Del.Enabled = Dal_ManageRights.ManageRights.SetUserManagementToDelete; btn_Edit.Enabled = Dal_ManageRights.ManageRights.SetUserManagemenetEditor; btn_ChangePassword.Enabled = Dal_ManageInfo.ManageInfo.ManageType == 0; btn_Jurisdiction.Enabled = Dal_ManageRights.ManageRights.SetUserAdministrationRights; } }
public JurisdictionSettings_Form(CbManageInfo mManageInfo) { InitializeComponent(); _mManageInfo = mManageInfo; this.Load += JurisdictionSettings_Load; this.Shown += JurisdictionSettings_Form_Shown; this.KeyDown += JurisdictionSettings_Form_KeyDown; cb_AllSelected.CheckedChanged += Cb_AllSelected_CheckedChanged; cb_AllSelected.MouseDown += Cb_AllSelected_MouseDown; tv_DataList.AfterCheck += Tv_DataList_AfterCheck; tv_DataList.NodeMouseClick += Tv_DataList_NodeMouseClick; btn_Enter.Click += Btn_Enter_Click; }
private void Btn_Edit_Click(object sender, EventArgs e) { int index = 0; CbManageInfo mManageInfo = FormComm.GetDataSourceToClass <CbManageInfo>(dgv_ManageList, ref index); using (EditManager_Form editmanage = new EditManager_Form(mManageInfo)) { if (editmanage.ShowDialog() != DialogResult.OK) { return; } mManageInfo = editmanage.Tag as CbManageInfo; FormComm.UpdateDgvDataSource <CbManageInfo>(mManageInfo, dgv_ManageList, index); } }
private void Btn_ChangePassword_Click(object sender, EventArgs e) { int index = 0; CbManageInfo mManageInfo = FormComm.GetDataSourceToClass <CbManageInfo>(dgv_ManageList, ref index); using (ChangePassword_Form changepassword = new ChangePassword_Form(mManageInfo)) { if (changepassword.ShowDialog() != DialogResult.OK) { return; } mManageInfo = changepassword.Tag as CbManageInfo; FormComm.UpdateDgvDataSource <CbManageInfo>(mManageInfo, dgv_ManageList, index); } }
private void Btn_Jurisdiction_Click(object sender, EventArgs e) { int index = 0; CbManageInfo mManageInfo = FormComm.GetDataSourceToClass <CbManageInfo>(dgv_ManageList, ref index); using (JurisdictionSettings_Form jurisdiction = new JurisdictionSettings_Form(mManageInfo)) { if (jurisdiction.ShowDialog() != DialogResult.OK) { return; } GetManageInfo(); dgv_ManageList.Rows[index].Selected = true; } }
public EditManager_Form(CbManageInfo mManageInfo) { InitializeComponent(); this._mManageInfo = mManageInfo; this.Load += AddManager_Form_Load; this.KeyDown += EditManager_Form_KeyDown; l_AccountsTitle.MouseDown += L_AccountsTitle_MouseDown; tb_Accounts.TextChanged += Tb_Accounts_TextChanged; l_NameTitle.MouseDown += L_NameTitle_MouseDown; tb_Name.TextChanged += Tb_Name_TextChanged; tb_Name.KeyPress += Tb_Name_KeyPress; btn_Enter.Click += Btn_Enter_Click; }
private void Btn_Enter_Click(object sender, EventArgs e) { string account = tb_Accounts.Text.Trim(); string password = tb_Password.Text.Trim(); if (account.Length == 0) { l_AccountsTitle.Text = "帐号不能为空"; l_AccountsTitle.ForeColor = Color.Red; tb_Accounts.Focus(); return; } //if (password.Length == 0) //{ // l_PasswordTitle.Text = "密码不能为空"; // l_PasswordTitle.ForeColor = Color.Red; // tb_Password.Focus(); // return; //} try { CbManageInfo Manage = Dal_ManageInfo.GetManage(account, password); if (Manage == null) { MessageBox.Show("帐号或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (account != Dal_SysSettings.SystemSettings.ManageAccount || cb_RecordPassword.Checked != Dal_SysSettings.SystemSettings.IsSavePassword || password != Dal_SysSettings.SystemSettings.ManagePassword) { Dal_SysSettings.SystemSettings.ManageAccount = account; Dal_SysSettings.SystemSettings.IsSavePassword = cb_RecordPassword.Checked; Dal_SysSettings.SystemSettings.ManagePassword = password; XmlHelper.Update <CbSysSettings>(Dal_SysSettings.SystemSettings); } Dal_ManageInfo.ManageInfo = Manage; Dal_ManageRights.ManageRights = Dbhelper.Db.FirstDefault <CbManageRights>(" and UserId=" + Manage.ID); this.DialogResult = DialogResult.OK; } catch (Exception ex) { CustomExceptionHandler.GetExceptionMessage(ex); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ChangePassword_Form(CbManageInfo mManageInfo) { InitializeComponent(); this.Load += ChangePassword_Form_Load; this.KeyDown += ChangePassword_Form_KeyDown; _mManageInfo = mManageInfo; l_OldTitle.MouseDown += L_OldTitle_MouseDown; tb_OldPassword.TextChanged += Tb_OldPassword_TextChanged; tb_OldPassword.KeyPress += Tb_OldPassword_KeyPress; l_NewTitle.MouseDown += L_NewTitle_MouseDown; tb_NewPassword.TextChanged += Tb_NewPassword_TextChanged; tb_NewPassword.KeyPress += Tb_NewPassword_KeyPress; l_ConfirmTitle.MouseDown += L_ConfirmTitle_MouseDown; tb_ConfirmPassword.TextChanged += Tb_ConfirmPassword_TextChanged; tb_ConfirmPassword.KeyPress += Tb_ConfirmPassword_KeyPress; btn_Enter.Click += Btn_Enter_Click; }
private void Btn_Del_Click(object sender, EventArgs e) { int index = 0; CbManageInfo mManageInfo = FormComm.GetDataSourceToClass <CbManageInfo>(dgv_ManageList, ref index); if (MessageBox.Show("确认删除管理员:" + mManageInfo.UserName + "", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK) { return; } try { Dbhelper.Db.Del <CbManageInfo>(mManageInfo.ID); Dbhelper.Db.Del <CbManageRights>(" and UserID=" + mManageInfo.ID); DataTable dt = dgv_ManageList.DataSource as DataTable; dt.Rows.RemoveAt(index); dgv_ManageList.Rows[0].Selected = true; } catch (Exception ex) { CustomExceptionHandler.GetExceptionMessage(ex); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Btn_Enter_Click(object sender, EventArgs e) { string account = tb_Accounts.Text.Trim(); string name = tb_Name.Text.Trim(); string password = tb_Password.Text.Trim(); string confirmpassword = tb_ConfirmPassword.Text.Trim(); int index = cb_ManageType.SelectedIndex; if (account.Length == 0) { //l_AccountsTitle.Text = "帐号不能为空"; l_AccountsTitle.ForeColor = Color.Red; tb_Accounts.Focus(); return; } if (account.Length < 6) { MessageBox.Show("帐号长度不能小于 6 位,请重新输入。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tb_Accounts.Focus(); tb_Accounts.SelectionStart = tb_Accounts.TextLength; return; } if (name.Length == 0) { //l_NameTitle.Text = "用户名称不能为空"; l_NameTitle.ForeColor = Color.Red; tb_Name.Focus(); return; } if (password.Length == 0) { //l_PasswordTitle.Text = "密码不能为空"; l_PasswordTitle.ForeColor = Color.Red; tb_Password.Focus(); return; } if (password.Length < 6) { MessageBox.Show("密码长度不能小于 6 位,请重新输入。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tb_Password.Focus(); tb_Password.SelectionStart = tb_Password.TextLength; return; } if (confirmpassword.Length == 0) { //l_ConfrimTitle.Text = "确认密码不能为空"; l_ConfrimTitle.ForeColor = Color.Red; tb_ConfirmPassword.Focus(); return; } if (confirmpassword.Length < 6) { MessageBox.Show("确认密码长度不能小于 6 位,请重新输入。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tb_ConfirmPassword.Focus(); tb_ConfirmPassword.SelectionStart = tb_ConfirmPassword.TextLength; return; } if (password != confirmpassword) { MessageBox.Show("密码与确认密码不一致,请重新输入。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tb_ConfirmPassword.Focus(); tb_ConfirmPassword.SelectionStart = tb_ConfirmPassword.TextLength; return; } try { int count = Dbhelper.Db.GetCount <CbManageInfo>("ManageName", string.Format(" and ManageName='{0}' ", account)); if (count > 0) { MessageBox.Show(string.Format("{0} 已经存在", account), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tb_Accounts.Focus(); tb_Accounts.SelectionStart = tb_Accounts.TextLength; return; } CbManageInfo mManageInfo = new CbManageInfo() { ManageName = account, ManagePwd = password, ManageType = index + 1, UserName = name }; mManageInfo.ID = Dbhelper.Db.Insert <CbManageInfo>(mManageInfo); //添加权限 CbManageRights mManageRights = new CbManageRights() { UserID = mManageInfo.ID }; PropertyInfo[] pinfos = typeof(CbManageRights).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (PropertyInfo item in pinfos) { if (item.PropertyType == typeof(Boolean)) { item.SetValue(mManageRights, true, null); } } Dbhelper.Db.Insert <CbManageRights>(mManageRights); this.DialogResult = DialogResult.OK; } catch (Exception ex) { CustomExceptionHandler.GetExceptionMessage(ex); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }