private void btnQuary_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtHospitalNumber.Text)) { MessageBox.Show("住院号不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (!SqlDeal.checkNumberExist(txtHospitalNumber.Text)) { MessageBox.Show("住院号不存在", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); clearAllInput(); clearOrder(); return; } try { DataTable table = SqlDeal.getPatientByHospitalNumber(txtHospitalNumber.Text); txtName.Text = table.Rows[0]["name"].ToString(); txtHospitalNumber.Text = table.Rows[0]["hospitalnumber"].ToString(); txtAge.Text = table.Rows[0]["age"].ToString(); cbSex.Text = table.Rows[0]["sex"].ToString(); txtCategory.Text = table.Rows[0]["category"].ToString(); txtBedNumber.Text = table.Rows[0]["bednumber"].ToString(); dateTimePicker1.Value = Convert.ToDateTime(table.Rows[0]["time"].ToString()); rtxtRemark.Text = table.Rows[0]["remark"].ToString(); } catch { MessageBox.Show("查询失败", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); clearAllInput(); clearOrder(); } }
private void AllPets_Load(object sender, EventArgs e) { DateTime dateTime = DateTime.Now.AddDays(-7); dateTimePicker2.Value = dateTime; //图标显示控件设定 axTChart1.Legend.DividingLines.Visible = true; axTChart1.Environment.MouseWheelScroll = false; //取消鼠标滚轮滑动 axTChart1.Scroll.Enable = TeeChart.EChartScroll.pmHorizontal; //水平滚动 axTChart1.Scroll.MouseButton = TeeChart.EMouseButton.mbRight; //右键滚动 axTChart1.Zoom.Enable = true; //开启缩放 try { //初始化显示一周内的病人记录 QueryParameter queryParameter = getQueryParameter(); DataTable table = SqlDeal.getPatientsByParameters(queryParameter); foreach (DataRow row in table.Rows) { rows.Add(row["hospitalnumber"].ToString(), row); } DataTable dat = table.DefaultView.ToTable(false, new string[] { "hospitalnumber", "name", "sex", "category", "ifchecked" }); renameTable(dat); dataGridView1.DataSource = dat; } catch (Exception e1) { } }
/// <summary> /// Button删除记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click_1(object sender, EventArgs e) { if (dataGridView1.Rows.Count <= 0) { return; } if (dataGridView1.CurrentRow.Index >= 0) { if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { string hospitalNumber = dataGridView1.CurrentRow.Cells["住院号"].Value.ToString(); SqlDeal.deleteItem(hospitalNumber); try { rows.Clear(); QueryParameter queryParameter = getQueryParameter(); DataTable table = SqlDeal.getPatientsByParameters(queryParameter); foreach (DataRow row in table.Rows) { rows.Add(row["hospitalnumber"].ToString(), row); } DataTable dat = table.DefaultView.ToTable(false, new string[] { "hospitalnumber", "name", "sex", "category", "ifchecked" }); renameTable(dat); dataGridView1.DataSource = dat; } catch (Exception e1) { throw e1; } } } }
private void btnStop_Click(object sender, EventArgs e) { if (MessageBox.Show("确认结束?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { return; } try { WorkStatus = 0; btnStart.Text = "开 始(S)"; string path = Application.StartupPath + @"\picture\" + txtHospitalNumber.Text + " " + txtName.Text + ".jpg"; if (File.Exists(path)) { File.Delete(path); } axTChart1.Export.asJPEG.SaveToFile(path); if (receiveData.Count > 0) { //更新患者数据 patient = getPatient(path); SqlDeal.updateData(patient); toolUnity.Tool.exportWord(patient); } else { if (MessageBox.Show("未接收有效数据,是否继续保存?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { //更新患者数据 patient = getPatient(path); SqlDeal.updateData(patient); toolUnity.Tool.exportWord(patient); } } } catch (Exception e1) { MessageBox.Show("保存失败", "错误", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } receiveData.Clear(); resetWarning(); clearAllInput(); clearOrder(); iid = 0; sendStop(); }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("病人姓名不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtHospitalNumber.Text)) { MessageBox.Show("住院号不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtBedNumber.Text)) { MessageBox.Show("床号不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtCategory.Text)) { MessageBox.Show("科别不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (cbSex.SelectedIndex < 0) { MessageBox.Show("性别不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (SqlDeal.checkNumberExist(txtHospitalNumber.Text)) { MessageBox.Show("该住院号已存在,请更换", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } patient = getPatient(); try { SqlDeal.saveData(patient); Enable(btnAdd); disEnable(btnSave); } catch { MessageBox.Show("保存失败", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } }
/// <summary> /// 数据库查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCertain_Click(object sender, EventArgs e) { QueryParameter queryParameter = getQueryParameter(); if (chcTimeSelect.Checked && dateTimePicker2.Value > dateTimePicker3.Value) { MessageBox.Show("起始日期需在结束日期之前", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } //查询数据库 DataTable table1 = SqlDeal.getPatientsByParameters(queryParameter); rows.Clear(); foreach (DataRow row in table1.Rows) { rows.Add(row["hospitalnumber"].ToString(), row); } DataTable dat1 = table1.DefaultView.ToTable(false, new string[] { "hospitalnumber", "name", "sex", "category", "ifchecked" }); renameTable(dat1); dataGridView1.DataSource = dat1; }
private void PetCheck_Load(object sender, EventArgs e) { //只允许有一个进程存在 Process[] processes = Process.GetProcessesByName("NaDetector"); if (processes.Count() > 1) { Environment.Exit(0); } if (SqlDeal.ifTableExist()) { int id = SqlDeal.getID(); if (id >= 2000) { MessageBox.Show("系统内存已满!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); Thread.Sleep(1000); Environment.Exit(0); } else { id = id + 1; SqlDeal.setID(id); } } else { SqlDeal.createTable(); } hospital = OperatorFile.GetIniFileString("patientCheck", "name", "", Application.StartupPath + "\\setting.ini"); label1.Text = "钠离子检测(" + hospital + ")"; try { int temp1 = int.Parse(OperatorFile.GetIniFileString("patientCheck", "bookByte", "", Application.StartupPath + "\\setting.ini")); JingShi = double.Parse(OperatorFile.GetIniFileString("patientCheck", "JingShi", "", Application.StartupPath + "\\setting.ini")); textBox1.Text = JingShi.ToString(); k = double.Parse(OperatorFile.GetIniFileString("patientCheck", "k", "", Application.StartupPath + "\\setting.ini")); b1 = double.Parse(OperatorFile.GetIniFileString("patientCheck", "b", "", Application.StartupPath + "\\setting.ini")); byte.TryParse(temp1.ToString(), out bookByte); } catch { throw new Exception("获取初始化数据错误"); } //图标显示控件设定 axTChart1.Legend.DividingLines.Visible = true; axTChart1.Environment.MouseWheelScroll = false;//取消鼠标滚轮滑动 axTChart1.Scroll.Enable = TeeChart.EChartScroll.pmHorizontal; axTChart1.Scroll.MouseButton = TeeChart.EMouseButton.mbRight; axTChart1.Zoom.Enable = true; //for (int i = 0; i < 1000; i++) // Warning.Add(JingShi); //axTChart1.Invoke((EventHandler)(delegate //{ // axTChart1.Series(0).AddArray(5000, Warning.ToArray()); //})); resetWarning(); drawWarningLine(); this.dateTimePicker1.CustomFormat = "yyyy-MM-dd HH:mm:ss"; this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom; for (int i = 1; i < 21; i++) { toolStripComboBox1.Items.Add(i.ToString()); } part = new byte[1]; string com = ""; try { com = OperatorFile.GetIniFileString("patientCheck", "port", "", Application.StartupPath + "\\setting.ini"); serialPort1.PortName = com; serialPort1.Open(); } catch { MessageBox.Show(com + "串口打开失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (serialPort1.IsOpen) { serialPort1.Close(); } } this.BackColor = Color.FromArgb(173, 220, 250); disEnable(btnStop); try //创建文件夹 { CreateDirectory("word"); //?:为什么要用静态类和实例类各创建一次 CreateDirectory("pdf"); CreateDirectory("picture"); } catch { MessageBox.Show("文件夹创建失败,请手动创建!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnStart_Click(object sender, EventArgs e) { if (btnStart.Text == "开 始(S)") { if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("病人姓名不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtHospitalNumber.Text)) { MessageBox.Show("住院号不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtBedNumber.Text)) { MessageBox.Show("床号不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtCategory.Text)) { MessageBox.Show("科别不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (cbSex.SelectedIndex < 0) { MessageBox.Show("性别不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (!SqlDeal.checkNumberExist(txtHospitalNumber.Text)) { MessageBox.Show("该住院号不存在,请更换", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } dateTimePicker1.Value = DateTime.Now; if (SqlDeal.ifChecked(txtHospitalNumber.Text)) { if (MessageBox.Show("该病人已检测过,继续检测将覆盖原有数据,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { return; } } string com = ""; try { com = OperatorFile.GetIniFileString("patientCheck", "port", "", Application.StartupPath + "\\setting.ini"); if (!serialPort1.IsOpen) { serialPort1.PortName = com; serialPort1.Open(); } } catch { MessageBox.Show(com + "串口打开失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (serialPort1.IsOpen) { serialPort1.Close(); } return; } btnStart.Text = "暂 停(P)"; if (serialPort1.IsOpen) { //发送获取数据指令 sendTo(); } else { serialPort1.Open(); sendTo(); } receiveData.Clear(); WorkStatus = 1; } else if (btnStart.Text == "暂 停(P)") { btnStart.Text = "继 续(C)"; WorkStatus = 3; } else if (btnStart.Text == "继 续(C)") { btnStart.Text = "暂 停(P)"; WorkStatus = 1; } }