public int addNewMedicalStaff(MySqlConnection conn, MedicalStaff staff)
        {
            string sql = "INSERT INTO medicalstaff (staffId, staffName, password, careerType, email, contactNumber" +
                         ", pagerNumber) VALUES ('" + staff.Staffid + "', '" + staff.Name + "' , '" + staff.Password + "', '" +
                         staff.Career + "' , '" + staff.Email + "', '" + staff.Contact + "' , '" + staff.Pager + "')";

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            return(sqlComm.ExecuteNonQuery());
        }
        public List <MedicalStaff> listStaff(MySqlConnection conn, MedicalStaff staff, int num)
        {
            List <MedicalStaff> listOfStaff = new List <MedicalStaff>();

            string sql = "";

            if (num == 1)
            {
                sql = "SELECT * from `medicalstaff` WHERE staffId LIKE '" + staff.Name + "%' OR staffName LIKE '" + staff.Name + "%' OR " +
                      "password LIKE '" + staff.Name + "%' OR careerType LIKE '" + staff.Name + "%' OR email LIKE '" + staff.Name + "%' OR contactNumber LIKE '" +
                      staff.Name + "%' OR pagerNumber LIKE '" + staff.Name + "%'";
            }
            else if (num == 2)
            {
                sql = "SELECT * from `medicalstaff` WHERE careerType LIKE '" + staff.Career + "'";
            }

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            using (MySqlDataReader sqlReader = sqlComm.ExecuteReader())
            {
                while (sqlReader.Read())
                {
                    MedicalStaff aStaff = new MedicalStaff();

                    aStaff.Id       = (int)sqlReader.GetValue(0);
                    aStaff.Staffid  = (string)sqlReader.GetValue(1);
                    aStaff.Name     = (string)sqlReader.GetValue(2);
                    aStaff.Password = (string)sqlReader.GetValue(7);
                    aStaff.Career   = (string)sqlReader.GetValue(3);
                    aStaff.Email    = (string)sqlReader.GetValue(4);
                    aStaff.Contact  = (string)sqlReader.GetValue(5);
                    aStaff.Pager    = (string)sqlReader.GetValue(6);

                    listOfStaff.Add(aStaff);
                }
            }

            return(listOfStaff);
        }
Exemple #3
0
        public void medicalStaffDBtable(int num)
        {
            DbConnector dbConn = new DbConnector();

            dbConn.connect();

            MedicalStaff        mStaff    = new MedicalStaff();
            MedicalStaffHandler mStaffHnd = new MedicalStaffHandler();

            if (num == 1)
            {
                mStaff.Name = textBox13.Text;
            }
            else if (num == 2)
            {
                mStaff.Career = "%";
            }

            dataGridView2.DataSource = mStaffHnd.listStaff(dbConn.getConn(), mStaff, num);

            dataGridView2.Columns[0].HeaderText = "ID";
            dataGridView2.Columns[1].HeaderText = "STAFF ID";
            dataGridView2.Columns[2].HeaderText = "NAME";
            dataGridView2.Columns[3].HeaderText = "PASSWORD";
            dataGridView2.Columns[4].HeaderText = "CAREER TYPE";
            dataGridView2.Columns[5].HeaderText = "EMAIL";
            dataGridView2.Columns[6].HeaderText = "CONTACT NUMBER";
            dataGridView2.Columns[7].HeaderText = "PAGER NUMBER";
            dataGridView2.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView2.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView2.Columns[0].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView2.Columns[1].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView2.Columns[2].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView2.Columns[3].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView2.Columns[4].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView2.Columns[5].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView2.Columns[6].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView2.Columns[7].AutoSizeMode    = DataGridViewAutoSizeColumnMode.Fill;
        }
        public bool checkMedicalStaffLoginDetail(MySqlConnection conn, MedicalStaff staff)
        {
            bool check = false;

            string sql = "SELECT id FROM medicalstaff WHERE staffId LIKE '" + staff.Staffid + "' AND password LIKE '" + staff.Password + "';";

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            using (MySqlDataReader sqlReader = sqlComm.ExecuteReader())
            {
                while (sqlReader.Read())
                {
                    MedicalStaff aStaff = new MedicalStaff();

                    if ((sqlReader.GetValue(0)).ToString() != " ")
                    {
                        check = true;
                    }
                }
            }

            return(check);
        }
Exemple #5
0
        //Onclick "Login" button verify username & password and navigate to Bedside System Page
        private void button1_Click(object sender, EventArgs e)
        {
            DbConnector dbConn = new DbConnector();

            dbConn.connect();

            MedicalStaff        mStaff    = new MedicalStaff();
            MedicalStaffHandler mStaffHnd = new MedicalStaffHandler();

            mStaff.Staffid  = textBox1.Text;
            mStaff.Password = textBox2.Text;

            if ((mStaffHnd.checkMedicalStaffLoginDetail(dbConn.getConn(), mStaff)) == true)
            {
                Central_Station central_station = new Central_Station();
                central_station.Show();
                //this.Close();
            }
            else
            {
                MessageBox.Show("Invalid Username or Password.");
            }
        }
Exemple #6
0
        //Add new medical staff button
        private void button7_Click(object sender, EventArgs e)
        {
            DbConnector dbConn = new DbConnector();

            dbConn.connect();

            MedicalStaff        mStaff    = new MedicalStaff();
            MedicalStaffHandler mStaffHnd = new MedicalStaffHandler();

            bool verifyCareer = false;

            if (textBox14.Text != "" && textBox15.Text != "" && textBox16.Text != "" &&
                (comboBox6.SelectedItem).ToString() != "- SELECT CAREER -")
            {
                if ((comboBox6.SelectedItem).ToString() == "Consultant")
                {
                    if (textBox17.Text != "")
                    {
                        verifyCareer = true;
                    }
                    else
                    {
                        MessageBox.Show("Invalid format for Email !");
                    }
                }
                else if ((comboBox6.SelectedItem).ToString() == "Doctor" || (comboBox6.SelectedItem).ToString() == "Nurse")
                {
                    if (int.TryParse(textBox18.Text, out int theContact))
                    {
                        if (int.TryParse(textBox19.Text, out int thePager))
                        {
                            verifyCareer = true;
                        }
                        else
                        {
                            MessageBox.Show("Invalid format for Pager Number !");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid format for Contact Number!");
                    }
                }
                else
                {
                    MessageBox.Show("Please select a type of career.");
                }

                if (verifyCareer == true)
                {
                    mStaff.Staffid  = textBox14.Text;
                    mStaff.Name     = textBox15.Text;
                    mStaff.Password = textBox16.Text;
                    mStaff.Email    = textBox17.Text;
                    mStaff.Contact  = textBox18.Text;
                    mStaff.Pager    = textBox19.Text;
                    mStaff.Career   = (comboBox6.SelectedItem).ToString();

                    int recordCnt = mStaffHnd.addNewMedicalStaff(dbConn.getConn(), mStaff);
                    MessageBox.Show(recordCnt + " Medical Staff Registered Successfully !");

                    textBox14.Text = "";
                    textBox15.Text = "";
                    textBox16.Text = "";
                    textBox17.Text = "";
                    textBox18.Text = "";
                    textBox19.Text = "";

                    comboBox6.SelectedIndex = 0;

                    medicalStaffDBtable(1);
                }
            }
            else
            {
                MessageBox.Show("Please fill up all fields to register.");
            }
        }