150 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using AIMSBLL;
 | |
| using AIMSModel;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Drawing;
 | |
| using System.Windows.Forms;
 | |
| 
 | |
| namespace AIMS.PublicUI.UI
 | |
| {
 | |
|     public partial class frmSelectPerson : Form
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 医生 麻醉医生 麻醉护士
 | |
|         /// </summary>
 | |
|         public string PersonType = "";
 | |
|         public string SelectDepartmentName = "";
 | |
|         public List<int> SelectPersonData = new List<int>();
 | |
|         public List<Department> listNew = new List<Department>();
 | |
|         public List<Department> listOnit = new List<Department>();
 | |
|         public frmSelectPerson()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|         }
 | |
| 
 | |
|         private void frmSelectPerson_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             ControlExtension.SetDgvAttribute(dgvSelectPerson);
 | |
| 
 | |
| 
 | |
|             listOnit = BDepartment.GetDepartmentAllListBYSql("");
 | |
|             listOnit.Insert(0, new Department() { Id = -1, Name = "全部科室" });
 | |
|             this.cboDept.Items.AddRange(listOnit.ToArray());
 | |
|             cboDept.ValueMember = "Id";
 | |
|             cboDept.DisplayMember = "Name";
 | |
|             cboDept.SelectedIndex = -1;
 | |
| 
 | |
|             dgvSelectPerson.Select();
 | |
|             this.txtHelpCode.Text = "简拼/汉字/ICD码";
 | |
| 
 | |
|             if (SelectPersonData.Count > 0)
 | |
|             {
 | |
|                 int DepId = BPerson.GetModel(int.Parse(SelectPersonData[0].ToString())).DepId.Value;
 | |
|                 cboDept.Text = BDepartment.GetModel(DepId).Name;
 | |
| 
 | |
|                 for (int i = 0; i < dgvSelectPerson.Rows.Count; i++)
 | |
|                 {
 | |
|                     if (SelectPersonData.Contains(int.Parse(dgvSelectPerson.Rows[i].Cells["IdColumn"].Value.ToString())))
 | |
|                     {
 | |
|                         dgvSelectPerson.Rows[i].Cells["CheckBoxColumn"].Value = true;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             else if (SelectDepartmentName != "")
 | |
|             {
 | |
|                 cboDept.Text = SelectDepartmentName;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void txtHelpCode_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.txtHelpCode.Text = "";
 | |
|             this.txtHelpCode.ForeColor = Color.Black;
 | |
|         }
 | |
| 
 | |
|         private void btnOk_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             Close();
 | |
|         }
 | |
|          
 | |
|         private void txtHelpCode_TextChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             int _deptId = -1;
 | |
|             if (cboDept.SelectedIndex >= 0 && cboDept.Text != "全部科室" && cboDept.SelectedItem != null)
 | |
|             {
 | |
|                 try
 | |
|                 {
 | |
|                     Department dt = cboDept.SelectedItem as Department;
 | |
|                     if (dt != null)
 | |
|                         _deptId = dt.Id.Value;
 | |
|                     else
 | |
|                         _deptId = BDepartment.GetModelName(cboDept.Text).Id.Value;
 | |
|                 }
 | |
|                 catch (Exception)
 | |
|                 {
 | |
|                     _deptId = BDepartment.GetModelName(cboDept.Text).Id.Value;
 | |
|                 }
 | |
|             }
 | |
|             dgvSelectPerson.DataSource = BPerson.GetPersonDataTableByDepId( _deptId, txtHelpCode.Text.Trim(), PersonType);
 | |
|         }
 | |
| 
 | |
|         private void dgvSelectPerson_CellClick(object sender, DataGridViewCellEventArgs e)
 | |
|         {
 | |
|             if (Convert.ToBoolean(dgvSelectPerson.CurrentRow.Cells["CheckBoxColumn"].EditedFormattedValue) == false)
 | |
|             {
 | |
|                 SelectPersonData.Add(int.Parse(dgvSelectPerson.CurrentRow.Cells["IdColumn"].Value.ToString()));
 | |
|                 dgvSelectPerson.CurrentRow.Cells["CheckBoxColumn"].Value = true;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 SelectPersonData.Remove(int.Parse(dgvSelectPerson.CurrentRow.Cells["IdColumn"].Value.ToString()));
 | |
|                 dgvSelectPerson.CurrentRow.Cells["CheckBoxColumn"].Value = false;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void cboDept_TextUpdate(object sender, EventArgs e)
 | |
|         {
 | |
|             //清空combobox
 | |
|             this.cboDept.Items.Clear();
 | |
|             //清空listNew
 | |
|             listNew.Clear();
 | |
|             //遍历全部备查数据
 | |
|             listNew = BDepartment.GetDepartmentAllListBYSql(" and (HelpCode like '%" + cboDept.Text + "%' or Name like '%" + cboDept.Text + "%' )  ");
 | |
|             if (cboDept.Text.Trim() == "" || listNew == null || listNew.Count <= 0)
 | |
|             {
 | |
|                 listNew = BDepartment.GetDepartmentAllListBYSql("");
 | |
|                 listNew.Insert(0, new Department() { Id = -1, Name = "全部科室" });
 | |
|             }
 | |
|             //combobox添加已经查到的关键词
 | |
|             this.cboDept.Items.AddRange(listNew.ToArray());
 | |
|             //设置光标位置,否则光标位置始终保持在第一列,造成输入关键词的倒序排列
 | |
|             this.cboDept.SelectionStart = this.cboDept.Text.Length;
 | |
|             //保持鼠标指针原来状态,有时候鼠标指针会被下拉框覆盖,所以要进行一次设置。
 | |
|             Cursor = Cursors.Default;
 | |
|             //自动弹出下拉框
 | |
|             if (cboDept.Text.Trim() != "") this.cboDept.DroppedDown = true;
 | |
|         }
 | |
| 
 | |
|         private void cboDept_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             int _deptId = -1;
 | |
|             if (cboDept.SelectedIndex >= 0 && cboDept.Text != "全部科室" && cboDept.SelectedItem != null)
 | |
|             {
 | |
|                 try
 | |
|                 {
 | |
|                     Department dt = cboDept.SelectedItem as Department;
 | |
|                     if (dt != null)
 | |
|                         _deptId = dt.Id.Value;
 | |
|                     else
 | |
|                         _deptId = BDepartment.GetModelName(cboDept.Text).Id.Value;
 | |
|                 }
 | |
|                 catch (Exception)
 | |
|                 {
 | |
|                     _deptId = BDepartment.GetModelName(cboDept.Text).Id.Value;
 | |
|                 }
 | |
|             }
 | |
|             dgvSelectPerson.DataSource = BPerson.GetPersonDataTableByDepId(_deptId, txtHelpCode.Text.Trim(), PersonType);
 | |
|         }
 | |
|     }
 | |
| }
 |