StableVersion4.3/HL_FristAidPlatform_FollowUp/FollowUpInfo/UC_FollowUpSomaticSymptoms.cs

177 lines
6.5 KiB
C#

using DevExpress.XtraEditors;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_Public;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HL_FristAidPlatform_FollowUp
{
public partial class UC_FollowUpSomaticSymptoms : UserControl
{
/// <summary>
///
/// </summary>
public string registerId;
/// <summary>
///
/// </summary>
public string month;
public UC_FollowUpSomaticSymptoms(string _registerId, string _month)
{
InitializeComponent();
registerId = _registerId;
month = _month;
}
private void UC_FollowUpSomaticSymptoms_Load(object sender, EventArgs e)
{
GetInfo();
}
/// <summary>
/// 获取数据
/// </summary>
public void GetInfo()
{
FollowUpSomaticSymptomsDTO dto = new FollowUpSomaticSymptomsDTO();
string url = string.Format("api/service/T_Service_ChestPain_FollowUpInfo/GetFollowUpSomaticSymptoms?registerId={0}&month={1}", registerId, month);
dto = DBHelpClass.GetDateModel<FollowUpSomaticSymptomsDTO>(url);
if (dto != null)
{
if (!string.IsNullOrEmpty(dto.somaticSymptoms))
{
string[] adverse = dto.somaticSymptoms.ToString().Split(new char[] { '|' });
for (int i = 0; i < adverse.Length; i++)
{
for (int j = 0; j < check_somaticSymptoms.Items.Count; j++)
{
if (check_somaticSymptoms.Items[j].Value.ToString().Trim().Contains(adverse[i]))
{
check_somaticSymptoms.SetItemChecked(j, true);
}
}
if (dto.somaticSymptoms.Contains("1"))
{
panel_chestPainSymptom.Visible = true;
panelControl1.Visible = true;
radio_chestPainSymptom.EditValue = dto.chestPainSymptom;
}
if (dto.somaticSymptoms.Contains("9"))
{
txt_somaticSymptomsDesc.Text = dto.somaticSymptomsDesc;
panel_somaticSymptomsDesc.Visible = true;
}
}
radio_anginapectorisGrade.EditValue = dto.anginapectorisGrade;
}
radio_nyha.EditValue = dto.nyha;
}
}
private void check_somaticSymptoms_MouseClick(object sender, MouseEventArgs e)
{
if (check_somaticSymptoms.SelectedIndex == 0)
{
if (check_somaticSymptoms.Items[0].CheckState == CheckState.Checked)
{
panel_chestPainSymptom.Visible = false;
panelControl1.Visible = false;
}
else
{
panel_chestPainSymptom.Visible = true;
panelControl1.Visible = true;
}
}
if (check_somaticSymptoms.SelectedIndex == 4)
{
if (check_somaticSymptoms.Items[4].CheckState == CheckState.Checked)
{
panel_somaticSymptomsDesc.Visible = false;
}
else
{
panel_somaticSymptomsDesc.Visible = true;
}
}
}
/// <summary>
/// 保存数据
/// </summary>
public void SaveFollowUpSomaticSymptoms(string status)
{
try
{
List<FollowUpSomaticSymptomsDTO> list = new List<FollowUpSomaticSymptomsDTO>();
FollowUpSomaticSymptomsDTO dto = new FollowUpSomaticSymptomsDTO();
dto.registerId = registerId;
dto.month = month;
dto.status = status;
for (int i = 0; i < check_somaticSymptoms.Items.Count; i++)
{
if (check_somaticSymptoms.Items[i].CheckState == CheckState.Checked)
{
dto.somaticSymptoms += check_somaticSymptoms.Items[i].Value.ToString() + "|";
}
}
if (!string.IsNullOrEmpty(dto.somaticSymptoms)) dto.somaticSymptoms = dto.somaticSymptoms.TrimEnd('|');
if (!string.IsNullOrEmpty(dto.somaticSymptoms))
{
if (dto.somaticSymptoms.Contains("1"))
{
dto.chestPainSymptom = radio_chestPainSymptom.EditValue != null ? radio_chestPainSymptom.EditValue.ToString() : "";
dto.anginapectorisGrade = radio_anginapectorisGrade.EditValue != null ? radio_anginapectorisGrade.EditValue.ToString() : "";
}
if (dto.somaticSymptoms.Contains("9")) dto.somaticSymptomsDesc = txt_somaticSymptomsDesc.Text;
}
dto.nyha = radio_nyha.EditValue != null ? radio_nyha.EditValue.ToString() : "";
list.Add(dto);
string Url = string.Empty;
Url = "api/service/T_Service_ChestPain_FollowUpInfo/SaveFollowUpSomaticSymptoms";
//初始化两个工厂
ClientFactory<FollowUpSomaticSymptomsDTO> httpClient = new HttpClientFactory<FollowUpSomaticSymptomsDTO>();
Client<FollowUpSomaticSymptomsDTO> client = httpClient.VisitFactory();
//访问
ListEntity<FollowUpSomaticSymptomsDTO> t = client.Post(Url, list);
if (t.Success)
{
JObject jo = (JObject)JsonConvert.DeserializeObject(t.DataString);
string msg = jo["Msg"].ToString();
if (!string.IsNullOrEmpty(msg))
{
XtraMessageBox.Show(msg);
}
}
else
{
// MessageBox.Show("保存失败");
}
}
catch (Exception)
{
throw;
}
}
}
}