Exemplo n.º 1
0
        private void payB_Click(object sender, EventArgs e)
        {
            repairSupplierID    = _supplier.RetrieveSupplierID(repairSupplierCB.Text);
            repairDate          = repairDateDTP.Value;
            repairInvoiceNumber = repairInvoiceNumberTB.Text;
            repairAmount        = double.Parse(repairAmountTB.Text);
            typeOfRepair        = typeOfRepairCB.Text;

            try
            {
                foreach (RepairDetail repairDetail in _repairDetails)
                {
                    _repairDetail.InsertRepairDetail(repairDetail);
                }
                plateNumber   = plateNumberCB.Text.Trim();
                repairDate    = repairDateDTP.Value;
                typeOfRepair  = typeOfRepairCB.Text.Trim();
                partID        = _part.RetrievePartID(partCB.Text);
                maintenanceID = _maintenance.RetrieveMaintenanceID(plateNumber, partID);

                repairSupplierID    = _supplier.RetrieveSupplierID(repairSupplierCB.Text.Trim());
                repairInvoiceNumber = repairInvoiceNumberTB.Text.Trim();
                repairAmount        = double.Parse(repairAmountTB.Text.Trim());
                status = statusCB.Text.Trim();

                _repair = new Repair(repairID, maintenanceID, repairDate, typeOfRepair, repairInvoiceNumber, repairSupplierID, repairAmount);
                _repair.InsertRepair(_repair);

                _maintenance = new Maintenance(maintenanceID, plateNumber, partID, status);
                _maintenance.UpdateMaintenanceInfo(_maintenance);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            NewPaymentForm newPaymentForm = new NewPaymentForm();

            newPaymentForm.ShowDialog();
        }
Exemplo n.º 2
0
        public void UpdateMaintenanceInfo(Maintenance maintenance)
        {
            try
            {
                _dbOp.DBConnect();
                MySqlCommand cmd = _dbOp._dbConn.CreateCommand();

                cmd.CommandText = @"UPDATE Maintenance SET MaintenanceID = @MaintenanceID,PlateNumber = @PlateNumber, PartID = @PartID, Status = @Status " + "WHERE MaintenanceID = @MaintenanceID";
                cmd.Parameters.AddWithValue("@MaintenanceID", maintenance.MaintenanceID);
                cmd.Parameters.AddWithValue("@PlateNumber", maintenance.PlateNumber);
                cmd.Parameters.AddWithValue("@PartID", maintenance.PartID);
                cmd.Parameters.AddWithValue("@Status", maintenance.Status);

                cmd.ExecuteNonQuery();
                MessageBox.Show("Maintenance Record has been updated!");
                _dbOp.DBClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 private void doneB_Click(object sender, EventArgs e)
 {
     if (plateNumberCB.Text == "")
     {
         MessageBox.Show("Please choose a PLATE NUMBER", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (partCB.Text == "")
     {
         MessageBox.Show("Please choose a VEHICLE PART/n If VEHICLE PART does exist on the choices, please ADD a NEW PART.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         _maintenanceID = _maintenance.CreateMaintenanceID();
         _repairID      = _repair.CreateRepairID();
         _plateNumber   = plateNumberCB.Text.Trim();
         _partID        = _part.RetrievePartID(partCB.Text.Trim());
         _maintenance   = new Maintenance(_maintenanceID, _plateNumber, _partID, _status);
         _maintenance.InsertMaintenance(_maintenance);
         plateNumberCB.Text = "";
         partCB.Text        = "";
     }
     Close();
 }