public SystemManageEditForm(SystemManage sys) { InitializeComponent(); init(); Id = sys.Id; SystemManage sm = sys; //编辑,根据id取出原来的数据,显示出来 textEdit_userName.Text = sm.UserName; textEdit_password.Text = sm.Password ; textEdit_name.Text = sm.Name; textEdit_IDCard.Text = sm.IdCard; comboBoxEdit_type.SelectedIndex = smService.getIndex(sm.Type); //不可修改用户名 textEdit_userName.Properties.ReadOnly = true; }
private void simpleButton_add_Click(object sender, EventArgs e) { SystemManage sm = new SystemManage(); sm.UserName = textEdit_userName.Text; sm.Password = textEdit_password.Text; sm.Name = textEdit_name.Text; sm.IdCard = textEdit_IDCard.Text; if (String.IsNullOrEmpty(sm.UserName)) { MessageBox.Show("用户名不能为空!", "提示"); return; } if (smService.findRowByIdAndName(id, sm.UserName)) { MessageBox.Show("用户名已重复!", "提示"); return; } if (String.IsNullOrEmpty(sm.Password)) { MessageBox.Show("密码不能为空!", "提示"); return; } if (String.IsNullOrEmpty(sm.Name)) { MessageBox.Show("姓名不能为空!", "提示"); return; } if (String.IsNullOrEmpty(sm.IdCard)) { MessageBox.Show("证件号不能为空!", "提示"); return; } if (comboBoxEdit_type.SelectedIndex == -1 || comboBoxEdit_type.SelectedIndex == 0) { MessageBox.Show("请选择类型!", "提示"); return; } sm.Type = (smService.getTypes())[comboBoxEdit_type.SelectedIndex].Key; sm.Id = Id; //保存 if (Id == 0 && smService.addRow(sm) == true) { MessageBox.Show("保存成功!", "提示"); LogService.getInstance().log("新增,用户名为" + sm.UserName, ModuleConstant.SystemManage_MODULE); this.Close(); } //编辑 else if (Id != 0 && smService.modifyRow(sm) == true) { MessageBox.Show("保存成功!", "提示"); LogService.getInstance().log("修改,用户名为" + sm.UserName, ModuleConstant.SystemManage_MODULE); this.Close(); } else { MessageBox.Show("保存失败!", "提示"); } }
public Boolean addRow(SystemManage systemManage) { try { ICustomsCMS server = XmlRpcInstance.getInstance(); Usercheck usercheck = new Usercheck(); usercheck.idcard = systemManage.IdCard; usercheck.password = systemManage.Password; usercheck.realname = systemManage.Name; usercheck.username = systemManage.UserName; usercheck.rolename = systemManage.Type.ToString(); DBRPCResponse dBRPCResponse = server.AddUser(usercheck); return true; } catch (Exception ex) { throw new Exception("错误:" + ex.Message); } }
private void simpleButton_modify_Click(object sender, EventArgs e) { if (gridView.SelectedRowsCount != 1) { MessageBox.Show("请选择一条记录!","警告"); return; } //获取选中的行的行号 int[] rowNums = gridView.GetSelectedRows(); DataTable dt = (DataTable)gridControl.DataSource; SystemManage sys = new SystemManage(); sys.Id = Int32.Parse(dt.Rows[rowNums[0]][SystemManage.ID_COLUMN].ToString()); sys.UserName = dt.Rows[rowNums[0]][SystemManage.USERNAME_COLUMN].ToString(); sys.Password = dt.Rows[rowNums[0]][SystemManage.PASSWORD_COLUMN].ToString(); sys.Type = Int32.Parse(dt.Rows[rowNums[0]][SystemManage.TYPE_COLUMN].ToString()); sys.TypeName = dt.Rows[rowNums[0]][SystemManage.TYPENAME_COLUMN].ToString(); sys.Name = dt.Rows[rowNums[0]][SystemManage.NAME_COLUMN].ToString(); sys.IdCard = dt.Rows[rowNums[0]][SystemManage.IDCARD_COLUMN].ToString(); SystemManageEditForm systemManageEditForm = new SystemManageEditForm(sys); systemManageEditForm.ShowDialog(); pageUpControl.GetDataTable(); }