private void btnDeleteBus_Click(object sender, EventArgs e) { if (lstBlockedSeatNo.Items.Count > 0) { MessageBox.Show("Bus cannot be deleted. Bus seats are booked.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (cbBus.SelectedIndex == -1) { MessageBox.Show("Please select a Bus.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } DialogResult f = MessageBox.Show("Are you sure to delete this entry?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (f == System.Windows.Forms.DialogResult.No) { return; } f = MessageBox.Show("Are you sure to delete this entry?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (f == System.Windows.Forms.DialogResult.No) { return; } f = MessageBox.Show("Are you sure to delete this entry?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (f == System.Windows.Forms.DialogResult.No) { return; } try { if (!addNew && cbBus.SelectedItem != null) { DateTime Navratri_Date = dtpNavratriDate.Value.Date; string Bus_Name = cbBus.SelectedItem.ToString(); BusinessRules objBusinessRules = new BusinessRules(); DataSet ds = objBusinessRules.DeleteBus(Bus_Name, Navratri_Date); if (ds.Tables[0].Rows[0][0].ToString() == "1") { MessageBox.Show("Bus cannot be deleted. Please check if this Bus has got bookings recently.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("Bus deleted successfully.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); InitializeForm(false); } } } catch (Exception ex) { Utilities.Instance.WriteLog("*** Exception in btnSubmit_Click : \n" + ex.Message); MessageBox.Show(ex.Message); } }