/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_Add_Click(object sender, EventArgs e) { Users model = null; if (_userID > 0) { //不修改用户密码 model = _usersBll.GetModel(_userID); model.UserAccount = textBox_UserAccount.Text; model.UserName = textBox_UserName.Text; model.Sex = radioButton_Man.Checked ? 0 : 1; model.Birthday = Convert.ToDateTime(dateTimePicker__Birthday.Text); model.Phone = textBox_Phone.Text; model.Email = textBox_Email.Text; model.EmployeeID = textBox_EmployeeID.Text; model.DepartmentID = 1; model.UserType = CommonClass.GetUserType(Convert.ToInt32(((ListItem)comboBox_UserType.SelectedItem).Value)); model.Remark = textBox_Remark.Text; //修改 if (_usersBll.EditModel(model) > 0) { MessageBox.Show("修改成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("修改失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { model = new Users(); model.UserAccount = textBox_UserAccount.Text; //加密 model.Password = _usersBll.GetMD5(textBox_Password.Text); model.UserName = textBox_UserName.Text; model.Sex = radioButton_Man.Checked ? 0 : 1; model.Birthday = Convert.ToDateTime(dateTimePicker__Birthday.Text); model.Phone = textBox_Phone.Text; model.Email = textBox_Email.Text; model.EmployeeID = textBox_EmployeeID.Text; model.DepartmentID = 1; model.UserType = CommonClass.GetUserType(Convert.ToInt32(((ListItem)comboBox_UserType.SelectedItem).Value)); //查询服务器时间 model.EntryDate = _usersBll.GetDBTime(); model.Remark = textBox_Remark.Text; //添加 if (_usersBll.AddModel(model) > 0) { MessageBox.Show("添加成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("添加失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// 重置密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewButtonColumn_Reset_Click(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { int userID = Convert.ToInt32(dataGridView_Users.Rows[e.RowIndex].Cells["UserID"].Value); Users model = _userBll.GetModel(userID); model.Password = _userBll.GetMD5("123456"); if (_userBll.EditModel(model) > 0) { MessageBox.Show("操作成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("操作失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }