StableVersion4.3/HL_FristAidPlatform_Base/Form_DiagnosisDetailInfo.cs

125 lines
4.4 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_Base
{
public partial class Form_DiagnosisDetailInfo : XtraForm
{
public int id;
public string name;
public long parentId;
public Form_DiagnosisDetailInfo(int _id,string _name,long _parentId)
{
InitializeComponent();
id = _id;
name = _name;
parentId = _parentId;
}
private void Form_InpatientDepartmentInfo_Load(object sender, EventArgs e)
{
DataTable ResultDT = DBHelpClass.Get("api/base/T_Base_Diagnosis/GetDiagnosisTableModel");
PublicClass.SetLookUpList(ref lookUpEdit1, ResultDT, 0, 1, false);
if (!string.IsNullOrEmpty(name))
textEdit1.Text = name;
if (parentId > 0)
lookUpEdit1.EditValue = parentId.ToString();
}
private void btn_Cancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btn_Save_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textEdit1.Text))
{
XtraMessageBox.Show("诊断名称不能为空");
return;
}
if (lookUpEdit1.Text == "")
{
XtraMessageBox.Show("诊断所属类别不能为空");
return;
}
string Url = "";
T_Base_DiagnosisDetailDTO dto = new T_Base_DiagnosisDetailDTO();
List<T_Base_DiagnosisDetailDTO> list = new List<T_Base_DiagnosisDetailDTO>();
dto.Name = textEdit1.Text.Trim();
dto.ParentId = lookUpEdit1.EditValue.ToString() == "" ? 0 : int.Parse(lookUpEdit1.EditValue.ToString());
if (id == 0)
{
Url = "api/base/T_Base_Diagnosis/SaveDiagnosisDetail";
}
if (id > 0)
{
dto.ID = id;
Url = "api/base/T_Base_Diagnosis/UpdateDiagnosisDetail";
}
list.Add(dto);
//初始化两个工厂
ClientFactory<T_Base_DiagnosisDetailDTO> httpClient = new HttpClientFactory<T_Base_DiagnosisDetailDTO>();
Client<T_Base_DiagnosisDetailDTO> client = httpClient.VisitFactory();
//访问
ListEntity<T_Base_DiagnosisDetailDTO> t = client.Post(Url, list);
if (t.Success)
{
if (!string.IsNullOrEmpty(t.DataString))
{
if (t.DataString.Contains("Success"))
{
JObject jo = (JObject)JsonConvert.DeserializeObject(t.DataString);
string msg = jo["Msg"].ToString();
if (!string.IsNullOrEmpty(msg))
{
XtraMessageBox.Show(msg);
}
}
else
{
string msg1 = t.DataString.Replace("/", "").Replace(@"\", "").Replace("\"", "");
XtraMessageBox.Show(msg1);
}
}
else
{
XtraMessageBox.Show("保存失败");
}
Form_DiagnosisDetail department;
department = (Form_DiagnosisDetail)this.Owner;
department.GetList();
this.Close();
}
else
{
XtraMessageBox.Show("保存失败");
Form_DiagnosisDetail department;
department = (Form_DiagnosisDetail)this.Owner;
department.GetList();
this.Close();
}
}
catch (Exception)
{
throw;
}
}
}
}