//this method returns the customerID number by passing a purchase request REQUESTID number public int getCustomerID(int tPRID) { int tCID = 0; dsPurchaseRequest tempPRDataSet = myDataLayer.findPurchaseRequest(tPRID); tCID = tempPRDataSet.PurchaseRequest[0].customerID; return(tCID); }
//this method returns the employeeID number by passing a purchase request REQUESTID number public int getEmployeeID(int tPRID) { int tEID = 0; dsPurchaseRequest tempPRDataSet = myDataLayer.findPurchaseRequest(tPRID); tEID = tempPRDataSet.PurchaseRequest[0].employeeID; return(tEID); }
//this method returns the vehicleID number by passing a purchase requestion REQUESTID number public int getVehicleID(int tPRID) { int tVID = 0; dsPurchaseRequest tempPRDataSet = myDataLayer.findPurchaseRequest(tPRID); tVID = tempPRDataSet.PurchaseRequest[0].vehicleID; return(tVID); }
//populates a dataset with information from the PurchaseRequest Table public dsPurchaseRequest findPurchaseRequest(int purchaseRequestID) { //the SQL statement filters the search by searching for a specific requestID string sqlStmt = "select * from PurchaseRequest where requestID like '" + purchaseRequestID + "'"; OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter(sqlStmt, dbConnection); //fills the data to a temporary data set dsPurchaseRequest tempDataSet = new dsPurchaseRequest(); sqlDataAdapter.Fill(tempDataSet.PurchaseRequest); //returns the resulting data set -- should be only 1 line because the requestID is Primary Key (Unique) return(tempDataSet); }
//populates a dropDownMenu with all Purchase Requests from the PurchaseRequest Table public dsPurchaseRequest dsPurchaseRequestDropDown() { //This SQL statement only finds REQUESTIDs for all Purchase Request //(Future TO DO): Include more information in the DropDownMenu so it makes it easier to lookup a customer //(Future TO DO): Only include Purchase Requests that have not been finalized/Sale Completed string sqlStmt = "Select requestID FROM PurchaseRequest"; OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter(sqlStmt, dbConnection); dsPurchaseRequest tempDataSet = new dsPurchaseRequest(); sqlDataAdapter.Fill(tempDataSet.PurchaseRequest); //returns a resulting data set with only one colum -- this list should be expected to have multiple rows return(tempDataSet); }
//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; } }