public DataTable searchPatientData(MySqlConnection conn, string searchText)
        {
            bool   status = int.TryParse(searchText, out int result);
            string sql;

            if (status)
            {
                sql = "SELECT * FROM patient WHERE id LIKE '" + result + "%' OR identityCard LIKE '" + result + "%' OR phone LIKE '" + result + "%' OR age LIKE '" + result + "%' OR bedsideId LIKE '" + result + "%'";
            }
            else
            {
                sql = "SELECT * FROM patient WHERe fullName LIKE '" + searchText + "%' OR address LIKE '" + searchText + "%' OR email LIKE '" + searchText + "%' OR gender LIKE '" + searchText + "%'";
            }

            DBConnector dBConn = new DBConnector();

            dBConn.connect();
            MySqlDataAdapter sqlData = new MySqlDataAdapter(sql, dBConn.getConn());
            DataTable        table   = new DataTable();

            sqlData.Fill(table);
            dBConn.getConn().Close();

            return(table);
        }
        //login
        private void loginBtn_Click(object sender, EventArgs e)
        {
            if (departmentComboBox.SelectedIndex == 0)
            {
                MessageBox.Show("Please select department");
                return;
            }

            if (usernameTextBox.Text == "Enter your user id")
            {
                MessageBox.Show("Please enter username");
                return;
            }

            if (passwordTextBox.Text == "Enter password")
            {
                MessageBox.Show("Please enter password");
                return;
            }



            DBConnector dbC = new DBConnector();

            dbC.connect();
            UserHandler userHandler = new UserHandler();
            bool        login       = userHandler.proceedLogin(dbC.getConn(), departmentComboBox.SelectedItem.ToString().ToLower(), usernameTextBox.Text, passwordTextBox.Text);

            if (login)
            {
                bool status = userHandler.changeLoginStatus(dbC.getConn(), usernameTextBox.Text, login, departmentComboBox.SelectedItem.ToString());

                if (status)
                {
                    userIdStatic   = usernameTextBox.Text;
                    userDepartment = departmentComboBox.SelectedItem.ToString().ToLower();
                    MainScreen mainscreen = new MainScreen();
                    mainscreen.Show();
                    Close();
                }
                else
                {
                    MessageBox.Show("Invalid username or password");
                    usernameTextBox.Text = "";
                    passwordTextBox.Text = "";
                }
            }
            else
            {
                MessageBox.Show("Invalid username or password");
                usernameTextBox.Text = "";
                passwordTextBox.Text = "";
            }

            //MainScreen mainscreen = new MainScreen();
            //mainscreen.Show();
            //Close();
        }
        private void updatePatientButton_Click(object sender, EventArgs e)
        {
            DBConnector dbC = new DBConnector();

            dbC.connect();
            PatientHandler patientHandler = new PatientHandler();
            Patient        oldPatientData = new Patient();

            if (choosePatientIDUpdateComboBox.SelectedIndex == 0)
            {
                MessageBox.Show("Please select valid ID");
                return;
            }
            if (nricUpdateTextBox.Enabled == false)
            {
                MessageBox.Show("Please press 'Enter' to generate data first");
                return;
            }
            else
            {
                oldPatientData = patientHandler.getSpecificPatient(dbC.getConn(), int.Parse(choosePatientIDUpdateComboBox.SelectedItem.ToString()));
            }

            if ((oldPatientData.IdentityCard.ToString() != nricUpdateTextBox.Text) || (oldPatientData.FullName != fullNameUpdateTextBox.Text) || (oldPatientData.Email != emailUpdateTextBox.Text) || (oldPatientData.Gender != genderUpdatecomboBox.SelectedItem.ToString()) || (oldPatientData.Phone.ToString() != phoneUpdateTextBox.Text) || (oldPatientData.Address != addressUpdateTextBox.Text) || (oldPatientData.Age.ToString() != ageUpdateTextBox.Text) || (oldPatientData.BedsideId.ToString() != bedsideIdUpdateTextBox.Text))
            {
                Patient newPatientData = new Patient();
                newPatientData.Id           = int.Parse(choosePatientIDUpdateComboBox.SelectedItem.ToString());
                newPatientData.IdentityCard = long.Parse(nricUpdateTextBox.Text);
                newPatientData.FullName     = fullNameUpdateTextBox.Text;
                newPatientData.Email        = emailUpdateTextBox.Text;
                newPatientData.Gender       = genderUpdatecomboBox.SelectedItem.ToString();
                newPatientData.Phone        = int.Parse(phoneUpdateTextBox.Text);
                newPatientData.Address      = addressUpdateTextBox.Text;
                newPatientData.Age          = int.Parse(ageUpdateTextBox.Text);
                newPatientData.BedsideId    = int.Parse(bedsideIdUpdateTextBox.Text);

                int updateResult = patientHandler.updatePatientData(dbC.getConn(), newPatientData);

                if (updateResult == 1)
                {
                    MessageBox.Show("Update Successfully");
                    closeAllTextBox(fullNameUpdateTextBox, nricUpdateTextBox, emailUpdateTextBox, phoneTextBox, addressUpdateTextBox, ageUpdateTextBox, bedsideIdUpdateTextBox, choosePatientIDUpdateComboBox, genderUpdatecomboBox);
                    patientHandler.FetchId(choosePatientIDUpdateComboBox);
                }
                else
                {
                    MessageBox.Show("Update Failed");
                }
            }
            else
            {
                MessageBox.Show("Nothing is changes");
            }
        }
        private void PatientScreen_Load(object sender, EventArgs e)
        {
            viewControlPanel.Width     = 879;
            viewControlPanel.Height    = 365;
            viewControlPanel.Location  = new Point(5, 195);
            addRecordPanel.Width       = 879;
            addRecordPanel.Height      = 365;
            addRecordPanel.Location    = new Point(5, 195);
            updateRecordPanel.Width    = 879;
            updateRecordPanel.Height   = 365;
            updateRecordPanel.Location = new Point(5, 195);
            deleteRecordPanel.Width    = 879;
            deleteRecordPanel.Height   = 365;
            deleteRecordPanel.Location = new Point(5, 195);
            DBConnector dBconn = new DBConnector();

            dBconn.connect();

            PatientHandler patientHandler = new PatientHandler();

            patientGridView.DataSource = patientHandler.getAllPatient(dBconn.getConn());

            viewControlPanel.Show();
            addRecordPanel.Hide();
            updateRecordPanel.Hide();
            deleteRecordPanel.Hide();
        }
        public PatientScreen()
        {
            InitializeComponent();
            genderComboBox.SelectedIndex = 0;
            DBConnector dBConn = new DBConnector();

            dBConn.connect();
            PatientHandler patientHandler = new PatientHandler();

            patientGridView.DataSource = patientHandler.getAllPatient(dBConn.getConn());
        }
        private void searchtextBox_TextChanged(object sender, EventArgs e)
        {
            DBConnector dBconn = new DBConnector();

            dBconn.connect();
            PatientHandler patientHandler = new PatientHandler();

            if (searchtextBox.Text != "")
            {
                patientGridView.DataSource = patientHandler.searchPatientData(dBconn.getConn(), searchtextBox.Text);
            }
        }
        public DataTable searchData(string value)
        {
            DBConnector dBConn = new DBConnector();

            dBConn.connect();
            string           searchQuery = "SELECT * FROM patient where fullName='" + value + "'";
            MySqlDataAdapter sqlData     = new MySqlDataAdapter(searchQuery, dBConn.getConn());
            DataTable        table       = new DataTable();

            sqlData.Fill(table);

            return(table);
        }
        //-----------------------------------------------------------Add Record----------------------------------------------------------------------------//
        private void viewRecordBtn_Click(object sender, EventArgs e)
        {
            DBConnector dBconn = new DBConnector();

            dBconn.connect();

            PatientHandler patientHandler = new PatientHandler();

            patientGridView.DataSource = patientHandler.getAllPatient(dBconn.getConn());
            viewControlPanel.Show();
            addRecordPanel.Hide();
            updateRecordPanel.Hide();
            deleteRecordPanel.Hide();
        }
        private void choosePatientComboBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                if (choosePatientIDUpdateComboBox.SelectedIndex == 0)
                {
                    MessageBox.Show("Please select valid ID");
                }
                else
                {
                    nricUpdateTextBox.Enabled      = true;
                    fullNameUpdateTextBox.Enabled  = true;
                    emailUpdateTextBox.Enabled     = true;
                    genderUpdatecomboBox.Enabled   = true;
                    phoneUpdateTextBox.Enabled     = true;
                    addressUpdateTextBox.Enabled   = true;
                    ageUpdateTextBox.Enabled       = true;
                    bedsideIdUpdateTextBox.Enabled = true;
                    genderUpdatecomboBox.Items.Add("Male");
                    genderUpdatecomboBox.Items.Add("Female");
                    DBConnector dbC = new DBConnector();
                    dbC.connect();
                    PatientHandler patientHandler = new PatientHandler();
                    List <Patient> patientList    = new List <Patient>();
                    patientList = patientHandler.getAllPatient(dbC.getConn());
                    for (int i = 0; i < patientList.Count; i++)
                    {
                        if (choosePatientIDUpdateComboBox.SelectedItem.ToString() == patientList[i].Id.ToString())
                        {
                            nricUpdateTextBox.Text     = patientList[i].IdentityCard.ToString();
                            fullNameUpdateTextBox.Text = patientList[i].FullName;
                            emailUpdateTextBox.Text    = patientList[i].Email;

                            for (int n = 0; n < genderUpdatecomboBox.Items.Count; n++)
                            {
                                if (patientList[i].Gender == genderUpdatecomboBox.Items[n].ToString())
                                {
                                    genderUpdatecomboBox.SelectedIndex = n;
                                }
                            }

                            phoneUpdateTextBox.Text     = patientList[i].Phone.ToString();
                            addressUpdateTextBox.Text   = patientList[i].Address;
                            ageUpdateTextBox.Text       = patientList[i].Age.ToString();
                            bedsideIdUpdateTextBox.Text = patientList[i].BedsideId.ToString();
                        }
                    }
                }
            }
        }
