using AIMS; using AIMSBLL; using AIMSModel; using System; using System.Windows.Forms; namespace DataDictionary.UI { public partial class frmPatientKind : Form { public AIMSExtension.EditState _state; private int SelectPatientKindRowId = 0; public frmPatientKind() { InitializeComponent(); } private void frmPatientKind_Load(object sender, EventArgs e) { ControlExtension.SetDgvAttribute(dgvPatientKind); ControlExtension.EnabledControl(panel1, false); ControlExtension.ClearControl(panel1); _state = AIMSExtension.EditState.BROWSE; dgvPatientKind.DataSource = BPatientKind.GetDataTable(); } private void tsbAdd_Click(object sender, EventArgs e) { _state = AIMSExtension.EditState.ADD; PatientKind PatientKindObj = new PatientKind(); ControlExtension.EnabledControl(panel1, true); ControlExtension.ClearControl(panel1); chkIsValid.Checked = true; } private void tsbModify_Click(object sender, EventArgs e) { _state = AIMSExtension.EditState.EDIT; ControlExtension.EnabledControl(panel1, false); txtHelpCode.Enabled = true; chkIsValid.Enabled = true; if (dgvPatientKind.Rows.Count > 0) { SelectPatientKindRowId = int.Parse(dgvPatientKind.CurrentRow.Cells["Id"].Value.ToString()); txtNo.Text = dgvPatientKind.CurrentRow.Cells["No"].Value.ToString(); txtName.Text = dgvPatientKind.CurrentRow.Cells["NameColumn"].Value.ToString(); txtHelpCode.Text = dgvPatientKind.CurrentRow.Cells["HelpCode"].Value.ToString(); if (dgvPatientKind.CurrentRow.Cells["IsValid"].Value.ToString() == "有效") { chkIsValid.Checked = true; } else { chkIsValid.Checked = false; } } } private void tsbCancel_Click(object sender, EventArgs e) { _state = AIMSExtension.EditState.BROWSE; ControlExtension.EnabledControl(panel1, false); ControlExtension.ClearControl(panel1); } private void tsbSava_Click(object sender, EventArgs e) { if (this.ValidInput()) { PatientKind PatientKindObj = new PatientKind(); PatientKindObj.No = txtNo.Text.Trim(); PatientKindObj.Name = txtName.Text.Trim(); PatientKindObj.HelpCode = txtHelpCode.Text; PatientKindObj.IsValid = int.Parse(chkIsValid.Checked ? "1" : "0"); PatientKindObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo; PatientKindObj.OperatorName = AIMSExtension.PublicMethod.OperatorName; PatientKindObj.OperateDate = AIMSExtension.PublicMethod.SystemDate(); if (_state == AIMSExtension.EditState.ADD) { if (BPatientKind.IsExit(txtNo.Text.Trim())) { MessageBox.Show("该事件已存在"); return; } if (BPatientKind.NameExit(txtName.Text.Trim())) { MessageBox.Show("该事件已存在"); return; } BPatientKind.Add(PatientKindObj); } if (_state == AIMSExtension.EditState.EDIT) { PatientKindObj.Id = SelectPatientKindRowId; BPatientKind.Update(PatientKindObj); } } } private bool ValidInput() { bool result = false; if (this.txtNo.Text.Trim().Length < 1) { MessageBox.Show("请输入名称!"); } else if (txtName.Text.Trim().Length < 1) { MessageBox.Show("事件不能为空!"); } else { result = true; } return result; } private void tsbExit_Click(object sender, EventArgs e) { _state = AIMSExtension.EditState.BROWSE; ControlExtension.EnabledControl(panel1, false); ControlExtension.ClearControl(panel1); } private void tsbExit_Click_1(object sender, EventArgs e) { Close(); } private void txtName_TextChanged(object sender, EventArgs e) { txtHelpCode.Text = AIMSExtension.PublicMethod.GetFirstLetter(txtName.Text); } } }