//接收数据 private void Com_DataReceived(object sender, SerialDataReceivedEventArgs e) { bool flag2 = PortConfig.serialPort1 == null || !PortConfig.serialPort1.IsOpen; if (!flag2) { string backStr = PortConfig.serialPort1.ReadExisting(); if (backStr.Length > 30) { if (backStr.Substring(0, 1) == "{") { string height = null; if (memberHeight != null) { if (memberHeight.IndexOf('.') > -1) { height = memberHeight; } else { height = memberHeight + ".0"; } TeacherCheckData data = new TeacherCheckData { Id = Guid.NewGuid().ToString(), memberName = memberName, memberAge = memberBirthDay, memberSex = memberSex, memberHeight = double.Parse(memberHeight), checkDate = DateTime.Now.ToString(), memberId = memberId, JsonContent = backStr, isUpload = "0" }; bool isSave = dbUtill.SavaTeacherCheckData(data); if (isSave) { Dispatcher.Invoke(new Action(() => { MessageBox.Show("检测完毕,请离开体测仪", "提示"); closeBtn.IsEnabled = true; checkBtn.IsEnabled = true; display.Text = "检测完成,如需重新检测请按\"开始检测\"进行检测"; })); } else { Dispatcher.Invoke(new Action(() => { MessageBox.Show("保存失败", "提示"); closeBtn.IsEnabled = true; checkBtn.IsEnabled = true; display.Text = "检测完成,如需重新检测请按\"开始检测\"进行检测"; })); } } else { MessageBox.Show("没有数据", "提示"); } } } } }