图5-5 修改权限界面
主要实现代码如下:
//修改权限
protected override void radBtnOk_Click(object sender, EventArgs e) {
if (radTxtBoxOldPsw.Text == null || radTxtBoxOldPsw.Text.Trim() == \) {
MessageBox.Show(\请输入用户名!。\, \提醒\, MessageBoxButtons.OK, MessageBoxIcon.Information); return; }
if (radComBoxPower.Text == null || radComBoxPower.Text.Trim() == \) {
MessageBox.Show(\请为用户设置权限!。\, \提醒\, MessageBoxButtons.OK, MessageBoxIcon.Information); return; }
commandUnit com = new commandUnit();
string str = @\ +
radComBoxPower.SelectedValue.ToString() + \ + radTxtBoxOldPsw.Text.ToString() + \;
if (com.ExecuteCommand(str) > 0) {
MessageBox.Show(\权限修改成功!。\, \提醒\, MessageBoxButtons.OK, MessageBoxIcon.Information); } else
{
MessageBox.Show(\权限修改失败,请联系管理员!。\, \提醒\, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
(5) 编辑员工信息界面
管理员成功登录系统后,单击“基本信息管理”菜单的“员工信息”,可以进入“查看员工信息”界面和“编辑员工信息”界面,“查看员工信息”界面只能查看员工信息,“编辑员工信息”界面进行员工信息的修改、添加、删除等功能。编辑员工信息界面如图5-6所示。
图5-6 编辑员工信息界面
主要实现代码如下:
//保存
protected virtual void tSBtnSave_Click(object sender, EventArgs e)
{
try {
if (IsVilude())
{
bool isSuccess = false;
commandUnit com = new commandUnit(); EmployeeModel emp;
for (int j = 0; j < radWithGV.RowCount; j++) {
emp = new EmployeeModel(); #region 同步数据
if (radWithGV.Rows[j].Tag != null) {
emp = radWithGV.Rows[j].Tag as EmployeeModel;
} else {
emp.EmployeeNo =
radWithGV.Rows[j].Cells[\].Value.ToString(); emp.Name =
radWithGV.Rows[j].Cells[\].Value.ToString(); emp.Sex =
radWithGV.Rows[j].Cells[\].Value.ToString(); emp.IdCard =
radWithGV.Rows[j].Cells[\].Value.ToString(); emp.Duty =
radWithGV.Rows[j].Cells[\].Value.ToString(); emp.Note =
radWithGV.Rows[j].Cells[\].Value.ToString(); emp.IsNew = true;
}
#endregion
if (emp.IsNew) {
string str = \where employeeNo = '\ + emp.EmployeeNo + \;
DataTable dtable = com.GetDataSet(str); if (dtable.Rows.Count <= 0) {
str = @\
values('\ + emp.EmployeeNo + \ + emp.Name + \ + emp.Sex + \ + emp.IdCard + \ + emp.Duty + \ + emp.Note + \;
if (com.ExecuteCommand(str) > 0) {
_isSaved = true; isSuccess = true; emp.IsNew = false;
radWithGV.Rows[j].Tag = emp; } } else {
MessageBox.Show(\该员工已存在,请审核信息!\);
} }
else if (emp.IsModified) {
string strSql = @\name = '\ + emp.Name + \= '\ + emp.Sex + \= '\ + emp.IdCard + \
+ emp.Duty + \ + emp.Note + \ + emp.EmployeeNo + \; if (com.ExecuteCommand(strSql) > 0) {
_isSaved = true; isSuccess = true;
emp.IsModified = false;
radWithGV.Rows[j].Tag = emp; }
} else
continue; }
if (isSuccess) {
MessageBox.Show(\保存成功!\); } } else {
MessageBox.Show(\数据非法!\); } }
catch (System.Exception ex) {
throw ex;
} }
(6) 职务信息界面
管理员成功登录系统后,单击“基本信息管理”菜单的“职务信息”,可以进入“职务信息”界面 ,“职务信息”界面进行职务信息的修改、添加、删除等功能。职务信息界面如图5-7所示。
图5-7 职务信息界面
主要实现代码如下:
protected override void tSBtnDelete_Click(object sender, EventArgs e)
{
DutyModel employee = this.radWithGV.CurrentRow.Tag as DutyModel;
if (employee != null) { if (!employee.IsNew)
{commandUnit com = new commandUnit(); string numRow =
radWithGV.CurrentRow.Cells[\].Value.ToString(); string str = \dutyInfo where dutyId
= '\ + numRow + \;
if (com.ExecuteCommand(str) > 0) {
this.radWithGV.Rows.Remove(radWithGV.CurrentRow as GridViewDataRowInfo);
IsSaved = true; } } else {
this.radWithGV.Rows.Remove(radWithGV.CurrentRow as GridViewDataRowInfo); } } }