// gets the catelog information from the database and displays the information on the page. public void SetCatelogInfo(string ItemName) { BusinessObjects _businessObjects = new BusinessObjects(); CatelogItem = _businessObjects.GetCatalogItemByItemName(ItemName); lblItemCost.Text = "Cost: " + CatelogItem.ItemCost.ToString(); string InstriptionTypes = CatelogItem.InscriptionType.ToString(); lblInscriptionType.Text = "Inscryption Type: " + InstriptionTypes; }
// this event is triggered when the order button is clicked on the customer page. protected void btnOrderNow_Click(object sender, EventArgs e) { if ((txtDesiredText.Text == null) || (txtDesiredText.Text == string.Empty)) { lblError.Text = "Error: You need to enter your desired text"; lblError.Visible = true; return; } BusinessObjects _businessObjects = new BusinessObjects(); string strLastName = lastnamelbl.Text; // create new order and newitem objects Order newOrder = new Order(); OrderItem newItem = new OrderItem(); // populate the new order and newitem objects with data from the database string ItemName = ItemDPList.Items[ItemDPList.SelectedIndex].Text; CatelogItem = _businessObjects.GetCatalogItemByItemName(ItemName); Customer = _businessObjects.GetCustomerByLastName(strLastName); Customer ActualCustomer = new Customer(); foreach (Customer Cust in Customer) { if (Cust.PersonType.ToString() == "Customer") { ActualCustomer = Cust; } } lastnamelbl.Text = ActualCustomer.PersonType.ToString(); // fill new item object with data newItem.CatalogItem = CatelogItem; newItem.ItemInscription = txtDesiredText.Text; newOrder.ItemList.Add(newItem); newOrder.OrderEntryDate = DateTime.Now; newOrder.Person = ActualCustomer; OrderStatus orderstatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), "Submitted"); newOrder.OrderStatus = orderstatus; // call the createorder method to create new order int returnValue = ApplicationObjects.CreateOrder(newOrder); if (returnValue == 0) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Your Order is complete!" + "');", true); } Response.Redirect(Request.RawUrl); txtDesiredText = null; lblInscriptionType = null; lblItemCost = null; }
private void btn_SearchSubmit_Click(object sender, EventArgs e) { BusinessObjects _businessObjects = new BusinessObjects(); // Element reset to be performed each time, before a search is ran lbl_CatalogResultsFound.Text = null; // Clear contents of search result label cbx_CatalogResultsList.Items.Clear(); // Clear old search results from results combo box cbx_CatalogResultsList.Text = ""; // Clear text from visible combobox area rbx_CatalogSearchResults.Clear(); // Clear search results each time a new search is submitted catalogItemCollection = null; // Clear inventory items from list // Verify that a query type was selected by the user if (cbx_CatalogQueryType.SelectedItem == null) { MessageBox.Show("You forgot to select a query type. Please try again", "Invalid Query", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } // SEARCH BY MANUFACTURER NAME - Chech to see if user entered a Manufacturer Name else if (cbx_CatalogQueryType.SelectedItem.ToString() == "Manufacturer") { // Generate a list of Inventory Items that match the Manufacturer Name entered by the user catalogItemCollection = _businessObjects.GetCatalogItemByManufacturer(tbx_CatalogQueryInput.Text); } // SEARCH BY ITEM NAME - Check to see if user entered an Item Name else if (cbx_CatalogQueryType.SelectedItem.ToString() == "Item Name") { // Generate a list of Catalog Items that match the Item Name entered by the user catalogItemCollection = (catalogItemCollection == null) ? new List <CatalogItem>() : catalogItemCollection; catalogItemCollection.Add(_businessObjects.GetCatalogItemByItemName(tbx_CatalogQueryInput.Text)); } // SEARCH BY ITEM GUID - Check to see if user entered an ID Number else if (cbx_CatalogQueryType.SelectedItem.ToString() == "Catalog ID") { try { // Generate a list of Catalog Items that match the Item ID entered by the user catalogItemCollection = (catalogItemCollection == null) ? new List <CatalogItem>() : catalogItemCollection; catalogItemCollection.Add(ApplicationObjects.GetCatalogItemByCatalogItemId(new Guid(tbx_CatalogQueryInput.Text))); } catch (Exception) { // Catch if a non-Guid was entered MessageBox.Show("You entered an invalid ID. Please make sure that the ID contains 32 characters and 4 hyphens", "Invalid GUID", MessageBoxButtons.OK, MessageBoxIcon.Hand); rbx_CatalogSearchResults.AppendText("Input error - please try again"); return; } } // If nothing is populated into the searchDisplay box, we can assume that there were no search results else { lbl_CatalogResultsFound.Text = "No results found"; } // Populate label that displays how many results were found lbl_CatalogResultsFound.Text = (catalogItemCollection.Count.ToString() + " result(s) found!"); // This string list holds the results of an CatalogItem's ToItemDescription method, which actually // returns a list of individual line items, which each hold the item's attributes that will be // displayed on seperate lines of the text box List <string> itemDescriptions = (catalogItemCollection.Count > 0) ? catalogItemCollection.FirstOrDefault().ToItemDescription() : new List <string>(); foreach (string lineItem in itemDescriptions) { // Add each description line item to the text box rbx_CatalogSearchResults.AppendText(lineItem + Environment.NewLine); } // Populate the search result combobox with the Catalog Id numbers of the search results foreach (CatalogItem catalogItem in catalogItemCollection) { cbx_CatalogResultsList.Items.Add(catalogItem.CatalogItemId.ToString()); } // Set the combobox to show the catalog number of the first search record if (cbx_CatalogResultsList.Items.Count > 0) { cbx_CatalogResultsList.SelectedIndex = 0; } }