//To leave the register which belong to user
        private void btnLeave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToInt32(dgwVoluteerWorker.CurrentRow.Cells[5].Value) == Convert.ToInt32(tbxUserId.Text))
                {
                    int id = Convert.ToInt32(dgwVoluteerWorker.CurrentRow.Cells[0].Value);
                    _managementFood = _wrt.ManagementFoods.FirstOrDefault(mid => mid.Id == id);
                    _managementFood.SupplyDelivery  = false;
                    _managementFood.DeliveryTime    = null;
                    _managementFood.ResponsibleUser = null;

                    int managementId = Convert.ToInt32(dgwVoluteerWorker.CurrentRow.Cells[1].Value);
                    _management        = _wrt.Managements.FirstOrDefault(mi => mi.Id == managementId);
                    _management.Point -= 1;
                    _wrt.SubmitChanges();

                    int userId = Convert.ToInt32(tbxUserId.Text);
                    _user        = _wrt.Users.FirstOrDefault(ui => ui.Id == userId);
                    _user.Point -= 1;
                    _wrt.SubmitChanges();

                    _wrt.SubmitChanges();
                    GetManagementFoodsTable();
                    cbxFalse.Checked = false;
                    cbxTrue.Checked  = false;

                    MessageBox.Show("Register delivered successfully");
                }
                else
                {
                    MessageBox.Show("You cannot leave the register which isn't yours");
                }
            }
            catch
            {
                MessageBox.Show("We got a problem on the system.Try it another time.");
            }
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (Convert.ToInt32(dgwManagementWorker.CurrentRow.Cells[1].Value) == Convert.ToInt32(tbxManagementId.Text))
         {
             int id = Convert.ToInt32(dgwManagementWorker.CurrentRow.Cells[0].Value);
             _managementFood = _wrt.ManagementFoods.FirstOrDefault(mif => mif.Id == id);
             _wrt.ManagementFoods.DeleteOnSubmit(_managementFood);
             _wrt.SubmitChanges();
             GetManagementFoodsTable();
             MessageBox.Show("Entity deleted successfully");
         }
         else
         {
             MessageBox.Show("You cannot delete the register which isn't yours");
         }
     }
     catch
     {
         MessageBox.Show("We got a problem on the system.Try it another time.");
     }
 }
 //We'll create a register on the griedview
 private void btnTakeMission_Click(object sender, EventArgs e)
 {
     try
     {
         using (var context = new WeAreTogetherDataContext())
         {
             var managementFood = new ManagementFood
             {
                 ManagementId   = Convert.ToInt32(tbxManagementId.Text),
                 DateOfFood     = dtpDateOfFood.Value,
                 SupplyDelivery = false
             };
             context.ManagementFoods.InsertOnSubmit(managementFood);
             context.SubmitChanges();
             GetManagementFoodsTable();
             dtpDateOfFood.Text = "";
             MessageBox.Show("Entity added successfully");
         }
     }
     catch
     {
         MessageBox.Show("We got a problem on the system.Try it another time.");
     }
 }