コード例 #1
0
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBox1.Text) || string.IsNullOrEmpty(textBox1.Text))
     {
         textBox1.Invoke((EventHandler)(delegate { textBox1.Text = JingShi.ToString(); }));
         MessageBox.Show("警示值不能为空!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
     }
     else
     {
         JingShi = double.Parse(textBox1.Text);
         OperatorFile.WriteIniData("patientCheck", "JingShi", JingShi.ToString(), Application.StartupPath + "\\setting.ini");
         if (Warning.Count > 0)
         {
             int temp = Warning.Count;
             for (int i = (int)iid; i < iid + 1000; i++)
             {
                 if (i < temp)
                 {
                     Warning[i] = JingShi;
                 }
                 else
                 {
                     Warning.Add(JingShi);
                 }
             }
             axTChart1.Series(0).Clear();
             axTChart1.Series(4).Clear();
             axTChart1.Series(5).Clear();
             drawWarningLine();
             //axTChart1.Invoke((EventHandler)(delegate
             //{
             //    axTChart1.Series(0).Clear();
             //    axTChart1.Series(0).AddArray(Warning.Count, Warning.ToArray());
             //}));
         }
     }
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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;
            }
        }