public void populateDropDownList(string sValue) { try { dsCustomer dsPopulate = new dsCustomer(); string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); dsPopulate = dataLayerObj.dsCustomerDropDown(); //these codes bind the data from the dataset to the drop down menu //the TextField shows the Text in the dropdownlist //the ValueField holds the values ddlCustomerID.DataSource = dsPopulate; ddlCustomerID.DataTextField = "Customer"; ddlCustomerID.DataValueField = "CustomerID"; ddlCustomerID.DataBind(); //ddlCustomerID.Items.FindByValue(storeFieldtemp).Selected = true; ddlCustomerID.SelectedValue = sValue; //ddlCustomerID.Items.Insert(0, new ListItem("<Select CustomerID", "0")); } catch (Exception error) { Warnings.Text = "Critical Error: " + error; } }
//posts information from the database to the text fields on the screen public void updateAllFields() { //define a dsVehicle object dsVehicle dsSwitchVehicle; string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); try { //loads the vehicle dataset with information from the Vehicle Table dsSwitchVehicle = dataLayerObj.findVehicle(Int32.Parse(ddlVehicleID.Text)); if (dsSwitchVehicle.Vehicle.Rows.Count > 0) { //uses try/catch to eliminate errors from NULL items. try { lblVIN.Text = dsSwitchVehicle.Vehicle[0].vin; } catch (Exception error) { lblVIN.Text = ""; } try { lblMSRP.Text = dsSwitchVehicle.Vehicle[0].price.ToString("$#,##0.00"); } catch (Exception error) { lblMSRP.Text = ""; } try { lblTaxes.Text = dsSwitchVehicle.Vehicle[0].taxes.ToString("$#,##0.00"); } catch (Exception error) { lblTaxes.Text = ""; } try { lblFees.Text = (dsSwitchVehicle.Vehicle[0].Licensefee.ToString("$#,##0.00")); } catch (Exception error) { lblFees.Text = ""; } try { lblLocation.Text = dsSwitchVehicle.Vehicle[0].VehicleLocation; } catch (Exception error) { lblLocation.Text = ""; } double TotalVCost = 0; try { TotalVCost = (double)dsSwitchVehicle.Vehicle[0].price + (double)dsSwitchVehicle.Vehicle[0].taxes + (double)dsSwitchVehicle.Vehicle[0].Licensefee; lblTotalCost.Text = TotalVCost.ToString("$#,##0.00"); } catch (Exception error) { Warnings.Text = "Unable to calculate total cost."; } } else { Warnings.Text = "Not Found."; } } catch (Exception error) { string message = "Error = "; Warnings.Text = message + error.Message; } }
//this function posts all information from the database to the screen public void updateAllFields() { //define a dsCustomer object dsEmployee dsSwitchEmployee; string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); try { //retrieves information for a specific Employee and places it in a dataset dsSwitchEmployee = dataLayerObj.findEmployee(Int32.Parse(ddlEmployeeID.Text)); if (dsSwitchEmployee.Employee.Rows.Count > 0) { //try/catch are used to prevent errors reading NULL data fields try { lblFirst.Text = dsSwitchEmployee.Employee[0].firstName; } catch (Exception error) { lblFirst.Text = ""; } try { lblLast.Text = dsSwitchEmployee.Employee[0].lastName; } catch (Exception error) { lblLast.Text = ""; } try { lblPosition.Text = dsSwitchEmployee.Employee[0].Position; } catch (Exception error) { lblPosition.Text = ""; } try { lblDateHired.Text = (dsSwitchEmployee.Employee[0].DateHire).ToString(); } catch (Exception error) { lblDateHired.Text = ""; } try { lblCommission.Text = myBusinessLayer.calculateCommissionRate(dsSwitchEmployee.Employee[0].CommisionRate); } catch (Exception error) { lblCommission.Text = ""; } } else { Warnings.Text = "Not Found."; } } catch (Exception error) { string message = "Error = "; Warnings.Text = message + error.Message; } }
//there is only one field on this page to update, this method updates the customer's offer to the Purchase Request. public void updateCustomerOffer() { string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); dsPurchaseRequest dsGetCustomerOffer; try { int tempPRID = (int)Session["PurchaseRequest"]; dsGetCustomerOffer = dataLayerObj.findPurchaseRequest(tempPRID); if (dsGetCustomerOffer.PurchaseRequest.Rows.Count > 0) { try { txtCustomerOffer.Text = dsGetCustomerOffer.PurchaseRequest[0].negotiatedPrice.ToString("#,##0.00"); } catch (Exception error) { txtCustomerOffer.Text = ""; } } } catch (Exception error) { txtCustomerOffer.Text = "Error 2: " + error; } }
public void populateDropDownList(int sValue) { try { dsEmployee dsPopulate = new dsEmployee(); string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); dsPopulate = dataLayerObj.dsEmployeeDropDown(); ddlEmployeeID.DataSource = dsPopulate; ddlEmployeeID.DataTextField = "Employee"; ddlEmployeeID.DataValueField = "employeeID"; ddlEmployeeID.DataBind(); //this is the that selects the item that was passed to the method (by value) ddlEmployeeID.SelectedValue = sValue.ToString(); } catch (Exception error) { Warnings.Text = "Critical Error: " + error; } }
//populates the dropdown list with information from the Vehicle Table public void populateDropDownList(int sValue) { try { dsVehicle dsPopulate = new dsVehicle(); string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); dsPopulate = dataLayerObj.dsVehicleDropDown(); ddlVehicleID.DataSource = dsPopulate; ddlVehicleID.DataTextField = "Vehicle"; ddlVehicleID.DataValueField = "vehicleID"; ddlVehicleID.DataBind(); //re-selects the vehicle with the value of sValue one the dropdownmenu has been repopulated ddlVehicleID.SelectedValue = sValue.ToString(); } catch (Exception error) { Warnings.Text = "Critical Error: " + error; } }
//this method populates the dropdown menu from PurchaseRequests public void populateDropDownList(int sValue) { try { dsPurchaseRequest dsPopulate = new dsPurchaseRequest(); string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); dsPopulate = dataLayerObj.dsPurchaseRequestDropDown(); //The drop down menu is populated with information from the Purchase Request Table. //TO DO: Make the Purchase ID more user friendly. Right now, it only shows numbers. This could show Names and Vehicles ddlPurchaseRequestID.DataSource = dsPopulate; ddlPurchaseRequestID.DataTextField = "requestID"; ddlPurchaseRequestID.DataValueField = "requestID"; ddlPurchaseRequestID.DataBind(); //this line makes sure the last thing selected in the dropdown menu is selected again by default. ddlPurchaseRequestID.SelectedValue = sValue.ToString(); } catch (Exception error) { Warnings.Text = "Critical Error: " + error; } }
//this method copies data fields from the Customer Database Table to the screen public void updateAllFields() { //define a dsCustomer object dsCustomer dsSwitchCustomer; string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); try { //populates the dsSwitchCustome dataset with customer information dsSwitchCustomer = dataLayerObj.findCustomer(Int32.Parse(ddlCustomerID.Text)); if (dsSwitchCustomer.Customer.Rows.Count > 0) { //post information about the customer to the text boxes on the screen //try/catch is used to prevent NULL errors try { txtSocial.Text = dsSwitchCustomer.Customer[0].socialSecurity; } catch (Exception error) { txtSocial.Text = ""; } try { txtLicense.Text = dsSwitchCustomer.Customer[0].driversLicense; } catch (Exception error) { txtLicense.Text = ""; } try { txtFirst.Text = dsSwitchCustomer.Customer[0].firstName; } catch (Exception error) { txtFirst.Text = ""; } try { txtLast.Text = dsSwitchCustomer.Customer[0].lastName; } catch (Exception error) { txtLast.Text = ""; } try { txtAddress1.Text = dsSwitchCustomer.Customer[0].addressLine1; } catch (Exception error) { txtAddress1.Text = ""; } try { txtAddress2.Text = dsSwitchCustomer.Customer[0].addressLine2; } catch (Exception error) { txtAddress2.Text = ""; } try { txtCity.Text = dsSwitchCustomer.Customer[0].city; } catch (Exception error) { txtCity.Text = ""; } try { txtState.Text = dsSwitchCustomer.Customer[0].state; } catch (Exception error) { txtState.Text = ""; } try { txtZip.Text = dsSwitchCustomer.Customer[0].zipCode; } catch (Exception error) { txtZip.Text = ""; } try { txtEmail.Text = dsSwitchCustomer.Customer[0].email; } catch (Exception error) { txtEmail.Text = ""; } try { txtPhone.Text = dsSwitchCustomer.Customer[0].phoneNumber; } catch (Exception error) { txtPhone.Text = ""; } } else { Warnings.Text = "Not Found."; } } catch (Exception error) { string message = "Error = "; Warnings.Text = message + error.Message; } //validateRequired highlights any fields that contain erros that will not allow for a re-save if (validateRequired()) { } else { Warnings.Text = "Errors on Page."; } }
public void updateAllFields() { //define a dataset object for all the different kinds of information this page will need dsPurchaseRequest dsFinanceDetails; dsVehicle dsVehicleInfo; dsTradeIn dsTradeInInfo; string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); try { int tPRO = (int)Session["PurchaseRequest"]; dsFinanceDetails = dataLayerObj.findPurchaseRequest(tPRO); //uses information from the Purchase Request to locate information about Vehicle and TradeIn - similar to a Table JOIN dsVehicleInfo = dataLayerObj.findVehicle(dsFinanceDetails.PurchaseRequest[0].vehicleID); dsTradeInInfo = dataLayerObj.findTradeIn(dsFinanceDetails.PurchaseRequest[0].tradeinID); if (dsFinanceDetails.PurchaseRequest.Rows.Count > 0) { double customerOffer = 0, licenseFee = 0, taxes = 0, tradeInValue = 0, downPayment = 0, amountToFinance = 0; try { //TO DO: Turn this process into a function in the business layer. //This code calculates the total cost of a vehicle (ie. adds CustomerOffer, LicenseFee, and Taxes) //TO DO: Include Add-Ons to the Total Cost customerOffer = (double)dsFinanceDetails.PurchaseRequest[0].negotiatedPrice; licenseFee = (double)dsVehicleInfo.Vehicle[0].Licensefee; taxes = (double)dsVehicleInfo.Vehicle[0].taxes; //Missing the cost of the add-ons //TO DO: Calculate the Cost of the Add-Ons in the Business Layer try { lblTotalCost.Text = (customerOffer + licenseFee + taxes).ToString("$#,##0.00"); } catch (Exception error) { lblTotalCost.Text = ""; } } catch (Exception error) { Warnings.Text = "Unable to calculate Total Cost."; } //Post Trade-In Information to the screen try { tradeInValue = (double)dsTradeInInfo.TradeIn[0].amount; try { lblTradeInValue.Text = tradeInValue.ToString("$#,##0.00"); } catch (Exception error) { lblTradeInValue.Text = ""; } } catch (Exception error) { Warnings.Text = "Unable to calculate Trade-In Value."; } //Post information about Finances to screen try { downPayment = Double.Parse(dsFinanceDetails.PurchaseRequest[0].downPayment); try { txtDownPayment.Text = string.Format("{0:C2}", dsFinanceDetails.PurchaseRequest[0].downPayment); } catch (Exception error) { txtDownPayment.Text = ""; } amountToFinance = (customerOffer + licenseFee + taxes) - tradeInValue - downPayment; try { lblAmountToFinance.Text = amountToFinance.ToString("$#,##0.00"); } catch (Exception error) { lblAmountToFinance.Text = ""; } try { lblMonthlyPayment.Text = (myBusinessLayer.calculateMonthlyPayment(dsFinanceDetails.PurchaseRequest[0].ficoScore, amountToFinance, myBusinessLayer.convertLoanLengthToInt(dsFinanceDetails.PurchaseRequest[0].financeLength))); } catch (Exception error) { lblMonthlyPayment.Text = ""; } } catch (Exception error) { Warnings.Text = "Unable to calculate Amount to Finance."; } //post APR information to the screen try { lblInterestRate.Text = myBusinessLayer.calculateAPR(dsFinanceDetails.PurchaseRequest[0].ficoScore); } catch (Exception error) { lblInterestRate.Text = ""; } //post FICO score to screen try { txtFICO.Text = dsFinanceDetails.PurchaseRequest[0].ficoScore.ToString(); } catch (Exception error) { txtFICO.Text = ""; } //post the date the FICO scored was last updated to the screen try { txtFICODate.Text = dsFinanceDetails.PurchaseRequest[0].ficoScoreDate.ToString(); } catch (Exception error) { txtFICODate.Text = ""; } //post the life-of-loan information to the screen try { ddlFinanceLength.Text = dsFinanceDetails.PurchaseRequest[0].financeLength; } catch (Exception error) { ddlFinanceLength.Text = "48-Months"; } } else { Warnings.Text = "Record Not Found."; } } catch (Exception error) { string message = "Error = "; Warnings.Text = message + error.Message; } }
public void updateAllFields() { //instantiate a dataset object for each database that will supply information dsPurchaseRequest dsPROPurchaseRequest; dsCustomer dsPROCustomer; dsEmployee dsPROEmployee; dsTradeIn dsPROTradeIn; dsVehicle dsPROVehicle; //create a general dataLayerObject that will serve to populate with datasets as needed string tempPath = Server.MapPath("~/HTVDatabase1.mdb"); clsDataLayer dataLayerObj = new HTV.clsDataLayer(tempPath); try { //populate the PurchaseRequest information. This will also help to link to other Tables using foreign keys dsPROPurchaseRequest = dataLayerObj.findPurchaseRequest(Int32.Parse(ddlPurchaseRequestID.Text)); //only proceeds if there is data in the data set if (dsPROPurchaseRequest.PurchaseRequest.Rows.Count > 0) { Session["PurchaseRequest"] = dsPROPurchaseRequest.PurchaseRequest[0].requestID; lblPR.Text = ((int)Session["PurchaseRequest"]).ToString(); //Retreive Information about the Employee using a DataSet for the Employee information try { dsPROEmployee = dataLayerObj.findEmployee(dsPROPurchaseRequest.PurchaseRequest[0].employeeID); try { lblEmployee.Text = "ID: " + dsPROPurchaseRequest.PurchaseRequest[0].employeeID.ToString() + " - " + dsPROEmployee.Employee[0].lastName + ", " + dsPROEmployee.Employee[0].firstName; } catch (Exception error) { lblEmployee.Text = ""; } } catch (Exception error) { lblEmployee.Text = "No Employee Assigned."; } //Retreive Information about the Customer using a DataSet for the Customer Informaiton try { dsPROCustomer = dataLayerObj.findCustomer(dsPROPurchaseRequest.PurchaseRequest[0].customerID); try { lblCustomer.Text = "SSN: " + dsPROCustomer.Customer[0].socialSecurity + " - " + dsPROCustomer.Customer[0].lastName + ", " + dsPROCustomer.Customer[0].firstName; } catch (Exception error) { lblCustomer.Text = ""; } try { lblCustomer.Text = "SSN: " + dsPROCustomer.Customer[0].socialSecurity + " - " + dsPROCustomer.Customer[0].lastName + ", " + dsPROCustomer.Customer[0].firstName; } catch (Exception error) { lblCustomer.Text = ""; } } catch (Exception error) { lblCustomer.Text = "No Customer Assigned."; } try { lblFICO.Text = "FICO: " + dsPROPurchaseRequest.PurchaseRequest[0].ficoScore.ToString(); } catch (Exception error) { lblFICO.Text = ""; } //Retrieve Information about the Vehicle using a DataSet for the Vehicle Database try { dsPROVehicle = dataLayerObj.findVehicle(dsPROPurchaseRequest.PurchaseRequest[0].vehicleID); try { lblVehicleID.Text = "Vehicle ID: " + dsPROPurchaseRequest.PurchaseRequest[0].vehicleID.ToString() + " - " + dsPROVehicle.Vehicle[0].vin; } catch (Exception error) { lblVehicleID.Text = ""; } try { lblMSRP.Text = string.Format("Vehicle MSRP: {0,000:C2}", dsPROVehicle.Vehicle[0].price); } catch (Exception error) { lblMSRP.Text = ""; } try { lblCustomerOffer.Text = "Customer's Offer: " + dsPROPurchaseRequest.PurchaseRequest[0].negotiatedPrice.ToString("$#,##0.00"); } catch (Exception error) { lblCustomerOffer.Text = ""; } try { lblVehicleLocation.Text = "Location: " + dsPROVehicle.Vehicle[0].VehicleLocation; } catch (Exception error) { lblVehicleLocation.Text = ""; } //This portion fills in the Financing Details of the Overview try { lblDownPayment.Text = string.Format("Total Down Payment: ${0,000:C2}", dsPROPurchaseRequest.PurchaseRequest[0].downPayment); } catch (Exception error) { lblDownPayment.Text = ""; } try { lblCreditAmount.Text = "Remaining Financing Needed: $" + dsPROPurchaseRequest.PurchaseRequest[0].creditAmount.ToString("0,000.00"); } catch (Exception error) { lblCreditAmount.Text = ""; } try { lblAPR.Text = "Credit Rate Available: " + myBusinessLayer.calculateAPR(dsPROPurchaseRequest.PurchaseRequest[0].ficoScore); } catch (Exception error) { lblDownPayment.Text = ""; } try { lblFinanceLength.Text = dsPROPurchaseRequest.PurchaseRequest[0].financeLength; } catch (Exception error) { lblFinanceLength.Text = ""; } try { lblMonthlyEstimate.Text = "Estimated Monthly Payment: " + myBusinessLayer.calculateMonthlyPayment(dsPROPurchaseRequest.PurchaseRequest[0].ficoScore, myBusinessLayer.calculateAmountToFinance((int)Session["PurchaseRequest"]), myBusinessLayer.convertLoanLengthToInt(dsPROPurchaseRequest.PurchaseRequest[0].financeLength)); } catch (Exception error) { lblMonthlyEstimate.Text = ""; } } catch (Exception error) { //clears all text fields if there is an error, otherwise previous data may stay on the page lblVehicleID.Text = "No Vehicle Assigned"; lblVehicleLocation.Text = ""; lblDownPayment.Text = ""; lblCreditAmount.Text = ""; lblAPR.Text = ""; lblFinanceLength.Text = ""; lblMonthlyEstimate.Text = ""; } //TO DO: This section is left to do. This will describe the Add-Ons for the Vehicle. try { lblAddOns.Text = dsPROPurchaseRequest.PurchaseRequest[0].requestID.ToString() + " Unfinished Code."; } catch (Exception error) { lblAddOns.Text = ""; } try { lblAddOnsCost.Text = dsPROPurchaseRequest.PurchaseRequest[0].requestID.ToString() + " Unfinished Code."; } catch (Exception error) { lblAddOnsCost.Text = ""; } //Retreive Information about the Trade In using a DataSet for the Trade In information try { dsPROTradeIn = dataLayerObj.findTradeIn(dsPROPurchaseRequest.PurchaseRequest[0].tradeinID); try { lblTradeInID.Text = "ID: " + dsPROPurchaseRequest.PurchaseRequest[0].tradeinID.ToString() + " - " + dsPROTradeIn.TradeIn[0].make + " / " + dsPROTradeIn.TradeIn[0].model + " / " + dsPROTradeIn.TradeIn[0].year; } catch (Exception error) { lblTradeInID.Text = ""; } try { lblTradeInTitle.Text = "Title is Clear. " + dsPROTradeIn.TradeIn[0].titleClear; } catch (Exception error) { lblTradeInTitle.Text = ""; } try { lblTradeInValue.Text = string.Format("Trade-In Value: {0:C2}", dsPROTradeIn.TradeIn[0].amount); } catch (Exception error) { lblTradeInValue.Text = ""; } //Retrieve the Mechanic's Name by using a DataSet that retrieves Employee Information using TradeIn Table FK dsPROEmployee = dataLayerObj.findEmployee(dsPROTradeIn.TradeIn[0].inspectedID); try { lblMechanicApproval.Text = "Approved By: ID " + dsPROTradeIn.TradeIn[0].inspectedID + " - " + dsPROEmployee.Employee[0].lastName + ", " + dsPROEmployee.Employee[0].firstName; } catch (Exception error) { lblMechanicApproval.Text = ""; } } catch (Exception error) { lblTradeInID.Text = "No Trade-In Assigned."; lblTradeInTitle.Text = ""; lblTradeInValue.Text = ""; lblMechanicApproval.Text = "No Trade-In to inspect."; } //Retrieve the Manager's Name by using a DataSet that retrieves Employee Information using the ManagerApproval Employee ID Number try { dsPROEmployee = dataLayerObj.findEmployee(dsPROPurchaseRequest.PurchaseRequest[0].managerApproval); try { lblManagerApproval.Text = dsPROPurchaseRequest.PurchaseRequest[0].approvalstatus + " by " + dsPROEmployee.Employee[0].lastName + ", " + dsPROEmployee.Employee[0].firstName; } catch (Exception error) { lblManagerApproval.Text = "Unable to retrieve Manager Approval information."; } try { lblDisapprovedDescription.Text = dsPROPurchaseRequest.PurchaseRequest[0].disapprovedDescription; } catch (Exception error) { lblDisapprovedDescription.Text = ""; } } catch (Exception error) { lblManagerApproval.Text = "Pending Manager Approval."; lblDisapprovedDescription.Text = ""; } //posts information to the Purchase Request Date field try { lblPurchaseRequestDate.Text = dsPROPurchaseRequest.PurchaseRequest[0].requestCreationDate.ToString(); } catch (Exception error) { lblPurchaseRequestDate.Text = ""; } } else { Warnings.Text = "Error Switching Purchase Requests."; } } catch (Exception error) { string message = "Error = "; Warnings.Text = message + error.Message; } }