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_AccidentLevelInfo : XtraForm { public int id; public string name; public int AccidentLevel; public string describe; public Form_AccidentLevelInfo(int _id,string _name,int _AccidentLevel, string _describe) { InitializeComponent(); id = _id; name = _name; AccidentLevel = _AccidentLevel; describe = _describe; } 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 = "三级"; } if (AccidentLevel == 4) { comboBoxEdit1.EditValue = "四级"; } } if (!string.IsNullOrEmpty(describe)) textBox1.Text = describe; } 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_AccidentLevelDTO dto = new T_Base_AccidentLevelDTO(); List list = new List(); dto.LevelName = textEdit1.Text.Trim(); string value = comboBoxEdit1.EditValue.ToString(); if (value == "一级") { dto.AccidentLevel = 1; } if (value == "二级") { dto.AccidentLevel = 2; } if (value == "三级") { dto.AccidentLevel = 3; } if (value == "四级") { dto.AccidentLevel = 4; } dto.Describe = textBox1.Text.Trim(); if (id == 0) { dto.CreateUser = Information.User.ID; Url = "api/base/T_Base_AccidentInfo/SaveAccidentLevel"; } if (id > 0) { dto.ID = id; Url = "api/base/T_Base_AccidentInfo/UpdateAccidentLevel"; } list.Add(dto); //初始化两个工厂 ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); //访问 ListEntity 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_AccidentLevel department; department = (Form_AccidentLevel)this.Owner; department.GetList(); this.Close(); } else { XtraMessageBox.Show("保存失败"); Form_AccidentLevel department; department = (Form_AccidentLevel)this.Owner; department.GetList(); this.Close(); } } catch (Exception) { throw; } } } }