Esempio 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();
        }
        public List <Repair> RetrieveRepairIDList(int repairID)
        {
            List <Repair> repairList = new List <Repair>();

            try
            {
                _dbOp.DBConnect();

                MySqlCommand cmd = _dbOp._dbConn.CreateCommand();

                cmd.CommandText = "SELECT * FROM Repair " + "WHERE RepairID = @RepairID";
                cmd.Parameters.AddWithValue("@RepairID", repairID);

                MySqlDataReader reader = cmd.ExecuteReader();

                Repair temp = new Repair();

                while (reader.Read())
                {
                    RepairID      = (int)reader.GetValue(0);
                    MaintenanceID = (int)reader.GetValue(1);
                    RepairDate    = (DateTime)reader.GetValue(2);
                    TypeOfRepair  = (string)reader.GetValue(3);
                    SupplierID    = (int)reader.GetValue(4);
                    InvoiceNumber = (string)reader.GetValue(5);
                    Amount        = (double)reader.GetValue(6);

                    temp = new Repair(RepairID, MaintenanceID, RepairDate, TypeOfRepair, InvoiceNumber, SupplierID, Amount);

                    repairList.Add(temp);
                }
                reader.Close();
                _dbOp.DBClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(repairList);
        }
        private void repairEditB_Click(object sender, EventArgs e)
        {
            Button bt = (Button)sender;

            switch (bt.Text)
            {
            case "Edit":
                repairEditB.Text = "Save";
                EnableRepair();
                break;

            case "Save":
                if (_repairDate != repairDateDTP.Value ||
                    _typeOfRepair != repairTypeOfRepairTB.Text ||
                    _repairSupplier != repairSupplierCB.Text ||
                    _repairAmount != double.Parse(repairAmountTB.Text))
                {
                    _repair = new Repair(int.Parse(_repair.RepairID.ToString()),
                                         _repair.MaintenanceID,
                                         repairDateDTP.Value,
                                         repairTypeOfRepairTB.Text,
                                         repairInvoiceNumberCB.Text,
                                         _supplier.RetrieveSupplierID(repairSupplierCB.Text),
                                         double.Parse(repairAmountTB.Text));
                }

                _repair.UpdateRepairInfo(_repair);
                DisableRepair();
                repairEditB.Text = "Edit";

                LoadRegistration(_plateNumber);
                LoadInsurance(_plateNumber);
                LoadRepair(_plateNumber);
                Loadfuel(_plateNumber);
                break;
            }
        }