private void btnSave_Click(object sender, EventArgs e) { try { if (txtBuildingName.Text == "" || txtRoomName.Text == "" || txtCapacity.Text == "") { MessageBox.Show("Please insert all fields!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string roomType; if (rbtLectureHall.Checked) { roomType = "Lecture Hall"; } else { roomType = "Laboratory"; } SQLiteConnection connection = new Classes.SqliteHelper().GetSQLiteConnection(); connection.Open(); SQLiteCommand command = new SQLiteCommand("INSERT INTO [Location](Building, Room, Room_Type, Capacity) " + " VALUES ('" + txtBuildingName.Text + "','" + txtRoomName.Text + "','" + roomType + "','" + txtCapacity.Text + "')", connection); int i = command.ExecuteNonQuery(); if (i != 0) { clear(); connection.Close(); MessageBox.Show("Data Saved"); ManageLocations frm2 = new ManageLocations(); frm2.Show(); this.Hide(); } else { connection.Close(); MessageBox.Show("Data not Saved", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnManage_Click(object sender, EventArgs e) { ManageLocations M = new ManageLocations(); M.Show(); }