/*fill up the website with items */ public void stockStore() { try { lblError.Visible = false; foreach (Record_Product item in Functions_Product.getProduct()) { mainStore.Text += (Functions_Product.displayProducts( item.Title , item.Description , item.Quantity , item.Cost , item.PicturePath)); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = "No products are available to display at this time."; Debug.WriteLine ("******ALERT*****\n" + $"{ex}\n" + "******ENDALERT*****\n"); } }
/*Run the Add_Product Method from the Data_layer */ protected void btnAdd_Click(object sender, EventArgs e) { try { captureData(); if (Functions_Product.AddProduct (product.Title , product.Description , product.Quantity , product.Cost , product.PicturePath)) { lblError.Visible = true; lblError.Text = "Upload Successful!"; } else { lblError.Visible = true; lblError.Text = "Upload Failed!"; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Error Occured in Add: \n" + ex.ToString() + "\n"); } }
protected void txtID_TextChanged(object sender, EventArgs e) { /*get data for the rest of the boxes to fill in */ try { product = Functions_Product.getOneProductById(Convert.ToInt32(txtID.Text)); txtTitle.Text = product.Title; txtDesc.Text = product.Description; txtQuan.Text = product.Quantity.ToString(); txtCost.Text = product.Cost.ToString(); } catch (Exception ex) { globalMethods.printDebug(ex.ToString()); } }
protected void btnModify_Click(object sender, EventArgs e) { captureData(); try { if (Functions_Product.modifyProduct(product.productID, product.Title, product.Description, product.Quantity, product.Cost, product.PicturePath)) { } } catch (Exception ex) { globalMethods.printDebug(ex.ToString()); } txtID.Text = null; }
/* this function combines the product list with the HTML to turn it into a table */ public void fillTable() { { productTable.Text = @" <div class = 'container'> <thead> <tr> <th scope = 'col'>ID</th> <th scope = 'col'>Title</th> <th scope = 'col'>Description</th> <th scope = 'col'>Quantity</th> <th scope = 'col'>Cost</th> <th scope = 'col'>Picture Path</th> </tr> </thead> <tbody>"; try { foreach (Record_Product item in Functions_Product.getProduct()) { productTable.Text += (Functions_Product.tableProducts( item.productID , item.Title , item.Description , item.Quantity , item.Cost , item.PicturePath)); } productTable.Text += "</tbody></div>"; } catch (Exception ex) { globalMethods.printDebug( ("******ALERT*****\n" + $"{ex}\n" + "******ENDALERT*****\n")); } } }