533 lines
22 KiB
C#
533 lines
22 KiB
C#
using DevExpress.XtraEditors;
|
||
using HL_FristAidPlatform_DTO;
|
||
using HL_FristAidPlatform_Public;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Windows.Forms;
|
||
|
||
namespace HL_FristAidPlatform_ChestPain
|
||
{
|
||
public partial class Form_ChestPain_OutDrug : XtraForm
|
||
{
|
||
#region 全局变量
|
||
/// <summary>
|
||
/// 当前病人编号(GUID)
|
||
/// </summary>
|
||
private string Cur_PatientGuid = string.Empty;
|
||
|
||
/// <summary>
|
||
/// 当前患者所有的带药记录
|
||
/// </summary>
|
||
private DataTable Cur_BindDT = new DataTable();
|
||
|
||
/// <summary>
|
||
/// 当前修改的记录信息
|
||
/// </summary>
|
||
private DataTable Cur_DetailDT = new DataTable();
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 出院带药详情列表
|
||
/// </summary>
|
||
/// <param name="_patientGuid">当前患者编号(GUID)</param>
|
||
public Form_ChestPain_OutDrug(string _patientGuid)
|
||
{
|
||
InitializeComponent();
|
||
Cur_PatientGuid = _patientGuid;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 窗体加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void Form_ChestPain_OutDrug_Load(object sender, EventArgs e)
|
||
{
|
||
Bind_List();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定药物列表
|
||
/// </summary>
|
||
private void Bind_List()
|
||
{
|
||
try
|
||
{
|
||
string Url = string.Format("api/service/T_Service_ChestPain_OutDrugDetail/GetByPatientGuid?patientGuid={0}", Cur_PatientGuid);
|
||
DataTable patientDT = DBHelpClass.GetJsonText(Url);
|
||
|
||
grid_List.DataSource = patientDT;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "绑定药物列表:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 列表中某列值自定义显示
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void grv_List_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
||
{
|
||
if (e.Column.FieldName == "Type")
|
||
{
|
||
int value = PublicClass.ToInt32(e.Value, 0);
|
||
switch (value)
|
||
{
|
||
case 1:
|
||
e.DisplayText = "抗血小板药物";
|
||
break;
|
||
case 2:
|
||
e.DisplayText = "ACEI/ARB";
|
||
break;
|
||
case 3:
|
||
e.DisplayText = "调脂药物";
|
||
break;
|
||
case 4:
|
||
e.DisplayText = "β受体阻滞剂";
|
||
break;
|
||
default:
|
||
e.DisplayText = "";
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (e.Column.FieldName == "Rete_Count")
|
||
{
|
||
int value = PublicClass.ToInt32(e.Value, 0);
|
||
switch (value)
|
||
{
|
||
case 1:
|
||
e.DisplayText = "1次";
|
||
break;
|
||
case 2:
|
||
e.DisplayText = "2次";
|
||
break;
|
||
case 3:
|
||
e.DisplayText = "3次";
|
||
break;
|
||
case 4:
|
||
e.DisplayText = "4次";
|
||
break;
|
||
default:
|
||
e.DisplayText = "";
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (e.Column.FieldName == "Rete_Time")
|
||
{
|
||
int value = PublicClass.ToInt32(e.Value, 0);
|
||
switch (value)
|
||
{
|
||
case 1:
|
||
e.DisplayText = "每日";
|
||
break;
|
||
case 2:
|
||
e.DisplayText = "每周";
|
||
break;
|
||
case 3:
|
||
e.DisplayText = "每月";
|
||
break;
|
||
default:
|
||
e.DisplayText = "";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存按钮事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btn_Save_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
#region 验证
|
||
int Type = PublicClass.ToInt32(comboBox_Type.SelectedIndex, 0);
|
||
if (Type == 0)
|
||
{
|
||
XtraMessageBox.Show("请选择药物类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
comboBox_Type.Focus();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
if (Cur_BindDT.Rows.Count > 0 && Cur_DetailDT.Rows.Count == 0)
|
||
{
|
||
DataRow[] DataRow = Cur_BindDT.Select("Type='" + Type + "'");
|
||
switch (Type)
|
||
{
|
||
case 1:
|
||
if (DataRow.Length >= 2)
|
||
{
|
||
XtraMessageBox.Show(string.Format("当前已经存在药物类型【抗血小板药物】的两条记录,无法继续新增!\r\n\r\n您可以在列表中选择该药物类型记录进行修改或者删除后再继续新增!", comboBox_Type.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
comboBox_Type.Focus();
|
||
return;
|
||
}
|
||
break;
|
||
case 2:
|
||
if (DataRow.Length >= 1)
|
||
{
|
||
XtraMessageBox.Show(string.Format("当前已经存在药物类型【ACEI/ARB】的记录,无法继续新增!\r\n\r\n您可以在列表中选择该药物类型记录进行修改或者删除后再继续新增!", comboBox_Type.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
comboBox_Type.Focus();
|
||
return;
|
||
}
|
||
break;
|
||
case 3:
|
||
if (DataRow.Length >= 3)
|
||
{
|
||
XtraMessageBox.Show(string.Format("当前已经存在药物类型【调脂药物】的三条记录,无法继续新增!\r\n\r\n您可以在列表中选择该药物类型记录进行修改或者删除后再继续新增!", comboBox_Type.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
comboBox_Type.Focus();
|
||
return;
|
||
}
|
||
break;
|
||
case 4:
|
||
if (DataRow.Length >= 1)
|
||
{
|
||
XtraMessageBox.Show(string.Format("当前已经存在药物类型【β受体阻滞剂】的记录,无法继续新增!\r\n\r\n您可以在列表中选择该药物类型记录进行修改或者删除后再继续新增!", comboBox_Type.Text), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
comboBox_Type.Focus();
|
||
return;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
}
|
||
string Name = PublicClass.ToString(lookUp_Name.EditValue, "");
|
||
if (string.IsNullOrEmpty(Name))
|
||
{
|
||
XtraMessageBox.Show("请选择药物名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
lookUp_Name.Focus();
|
||
return;
|
||
}
|
||
else if (Name == "99")
|
||
{
|
||
if (string.IsNullOrEmpty(txt_Other_Drug_Name.Text.Trim()))
|
||
{
|
||
XtraMessageBox.Show("请填写其他药物名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
txt_Other_Drug_Name.Focus();
|
||
return;
|
||
}
|
||
}
|
||
|
||
int Rete_Count = PublicClass.ToInt32(comboBox_Rete_Count.SelectedIndex, 0);
|
||
if (Rete_Count == 0)
|
||
{
|
||
XtraMessageBox.Show("请选择服用频次!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
comboBox_Rete_Count.Focus();
|
||
return;
|
||
}
|
||
|
||
int Rete_Time = PublicClass.ToInt32(comboBox_Rete_Time.SelectedIndex, 0);
|
||
if (Rete_Time == 0)
|
||
{
|
||
XtraMessageBox.Show("请选择服用时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
comboBox_Rete_Time.Focus();
|
||
return;
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(txt_Dose.Text))
|
||
{
|
||
XtraMessageBox.Show("请填写单次剂量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
txt_Dose.Focus();
|
||
return;
|
||
}
|
||
#endregion
|
||
|
||
if (Save())
|
||
{
|
||
XtraMessageBox.Show("保存出院带药记录成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
//重新绑定
|
||
Bind_List();
|
||
|
||
btn_Add.Enabled = true;
|
||
btn_Update.Enabled = true;
|
||
btn_Delete.Enabled = true;
|
||
}
|
||
else
|
||
{
|
||
XtraMessageBox.Show("保存出院带药记录失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "保存按钮事件:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新增
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btn_Add_Click(object sender, EventArgs e)
|
||
{
|
||
PublicClass.EnabledControl(groupControl_Info, false, true);
|
||
Cur_DetailDT = new DataTable();
|
||
lbl_Type.Tag = "";
|
||
lbl_Name.Tag = "";
|
||
btn_Delete.Enabled = false;
|
||
btn_Update.Enabled = false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btn_Update_Click(object sender, EventArgs e)
|
||
{
|
||
BindDetail();
|
||
|
||
PublicClass.EnabledControl(groupControl_Info, false, false);
|
||
btn_Add.Enabled = false;
|
||
btn_Delete.Enabled = false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btn_Delete_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (grv_List.DataRowCount > 0)
|
||
{
|
||
int selectRow = grv_List.GetSelectedRows()[0];
|
||
long ID = PublicClass.ToInt64(grv_List.GetRowCellValue(selectRow, "ID"), 0);
|
||
if (ID == 0)
|
||
{
|
||
XtraMessageBox.Show("请先选择要删除的带药记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
|
||
if (XtraMessageBox.Show("确定要删除当前带药记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||
{
|
||
List<T_Service_ChestPain_OutDrugDetailDTO> list = new List<T_Service_ChestPain_OutDrugDetailDTO>();
|
||
T_Service_ChestPain_OutDrugDetailDTO model = new T_Service_ChestPain_OutDrugDetailDTO();
|
||
|
||
string Url = "api/service/T_Service_ChestPain_OutDrugDetail/LogicalDelete";
|
||
model.ID = ID;
|
||
model.DeleteFlag = 1;
|
||
model.EditorID = Information.User.ID;
|
||
model.Editor = Information.User.FullName;
|
||
model.EditTime = PublicClass.DateTimeNow();
|
||
list.Add(model);
|
||
|
||
//初始化两个工厂
|
||
ClientFactory<T_Service_ChestPain_OutDrugDetailDTO> httpClient = new HttpClientFactory<T_Service_ChestPain_OutDrugDetailDTO>();
|
||
Client<T_Service_ChestPain_OutDrugDetailDTO> client = httpClient.VisitFactory();
|
||
|
||
if (client.Post(Url, list).Success)
|
||
{
|
||
XtraMessageBox.Show("删除带药记录成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
PublicClass.EnabledControl(this.groupControl_Info, true, false);
|
||
//列表分页数据绑定
|
||
Bind_List();
|
||
}
|
||
else
|
||
{
|
||
XtraMessageBox.Show("删除带药记录失败,请稍后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "删除:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 显示详情
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void grid_List_MouseClick(object sender, MouseEventArgs e)
|
||
{
|
||
PublicClass.EnabledControl(this.groupControl_Info, true, false);
|
||
BindDetail();
|
||
|
||
btn_Add.Enabled = true;
|
||
btn_Update.Enabled = true;
|
||
btn_Delete.Enabled = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定详情
|
||
/// </summary>
|
||
private void BindDetail()
|
||
{
|
||
try
|
||
{
|
||
if (grv_List.DataRowCount > 0)
|
||
{
|
||
int selectRow = grv_List.GetSelectedRows()[0];
|
||
long ID = Convert.ToInt64(grv_List.GetRowCellValue(selectRow, "ID").ToString());
|
||
Cur_DetailDT = DBHelpClass.GetDataRow(string.Format("api/service/T_Service_ChestPain_OutDrugDetail/{0}", ID));
|
||
if (Cur_DetailDT != null && Cur_DetailDT.Rows.Count > 0)
|
||
{
|
||
lbl_Type.Tag = Cur_DetailDT.Rows[0]["ID"].ToString();
|
||
lbl_Name.Tag = Cur_DetailDT.Rows[0]["GUID"].ToString();
|
||
//药物类型
|
||
comboBox_Type.SelectedIndex = PublicClass.ToInt32(Cur_DetailDT.Rows[0]["Type"], 0);
|
||
//药物名称
|
||
string Name = PublicClass.ToString(Cur_DetailDT.Rows[0]["Name"], "");
|
||
lookUp_Name.EditValue = Name;
|
||
if (Name == "99")
|
||
{
|
||
txt_Other_Drug_Name.Text = Cur_DetailDT.Rows[0]["Other_Drug_Name"].ToString();
|
||
}
|
||
//服用频次
|
||
comboBox_Rete_Count.SelectedIndex = PublicClass.ToInt32(Cur_DetailDT.Rows[0]["Rete_Count"], 0);
|
||
//服用时间
|
||
comboBox_Rete_Time.SelectedIndex = PublicClass.ToInt32(Cur_DetailDT.Rows[0]["Rete_Time"], 0);
|
||
//药物剂量
|
||
txt_Dose.Text = Cur_DetailDT.Rows[0]["Dose"].ToString();
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "绑定详情:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool Save()
|
||
{
|
||
try
|
||
{
|
||
string Url = string.Empty;
|
||
|
||
#region 保存
|
||
List<T_Service_ChestPain_OutDrugDetailDTO> list_Model = new List<T_Service_ChestPain_OutDrugDetailDTO>();
|
||
T_Service_ChestPain_OutDrugDetailDTO model = new T_Service_ChestPain_OutDrugDetailDTO();
|
||
|
||
//存在则修改 否则新增
|
||
if (Cur_DetailDT != null && Cur_DetailDT.Rows.Count > 0)
|
||
{
|
||
Url = "api/service/T_Service_ChestPain_OutDrugDetail/Update";
|
||
model.ID = PublicClass.ToInt64(lbl_Type.Tag, -1);
|
||
model.GUID = lbl_Name.Tag.ToString();
|
||
model.DeleteFlag = PublicClass.ToInt32(Cur_DetailDT.Rows[0]["DeleteFlag"], -1);
|
||
|
||
model.CreatorID = PublicClass.ToInt64(Cur_DetailDT.Rows[0]["CreatorID"], 0);
|
||
model.Creator = Cur_DetailDT.Rows[0]["Creator"].ToString();
|
||
model.CreationDate = Cur_DetailDT.Rows[0]["CreationDate"].ToString();
|
||
model.EditorID = Information.User.ID;
|
||
model.Editor = Information.User.FullName;
|
||
model.EditTime = PublicClass.DateTimeNow();
|
||
}
|
||
else
|
||
{
|
||
Url = "api/service/T_Service_ChestPain_OutDrugDetail";
|
||
model.GUID = Guid.NewGuid().ToString();
|
||
model.DeleteFlag = 0;
|
||
|
||
model.CreatorID = Information.User.ID;
|
||
model.Creator = Information.User.FullName;
|
||
model.CreationDate = PublicClass.DateTimeNow();
|
||
}
|
||
|
||
model.PatientGuid = Cur_PatientGuid;
|
||
//类型
|
||
model.Type = comboBox_Type.SelectedIndex == 0 ? "" : comboBox_Type.SelectedIndex.ToString();
|
||
//名称
|
||
string Name = PublicClass.ToString(lookUp_Name.EditValue, "-1");
|
||
model.Name = Name == "-1" ? "" : Name;
|
||
if (model.Name == "99")
|
||
{
|
||
model.Other_Drug_Name = txt_Other_Drug_Name.Text.Trim();
|
||
}
|
||
//服用频次
|
||
model.Rete_Count = comboBox_Rete_Count.SelectedIndex == 0 ? "" : comboBox_Rete_Count.SelectedIndex.ToString();
|
||
//服用时间
|
||
model.Rete_Time = comboBox_Rete_Time.SelectedIndex == 0 ? "" : comboBox_Rete_Time.SelectedIndex.ToString();
|
||
//剂量
|
||
model.Dose = txt_Dose.Text;
|
||
|
||
list_Model.Add(model);
|
||
|
||
//初始化两个工厂
|
||
ClientFactory<T_Service_ChestPain_OutDrugDetailDTO> httpClient = new HttpClientFactory<T_Service_ChestPain_OutDrugDetailDTO>();
|
||
Client<T_Service_ChestPain_OutDrugDetailDTO> client = httpClient.VisitFactory();
|
||
#endregion
|
||
|
||
//访问
|
||
return client.Post(Url, list_Model).Success;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "保存:\r\n" + ex);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定药物名称
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void comboBox_Type_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
int type = PublicClass.ToInt32(comboBox_Type.SelectedIndex, 0);
|
||
switch (type)
|
||
{
|
||
case 1:
|
||
PublicClass.SetLookUpList(lookUp_Name, Enumerate.PublicDictionaryType.抗血小板药物, true, "请选择");
|
||
break;
|
||
case 2:
|
||
PublicClass.SetLookUpList(lookUp_Name, Enumerate.PublicDictionaryType.ACEIOrARB, true, "请选择");
|
||
break;
|
||
case 3:
|
||
PublicClass.SetLookUpList(lookUp_Name, Enumerate.PublicDictionaryType.调脂药物, true, "请选择");
|
||
break;
|
||
case 4:
|
||
PublicClass.SetLookUpList(lookUp_Name, Enumerate.PublicDictionaryType.β受体阻滞剂, true, "请选择");
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 其他
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void lookUp_Name_EditValueChanged(object sender, EventArgs e)
|
||
{
|
||
string EditValue = PublicClass.ToString(lookUp_Name.EditValue, "-1");
|
||
//其他
|
||
if (EditValue == "99")
|
||
{
|
||
txt_Other_Drug_Name.Visible = true;
|
||
}
|
||
else
|
||
{
|
||
txt_Other_Drug_Name.Visible = false;
|
||
}
|
||
}
|
||
|
||
private void grv_List_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
||
{
|
||
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
||
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
||
}
|
||
}
|
||
}
|