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.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; namespace HL_FristAidPlatform_ChestPain { public partial class Form_AddChestPainHighRiskScreening : XtraForm { public Form_AddChestPainHighRiskScreening() { InitializeComponent(); } private void simpleButton1_Click(object sender, EventArgs e) { try { #region 判空 if (rgUnconsciousness.SelectedIndex == -1|| rgPale.SelectedIndex==-1|| rgBreathShortness.SelectedIndex == -1|| rgChestTightness.SelectedIndex==-1|| rgExtremityCold.SelectedIndex == -1) { XtraMessageBox.Show("请检查完善筛查必填项信息!!"); return; } if (string.IsNullOrEmpty(txtHeight.Text+"")|| string.IsNullOrEmpty(txtWeight.Text + "")|| string.IsNullOrEmpty(txtName.Text + "")|| string.IsNullOrEmpty(txtAge.Text + "")) { XtraMessageBox.Show("请检查完善人员信息必填项信息!!"); return; } if (rgGender.SelectedIndex == -1) { XtraMessageBox.Show("请检查完善性别信息!!"); return; } if (string.IsNullOrEmpty(txtPhone.Text + "")&& string.IsNullOrEmpty(txtIDCard.Text + "")) { XtraMessageBox.Show("请检查完善手机号或身份证号信息!!"); return; } #endregion List list = new List(); T_Service_FirstAid_ChestPainHighRiskScreeningDTO dto = new T_Service_FirstAid_ChestPainHighRiskScreeningDTO(); dto.Unconsciousness = int.Parse(rgUnconsciousness.EditValue.ToString()); dto.Pale = int.Parse(rgPale.EditValue.ToString()); dto.BreathShortness = int.Parse(rgBreathShortness.EditValue.ToString()); dto.ChestTightness = int.Parse(rgChestTightness.EditValue.ToString()); dto.ExtremityCold = int.Parse(rgExtremityCold.EditValue.ToString()); if (rgHypertension.SelectedIndex != -1) { dto.Hypertension = rgHypertension.EditValue.ToString(); } if (rgBloodFat.SelectedIndex != -1) { dto.BloodFat = rgBloodFat.EditValue.ToString(); } if (rgDiabetes.SelectedIndex != -1) { dto.Diabetes = rgDiabetes.EditValue.ToString(); } if (rgApoplexy.SelectedIndex != -1) { dto.Apoplexy = rgApoplexy.EditValue.ToString(); } if (rgKidney.SelectedIndex != -1) { dto.Kidney = rgKidney.EditValue.ToString(); } if (rgSmoke.SelectedIndex != -1) { dto.Smoke = rgSmoke.EditValue.ToString(); } if (rgDrinkWine.SelectedIndex != -1) { dto.DrinkWine = rgDrinkWine.EditValue.ToString(); } if (rgDrugAllergy.SelectedIndex != -1) { dto.DrugAllergy = rgDrugAllergy.EditValue.ToString(); } if (rgSurgicalTrauma.SelectedIndex != -1) { dto.SurgicalTrauma = rgSurgicalTrauma.EditValue.ToString(); } if (rgHypertensionFamily.SelectedIndex != -1) { dto.HypertensionFamily = rgHypertensionFamily.EditValue.ToString(); } if (rgDiabetesFamily.SelectedIndex != -1) { dto.DiabetesFamily = rgDiabetesFamily.EditValue.ToString(); } if (rgCerebrovascularDisease.SelectedIndex != -1) { dto.CerebrovascularDisease = rgCerebrovascularDisease.EditValue.ToString(); } if (rgPhysicalLabor.SelectedIndex != -1) { dto.PhysicalLabor = rgPhysicalLabor.EditValue.ToString(); } if (rgSitQuietly.SelectedIndex != -1) { dto.SitQuietly = rgSitQuietly.EditValue.ToString(); } if (rgHeavySalt.SelectedIndex != -1) { dto.HeavySalt = rgHeavySalt.EditValue.ToString(); } if (rgSnore.SelectedIndex != -1) { dto.Snore = rgSnore.EditValue.ToString(); } dto.Height = txtHeight.Text + ""; dto.Weight = txtWeight.Text + ""; double height = double.Parse(txtHeight.Text + ""); // 身高变量,单位:米 height = height / 100; double weight = double.Parse(txtWeight.Text + ""); // 体重变量,单位:千克 double exponent = weight / (height * height);// BMI计算公式 dto.BMI = exponent.ToString("#0.00"); dto.Name = txtName.Text + ""; dto.Gender = int.Parse(rgGender.EditValue.ToString()); dto.Age = int.Parse(txtAge.Text + ""); dto.Phone = txtPhone.Text + ""; dto.IDCard = txtIDCard.Text + ""; dto.Remarks = memoEditRemarks.Text + ""; dto.HospitalGUID= Information.Hospital.GUID; list.Add(dto); string Url = "api/service/T_Service_FirstAid_ChestPainHighRiskScreening"; //初始化两个工厂 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["ResultMsg"].ToString(); string msg1 = jo["Msg"].ToString(); if (!string.IsNullOrEmpty(msg1)) { if (msg1 == "1") { XtraMessageBox.Show("新增成功!该人员为高危人群"); } else { XtraMessageBox.Show("新增成功!该人员为低危人群"); } Form_ChestPainHighRiskScreening chestPainHighRiskScreening; chestPainHighRiskScreening = (Form_ChestPainHighRiskScreening)this.Owner; chestPainHighRiskScreening.FillGridListCtrlQuery(1, 20); this.Close(); } else { XtraMessageBox.Show(msg1); } } else { string msg1 = t.DataString.Replace("/", "").Replace(@"\", "").Replace("\"", ""); XtraMessageBox.Show(msg1); } } else { XtraMessageBox.Show("保存失败"); } } else { XtraMessageBox.Show("保存失败"); } } catch (Exception ex) { throw ex; } } private void txtIDCard_EditValueChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtIDCard.Text)) { try { string resulst = txtIDCard.Text.ToString().Trim(); if (resulst.Length == 18) { rgGender.Enabled = false; txtAge.Enabled = false; long n = 0; if (long.TryParse(resulst.Remove(17), out n) == false || n < Math.Pow(10, 16) || long.TryParse(resulst.Replace('x', '0').Replace('X', '0'), out n) == false) { lbl_IdentityCard.Visible = true; } string address = "11x22x35x44x53x12x23x36x45x54x13x31x37x46x61x14x32x41x50x62x15x33x42x51x63x21x34x43x52x64x65x71x81x82x91"; if (address.IndexOf(resulst.Remove(2)) == -1) { lbl_IdentityCard.Visible = true; } string birth = resulst.Substring(6, 8).Insert(6, "-").Insert(4, "-"); DateTime time = new DateTime(); if (DateTime.TryParse(birth, out time) == false) { lbl_IdentityCard.Visible = true; } //string[] arrVarifyCode = ("1,0,x,9,8,7,6,5,4,3,2").Split(','); //int y = -1; //if (arrVarifyCode[y] != resulst.Substring(17, 1).ToLower()) //{ // lbl_IdentityCard.Visible = true; //} string year = resulst.Substring(6, 4); string month = resulst.Substring(10, 2); string day = resulst.Substring(12, 2); string birthday = year + "-" + month + "-" + day; //性别 int sex = Convert.ToInt32(resulst.Substring(resulst.Length - 2, 1)); if (sex % 2 == 0) rgGender.EditValue = "2"; else if (sex % 2 == 1) rgGender.EditValue = "1"; int ageUnit = 0; int age = PublicClass.GetAge(Convert.ToDateTime(birthday + ""), DateTime.Now, out ageUnit); txtAge.Text = age + ""; lbl_IdentityCard.Visible = false; } else { rgGender.Enabled = true; txtAge.Enabled = true; lbl_IdentityCard.Visible = true; } } catch (Exception ex) { rgGender.Enabled = true; txtAge.Enabled = true; lbl_IdentityCard.Visible = true; return; } } else { lbl_IdentityCard.Visible = false; rgGender.EditValue = -1; txtAge.Text = ""; } } private void txtPhone_EditValueChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtPhone.Text)) { if (Regex.IsMatch(txtPhone.Text, @"^(0\d{2,3})?(\d{7,8})$") || Regex.IsMatch(txtPhone.Text, @"^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$")) { lbl_MobilePhone.Visible = false; } else { lbl_MobilePhone.Visible = true; } } } } }