/// <summary> /// 保存 /// </summary> private void btnSave_Click_1(object sender, EventArgs e) { if (CheckInput()) { if (_currentRolesTable == null) { _currentRolesTable = new BaseRolesTable(); } _currentRolesTable.CODE = txtCode.Text; _currentRolesTable.NAME = txtName.Text; _currentRolesTable.MEMO = txtMemo.Text; _currentRolesTable.LAST_UPDATE_USER = _userInfo.CODE; try { if (bRoles.Exists(txtCode.Text.Trim())) { bRoles.Update(_currentRolesTable); } else { _currentRolesTable.CREATE_USER = _userInfo.CODE; bRoles.Add(_currentRolesTable); } } catch (Exception ex) { MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); } }
private void txtCode_Leave(object sender, EventArgs e) { BaseRolesTable RolesCode = new BaseRolesTable(); RolesCode = bRoles.GetModel(txtCode.Text); if (RolesCode != null) { txtCode.Focus(); txtCode.Text = ""; MessageBox.Show("编号已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 获得当前选中的数据 /// </summary> private void GetCurrentSelectedTable() { try { string code = dgvData.SelectedRows[0].Cells["CODE"].Value.ToString(); if (code != "") { _currentRolesTable = bRoles.GetModel(code); } } catch (Exception ex) { } if (_currentRolesTable == null || _currentRolesTable.CODE == null || "".Equals(_currentRolesTable.CODE)) { _currentRolesTable = null; } }
/// <summary> /// 打开新窗口 /// </summary> private void OpenDialogFrm(int mode) { if (mode == CConstant.MODE_NEW || _currentRolesTable != null) { FrmRolesDialog frm = new FrmRolesDialog(); frm.UserInfo = _userInfo; frm.CurrentRolesTable = _currentRolesTable; frm.Mode = mode; DialogResult resule = frm.ShowDialog(this); if (resule == DialogResult.OK && isSearch) { Search(this.pgControl.GetCurrentPage()); } frm.Dispose(); } else { //MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } _currentRolesTable = null; }
/// <summary> /// 删除 /// </summary> private void MasterToolBar_DoDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK) { try { GetCurrentSelectedTable(); if (_currentRolesTable != null) { bRoles.Delete(_currentRolesTable.CODE); Search(this.pgControl.GetCurrentPage()); } else { MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } _currentRolesTable = null; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BaseRolesTable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(BaseRolesTable model) { return(dal.Add(model)); }