Esempio n. 1
0
        public override bool delete(Patient item)
        {
            OleDbConnection connect = Medible.AquireConnection();

            connect.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection = connect;
            string query = "PatientID ='" + item.PatientID.ToString() + "'";

            cmd.CommandText = "SELECT * From General_Patient where " + query;
            OleDbDataReader reader = cmd.ExecuteReader();
            bool            exist  = false;

            while (reader.Read())
            {
                exist = reader.HasRows;
            }
            connect.Close();
            if (!exist)
            {
                return(exist);
            }
            else
            {
                connect.Open();
                cmd.Connection  = connect;
                cmd.CommandText = "Delete from General_Patient where " + query;
                cmd.ExecuteNonQuery();
                cmd.CommandText = "Delete from Critical_Patient where " + query;
                cmd.ExecuteNonQuery();
                connect.Close();
                return(exist);
            }
        }
Esempio n. 2
0
        public override void insert(Patient item)
        {
            OleDbConnection connect = Medible.AquireConnection();

            connect.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection = connect;
            string query = "('" + item.PatientID + "','" + item.PatientName + "','" + item.WardID + "','" + item.Daysleft.ToString() + "','" + item.Critical.ToString() + "','" + item.Discharge.ToString() + "')";

            cmd.CommandText = "INSERT into General_Patient ( PatientID, PatientName, Ward, Dayleft, Critical, Discharge) values" + query;
            cmd.ExecuteNonQuery();
            connect.Close();
        }
Esempio n. 3
0
        public override void insert(nurse item)
        {
            //source:https://www.youtube.com/channel/UCs6nmQViDpUw0nuIx9c_WvA
            OleDbConnection connect = Medible.AquireConnection();

            connect.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection = connect;
            string query = "('" + item.NurseID + "','" + item.NurseName + "','" + item.Rank.ToString() + "','" + item.WardID + "')";

            cmd.CommandText = "INSERT into Nurses ( NurseID, NurseName, Rank, WardID ) values" + query;
            cmd.ExecuteNonQuery();
            connect.Close();
        }
Esempio n. 4
0
        public Patientlist()
        {
            InitializeComponent();
            OleDbConnection connect = Medible.AquireConnection();

            connect.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection  = connect;
            cmd.CommandText = "SELECT  General_Patient.*, Critical_Patient.* FROM(General_Patient LEFT JOIN Critical_Patient ON General_Patient.[PatientID] = Critical_Patient.PatientID) UNION SELECT General_Patient.*, Critical_Patient.*FROM (Critical_Patient LEFT  JOIN General_Patient ON Critical_Patient.[PatientID] = General_Patient.PatientID)";
            OleDbDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                dataGridView1.Rows.Add(reader[0], reader["PatientName"], reader["Ward"], reader["DayLeft"], reader["Critical"], reader["Discharge"], reader["Level"], reader["Shareward"]);
            }
            connect.Close();
        }
Esempio n. 5
0
        public Nurselist()
        {
            InitializeComponent();
            OleDbConnection connect = Medible.AquireConnection();

            connect.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection  = connect;
            cmd.CommandText = "select* from Nurses";
            OleDbDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                dataGridView1.Rows.Add(reader["NurseID"], reader["NurseName"], reader["Rank"], reader["WardID"]);
            }
            connect.Close();
        }
Esempio n. 6
0
        public override bool discharge(Patient item)
        {
            OleDbConnection connect = Medible.AquireConnection();

            connect.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection = connect;
            string query      = item.PatientID;
            string discharged = "";

            cmd.CommandText = "SELECT * From General_Patient where PatientID = '" + query + "'";
            OleDbDataReader reader = cmd.ExecuteReader();
            bool            exist  = false;

            while (reader.Read())
            {
                exist      = reader.HasRows;
                discharged = reader["discharge"].ToString();
            }
            connect.Close();
            if (discharged.Equals("True"))
            {
                exist = false;
                return(exist);
            }
            if (!exist)
            {
                return(exist);
            }
            else
            {
                connect.Open();
                cmd.Connection  = connect;
                cmd.CommandText = "update General_Patient set  discharge = 'True' where PatientID = '" + query + "'";
                cmd.ExecuteNonQuery();
                connect.Close();
                return(exist);
            }
        }
