private void buttonManageUpdate_Click(object sender, EventArgs e) { string RoomType = ""; if (radioButtonLecture.Checked) { RoomType = "Lecture Hall"; } else if (radioButtonLab.Checked) { RoomType = "Laboratory"; } //Database connection SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-45UO70S;Initial Catalog=ITPM;Integrated Security=True"); SqlCommand cmd; cmd = new SqlCommand("update location set BuildingName=@BuildingName,RoomName=@RoomName,RoomType=@RoomType,Capacity=@Capacity where id=@id", con); con.Open(); cmd.Parameters.AddWithValue("@BuildingName", textBoxBuilding.Text.ToString()); cmd.Parameters.AddWithValue("@RoomName", textBoxRoom.Text.ToString()); cmd.Parameters.AddWithValue("@RoomType", RoomType); cmd.Parameters.AddWithValue("@Capacity", textBoxCapacity.Text.ToString()); cmd.Parameters.AddWithValue("@id", dataId); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Record Updated Successfully"); manageLocation m1 = new manageLocation(); this.Hide(); m1.Show(); }
private void buttonView_Click_1(object sender, EventArgs e) { if (m1 == null || m1.IsDisposed) { //SqlConnection conn = new SqlConnection("Data Source=LAPTOP-AU11U311;Initial Catalog=timetablemanagement;Integrated Security=True"); m1 = new manageLocation(); } m1.Show(); this.Hide(); }
private void buttonManageDelete_Click(object sender, EventArgs e) { //Database connection SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-45UO70S;Initial Catalog=ITPM;Integrated Security=True"); SqlCommand cmd; cmd = new SqlCommand("delete from location where id=@id", con); con.Open(); cmd.Parameters.AddWithValue("@id", dataId); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Record Deleted Successfully"); manageLocation m1 = new manageLocation(); this.Hide(); m1.Show(); }
public AddLocations(manageLocation m) { InitializeComponent(); this.m1 = m; }