Exemplo n.º 1
0
        private void EditPatient(int id, PatientWindow info)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = db;
            cmd.CommandText = "UPDATE Patient SET first_name = @fname, last_name = @lname, house_number = @house, street = @street, city = @city, postal_code = @pcode, province = @prov, date_of_birth = @dob, gender = @gender WHERE pid = @id";

            cmd.Parameters.AddWithValue("@fname", info.firstName);
            cmd.Parameters.AddWithValue("@lname", info.lastName);
            cmd.Parameters.AddWithValue("@house", info.houseNumber);
            cmd.Parameters.AddWithValue("@street", info.street);
            cmd.Parameters.AddWithValue("@city", info.city);
            cmd.Parameters.AddWithValue("@pcode", info.postalCode);
            cmd.Parameters.AddWithValue("@prov", info.province);
            cmd.Parameters.AddWithValue("@dob", info.dob);
            cmd.Parameters.AddWithValue("@gender", info.gender);
            cmd.Parameters.AddWithValue("@id", id);

            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                MessageBox.Show((string)reader.GetValue(0));
            }

            MessageBox.Show("Successfully edited patient");

            reader.Close();
            cmd.Dispose();
            LoadPatients();
        }
Exemplo n.º 2
0
        private void AddPatient(PatientWindow info)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = db;
            cmd.CommandText = "INSERT INTO Patient VALUES(@firstname, @lastname, @housenumber, @street, @city, @postalcode, @province, @dob, @gender)";

            cmd.Parameters.AddWithValue("@firstname", info.firstName);
            cmd.Parameters.AddWithValue("@lastname", info.lastName);
            cmd.Parameters.AddWithValue("@housenumber", info.houseNumber);
            cmd.Parameters.AddWithValue("@street", info.street);
            cmd.Parameters.AddWithValue("@city", info.city);
            cmd.Parameters.AddWithValue("@postalcode", info.postalCode);
            cmd.Parameters.AddWithValue("@province", info.province);
            cmd.Parameters.AddWithValue("@dob", info.dob);
            cmd.Parameters.AddWithValue("@gender", info.gender);

            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                MessageBox.Show((string)reader.GetValue(0));
            }

            MessageBox.Show("Successfully added new patient");

            reader.Close();
            cmd.Dispose();
            LoadPatients();
        }