private void LoginButton_Click(object sender, System.EventArgs e) { User user = new User(); string userno=this.txt_Name.Text.Trim(); if (userno == "") { MessageBox.Show("�������û���������Ϣ", "ϵͳ��¼", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { switch (user.UserLogin(userno, this.textBox1.Text.Trim())) { case -2: MessageBox.Show("�û�������,�������������", "ϵͳ��¼", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txt_Name.Focus(); return; case -1: MessageBox.Show("�û��������", "ϵͳ��¼", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.textBox1.Focus(); return; } PSWD pswd = PSWD.GetById("0000", userno); LoginUser lguser = new LoginUser(pswd); AttnObjects.PSWD.LoginUser = pswd; LoginService.LoginUser = lguser; SetQxMod(); if (isLogin) { WorkbenchSingleton.Workbench.RedrawAllComponents(); } this.DialogResult = DialogResult.OK; isLogin = true; PropertyService.Set<string>("PrvLoginName", userno); this.DialogResult = DialogResult.OK; } }
private void Frm_Data_Load(object sender, EventArgs e) { User user = new User(); DataSet allUser = user.GetAllUser(); this.Lvw_User.Items.Clear(); this.lbx_User.Items.Clear(); for (int i = 0; i < allUser.Tables[0].Rows.Count; i++) { ListViewItem item = new ListViewItem { Text = allUser.Tables[0].Rows[i]["UserName"].ToString() }; item.SubItems.Add(allUser.Tables[0].Rows[i]["TrueName"].ToString()); item.SubItems.Add(allUser.Tables[0].Rows[i]["Duty"].ToString()); item.SubItems.Add(allUser.Tables[0].Rows[i]["BarCode"].ToString()); this.Lvw_User.Items.Add(item); this.lbx_User.Items.Add(item.Text.Trim()); } allUser = user.GetAllAuthority(); this.lvw_Authority.Items.Clear(); for (int j = 0; j < allUser.Tables[0].Rows.Count; j++) { ListViewItem item2 = new ListViewItem { Text = allUser.Tables[0].Rows[j]["CodeName"].ToString(), Tag = allUser.Tables[0].Rows[j]["Code"].ToString() }; this.lvw_Authority.Items.Add(item2); } foreach (string str in PrinterSettings.InstalledPrinters) { this.cbx_SendListPrinter.Items.Add(str); this.cbx_SendPrinter.Items.Add(str); } this.cbx_SendPrinter.Text = Invoice.GetSendPrinter(); this.cbx_SendListPrinter.Text = Invoice.GetSendListPrinter(); this.tbx_UName.Text = User.UserName; if (!User.IsHaveAuthority("用户管理")) { this.tabControl.TabPages.Remove(this.tabPage1); } if (!User.IsHaveAuthority("权限设定")) { this.tabControl.TabPages.Remove(this.tabPage2); } if (!User.IsHaveAuthority("修改密码")) { this.tabControl.TabPages.Remove(this.tabPage3); } if (!User.IsHaveAuthority("选项设置")) { this.tabControl.TabPages.Remove(this.tabPage4); } MbTask task = new MbTask(); this.tbx_BoxAmount.Text = task.GetBoxCapability().ToString(); }
private void lbx_User_SelectedIndexChanged(object sender, EventArgs e) { DataSet userAllAuthority = new User().GetUserAllAuthority(this.lbx_User.SelectedItem.ToString()); foreach (ListViewItem item in this.lvw_Authority.Items) { item.Checked = false; for (int i = 0; i < userAllAuthority.Tables[0].Rows.Count; i++) { if (item.Tag.ToString() == userAllAuthority.Tables[0].Rows[i]["Code"].ToString()) { item.Checked = true; } } } }
private void btn_SetAuthority_Click(object sender, EventArgs e) { User user = new User(); if (this.lbx_User.SelectedItem.ToString().ToUpper() == "ADMIN") { MessageBox.Show("系统管理员无法更改其权限", "设置权限", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { foreach (ListViewItem item in this.lvw_Authority.Items) { user.UpdateUserAuthority(this.lbx_User.SelectedItem.ToString(), item.Tag.ToString(), !item.Checked); } MessageBox.Show("权限设置成功", "设置权限", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void btn_Modi_Click(object sender, EventArgs e) { if (((this.tbx_UserName.Text == "") || (this.tbx_Pwd.Text == "")) || (this.tbx_ConfirmPwd.Text == "")) { MessageBox.Show("请填写用户名和密码", "修改用户", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (this.tbx_Pwd.Text != this.tbx_ConfirmPwd.Text) { MessageBox.Show("两次密码输入不一致", "添加用户", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { User user = new User(); if (user.ModiUser(this.tbx_UserName.Text.Trim(), this.tbx_Pwd.Text.Trim(), this.tbx_TrueName.Text.Trim(), this.tbx_Duty.Text.Trim(), this.tbx_BarCode.Text.Trim())) { MessageBox.Show("用户修改成功", "修改用户", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.tbx_UserName.Text = ""; this.tbx_Pwd.Text = ""; this.tbx_ConfirmPwd.Text = ""; this.tbx_TrueName.Text = ""; this.tbx_Duty.Text = ""; this.Frm_Data_Load(this, new EventArgs()); } else { MessageBox.Show("用户修改失败", "修改用户", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } }
private void btn_ModiPwd_Click(object sender, EventArgs e) { if (this.tbx_OldPwd.Text.Trim() == "") { MessageBox.Show("请输入用户原密码", "修改密码", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (this.tbx_NewPwd.Text.Trim() == "") { MessageBox.Show("请输入新密码", "修改密码", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (this.tbx_NewPwd.Text.Trim() != this.tbx_ConfirmNewPwd.Text.Trim()) { MessageBox.Show("两次密码输入不一致", "修改密码", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { User user = new User(); if (user.UserLogin(User.UserName, this.tbx_OldPwd.Text.Trim()) == 1) { if (user.ModiPwd(this.tbx_NewPwd.Text.Trim())) { MessageBox.Show("密码修改成功", "修改密码", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("用户原密码错误", "修改密码", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void btn_Delete_Click(object sender, EventArgs e) { if (this.Lvw_User.SelectedItems.Count > 0) { if (this.Lvw_User.SelectedItems[0].Text.Trim().ToUpper() == "ADMIN") { MessageBox.Show("系统管理员不能删除", "删除用户", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } User user = new User(); if (MessageBox.Show("确定删除此用户" + this.Lvw_User.SelectedItems[0].Text.Trim() + "吗?", "删除用户", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (user.DeleteUser(this.Lvw_User.SelectedItems[0].Text.Trim())) { MessageBox.Show("用户删除成功", "删除用户", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("用户删除失败", "删除用户", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } this.Frm_Data_Load(this, new EventArgs()); }
private void OK_Click(object sender, EventArgs e) { User user = new User(); if ((this.tbxUserName.Text.Trim() == "") || (this.tbxPassword.Text.Trim() == "")) { MessageBox.Show("请输入用户的完整信息", "系统登录", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { switch (user.UserLogin(this.tbxUserName.Text.Trim(), this.tbxPassword.Text.Trim())) { case -2: MessageBox.Show("用户不存在,请检查后重新输入", "系统登录", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tbxUserName.Focus(); return; case -1: MessageBox.Show("用户密码错误", "系统登录", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tbxPassword.Focus(); return; } base.Hide(); new Frm_Main().Show(); } }