private void button3_Click(object sender, EventArgs e) { bool flag = true; if (dataGridView1.Rows.Count == 0) { MessageBox.Show("You Dont have any orders to deliever"); } else { try { DataGridViewRow rows = dataGridView1.SelectedRows[0]; } catch (Exception) { MessageBox.Show("Please Select an order to deliever first"); flag = false; } if (flag == true) { DataGridViewRow row = dataGridView1.SelectedRows[0]; string s = row.Cells[0].Value.ToString(); int orderid = int.Parse(s); DialogResult res = MessageBox.Show("Did you Delievere All Orders with ID " + orderid + " ?", "closing", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (res == DialogResult.Yes) { int r1 = controllerObj.AddPay(orderid); if (r1 == 0) { MessageBox.Show("foul!"); } int r = controllerObj.DeleteTheseorder(orderid); if (r != 0) { MessageBox.Show("Good Job!"); DataTable dt = controllerObj.GetEmpOrders(username); dataGridView1.DataSource = dt; dataGridView1.Refresh(); } } } } }