150 lines
4.9 KiB
C#
150 lines
4.9 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_AccidentInfo : XtraForm
|
|
{
|
|
public int id;
|
|
public string name;
|
|
public int AccidentLevel;
|
|
public Form_AccidentInfo(int _id,string _name,int _AccidentLevel)
|
|
{
|
|
InitializeComponent();
|
|
id = _id;
|
|
name = _name;
|
|
AccidentLevel = _AccidentLevel;
|
|
}
|
|
|
|
private void Form_InpatientDepartmentInfo_Load(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(name))
|
|
textEdit1.Text = name;
|
|
if (AccidentLevel > 0)
|
|
{
|
|
if (AccidentLevel == 1)
|
|
{
|
|
comboBoxEdit1.EditValue = "一级";
|
|
}
|
|
if (AccidentLevel == 2)
|
|
{
|
|
comboBoxEdit1.EditValue = "二级";
|
|
}
|
|
if (AccidentLevel == 3)
|
|
{
|
|
comboBoxEdit1.EditValue = "三级";
|
|
}
|
|
}
|
|
}
|
|
|
|
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 (string.IsNullOrEmpty(comboBoxEdit1.EditValue + ""))
|
|
{
|
|
XtraMessageBox.Show("事件等级不能为空");
|
|
return;
|
|
}
|
|
string Url = "";
|
|
T_Base_AccidentInfoDTO dto = new T_Base_AccidentInfoDTO();
|
|
List<T_Base_AccidentInfoDTO> list = new List<T_Base_AccidentInfoDTO>();
|
|
dto.ParentName = textEdit1.Text.Trim();
|
|
|
|
string value = comboBoxEdit1.EditValue.ToString();
|
|
if (value == "一级")
|
|
{
|
|
dto.AccidentLevel = 1;
|
|
}
|
|
if (value == "二级")
|
|
{
|
|
dto.AccidentLevel = 2;
|
|
}
|
|
if (value == "三级")
|
|
{
|
|
dto.AccidentLevel = 3;
|
|
}
|
|
if (id == 0)
|
|
{
|
|
dto.CreateUser = Information.User.ID;
|
|
Url = "api/base/T_Base_AccidentInfo/SaveAccidentInfo";
|
|
}
|
|
if (id > 0)
|
|
{
|
|
dto.ID = id;
|
|
Url = "api/base/T_Base_AccidentInfo/UpdateAccidentInfo";
|
|
}
|
|
list.Add(dto);
|
|
//初始化两个工厂
|
|
ClientFactory<T_Base_AccidentInfoDTO> httpClient = new HttpClientFactory<T_Base_AccidentInfoDTO>();
|
|
Client<T_Base_AccidentInfoDTO> client = httpClient.VisitFactory();
|
|
//访问
|
|
ListEntity<T_Base_AccidentInfoDTO> 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_Accident department;
|
|
department = (Form_Accident)this.Owner;
|
|
department.GetList();
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show("保存失败");
|
|
Form_Accident department;
|
|
department = (Form_Accident)this.Owner;
|
|
department.GetList();
|
|
this.Close();
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|