private void buttonX1_Click(object sender, EventArgs e)
        {
            serialPort1.Close();
            PortSelectionForm form5 = new PortSelectionForm();

            form5.ShowDialog();
            serialPort1.PortName = comPort;
            serialPort1.Open();
            checkConnection = false;
        }
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                PatientIDBox.ReadOnly   = true;
                PatientNameBox.ReadOnly = true;
                BirthdateBox.ReadOnly   = true;
                GenderBox.ReadOnly      = true;
                ContactNoBox.ReadOnly   = true;
                AddressBox.ReadOnly     = true;
                LastUpdateBox.ReadOnly  = true;

                calendar1.SelectedDate = DateTime.Now;
                intervalChoice         = "30mins";
                if (chart1.Series.Count == 1)
                {
                    chart1.Series["Series1"].Name = "Systolic";
                    chart1.Series.Add("Diastolic");

                    chart1.Series.Add("Systolic2");
                    chart1.Series.Add("Diastolic2");
                }
                if (alreadyLog == 0)
                {
                    LoginForm login = new LoginForm();

                    login.ShowDialog();
                }
                PortSelectionForm form5 = new PortSelectionForm();
                form5.ShowDialog();
                if (serialPort1.IsOpen)
                {
                    serialPort1.Close();
                }
                serialPort1.PortName = comPort;
                serialPort1.Open();
                if (!checkConnection)
                {
                    MessageBox.Show("WARNING: The console has not been yet detected!");
                }
                alreadyLog = 1;
                string          source = "SELECT * from Profile where [PatientID] = '" + patientID + "'";
                OleDbConnection cn     = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + "C:\\Patient\'s Record.accdb");
                cn.Open();
                OleDbCommand    cmd    = new OleDbCommand(source, cn);
                OleDbDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    if (patientID == reader.GetValue(0).ToString())
                    {
                        PatientIDBox.Text         = reader.GetValue(0).ToString();
                        PatientNameBox.Text       = reader.GetValue(1).ToString();
                        BirthdateBox.Text         = reader.GetValue(2).ToString();
                        LastUpdateBox.Text        = reader.GetValue(3).ToString();
                        AddressBox.Text           = reader.GetValue(4).ToString();
                        ContactNoBox.Text         = reader.GetValue(6).ToString();
                        GenderBox.Text            = reader.GetValue(5).ToString();
                        pictureBox1.ImageLocation = reader.GetValue(7).ToString();
                        try
                        {
                            pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
                            pictureBox1.Load();
                        }
                        catch (Exception)
                        {
                            pictureBox1.Enabled = false;
                        }
                        break;
                    }
                }
                reader.Close();
                cn.Close();
                calendar1.OnlyMonthMode = true;
                show30MinuteChart();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show("Invalid operation has been detected!");
                Application.Exit();
            }
        }