using AIMSBLL; using AIMSModel; using DataDictionary; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace AIMS.PublicUI.UI { public partial class frmUserPurview : Form { public AIMSExtension.EditState _state; private Role RoleRowData; public frmUserPurview() { InitializeComponent(); } private void tsbExit_Click(object sender, EventArgs e) { Close(); } private void frmUserPurview_Load(object sender, EventArgs e) { ControlExtension.SetDgvAttribute(dgvUserPurview); ControlExtension.EnabledControl(panel2, false); _state = AIMSExtension.EditState.BROWSE; dgvUserPurview.DataSource = BRole.GetDataTable(); } private void tsbAdd_Click(object sender, EventArgs e) { ControlExtension.EnabledControl(panel2, true); ControlExtension.ClearControl(panel2); _state = AIMSExtension.EditState.ADD; } private void tsbCancel_Click(object sender, EventArgs e) { ControlExtension.EnabledControl(panel2, false); ControlExtension.ClearControl(panel2); _state = AIMSExtension.EditState.BROWSE; } private void tsbModify_Click(object sender, EventArgs e) { if (dgvUserPurview.Rows.Count > 0) { ControlExtension.EnabledControl(panel2, true); _state = AIMSExtension.EditState.EDIT; RoleRowData = BRole.GetModel(int.Parse(dgvUserPurview.CurrentRow.Cells["Id"].Value.ToString())); txtRoleName.Text = RoleRowData.RoleName; if (RoleRowData.IsValid == 1) { chkIsValid.Checked = true; } else { chkIsValid.Checked = false; } } } private void tsbSava_Click(object sender, EventArgs e) { if (this.ValidInput()) { Role RoleObj = new Role(); RoleObj.RoleName = txtRoleName.Text.Trim(); RoleObj.IsValid = System.Convert.ToInt32(chkIsValid.Checked ? "1" : "0"); RoleObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo; RoleObj.OperatorName = AIMSExtension.PublicMethod.OperatorName; RoleObj.OperateDate = AIMSExtension.PublicMethod.SystemDate(); if (_state == AIMSExtension.EditState.ADD) { BRole.Add(RoleObj); } if (this._state == AIMSExtension.EditState.EDIT) { if (dgvUserPurview.Rows.Count > 0) { RoleObj.Id= RoleRowData.Id; BRole.Update(RoleObj); ControlExtension.ClearControl(panel2); this._state = AIMSExtension.EditState.BROWSE; } } } ControlExtension.EnabledControl(panel2, false); ControlExtension.ClearControl(panel2); dgvUserPurview.DataSource = BRole.GetDataTable(); } private bool ValidInput() { bool result = false; if (this.txtRoleName.Text.Trim().Length < 1) { MessageBox.Show("请输入名称!"); } else { result = true; } return result; } private void dgvUserPurview_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (this.dgvUserPurview.Columns[e.ColumnIndex].Name == "OperatorColumn") { frmUserPurviewDetail frmUserPurviewDetail = new frmUserPurviewDetail(); frmUserPurviewDetail.RoleId = System.Convert.ToInt32(this.dgvUserPurview.SelectedRows[0].Cells["Id"].Value); frmUserPurviewDetail.RoleName = this.dgvUserPurview.SelectedRows[0].Cells["RoleName"].Value.ToString(); frmUserPurviewDetail.ShowDialog(); } } } }