450 lines
17 KiB
C#
450 lines
17 KiB
C#
using AIMSBLL;
|
||
using AIMSExtension;
|
||
using DrawGraph;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Windows.Forms;
|
||
|
||
namespace AIMS.PublicUI.UI
|
||
{
|
||
public partial class frmAanesthesiaQuality : Form
|
||
{
|
||
/// <summary>
|
||
/// 手术记录
|
||
/// </summary>
|
||
public DrawGraph.OperationRecord _record;
|
||
/// <summary>
|
||
/// 质控集合
|
||
/// </summary>
|
||
private List<AdverseEvent> _adverseEventList;
|
||
/// <summary>
|
||
/// 不良事件集合
|
||
/// </summary>
|
||
private List<AdverseEvent> _adverseEventListBlsj;
|
||
/// <summary>
|
||
/// 构造函数
|
||
/// </summary>
|
||
public frmAanesthesiaQuality()
|
||
{
|
||
InitializeComponent();
|
||
_adverseEventList = new List<AdverseEvent>();
|
||
_adverseEventListBlsj = new List<AdverseEvent>();
|
||
}
|
||
/// <summary>
|
||
/// 窗体加载质控
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void frmAnaseDataQualityRecord_Load(object sender, EventArgs e)
|
||
{
|
||
Initial();
|
||
}
|
||
/// <summary>
|
||
/// 初始化质控
|
||
/// </summary>
|
||
private void Initial()
|
||
{
|
||
//得到质控数据
|
||
_adverseEventList = BAdverseEvent.SelectAll("质控指标");
|
||
_adverseEventListBlsj = BAdverseEvent.SelectAll2("质控指标");
|
||
|
||
var rList = _record.AnaseDataQualityRecordList.Where(p => p.AdverseEvenLevel.Equals("质控指标")).Select(p => p);
|
||
bool isNotChecked = false;
|
||
if (_record.AnaseDataQualityRecordList == null)
|
||
_record.AnaseDataQualityRecordList = new List<AnaseDataQualityRecord>();
|
||
if (_record.AnaseDataQualityRecordList.Count > 0)
|
||
{
|
||
isNotChecked = true;
|
||
}
|
||
FullPanel(panelExZKZB, _adverseEventList, rList.ToList(), isNotChecked);
|
||
|
||
|
||
var rListBLSJ = _record.AnaseDataQualityRecordList.Where(p => p.AdverseEvenLevel != "质控指标").Select(p => p);
|
||
if (_record.AnaseDataQualityRecordList == null)
|
||
_record.AnaseDataQualityRecordList = new List<AnaseDataQualityRecord>();
|
||
if (_record.AnaseDataQualityRecordList.Count > 0)
|
||
{
|
||
checkBox1.Checked = true;
|
||
}
|
||
FullPanelBLSJ(panelExBLSJ, _adverseEventListBlsj, rListBLSJ.ToList(), isNotChecked);
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// 加载相应的不良质控控件(同时赋值)
|
||
/// </summary>
|
||
/// <param name="panel"></param>
|
||
/// <param name="list"></param>
|
||
/// <param name="rList"></param>
|
||
private void FullPanel(Panel panel, List<AdverseEvent> list, List<AnaseDataQualityRecord> rList, bool isNotChecked)
|
||
{
|
||
panel.Controls.Clear();
|
||
int rows = 0;
|
||
int cols = 0;
|
||
int x = 0;
|
||
//循环加载CheckBox控件
|
||
foreach (AdverseEvent ade in list)
|
||
{
|
||
x = cols * 400 + 50;
|
||
System.Windows.Forms.Label txtName = new System.Windows.Forms.Label();
|
||
txtName.Text = ade.Name;
|
||
txtName.Font = new System.Drawing.Font("微软雅黑", 10.5f);
|
||
txtName.Width = 300;
|
||
txtName.Tag = ade;
|
||
txtName.Location = new Point(x, rows * (txtName.Height + 3) + 17);
|
||
panel.Controls.Add(txtName);
|
||
|
||
CheckBox chkNo = new CheckBox();
|
||
chkNo.AutoSize = true;
|
||
chkNo.Location = new System.Drawing.Point(46, 1);
|
||
chkNo.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||
chkNo.Size = new System.Drawing.Size(36, 16);
|
||
chkNo.Text = "否";
|
||
chkNo.UseVisualStyleBackColor = true;
|
||
chkNo.Tag = ade;
|
||
|
||
CheckBox chkYes = new CheckBox();
|
||
chkYes.AutoSize = true;
|
||
chkYes.Location = new System.Drawing.Point(4, 1);
|
||
chkYes.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||
chkYes.Size = new System.Drawing.Size(36, 16);
|
||
chkYes.Text = "是";
|
||
chkYes.UseVisualStyleBackColor = true;
|
||
chkYes.Tag = ade;
|
||
|
||
//为控件的Checked属性赋值
|
||
foreach (AnaseDataQualityRecord r in rList)
|
||
{
|
||
if (r.AdverseEventId == ade.Id)
|
||
{
|
||
chkYes.Checked = true;
|
||
break;
|
||
}
|
||
}
|
||
if (isNotChecked == true)
|
||
{
|
||
if (chkYes.Checked == true)
|
||
chkNo.Checked = false;
|
||
else
|
||
chkNo.Checked = true;
|
||
}
|
||
|
||
//给CheckBox控件生成CheckedChanged质控chkYes_CheckedChanged
|
||
chkYes.CheckedChanged += new EventHandler(cb_CheckedChanged);
|
||
//给CheckBox控件生成CheckedChanged质控chkNo_CheckedChanged
|
||
chkNo.CheckedChanged += new EventHandler(cb_CheckedChanged);
|
||
|
||
Panel panelChk = new System.Windows.Forms.Panel();
|
||
panelChk.Controls.Add(chkYes);
|
||
panelChk.Controls.Add(chkNo);
|
||
panelChk.Location = new Point(x + 300, rows * (txtName.Height + 3) + 20);
|
||
panelChk.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||
panelChk.Size = new System.Drawing.Size(94, 26);
|
||
panel.Controls.Add(panelChk);
|
||
//如果已加载15行,则另起一列,最多显示3列
|
||
rows++;
|
||
if (rows == 22)
|
||
{
|
||
rows = 0;
|
||
cols++;
|
||
if (cols == 2)
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 加载相应的不良事件控件(同时赋值)
|
||
/// </summary>
|
||
/// <param name="panel"></param>
|
||
/// <param name="list"></param>
|
||
/// <param name="rList"></param>
|
||
private void FullPanelBLSJ(Panel panel, List<AdverseEvent> list, List<AnaseDataQualityRecord> rList, bool isNotChecked)
|
||
{
|
||
panel.Controls.Clear();
|
||
int rows = 0;
|
||
int cols = 0;
|
||
int x = 0;
|
||
//循环加载CheckBox控件
|
||
foreach (AdverseEvent ade in list)
|
||
{
|
||
x = cols * 400 + 20;
|
||
System.Windows.Forms.Label txtName = new System.Windows.Forms.Label();
|
||
txtName.Text = ade.Name;
|
||
txtName.Font = new System.Drawing.Font("微软雅黑", 10.5f);
|
||
txtName.Width = 300;
|
||
txtName.Tag = ade;
|
||
txtName.Location = new Point(x, rows * (txtName.Height + 3) + 17);
|
||
panel.Controls.Add(txtName);
|
||
|
||
CheckBox chkNo = new CheckBox();
|
||
chkNo.AutoSize = true;
|
||
chkNo.Location = new System.Drawing.Point(46, 1);
|
||
chkNo.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||
chkNo.Size = new System.Drawing.Size(36, 16);
|
||
chkNo.Text = "否";
|
||
chkNo.UseVisualStyleBackColor = true;
|
||
chkNo.Tag = ade;
|
||
|
||
CheckBox chkYes = new CheckBox();
|
||
chkYes.AutoSize = true;
|
||
chkYes.Location = new System.Drawing.Point(4, 1);
|
||
chkYes.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||
chkYes.Size = new System.Drawing.Size(36, 16);
|
||
chkYes.Text = "是";
|
||
chkYes.UseVisualStyleBackColor = true;
|
||
chkYes.Tag = ade;
|
||
|
||
//为控件的Checked属性赋值
|
||
foreach (AnaseDataQualityRecord r in rList)
|
||
{
|
||
if (r.AdverseEventId == ade.Id)
|
||
{
|
||
chkYes.Checked = true;
|
||
checkBox1.Checked = false;
|
||
break;
|
||
}
|
||
}
|
||
if (isNotChecked == true)
|
||
{
|
||
if (chkYes.Checked == true)
|
||
chkNo.Checked = false;
|
||
else
|
||
chkNo.Checked = true;
|
||
}
|
||
|
||
//给CheckBox控件生成CheckedChanged质控chkYes_CheckedChanged
|
||
chkYes.CheckedChanged += new EventHandler(cb_CheckedChanged);
|
||
//给CheckBox控件生成CheckedChanged质控chkNo_CheckedChanged
|
||
chkNo.CheckedChanged += new EventHandler(cb_CheckedChanged);
|
||
|
||
Panel panelChk = new System.Windows.Forms.Panel();
|
||
panelChk.Controls.Add(chkYes);
|
||
panelChk.Controls.Add(chkNo);
|
||
panelChk.Location = new Point(x + 300, rows * (txtName.Height + 3) + 20);
|
||
panelChk.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||
panelChk.Size = new System.Drawing.Size(94, 26);
|
||
panel.Controls.Add(panelChk);
|
||
//如果已加载15行,则另起一列,最多显示3列
|
||
rows++;
|
||
if (rows == 20)
|
||
{
|
||
rows = 0;
|
||
cols++;
|
||
if (cols == 2)
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// CheckBox控件CheckedChanged质控
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
void cb_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
CheckBox ck = sender as CheckBox;
|
||
//判断CheckBox被选中时
|
||
if (ck.Checked)
|
||
{
|
||
if (ck.Text == "是")
|
||
{
|
||
bool k = false;
|
||
//察看患者的不良质控记录是否存在
|
||
foreach (AnaseDataQualityRecord aerd in _record.AnaseDataQualityRecordList)
|
||
{
|
||
if ((ck.Tag as AdverseEvent).Id == aerd.AdverseEventId)
|
||
{
|
||
k = true;
|
||
break;
|
||
}
|
||
}
|
||
//如果不存在则添加
|
||
if (!k)
|
||
{
|
||
AnaseDataQualityRecord aer = new AnaseDataQualityRecord();
|
||
aer.OperationRecordId = this._record.Id;
|
||
aer.AdverseEventId = (ck.Tag as AdverseEvent).Id;
|
||
aer.AdverseEvenName = (ck.Tag as AdverseEvent).Name;
|
||
aer.AdverseEvenLevel = (ck.Tag as AdverseEvent).Level;
|
||
aer.OperatorId = AIMSExtension.PublicMethod.OperatorId;
|
||
aer.OpeatorTime = DateTime.Now;
|
||
_record.AnaseDataQualityRecordList.Add(aer);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//CheckBox取消选中时,判断患者不良质控集合是否存在,如果存在则移除
|
||
foreach (AnaseDataQualityRecord aerd in _record.AnaseDataQualityRecordList)
|
||
{
|
||
if (aerd.AdverseEventId == (ck.Tag as AdverseEvent).Id)
|
||
{
|
||
_record.AnaseDataQualityRecordList.Remove(aerd);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
//CheckBox取消选中时,判断患者不良质控集合是否存在,如果存在则移除
|
||
foreach (AnaseDataQualityRecord aerd in _record.AnaseDataQualityRecordList)
|
||
{
|
||
if (aerd.AdverseEventId == (ck.Tag as AdverseEvent).Id && ck.Text == "是")
|
||
{
|
||
_record.AnaseDataQualityRecordList.Remove(aerd);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
foreach (var item in ck.Parent.Controls)
|
||
{
|
||
if (item is CheckBox && ck.Checked == true && ((CheckBox)item).Text != ck.Text)
|
||
{
|
||
((CheckBox)item).Checked = false;
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 退出质控
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btnCancel_Click(object sender, EventArgs e)
|
||
{
|
||
this.Close();
|
||
}
|
||
/// <summary>
|
||
/// 保存质控
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
bool isNotChecked = false;
|
||
foreach (var item in panelExZKZB.Controls)
|
||
{
|
||
if (item is Panel)
|
||
{
|
||
bool isChecked = false;
|
||
foreach (var ck in ((Panel)item).Controls)
|
||
{
|
||
if (ck is CheckBox && ((CheckBox)ck).Checked == true)
|
||
{
|
||
isChecked = true;
|
||
}
|
||
}
|
||
if (isChecked == false)
|
||
isNotChecked = true;
|
||
}
|
||
}
|
||
if (isNotChecked == true)
|
||
{
|
||
MessageBox.Show("请选择质控指标?!");
|
||
return;
|
||
}
|
||
//if (checkBox1.Checked == false)
|
||
//{
|
||
// isNotChecked = false;
|
||
// foreach (var item in panelExBLSJ.Controls)
|
||
// {
|
||
// if (item is Panel)
|
||
// {
|
||
// bool isChecked = false;
|
||
// foreach (var ck in ((Panel)item).Controls)
|
||
// {
|
||
// if (ck is CheckBox && ((CheckBox)ck).Checked == true)
|
||
// {
|
||
// isChecked = true;
|
||
// }
|
||
// }
|
||
// if (isChecked == false)
|
||
// isNotChecked = true;
|
||
// }
|
||
// }
|
||
// if (isNotChecked == true)
|
||
// {
|
||
// MessageBox.Show("请选择不良事件?!");
|
||
// return;
|
||
// }
|
||
//}
|
||
|
||
if (_record.AnaseDataQualityRecordList.Count == 0)
|
||
{
|
||
AnaseDataQualityRecord aerd = new AnaseDataQualityRecord();
|
||
aerd.AdverseEvenLevel = "无";
|
||
aerd.OperationRecordId = _record.Id;
|
||
aerd.OperatorId = AIMSExtension.PublicMethod.OperatorId;
|
||
aerd.OpeatorTime = DateTime.Now;
|
||
_record.AnaseDataQualityRecordList.Clear();
|
||
_record.AnaseDataQualityRecordList.Add(aerd);
|
||
}
|
||
else if (_record.AnaseDataQualityRecordList.Count > 1)
|
||
{
|
||
foreach (AnaseDataQualityRecord aerd in _record.AnaseDataQualityRecordList)
|
||
{
|
||
if (aerd.AdverseEvenLevel == "无")
|
||
{
|
||
_record.AnaseDataQualityRecordList.Remove(aerd);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
BAnaseDataQualityRecord.UpdateAnaseDataQualityRecord(_record.AnaseDataQualityRecordList, Convert.ToInt32(_record.Id));
|
||
new frmMessageBox().Show();
|
||
this.Close();
|
||
}
|
||
public void SetDefultNo()
|
||
{
|
||
foreach (var item in panelExZKZB.Controls)
|
||
{
|
||
if (item is Panel)
|
||
{
|
||
foreach (var ck in ((Panel)item).Controls)
|
||
{
|
||
if (ck is CheckBox)
|
||
{
|
||
AdverseEvent ade = (AdverseEvent)(((CheckBox)ck).Tag);
|
||
if (ade.Remark == "是" || ade.Remark == "1")
|
||
{
|
||
if (((CheckBox)ck).Text == "否")
|
||
{
|
||
((CheckBox)ck).Checked = false;
|
||
}
|
||
if (((CheckBox)ck).Text == "是")
|
||
{
|
||
((CheckBox)ck).Checked = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (((CheckBox)ck).Text == "否")
|
||
{
|
||
((CheckBox)ck).Checked = true;
|
||
}
|
||
if (((CheckBox)ck).Text == "是")
|
||
{
|
||
((CheckBox)ck).Checked = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btndefault_Click(object sender, EventArgs e)
|
||
{
|
||
SetDefultNo();
|
||
checkBox1.Checked = true;
|
||
}
|
||
}
|
||
}
|