Esempio n. 1
0
 public Job deleteJob(int id)
 {
     try
     {
         Job Ijob = jdal.get(id);
         if (Ijob != null)
         {
             jdal.delete(Ijob);
             return(Ijob);
         }
         return(null);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                JobDTO job          = new JobDTO();
                int    currentIndex = dataGridView1.CurrentCell.RowIndex;
                int    job_id       = Convert.ToInt32(dataGridView1.Rows[currentIndex].Cells[1].Value.ToString());
                JobDAL.delete(job);

                dataGridView1.DataSource = dt;
                //  string deleteStr = "delete from DBJob where DBJob.job_id = '" + job_id + "' ";
                //  SqlCommand cmd = new SqlCommand(deleteStr, conn);
                // cmd.CommandType = CommandType.Text;
                // cmd.EndExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }



            /* DataTable sourceData = (DataTable)dataGridView1.DataSource;
             * foreach (DataGridViewRow row in this.dataGridView1.SelectedRows)
             * {
             *   if (MessageBox.Show("Sure you wanna delete?", "Warning", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
             *   {
             *       JobDTO job = new JobDTO();
             *       JobDAL.delete(job);
             *       dataGridView1.DataSource = dt;
             *
             *   }
             *       int rowIndex = dataGridView1.CurrentCell.RowIndex;
             *        dataGridView1.Rows.RemoveAt(rowIndex);
             *       int IdColumn = 0;
             *       dataGridView1.Rows.RemoveAt(row.Index);
             *       string sql = "delete DBJob" + "where job_id =  ('" + job.jId + "')";
             *
             * } */
        }