private void button4_Click(object sender, EventArgs e)
 {
     if (textBoxControl.Text == "")
     {
         MessageBox.Show("Please select Employee in Below that you want delete", "Selection error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
     else
     {
         try {
             SqlCommand cmd = new SqlCommand();
             cmd.Connection  = DbConnection.con;
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.CommandText = "DeleteTimeTable";
             cmd.Parameters.AddWithValue("@cnic", textBoxControl.Text);
             DbConnection.con.Open();
             cmd.ExecuteNonQuery();
             DbConnection.con.Close();
             Verification.Delete();
             gridView();
             Reset();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #2
0
 private void btndelete_Click(object sender, EventArgs e)
 {
     if (IdUpdate.Text == "")
     {
         MessageBox.Show("Please select Row that you want delete", "Selection error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
     else
     {
         DialogResult Question = MessageBox.Show("Are you sure want to delete?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (Question == DialogResult.Cancel)
         {
             return;
         }
         else
         {
             try
             {
                 SqlCommand cmd = new SqlCommand();
                 cmd.Connection  = DbConnection.con;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.CommandText = "EmpDelete";
                 cmd.Parameters.AddWithValue("@cnic", IdUpdate.Text);
                 DbConnection.con.Open();
                 cmd.ExecuteNonQuery();
                 Verification.Delete();
                 DbConnection.con.Close();
                 gridView();
                 Reset();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }