Exemplo n.º 1
0
        public override bool delete(nurse item)
        {
            OleDbConnection connect = Medible.AquireConnection();

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

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

            cmd.CommandText = "SELECT * From Nurses 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 Nurses where " + query;
                cmd.ExecuteNonQuery();
                connect.Close();
                return(exist);
            }
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        public virtual bool delete(nurse item)
        {
            bool exist = false;

            return(exist);
        }
Exemplo n.º 4
0
 public virtual void insert(nurse item)
 {
 }
Exemplo n.º 5
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            try
            {
                if (NurseSelectionBox.SelectedIndex == 0)
                {
                    try
                    {
                        int x = Int32.Parse(RankTextBox.Text);
                        if (x > 0 && x < 6)
                        {
                            nurse  item     = new nurse(IDTextBox.Text, NameTextBox.Text.ToString(), Int32.Parse(RankTextBox.Text), WardIDTextBox.Text.ToString());
                            string ID       = IDTextBox.Text;
                            int    IDlength = ID.Length;
                            if (IDlength == 4)
                            {
                                if (ID[0].ToString().Equals("N") && char.IsDigit(ID[1]) && char.IsDigit(ID[2]) && char.IsDigit(ID[3]))
                                {
                                    string WardID       = WardIDTextBox.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)
                                            {
                                                item.insert(item);

                                                NameTextBox.Text   = "";
                                                RankTextBox.Text   = "";
                                                IDTextBox.Text     = "";
                                                WardIDTextBox.Text = "";

                                                MessageBox.Show("Information 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 Nurse ID format. (Format: N000)");
                                }
                            }
                            else
                            {
                                MessageBox.Show("NurseID can only accept 4 characters");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please insert an integer within 1-5 for the 'Rank' field");
                        }
                    }
                    catch
                    {
                        MessageBox.Show("The data either existed or did not follow proper format");
                    }
                }
                else if (NurseSelectionBox.SelectedIndex == 1)
                {
                    nurse item  = new nurse(IDTextBox.Text);
                    bool  exist = item.delete(item);
                    switch (exist)
                    {
                    case true:
                        MessageBox.Show("Nurse deleted successfully");
                        break;

                    case false:
                        MessageBox.Show("Nurse not found or already deleted");
                        break;
                    }
                }
            }

            catch
            {
                MessageBox.Show("Please fill in the fields correctly.");
            }
        }