private void retrieveButton_Click(object sender, EventArgs e) { try { if (VehUtil.isEmpty(txtCustomerID.Text)) { MessageBox.Show(VehMessage.EmptyCustomerID); return; } if (!VehUtil.isCustomerID(txtCustomerID.Text)) { MessageBox.Show(VehMessage.InvalidCustomerID); return; } RentVehicleControl c = new RentVehicleControl(); Customer customer = c.RetrieveCustomerDetails(Int32.Parse(txtCustomerID.Text)); txtName.Text = customer.CustomerName; txtTelephone.Text = customer.Telephone.ToString(); txtEmail.Text = customer.EmailAddress; } catch (Exception) { MessageBox.Show(VehMessage.GeneralErrorMsg); } }
private void btnRetrieve_Click(object sender, EventArgs e) { try { if (VehUtil.isEmpty(txtCarPlateNumber.Text)) { MessageBox.Show(VehMessage.EmptyCarPlateNumber); return; } EnquireStatusControl statusControl = new EnquireStatusControl(); Vehicle v = statusControl.RetrieveVehicle(txtCarPlateNumber.Text); txtModel.Text = v.Model; txtColor.Text = v.Colour; txtESN.Text = v.EngineSerialNumber; txtStatus.Text = v.RentalStatus; } catch (VehException vehExcep) { //Console.WriteLine("Exception !!!"); //Console.WriteLine(vehExcep.Message); //Console.WriteLine(vehExcep.StackTrace); MessageBox.Show(vehExcep.Message); } catch (Exception excep) { //Console.WriteLine("Exception !!!"); //Console.WriteLine(excep.Message); //Console.WriteLine(excep.StackTrace); MessageBox.Show(VehMessage.GeneralErrorMsg); } }
private void rentButton_Click(object sender, EventArgs e) { //if (VehUtil.isEmpty(txtCustomerID.Text)) //{ // MessageBox.Show(VehMessage.CreateCustomer); //} try { if (VehUtil.isEmpty(txtCustomerID.Text)) { MessageBox.Show(VehMessage.EmptyCustomerID); return; } if (!VehUtil.isCustomerID(txtCustomerID.Text)) { MessageBox.Show(VehMessage.InvalidCustomerID); return; } if (!VehUtil.isEmailValid(txtEmail.Text)) { MessageBox.Show(VehMessage.InvalidEmaildAddress); return; } if (!VehUtil.isTelephone(txtTelephone.Text)) { MessageBox.Show(VehMessage.InvalidTelephone); return; } if (!VehUtil.isRentalDayValid(txtRentalDays.Text)) { MessageBox.Show(VehMessage.InvalidDays); return; } RentVehicleControl c = new RentVehicleControl(); string carPlateNumber = vehicleDetails.Cells[6].Value.ToString(); int customerID = Int32.Parse(txtCustomerID.Text); int days = Int32.Parse(txtRentalDays.Text); c.CreateTransaction(carPlateNumber, customerID, days); MessageBox.Show("Rent Success!"); } catch (Exception) { MessageBox.Show(VehMessage.GeneralErrorMsg); } }
private void btnSearch_Click(object sender, EventArgs e) { try { if (VehUtil.isEmpty(txtCarPlateNo.Text)) { MessageBox.Show(VehMessage.EmptyCarPlateNumber); return; } ReturnVehicleControl c = new ReturnVehicleControl(); c.ReturnTransaction(txtCarPlateNo.Text); } catch (Exception excep) { MessageBox.Show(excep.ToString()); MessageBox.Show(VehMessage.GeneralErrorMsg); } }