private void updateBtn_Click(object sender, EventArgs e)
        {
            int id      = int.Parse(IDlbl.Text);
            int roomNum = int.Parse(RoomTB.Text);
            var sql     = "UPDATE Staff SET Fname = @firstName, Mint = @middleInt, Lname = @lastName, Sex = @sex, Address = @address, Date_of_birth = @dateBirth, Room# = @room WHERE Doctor_Id = @id";

            string connectionString = Emergancy_Room_Database.Properties.Settings.Default.ERDatabaseConnectionString;

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                using (var cmd = new SqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("@firstName", fNameTB.Text);
                    cmd.Parameters.AddWithValue("@middleInt", MITB.Text);
                    cmd.Parameters.AddWithValue("@lastName", lNameTB.Text);
                    cmd.Parameters.AddWithValue("@sex", RoomTB.Text);
                    cmd.Parameters.AddWithValue("@address", addressTB.Text);
                    cmd.Parameters.AddWithValue("@dateBirth", dateOfBirthTB.Text);
                    cmd.Parameters.AddWithValue("@room", roomNum);
                    cmd.Parameters.AddWithValue("@id", id);
                    cmd.ExecuteNonQuery();
                }
            }
            this.Hide();
            displayStaffTable displayStaffTable = new displayStaffTable();

            displayStaffTable.ShowDialog();
            this.Close();
        }
Пример #2
0
        private void insertBtn_Click(object sender, EventArgs e)
        {
            var sql = "INSERT INTO Staff (Fname, Mint, Lname, Sex, Address, Date_of_birth) " +
                      "VALUES (@firstName, @middleInt, @lastName, @sex, @address, @dateBirth);";

            string connectionString = Emergancy_Room_Database.Properties.Settings.Default.ERDatabaseConnectionString;

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                using (var cmd = new SqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("@firstName", fNameTB.Text);
                    cmd.Parameters.AddWithValue("@middleInt", MITB.Text);
                    cmd.Parameters.AddWithValue("@lastName", lNameTB.Text);
                    cmd.Parameters.AddWithValue("@sex", SexTB.Text);
                    cmd.Parameters.AddWithValue("@address", addressTB.Text);
                    cmd.Parameters.AddWithValue("@dateBirth", dateOfBirthTB.Text);
                    cmd.ExecuteNonQuery();
                }
            }
            this.Hide();
            displayStaffTable displayStaffTable = new displayStaffTable();

            displayStaffTable.ShowDialog();
            this.Close();
        }
Пример #3
0
        private void displayStaffBtn_Click(object sender, EventArgs e)
        {
            this.Hide();
            displayStaffTable displayStaffTable = new displayStaffTable();

            displayStaffTable.ShowDialog();
            this.Close();
        }
Пример #4
0
        private void enterBtn_Click(object sender, EventArgs e)
        {
            int id  = int.Parse(idChoiceTb.Text);
            var sql = "DELETE FROM Staff WHERE Staff_Id = @id";

            string connectionString = Emergancy_Room_Database.Properties.Settings.Default.ERDatabaseConnectionString;

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                using (var cmd = new SqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("@id", id);
                    cmd.ExecuteNonQuery();
                }
            }
            this.Hide();
            displayStaffTable displayStaffTable = new displayStaffTable();

            displayStaffTable.ShowDialog();
            this.Close();
        }