306 lines
14 KiB
C#
306 lines
14 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 frmPerson : Form
|
|
{
|
|
public AIMSExtension.EditState _state;
|
|
private Person SelectPerson = new Person();
|
|
public List<Department> listNew = new List<Department>();
|
|
public List<Department> listOnit = new List<Department>();
|
|
public frmPerson()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void frmPerson_Load(object sender, EventArgs e)
|
|
{
|
|
AIMSExtension.PublicMethod.SetDgvAttribute(dgvPerson);
|
|
AIMSExtension.PublicMethod.EnabledControl(panel1, false);
|
|
Initial();
|
|
intPersonOrder.Text = "0";
|
|
GetPersonDataTable("", "");
|
|
}
|
|
|
|
private void Initial()
|
|
{
|
|
listOnit = BDepartment.Select("IsValid=1 ", new ParameterList(), RecursiveType.None, 0);
|
|
listOnit.Insert(0, new Department() { Id = -1, Name = "全部科室" });
|
|
this.cboDepartment.Items.AddRange(listOnit.ToArray());
|
|
cboDepartment.ValueMember = "Id";
|
|
cboDepartment.DisplayMember = "Name";
|
|
cboDepartment.Text = "全部科室";
|
|
cboDepartment.Enabled = true;
|
|
|
|
cboRole.DisplayMember = "RoleName";
|
|
cboRole.ValueMember = "Id";
|
|
cboRole.DataSource = BRole.GetDataTable();
|
|
cboRole.SelectedIndex = -1;
|
|
|
|
cboDiploma.DisplayMember = "Name";
|
|
cboDiploma.ValueMember = "Id";
|
|
cboDiploma.DataSource = BBasicDictionary.GetDataDictionaryDataTable(" ParentId IN (SELECT Id FROM BasicDictionary WHERE NAME='学历')");
|
|
cboDiploma.SelectedIndex = -1;
|
|
|
|
cboJobTitle.DisplayMember = "Name";
|
|
cboJobTitle.ValueMember = "Id";
|
|
cboJobTitle.DataSource = BBasicDictionary.GetDataDictionaryDataTable(" ParentId IN (SELECT Id FROM BasicDictionary WHERE NAME='工作职称')");
|
|
|
|
cboJobTitle.SelectedIndex = -1;
|
|
|
|
|
|
cboPersonType.DisplayMember = "Name";
|
|
cboPersonType.ValueMember = "Id";
|
|
cboPersonType.DataSource = BBasicDictionary.GetDataDictionaryDataTable(" ParentId IN (SELECT Id FROM BasicDictionary WHERE NAME='人员类型')");
|
|
cboPersonType.SelectedIndex = -1;
|
|
|
|
this.txtName.Enabled = true;
|
|
this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
|
|
|
|
this.cboDepartment.SelectedIndexChanged += new System.EventHandler(this.cboDepartment_SelectedIndexChanged);
|
|
}
|
|
|
|
private void tsbExit_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void tsbAdd_Click(object sender, EventArgs e)
|
|
{
|
|
_state = AIMSExtension.EditState.ADD;
|
|
this.txtName.TextChanged -= new System.EventHandler(this.txtName_TextChanged);
|
|
this.cboDepartment.SelectedIndexChanged -= new System.EventHandler(this.cboDepartment_SelectedIndexChanged);
|
|
AIMSExtension.PublicMethod.EnabledControl(panel1, true);
|
|
AIMSExtension.PublicMethod.ClearControl(panel1);
|
|
}
|
|
|
|
private void tsbModify_Click(object sender, EventArgs e)
|
|
{
|
|
_state = AIMSExtension.EditState.EDIT;
|
|
this.txtName.TextChanged -= new System.EventHandler(this.txtName_TextChanged);
|
|
this.cboDepartment.SelectedIndexChanged -= new System.EventHandler(this.cboDepartment_SelectedIndexChanged);
|
|
AIMSExtension.PublicMethod.EnabledControl(panel1, true);
|
|
if (dgvPerson.Rows.Count > 0)
|
|
{
|
|
SelectPerson.Id = int.Parse(dgvPerson.CurrentRow.Cells["Id"].Value.ToString());
|
|
cboDepartment.Text = dgvPerson.CurrentRow.Cells["DepNameColumn"].Value.ToString();
|
|
txtNo.Text = dgvPerson.CurrentRow.Cells["NoColumn"].Value.ToString();
|
|
txtName.Text = dgvPerson.CurrentRow.Cells["NameColumn"].Value.ToString();
|
|
txtHelpCode.Text = dgvPerson.CurrentRow.Cells["HelpCodeColumn"].Value.ToString();
|
|
cboSex.Text = dgvPerson.CurrentRow.Cells["SexColumn"].Value.ToString();
|
|
cboDiploma.Text = dgvPerson.CurrentRow.Cells["DiplomaColumn"].Value.ToString();
|
|
cboJobTitle.Text = dgvPerson.CurrentRow.Cells["JobTitleColumn"].Value.ToString();
|
|
dtpBirthDay.Text = dgvPerson.CurrentRow.Cells["BirthDayColumn"].Value.ToString();
|
|
dtpTimeToWork.Text = dgvPerson.CurrentRow.Cells["TimeToWorkColumn"].Value.ToString();
|
|
cboPersonType.Text = dgvPerson.CurrentRow.Cells["PersonTypeColumn"].Value.ToString();
|
|
|
|
cboRole.Text = dgvPerson.CurrentRow.Cells["RoleNameColumn"].Value.ToString();
|
|
txtPassWord.Text = dgvPerson.CurrentRow.Cells["PassWordColumn"].Value.ToString();
|
|
intPersonOrder.Text = dgvPerson.CurrentRow.Cells["PersonOrderColumn"].Value.ToString();
|
|
|
|
if (dgvPerson.CurrentRow.Cells["IsValidColumn"].Value.ToString() == "有效")
|
|
{
|
|
chkIsValid.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
chkIsValid.Checked = false;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void tsbCancel_Click(object sender, EventArgs e)
|
|
{
|
|
_state = AIMSExtension.EditState.BROWSE;
|
|
AIMSExtension.PublicMethod.EnabledControl(panel1, false);
|
|
AIMSExtension.PublicMethod.ClearControl(panel1);
|
|
|
|
this.txtName.Enabled = true;
|
|
this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
|
|
|
|
this.cboDepartment.Enabled = true;
|
|
this.cboDepartment.SelectedIndexChanged += new System.EventHandler(this.cboDepartment_SelectedIndexChanged);
|
|
}
|
|
|
|
private void tsbSava_Click(object sender, EventArgs e)
|
|
{
|
|
if (ValidInput())
|
|
{
|
|
Person PersonObj = new Person();
|
|
PersonObj.DepId = int.Parse(cboDepartment.SelectedValue.ToString());
|
|
PersonObj.No = txtNo.Text;
|
|
PersonObj.Name = txtName.Text.Trim();
|
|
PersonObj.HelpCode = txtHelpCode.Text;
|
|
PersonObj.Sex = cboSex.Text;
|
|
PersonObj.Diploma = cboDiploma.Text;
|
|
PersonObj.JobTitle = cboJobTitle.Text;
|
|
PersonObj.BirthDay = dtpBirthDay.Text;
|
|
PersonObj.TimeToWork = dtpTimeToWork.Text;
|
|
PersonObj.PersonType = cboPersonType.Text;
|
|
PersonObj.RoleId = int.Parse(cboRole.SelectedValue.ToString());
|
|
PersonObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
PersonObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
PersonObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
PersonObj.PassWord = txtPassWord.Text.Trim();
|
|
|
|
PersonObj.PersonOrder = int.Parse(intPersonOrder.Text);
|
|
PersonObj.IsValid = int.Parse(chkIsValid.Checked ? "1" : "0");
|
|
|
|
if (_state == AIMSExtension.EditState.ADD)
|
|
{
|
|
BPerson.Add(PersonObj);
|
|
|
|
dgvPerson.CurrentRow.Cells["DepNameColumn"].Value = cboDepartment.Text;
|
|
dgvPerson.CurrentRow.Cells["NoColumn"].Value = txtNo.Text;
|
|
dgvPerson.CurrentRow.Cells["NameColumn"].Value = txtName.Text;
|
|
dgvPerson.CurrentRow.Cells["HelpCodeColumn"].Value = txtHelpCode.Text;
|
|
dgvPerson.CurrentRow.Cells["SexColumn"].Value = cboSex.Text;
|
|
dgvPerson.CurrentRow.Cells["DiplomaColumn"].Value = cboDiploma.Text;
|
|
dgvPerson.CurrentRow.Cells["JobTitleColumn"].Value = cboJobTitle.Text;
|
|
dgvPerson.CurrentRow.Cells["BirthDayColumn"].Value = dtpBirthDay.Text;
|
|
dgvPerson.CurrentRow.Cells["TimeToWorkColumn"].Value = dtpTimeToWork.Text;
|
|
dgvPerson.CurrentRow.Cells["PersonTypeColumn"].Value = cboPersonType.Text;
|
|
dgvPerson.CurrentRow.Cells["RoleNameColumn"].Value = cboRole.Text;
|
|
dgvPerson.CurrentRow.Cells["PassWordColumn"].Value = txtPassWord.Text;
|
|
dgvPerson.CurrentRow.Cells["PersonOrderColumn"].Value = intPersonOrder.Text;
|
|
}
|
|
|
|
if (_state == AIMSExtension.EditState.EDIT)
|
|
{
|
|
PersonObj.Id = SelectPerson.Id;
|
|
BPerson.Update(PersonObj);
|
|
|
|
dgvPerson.CurrentRow.Cells["DepNameColumn"].Value = cboDepartment.Text;
|
|
dgvPerson.CurrentRow.Cells["NoColumn"].Value = txtNo.Text;
|
|
dgvPerson.CurrentRow.Cells["NameColumn"].Value = txtName.Text;
|
|
dgvPerson.CurrentRow.Cells["HelpCodeColumn"].Value = txtHelpCode.Text;
|
|
dgvPerson.CurrentRow.Cells["SexColumn"].Value = cboSex.Text;
|
|
dgvPerson.CurrentRow.Cells["DiplomaColumn"].Value = cboDiploma.Text;
|
|
dgvPerson.CurrentRow.Cells["JobTitleColumn"].Value = cboJobTitle.Text;
|
|
dgvPerson.CurrentRow.Cells["BirthDayColumn"].Value = dtpBirthDay.Text;
|
|
dgvPerson.CurrentRow.Cells["TimeToWorkColumn"].Value = dtpTimeToWork.Text;
|
|
dgvPerson.CurrentRow.Cells["PersonTypeColumn"].Value = cboPersonType.Text;
|
|
dgvPerson.CurrentRow.Cells["RoleNameColumn"].Value = cboRole.Text;
|
|
dgvPerson.CurrentRow.Cells["PassWordColumn"].Value = txtPassWord.Text;
|
|
dgvPerson.CurrentRow.Cells["PersonOrderColumn"].Value = intPersonOrder.Text;
|
|
}
|
|
_state = AIMSExtension.EditState.BROWSE;
|
|
AIMSExtension.PublicMethod.EnabledControl(panel1, false);
|
|
AIMSExtension.PublicMethod.ClearControl(panel1);
|
|
|
|
this.txtName.Enabled = true;
|
|
this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
|
|
|
|
this.cboDepartment.Enabled = true;
|
|
this.cboDepartment.SelectedIndexChanged += new System.EventHandler(this.cboDepartment_SelectedIndexChanged);
|
|
}
|
|
}
|
|
private bool ValidInput()
|
|
{
|
|
bool result = false;
|
|
|
|
if (cboDepartment.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("科室不能为空!");
|
|
}
|
|
else if (txtNo.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("工号不能为空!");
|
|
}
|
|
else if (this.txtName.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("名称不能为空!");
|
|
}
|
|
//else if (cboSex.Text.Trim().Length < 1)
|
|
//{
|
|
// MessageBox.Show("性别不能为空!");
|
|
//}
|
|
else if (cboRole.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("角色不能为空!");
|
|
}
|
|
else
|
|
{
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private void txtName_TextChanged(object sender, EventArgs e)
|
|
{
|
|
txtHelpCode.Text = AIMSExtension.PublicMethod.GetFirstLetter(txtName.Text.Trim());
|
|
GetPersonDataTable(txtName.Text.Trim(), "");
|
|
}
|
|
private void GetPersonDataTable(string name, string DepartName)
|
|
{
|
|
dgvPerson.Rows.Clear();
|
|
DataTable dt = BPerson.GetPersonDataTable(name,DepartName, chkAllShow.Checked);
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
dgvPerson.Rows.Add(dt.Rows[i]["Id"].ToString(),
|
|
dt.Rows[i]["DepName"].ToString(),
|
|
dt.Rows[i]["No"].ToString(),
|
|
dt.Rows[i]["Name"].ToString(),
|
|
dt.Rows[i]["HelpCode"].ToString(),
|
|
dt.Rows[i]["Sex"].ToString(),
|
|
dt.Rows[i]["Diploma"].ToString(),
|
|
dt.Rows[i]["JobTitle"].ToString(),
|
|
dt.Rows[i]["BirthDay"].ToString(),
|
|
dt.Rows[i]["TimeToWork"].ToString(),
|
|
dt.Rows[i]["PersonType"].ToString(),
|
|
dt.Rows[i]["RoleName"].ToString(),
|
|
dt.Rows[i]["PassWord"].ToString(),
|
|
dt.Rows[i]["IsValid"].ToString(),
|
|
dt.Rows[i]["PersonOrder"].ToString());
|
|
}
|
|
if (dgvPerson.Rows.Count > 0)
|
|
{
|
|
dgvPerson.ClearSelection();
|
|
dgvPerson.Rows[0].Selected = false;
|
|
dgvPerson.Rows[dgvPerson.Rows.Count - 1].Selected = true;
|
|
dgvPerson.CurrentCell = this.dgvPerson.Rows[dgvPerson.Rows.Count - 1].Cells[1];
|
|
}
|
|
}
|
|
|
|
|
|
private void cboDepartment_TextUpdate(object sender, EventArgs e)
|
|
{
|
|
//清空combobox
|
|
this.cboDepartment.Items.Clear();
|
|
//清空listNew
|
|
listNew.Clear();
|
|
//遍历全部备查数据
|
|
listNew = BDepartment.Select("IsValid=1 and (HCode like '%" + cboDepartment.Text + "%' or Name like '%" + cboDepartment.Text + "%' )", new ParameterList(), RecursiveType.None, 0);
|
|
if (listNew.Count <= 0)
|
|
{
|
|
listNew = BDepartment.Select("IsValid=1 ", new ParameterList(), RecursiveType.None, 0);
|
|
listNew.Insert(0, new Department() { Id = -1, Name = "全部科室" });
|
|
}
|
|
|
|
//combobox添加已经查到的关键词
|
|
this.cboDepartment.Items.AddRange(listNew.ToArray());
|
|
//设置光标位置,否则光标位置始终保持在第一列,造成输入关键词的倒序排列
|
|
this.cboDepartment.SelectionStart = this.cboDepartment.Text.Length;
|
|
//保持鼠标指针原来状态,有时候鼠标指针会被下拉框覆盖,所以要进行一次设置。
|
|
Cursor = Cursors.Default;
|
|
//自动弹出下拉框
|
|
this.cboDepartment.DroppedDown = true;
|
|
}
|
|
|
|
private void cboDepartment_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
GetPersonDataTable("", cboDepartment.Text.Trim());
|
|
}
|
|
}
|
|
}
|