private void addAmenityB_Click(object sender, EventArgs e) { if (amenityNameTB.Text == "" || amenityDescriptionTB.Text == "" || amenityPriceTB.Text == "") { MessageBox.Show("Please enter the missing data to add a new amenity into the system!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Amenity amenity = new Amenity(); amenity.AmenityName = amenityNameTB.Text; amenity.Description = amenityDescriptionTB.Text; amenity.Price = int.Parse(amenityPriceTB.Text); amenity.Insert(); amenity.CloseConnection(); ResetForm(); ReloadData(); } }
private void amenityDeleteB_Click(object sender, EventArgs e) { int rowCount = amenityDGV.Rows.Count; if (rowCount == 0) { MessageBox.Show("Currently there is no amenity to be deleted!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult result = MessageBox.Show("Do you really want to delete this amenity?", "Delete Amenity", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Amenity amenity = new Amenity(); int amenityId = (int)amenityDGV.SelectedRows[0].Cells[0].Value; amenity.Delete(amenityId); amenity.CloseConnection(); ResetForm(); ReloadData(); } } }
private void ReloadData() { Amenity amenity = new Amenity(); amenityDGV.DataSource = amenity.ListAll(); }