Exemple #10
0
        //current user log out
        private void logOutbtn_Click(object sender, EventArgs e)
        {
            DBConnector dBConn = new DBConnector();

            dBConn.connect();
            mainScreenUserIdStatic   = Login.userIdStatic;
            mainScreenUserDepartment = Login.userDepartment;
            UserHandler userHandler = new UserHandler();
            int         id          = userHandler.FindUserId(dBConn.getConn(), mainScreenUserDepartment, mainScreenUserIdStatic);
            bool        status      = userHandler.Logout(dBConn.getConn(), id);

            if (status)
            {
                MessageBox.Show("Log Out Successfully");
                Login login = new Login();
                login.Show();
                Close();
            }
            else
            {
                MessageBox.Show("Log Out Failed");
            }
        }
        private void deletePatientRecordBtn_Click(object sender, EventArgs e)
        {
            DBConnector dbC = new DBConnector();

            dbC.connect();
            PatientHandler patientHandler = new PatientHandler();
            Patient        oldPatientData = new Patient();

            if (choosePatientIDDeleteComboBox.SelectedIndex == 0)
            {
                MessageBox.Show("Please select valid ID");
                return;
            }
            if (string.IsNullOrEmpty(nricDeleteTextBox.Text))
            {
                MessageBox.Show("Please press 'Enter' to generate data first");
                return;
            }
            else
            {
                oldPatientData = patientHandler.getSpecificPatient(dbC.getConn(), int.Parse(choosePatientIDDeleteComboBox.SelectedItem.ToString()));
            }

            int deleteResult = patientHandler.deletePatientData(dbC.getConn(), oldPatientData.Id);

            if (deleteResult == 1)
            {
                MessageBox.Show("Delete Record Successfully");
                closeAllTextBox(fullNameDeleteTextBox, nricDeleteTextBox, emailDeleteTextBox, phoneDeleteTextBox, addressDeleteRichTextBox, ageDeleteTextBox, bedsideIdDeleteTextBox, choosePatientIDDeleteComboBox, genderDeleteComboBox);
                patientHandler.FetchId(choosePatientIDDeleteComboBox);
            }
            else
            {
                MessageBox.Show("Delete Failed");
            }
        }
        //-----------------------------------------------------------Add Record----------------------------------------------------------------------------//
        private void addRecordBtn_Click(object sender, EventArgs e)
        {
            DBConnector dBconn = new DBConnector();

            dBconn.connect();
            PatientHandler patientHandler = new PatientHandler();

            patientIdTextBox.Text        = patientHandler.getLastRecordID(dBconn.getConn());
            genderComboBox.SelectedIndex = 0;

            viewControlPanel.Hide();
            addRecordPanel.Show();
            updateRecordPanel.Hide();
            deleteRecordPanel.Hide();
        }
        //fetch centralstation name
        public void FetchCentralStationName(ComboBox selectedcomboBox)
        {
            selectedcomboBox.Items.Add("--Select ID--");

            selectedcomboBox.SelectedIndex = 0;
            DBConnector dbC = new DBConnector();

            dbC.connect();
            CentralStationHandler centralStationHand = new CentralStationHandler();
            List <CentralStation> listCentralStation = new List <CentralStation>();

            listCentralStation = centralStationHand.getAllCentralStation(dbC.getConn());
            for (int i = 0; i < listCentralStation.Count; i++)
            {
                selectedcomboBox.Items.Add(listCentralStation[i].CentralStationName);
            }
        }
        //fill combobox by taking database value
        private void setDepartment()
        {
            departmentComboBox.Items.Clear();
            departmentComboBox.Items.Add("--Select Department--");
            departmentComboBox.SelectedIndex = 0;
            DBConnector dbC = new DBConnector();

            dbC.connect();
            RoleHandler roleHandler = new RoleHandler();
            List <Role> rolesList   = new List <Role>();

            rolesList = roleHandler.getAllRole(dbC.getConn());
            for (int i = 0; i < rolesList.Count; i++)
            {
                departmentComboBox.Items.Add(rolesList[i].Position);
            }
        }
        //public int alterTable(MySqlConnection conn, int id)
        //{
        //    string sql = "ALTER TABLE patient AUTO INCREMENT= '" + id + "'";
        //    MySqlCommand alterCommand = new MySqlCommand(sql, conn);
        //    return alterCommand.ExecuteNonQuery();
        //}

        public void FetchId(ComboBox selectedcomboBox)
        {
            selectedcomboBox.Items.Add("--Select ID--");

            selectedcomboBox.SelectedIndex = 0;
            DBConnector dbC = new DBConnector();

            dbC.connect();
            PatientHandler patientHandler = new PatientHandler();
            List <Patient> patientList    = new List <Patient>();

            patientList = patientHandler.getAllPatient(dbC.getConn());
            for (int i = 0; i < patientList.Count; i++)
            {
                selectedcomboBox.Items.Add(patientList[i].Id);
            }
        }