Esempio n. 7
0
        private void WardSelectionBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //http://stackoverflow.com/questions/15128361/getting-data-from-ms-access-database-and-display-it-in-a-listbox
            OleDbConnection connect = Medible.AquireConnection();

            connect.Open();
            OleDbCommand cmd = new OleDbCommand();

            cmd.Connection = connect;

            //http://www.java2s.com/Code/CSharp/Database-ADO.net/Getcountvaluefromaselectquery.htm
            cmd.CommandText = "SELECT COUNT(*) FROM General_Patient WHERE Ward = '" + WardSelectionBox.Text + "'";
            int count = (int)cmd.ExecuteScalar();

            cmd.CommandText = "SELECT COUNT('General_Patient.*') FROM (General_Patient INNER JOIN Critical_Patient ON General_Patient.PatientID = Critical_Patient.PatientID) WHERE (General_Patient.Ward) = '" + WardSelectionBox.Text + "'";
            int ccount = (int)cmd.ExecuteScalar();

            cmd.CommandText = "SELECT COUNT(*) FROM Nurses WHERE WardID = '" + WardSelectionBox.Text + "'";
            int ncount = (int)cmd.ExecuteScalar();

            cmd.CommandText = "SELECT COUNT(*) FROM Nurses WHERE Rank > 2 AND WardID = '" + WardSelectionBox.Text + "'";
            int cncount = (int)cmd.ExecuteScalar();

            cmd.CommandText = "UPDATE Wards SET VeterenNursesRequired = '" + cncount + "' WHERE WardID = '" + WardSelectionBox.Text + "'";
            cmd.ExecuteNonQuery();

            cmd.CommandText = "UPDATE Wards SET NursesRequired = '" + ncount + "' WHERE WardID = '" + WardSelectionBox.Text + "'";
            cmd.ExecuteNonQuery();

            cmd.CommandText = "UPDATE Wards SET NoOfCriticalPatients = '" + ccount + "' WHERE WardID = '" + WardSelectionBox.Text + "'";
            cmd.ExecuteNonQuery();

            cmd.CommandText = "UPDATE Wards SET NoOfPatients = '" + count + "' WHERE WardID = '" + WardSelectionBox.Text + "'";
            cmd.ExecuteNonQuery();

            string query = "WardID = '" + WardSelectionBox.Text + "'";

            cmd.CommandText = "SELECT * From Wards where " + query;
            OleDbDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                NoPatientTextBox.Text  = reader["NoOfPatients"].ToString();
                NoNursesTextBox.Text   = reader["NursesRequired"].ToString();
                NoCPatientTextBox.Text = reader["NoOfCriticalPatients"].ToString();
                NoRank3TextBox.Text    = reader["VeterenNursesRequired"].ToString();
            }
            connect.Close();
            float nopatient = Int32.Parse(NoPatientTextBox.Text);
            float nonurses  = Int32.Parse(NoNursesTextBox.Text);
            float status    = (nopatient / nonurses);

            if (status <= 5)
            {
                StatusTextBox.Text = "Sufficient Nurse";
            }
            else
            {
                StatusTextBox.Text = "Insufficient Nurse";
            }
            float nocpatient = Int32.Parse(NoCPatientTextBox.Text);
            float nocnurse   = Int32.Parse(NoRank3TextBox.Text);
            float cstatus    = (nocpatient / nocnurse);

            if (cstatus == 0)
            {
                CStatusTextBox.Text = "Sufficient Rank 3+ Nurse";
            }
            else
            {
                CStatusTextBox.Text = "Insufficient Rank 3+ Nurse";
            }
        }
