private void EditRegistration(int id, RegistryWindow info) { SqlCommand cmd = new SqlCommand(); cmd.Connection = db; cmd.CommandText = "UPDATE Patient SET ward_id = @wid, doc_id = @did, status = @status, doc_notes = @notes WHERE rid = @id"; cmd.Parameters.AddWithValue("@wid", info.wid); cmd.Parameters.AddWithValue("@did", info.did); cmd.Parameters.AddWithValue("@status", info.status); cmd.Parameters.AddWithValue("@notes", info.notes); cmd.Parameters.AddWithValue("@id", id); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { MessageBox.Show((string)reader.GetValue(0)); } MessageBox.Show("Successfully edited registration"); reader.Close(); cmd.Dispose(); LoadRegistrations(); }
private void AddRegistration(RegistryWindow info) { SqlCommand cmd = new SqlCommand(); cmd.Connection = db; cmd.CommandText = "INSERT INTO Registration VALUES(@pid, @did, @wid, GETDATE(), @notes, @status)"; cmd.Parameters.AddWithValue("@pid", info.pid); cmd.Parameters.AddWithValue("@did", info.did); cmd.Parameters.AddWithValue("@wid", info.wid); cmd.Parameters.AddWithValue("@notes", info.notes); cmd.Parameters.AddWithValue("@status", info.status); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { MessageBox.Show((string)reader.GetValue(0)); } MessageBox.Show("Successfully added new registration"); reader.Close(); cmd.Dispose(); LoadRegistrations(); }
private void buttonRegSubmit_Click(object sender, EventArgs e) { RegistryWindow window = new RegistryWindow(); window.ShowDialog(); if (window.DialogResult == DialogResult.OK) { AddRegistration(window); } window.Dispose(); }
private void buttonRegEdit_Click(object sender, EventArgs e) { if (dataGridView4.SelectedRows.Count != 1) { MessageBox.Show("Please select only one row to edit."); return; } DataGridViewRow row = dataGridView4.SelectedRows[0]; RegistryWindow window = new RegistryWindow(); window.ShowDialog(); if (window.DialogResult == DialogResult.OK) { EditRegistration((int)row.Cells[0].Value, window); } window.Dispose(); }