177 lines
6.5 KiB
C#
177 lines
6.5 KiB
C#
using AIMSBLL;
|
|
using AIMSModel;
|
|
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 frmDepartment : Form
|
|
{
|
|
public AIMSExtension.EditState _state;
|
|
private Department SelectDepartmentRow = new Department();
|
|
public frmDepartment()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
|
|
private void frmDepartment_Load(object sender, EventArgs e)
|
|
{
|
|
ControlExtension.SetDgvAttribute(dgvDepartment);
|
|
ControlExtension.EnabledControl(panel1, false);
|
|
ControlExtension.ClearControl(panel1);
|
|
intDepOrder.Text = "0";
|
|
GetDepartmentDataTable();
|
|
}
|
|
private void tsbAdd_Click(object sender, EventArgs e)
|
|
{
|
|
_state = AIMSExtension.EditState.ADD;
|
|
ControlExtension.EnabledControl(panel1, true);
|
|
ControlExtension.ClearControl(panel1);
|
|
}
|
|
|
|
private void tsbModify_Click(object sender, EventArgs e)
|
|
{
|
|
_state = AIMSExtension.EditState.EDIT;
|
|
ControlExtension.EnabledControl(panel1, true);
|
|
if (dgvDepartment.Rows.Count > 0)
|
|
{
|
|
SelectDepartmentRow.Id = int.Parse(dgvDepartment.CurrentRow.Cells["Id"].Value.ToString());
|
|
|
|
cboKind.Text = dgvDepartment.CurrentRow.Cells["KindColumn"].Value.ToString();
|
|
txtName.Text = dgvDepartment.CurrentRow.Cells["NameColumn"].Value.ToString();
|
|
txtHelpCode.Text = dgvDepartment.CurrentRow.Cells["HelpCodeColumn"].Value.ToString();
|
|
if (dgvDepartment.CurrentRow.Cells["IsValidColumn"].Value.ToString() == "有效")
|
|
{
|
|
chkIsValid.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
chkIsValid.Checked = false;
|
|
}
|
|
|
|
cboKind.Text = dgvDepartment.CurrentRow.Cells["KindColumn"].Value.ToString();
|
|
|
|
txtDepAddress.Text = dgvDepartment.CurrentRow.Cells["DepAddressColumn"].Value.ToString();
|
|
|
|
chkIsClinic.Text =dgvDepartment.CurrentRow.Cells["ClinicColumn"].Value.ToString();
|
|
if (dgvDepartment.CurrentRow.Cells["HospitalColumn"].Value.ToString() == "是")
|
|
{
|
|
chkIsHospital.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
chkIsHospital.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())
|
|
{
|
|
Department DepartmentObj = new Department();
|
|
DepartmentObj.Name = txtName.Text.Trim();
|
|
DepartmentObj.HelpCode = AIMSExtension.PublicMethod.GetFirstLetter(txtName.Text.Trim());
|
|
DepartmentObj.Kind = cboKind.Text;
|
|
DepartmentObj.Clinic = int.Parse(chkIsClinic.Text);
|
|
DepartmentObj.Hospital = int.Parse(chkIsHospital.Checked ? "1" : "0");
|
|
DepartmentObj.DepAddress = txtDepAddress.Text.Trim();
|
|
DepartmentObj.DepOrder = int.Parse(intDepOrder.Text);
|
|
DepartmentObj.IsValid = int.Parse(chkIsValid.Checked ? "1" : "0");
|
|
DepartmentObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
DepartmentObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
DepartmentObj.OperateDate = DateTime.Now;
|
|
|
|
if (_state == AIMSExtension.EditState.ADD)
|
|
{
|
|
BDepartment.Add(DepartmentObj);
|
|
}
|
|
if (_state == AIMSExtension.EditState.EDIT)
|
|
{
|
|
DepartmentObj.Id = SelectDepartmentRow.Id;
|
|
BDepartment.Update(DepartmentObj);
|
|
}
|
|
}
|
|
_state = AIMSExtension.EditState.BROWSE;
|
|
ControlExtension.EnabledControl(panel1, false);
|
|
ControlExtension.ClearControl(panel1);
|
|
// dgvDepartment.DataSource = BLL.Department.GetDepartmentDataTable("");
|
|
GetDepartmentDataTable();
|
|
}
|
|
private bool ValidInput()
|
|
{
|
|
bool result = false;
|
|
|
|
if (this.txtName.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("请输入名称!");
|
|
}
|
|
else if (cboKind.Text.Trim().Length<1)
|
|
{
|
|
MessageBox.Show("科室性质不能为空!");
|
|
}
|
|
else
|
|
{
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
private void tsbExit_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void txtName_TextChanged(object sender, EventArgs e)
|
|
{
|
|
txtHelpCode.Text = AIMSExtension.PublicMethod.GetFirstLetter(txtName.Text.Trim());
|
|
}
|
|
private void GetDepartmentDataTable()
|
|
{
|
|
dgvDepartment.Rows.Clear();
|
|
DataTable dt = BDepartment.GetDepartmentDataTable("");
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
dgvDepartment.Rows.Add(dt.Rows[i]["Id"].ToString(),
|
|
dt.Rows[i]["Name"].ToString(),
|
|
dt.Rows[i]["HelpCode"].ToString(),
|
|
dt.Rows[i]["Kind"].ToString(),
|
|
dt.Rows[i]["Clinic"].ToString(),
|
|
dt.Rows[i]["Hospital"].ToString(),
|
|
dt.Rows[i]["DepOrder"].ToString(),
|
|
dt.Rows[i]["DepAddress"].ToString(),
|
|
dt.Rows[i]["IsValid"].ToString());
|
|
dgvDepartment.Rows[i].Cells["Id"].Selected = false;
|
|
}
|
|
if (dgvDepartment.Rows.Count > 0)
|
|
{
|
|
dgvDepartment.ClearSelection();
|
|
dgvDepartment.Rows[0].Selected = false;
|
|
dgvDepartment.Rows[dgvDepartment.Rows.Count - 1].Selected = true;
|
|
dgvDepartment.CurrentCell = this.dgvDepartment.Rows[dgvDepartment.Rows.Count - 1].Cells[1];
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|