Exemple #16
0
        //fetch patient alarm id
        public void FetchPatientAlarmId(ComboBox selectedcomboBox)
        {
            selectedcomboBox.Items.Add("--Select ID--");

            selectedcomboBox.SelectedIndex = 0;
            DBConnector dbC = new DBConnector();

            dbC.connect();
            AlarmHandler alarmhd   = new AlarmHandler();
            List <Alarm> alarmList = new List <Alarm>();

            alarmList = alarmhd.getAllAlarm(dbC.getConn());
            for (int i = 0; i < alarmList.Count; i++)
            {
                if ((alarmList[i].PatientId == 0))
                {
                    selectedcomboBox.Items.Add(alarmList[i].SpecificId);
                }
            }
        }
        private void savePatientBtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(fullNameTextBox.Text))
            {
                MessageBox.Show("Please enter full name");
                return;
            }

            if (string.IsNullOrEmpty(emailTextBox.Text))
            {
                MessageBox.Show("Please enter email");
                return;
            }

            if (genderComboBox.SelectedIndex == 0)
            {
                MessageBox.Show("Please select gender");
                return;
            }

            if (string.IsNullOrEmpty(nricTextBox.Text))
            {
                MessageBox.Show("Please enter nric");
                return;
            }

            if (string.IsNullOrEmpty(addressTextBox.Text))
            {
                MessageBox.Show("Please enter address");
                return;
            }

            if (string.IsNullOrEmpty(phoneTextBox.Text))
            {
                MessageBox.Show("Please enter phone");
                return;
            }

            if (string.IsNullOrEmpty(ageTextBox.Text))
            {
                MessageBox.Show("Please enter age");
                return;
            }

            Patient newPatient = new Patient();

            newPatient.FullName     = fullNameTextBox.Text;
            newPatient.IdentityCard = long.Parse(nricTextBox.Text);
            newPatient.Address      = addressTextBox.Text;
            newPatient.Email        = emailTextBox.Text;
            newPatient.Gender       = genderComboBox.SelectedItem.ToString();
            newPatient.Phone        = int.Parse(phoneTextBox.Text);
            newPatient.Age          = int.Parse(ageTextBox.Text);
            newPatient.BedsideId    = 0;

            DBConnector dBconn = new DBConnector();

            dBconn.connect();
            PatientHandler patientHandler = new PatientHandler();
            int            addResult      = patientHandler.addNewPatient(dBconn.getConn(), newPatient);

            if (addResult == 1)
            {
                MessageBox.Show("New Patient Record is inserted");
                fullNameTextBox.Text         = "";
                nricTextBox.Text             = "";
                addressTextBox.Text          = "";
                emailTextBox.Text            = "";
                genderComboBox.SelectedIndex = 0;
                phoneTextBox.Text            = "";
                ageTextBox.Text       = "";
                patientIdTextBox.Text = patientHandler.getLastRecordID(dBconn.getConn());
            }
        }
        private void confirmBtnAlarm_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(bPMin.Text))
            {
                MessageBox.Show("Please enter a valid value to the bloodpressure");
                return;
            }

            if (string.IsNullOrEmpty(bPMax.Text))
            {
                MessageBox.Show("Please enter a valid value to the bloodpressure");
                return;
            }

            if (string.IsNullOrEmpty(pulseMin.Text))
            {
                MessageBox.Show("Please enter a valid value to the pulse rate");
                return;
            }

            if (string.IsNullOrEmpty(pulseMax.Text))
            {
                MessageBox.Show("Please enter a valid value to the pulse rate");
                return;
            }

            if (string.IsNullOrEmpty(tempMin.Text))
            {
                MessageBox.Show("Please enter a valid value to the temperature");
                return;
            }

            if (string.IsNullOrEmpty(tempMax.Text))
            {
                MessageBox.Show("Please enter a valid value to the temperature");
                return;
            }

            if (string.IsNullOrEmpty(breathMin.Text))
            {
                MessageBox.Show("Please enter a valid value to the breathing rate");
                return;
            }

            if (string.IsNullOrEmpty(breathMax.Text))
            {
                MessageBox.Show("Please enter a valid value to the breathing rate");
                return;
            }

            if (double.Parse(bPMin.Text) > (double.Parse(bPMax.Text)))
            {
                MessageBox.Show("The minimum value must not bigger than maximum value");
                return;
            }

            if (double.Parse(pulseMin.Text) > (double.Parse(pulseMax.Text)))
            {
                MessageBox.Show("The minimum value must not bigger than maximum value");
                return;
            }

            if (double.Parse(tempMax.Text) > (double.Parse(tempMax.Text)))
            {
                MessageBox.Show("The minimum value must not bigger than maximum value");
                return;
            }

            if (double.Parse(breathMin.Text) > (double.Parse(breathMax.Text)))
            {
                MessageBox.Show("The minimum value must not bigger than maximum value");
                return;
            }

            Reading reading = new Reading();

            reading.MinBloodPressure = double.Parse(bPMin.Text);
            reading.MaxBloodPressure = double.Parse(bPMax.Text);
            reading.MinPulse         = double.Parse(pulseMin.Text);
            reading.MaxPulse         = double.Parse(pulseMax.Text);
            reading.MinTemperature   = double.Parse(tempMin.Text);
            reading.MaxTemperature   = double.Parse(tempMax.Text);
            reading.MinBreathing     = double.Parse(breathMin.Text);
            reading.MaxBreathing     = double.Parse(breathMax.Text);
            minb = bPMin.Text;

            DBConnector dbcon = new DBConnector();

            dbcon.connect();
            sessionId = BedsideSystem.BedsideLoginScreen.bedside_patient_id;
            ReadingHandler readingHandler = new ReadingHandler();
            bool           status         = readingHandler.checkExistsReading(dbcon.getConn(), sessionId);

            if (status)
            {
                int updateResult = readingHandler.updateReading(dbcon.getConn(), reading, sessionId);

                if (updateResult == 1)
                {
                    MessageBox.Show("The minimum and maximum value is up to date");
                    BedsideMainScreen mainScreen = new BedsideMainScreen();
                    //mainScreen.MinBP = reading.MinBloodPressure.ToString();
                    //mainScreen.MaxBP = reading.MaxBloodPressure.ToString();
                    //mainScreen.MinBR = reading.MinBreathing.ToString();
                    //mainScreen.MaxBR = reading.MaxBreathing.ToString();
                    //mainScreen.MinPR = reading.MinPulse.ToString();
                    //mainScreen.MaxPR = reading.MaxPulse.ToString();
                    //mainScreen.MinT = reading.MinTemperature.ToString();
                    //mainScreen.MaxT = reading.MaxTemperature.ToString();
                    mainScreen.Show(this);
                    Close();
                }
                else
                {
                    MessageBox.Show("Update Failed!");
                }
            }
            else
            {
                int result = readingHandler.addNewReading(dbcon.getConn(), reading, sessionId);

                if (result == 1)
                {
                    MessageBox.Show("The minimum and maximum value is ready to test");
                    BedsideMainScreen mainScreen = new BedsideMainScreen();
                    //mainScreen.MinBP = reading.MinBloodPressure.ToString();
                    //mainScreen.MaxBP = reading.MaxBloodPressure.ToString();
                    //mainScreen.MinBR = reading.MinBreathing.ToString();
                    //mainScreen.MaxBR = reading.MaxBreathing.ToString();
                    //mainScreen.MinPR = reading.MinPulse.ToString();
                    //mainScreen.MaxPR = reading.MaxPulse.ToString();
                    //mainScreen.MinT = reading.MinTemperature.ToString();
                    //mainScreen.MaxT = reading.MaxTemperature.ToString();
                    mainScreen.Refresh();
                    Close();
                }
                else
                {
                    MessageBox.Show("The minimum and maximum value is not ready to test");
                }
            }
        }