Example #1
0
        private void resetBtn_Click(object sender, EventArgs e)
        {
            updateConveyance frm1 = new updateConveyance(conveyance, conveyanceID);

            frm1.Show();
            this.Close();
        }
 private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (type == "updateShow")
     {
         updateConveyance updateConveyanceObj = new updateConveyance("" + conveyance + "", Convert.ToInt16(dataGridView1.Rows[e.RowIndex].Cells[0].Value));
         updateConveyanceObj.ShowDialog();
         this.Close();
     }
     else if (type == "deleteShow")
     {
         var proceed = MessageBox.Show("Are you sure you want to delete " + dataGridView1.Rows[e.RowIndex].Cells[2].Value + "", "Alert!", MessageBoxButtons.YesNo);
         if (proceed == DialogResult.Yes)
         {
             string sql = "SELECT TOP(1) " + conveyance + "ID FROM " + conveyance + "Passenger WHERE " + conveyance + "ID = " + Convert.ToInt16(dataGridView1.Rows[e.RowIndex].Cells[0].Value) + "";
             dt = db.selectData(sql);
             if (dt.Rows.Count != 0)
             {
                 MessageBox.Show("You cannot delete this " + conveyance + " untill you delete all the Passengers who are booked for this " + conveyance + "");
             }
             else
             {
                 sql = "DELETE FROM " + conveyance + "Detail WHERE " + conveyance + "ID = " + Convert.ToInt16(dataGridView1.Rows[e.RowIndex].Cells[0].Value) + "";
                 bool isDeleted = db.manipulateData(sql);
                 if (isDeleted == true)
                 {
                     MessageBox.Show("" + conveyance + " Deleted Successfully!");
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Failed!");
                 }
             }
         }
     }
 }