Esempio n. 8
0
        private void DonePictureBox_Click(object sender, EventArgs e)
        {
            try
            {
                //ADD
                if (PatientSelectionBox.SelectedIndex == 0)
                {
                    int x = Int32.Parse(IllnessLevelTextBox.Text);
                    if (x > 0 && x < 6)
                    {
                        string ID       = IDTextBox.Text;
                        int    IDlength = ID.Length;
                        if (IDlength == 5)
                        {
                            if (ID[0].ToString().Equals("G") && ID[1].ToString().Equals("P") && char.IsDigit(ID[2]) && char.IsDigit(ID[3]) && char.IsDigit(ID[4]))
                            {
                                string WardID       = WardTextBox.Text;
                                int    WardIDlength = WardID.Length;
                                if (WardIDlength == 4)
                                {
                                    if (WardID[0].ToString().Equals("W") && char.IsDigit(WardID[1]) && char.IsDigit(WardID[2]) && char.IsDigit(WardID[3]))
                                    {
                                        int WardNo = Int32.Parse(WardID[3].ToString());
                                        if (WardNo < 6 && WardNo > 0)
                                        {
                                            if (CriticalYesCheckBox.Checked == true)
                                            {
                                                bool shareward = false;
                                                if (ShareWardYesCheckBox.Checked == true)
                                                {
                                                    shareward = true;
                                                }
                                                else if (ShareWardYesCheckBox.Checked == false)
                                                {
                                                    shareward = false;
                                                }


                                                CriticalPatient item   = new CriticalPatient(IDTextBox.Text, NameTextBox.Text, Int32.Parse(DayLeftTextBox.Text), WardTextBox.Text, false, true, Int32.Parse(IllnessLevelTextBox.Text), shareward);
                                                string          query  = "('" + item.PatientID + "','" + item.PatientName + "','" + item.WardID + "','" + item.Daysleft.ToString() + "','" + item.Critical.ToString() + "','" + item.Discharge.ToString() + "')";
                                                string          query2 = "('" + item.PatientID + "','" + item.Level.ToString() + "','" + item.Shareward.ToString() + "')";

                                                item.insert(item);
                                                MessageBox.Show("Patient successfully added");
                                            }
                                            else if (CriticalYesCheckBox.Checked == false)
                                            {
                                                Patient item  = new Patient(IDTextBox.Text, NameTextBox.Text, Int32.Parse(DayLeftTextBox.Text), WardTextBox.Text, false, false);
                                                string  query = "('" + item.PatientID + "','" + item.PatientName + "','" + item.WardID + "','" + item.Daysleft.ToString() + "'," + item.Critical.ToString() + "," + item.Discharge.ToString() + ")";

                                                item.insert(item);
                                                MessageBox.Show("Patient successfully added");
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Please enter only Ward ID from 001 ~ 005");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Invalid Ward ID format. (Format: N000)");
                                    }
                                }

                                else
                                {
                                    MessageBox.Show("WardID can only accept 4 characters");;
                                }
                            }
                            else
                            {
                                MessageBox.Show("Invalid Patient ID format. (Format: GP000)");
                            }
                        }
                        else
                        {
                            MessageBox.Show("PatientID can only accept 5 characters");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please insert an integer within 1-5 for the 'Illness Level' field");
                    }
                }
                //SEARCH
                else if (PatientSelectionBox.SelectedIndex == 1)
                {
                    string query = "'" + IDTextBox.Text.ToString() + "'";
                    string tof1  = "";
                    string tof2  = "";

                    OleDbConnection connect = Medible.AquireConnection();
                    connect.Open();
                    OleDbCommand cmd = new OleDbCommand();
                    cmd.Connection  = connect;
                    cmd.CommandText = "select * from General_Patient where PatientID = " + query;
                    OleDbDataReader reader = cmd.ExecuteReader();
                    if (!reader.HasRows)
                    {
                        NameTextBox.Text             = "";
                        DayLeftTextBox.Text          = "";
                        WardTextBox.Text             = "";
                        CriticalNoCheckBox.Checked   = false;
                        CriticalYesCheckBox.Checked  = false;
                        ShareWardNoCheckBox.Checked  = false;
                        ShareWardYesCheckBox.Checked = false;
                        IllnessLevelTextBox.Text     = "";

                        MessageBox.Show("ID not found");
                    }

                    else
                    {
                        while (reader.Read())
                        {
                            IDTextBox.Text      = reader["PatientID"].ToString();
                            NameTextBox.Text    = reader["PatientName"].ToString();
                            DayLeftTextBox.Text = reader["DayLeft"].ToString();
                            WardTextBox.Text    = reader["Ward"].ToString();

                            tof1 = reader["Critical"].ToString();
                            tof2 = reader["Discharge"].ToString();
                        }
                        connect.Close();


                        if (tof1 == "True")
                        {
                            CriticalYesCheckBox.Checked  = true;
                            CriticalNoCheckBox.Checked   = false;
                            ShareWardNoCheckBox.Enabled  = false;
                            ShareWardYesCheckBox.Enabled = false;
                            IllnessLevelTextBox.Enabled  = false;

                            connect.Open();
                            cmd.Connection  = connect;
                            cmd.CommandText = "select * from Critical_Patient where PatientID = " + query;
                            reader          = cmd.ExecuteReader();
                            while (reader.Read())
                            {
                                string tof = reader["Shareward"].ToString();

                                IllnessLevelTextBox.Text = reader["Level"].ToString();

                                if (tof == "True")
                                {
                                    ShareWardNoCheckBox.Checked  = false;
                                    ShareWardYesCheckBox.Checked = true;
                                }
                                else
                                {
                                    ShareWardNoCheckBox.Checked  = true;
                                    ShareWardYesCheckBox.Checked = false;
                                }
                            }
                            connect.Close();
                        }
                        else
                        {
                            CriticalNoCheckBox.Checked  = true;
                            CriticalYesCheckBox.Checked = false;
                        }

                        if (tof2 == "True")
                        {
                            DischargeLabel.Text = "Yes";
                        }
                        else
                        {
                            DischargeLabel.Text = "No";
                        }
                    }
                }
                //Discharge
                else if (PatientSelectionBox.SelectedIndex == 2)
                {
                    Patient item  = new Patient(IDTextBox.Text);
                    bool    exist = item.discharge(item);
                    switch (exist)
                    {
                    case true:
                        MessageBox.Show("Patient discharged successfully");
                        break;

                    case false:
                        MessageBox.Show("Patient not found or already discharged");
                        break;
                    }
                }//Delete
                else if (PatientSelectionBox.SelectedIndex == 3)
                {
                    Patient item  = new Patient(IDTextBox.Text);
                    bool    exist = item.delete(item);
                    switch (exist)
                    {
                    case true:
                        MessageBox.Show("Patient deleted successfully");
                        break;

                    case false:
                        MessageBox.Show("Patient not found or already deleted");
                        break;
                    }
                }
            }
            catch
            {
                MessageBox.Show("please insert the data correctly");
            }
        }