예제 #1
0
 private void btnAddOwner_Click(object sender, EventArgs e)
 {
     try
     {
         DataRow newServicerRow = DM.dtService.NewRow();
         dtpService.Value = DateTime.Now;
         //If any of the text areas are empty then do not write data and return
         if (cmboHours.Text == "" || cmboServiceType.SelectedValue == null || cmboVehicleID.SelectedValue == null)
         {
             MessageBox.Show("You must provide all details", "Error");
         }
         else
         {
             newServicerRow["VehicleID"]     = cmboVehicleID.SelectedValue;
             newServicerRow["ServiceTypeID"] = cmboServiceType.SelectedValue;
             newServicerRow["Hours"]         = cmboHours.Text;
             newServicerRow["ServiceDate"]   = dtpService.Text;
             if (rdoNotPaid.Checked)
             {
                 newServicerRow["Status"] = "Pending";
             }
             else
             {
                 newServicerRow["Status"] = "Paid";
             }
             //Add the new row to the Table
             DM.dtService.Rows.Add(newServicerRow);
             DM.UpdatedService();
             //Give the user a success message
             MessageBox.Show("Service added successfully", "Success");
         }
         return;
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }