private void btnSaveService_Click(object sender, EventArgs e)
        {
            //Create a new row that the variables will be added into
            DataRow newServiceRow = DM.dtService.NewRow();

            //If any of the text areas are empty then do not write data and return
            if ((cboAddVehicleID.Text == "") || (cboAddServiceType.Text == "") ||
                (txtAddHours.Text == "") || (dtpServiceDate.Text == ""))
            {
                MessageBox.Show("You must enter a value for each of the text fields.", "Error");
            }
            else
            {
                newServiceRow["VehicleID"]     = cboAddVehicleID.Text;
                newServiceRow["ServiceTypeID"] = cboAddServiceType.Text;
                newServiceRow["Hours"]         = txtAddHours.Text;
                newServiceRow["ServiceDate"]   = dtpServiceDate.Text;
                newServiceRow["Status"]        = "Pending";

                //Add the new row to the Table
                DM.dtService.Rows.Add(newServiceRow);
                DM.UpdateService();
                //Give the user a success message
                MessageBox.Show("Service added successfully.", "Success");
            }
            return;
        }
Exemple #2
0
        private void btnDeleteService_Click(object sender, EventArgs e)
        {
            DataRow deleteServiceRow = DM.dtService.Rows[cmService.Position];

            if (deleteServiceRow["Status"].ToString() == "Pending")
            {
                MessageBox.Show("You may only delete paid services", "Error");
                return;
            }
            else if (deleteServiceRow["Status"].ToString() == "Paid")
            {
                if (MessageBox.Show("Are you you want to delete this service?", "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    deleteServiceRow.Delete();
                    DM.UpdateService();
                    MessageBox.Show("Service deleted successfully", "Success");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Service status is not paid or pending", "Error");
                return;
            }
        }