private void btnProdSearch_Click(object sender, EventArgs e) { ViewProductForm searchProd = new ViewProductForm(); searchProd.ShowDialog(); IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); if (string.IsNullOrWhiteSpace(txtProductSearch.Text)) { MessageBox.Show("Product Search value required."); return; } //good search List <Product> prodSearchResults = prodUtil.ProductSearch(txtProductSearch.Text); List <ProductViewModel> psVMCollection = new List <ProductViewModel>(); foreach (Product prodDTO in prodSearchResults) { //create new view model object ProductViewModel psVM = new ProductViewModel(prodDTO); //add to psVMVollection collection psVMCollection.Add(psVM); } //datasource grid view dgvProductSearch.DataSource = null; dgvProductSearch.DataSource = psVMCollection; }
private void btnAddProduct_Click(object sender, EventArgs e) { //Validate ListPrice, StandardCost and Weight as numbers decimal newLP; //New ListPrice decimal newSC; //New StandardCost decimal newWeight; //New Weight if (!decimal.TryParse(txtListPrice.Text, out newLP)) { MessageBox.Show("Standard Cost must be a valid number. $0.00"); return; //Exit the event handler } if (!decimal.TryParse(txtStandardCost.Text, out newSC)) { MessageBox.Show("List Price must be a valid number. $0.00"); return; //Exit the event handler } if (!decimal.TryParse(txtListPrice.Text, out newWeight)) { MessageBox.Show("Weight must be a valid number."); return; //Exit the event handler } //Product object Product prodToAdd = new Product() { ProductNumber = txtProdNumber.Text, Name = txtProdName.Text, Color = txtColor.Text, ListPrice = newLP, Weight = newWeight, Size = txtSize.Text, StandardCost = newSC, SellStartDate = dtpStartDate.Value, ModifiedDate = DateTime.Now }; //ICustomerUtility IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); //UpdateCustomer try { prodUtil.AddProductUtility(prodToAdd); } catch (Exception ex) { //Logging* //Error Handling* this.Close(); } //Close the form Close(); }
private void btnSave_Click(object sender, EventArgs e) { //Validate UnitPrice as Number decimal newLP; //new UnitPrice decimal newSC; decimal newWeight; if (!decimal.TryParse(txtListPrice.Text, out newLP)) { MessageBox.Show("Unit Price must be a valid number, $0.00"); return; //Exit the event handler } if (!decimal.TryParse(txtStandardPrice.Text, out newSC)) { MessageBox.Show("Standard Cost must be a valid number, $0.00"); return; //Exit the event handler } if (!decimal.TryParse(txtWeight.Text, out newWeight)) { MessageBox.Show("Weight must be a valid number."); return; //Exit the event handler } //Product object //Copy the values from the textbox into the new product object Product prodToUpdate = new Product() { ListPrice = newLP, Name = txtName.Text, StandardCost = newSC, Weight = newWeight, Color = txtColor.Text, SellStartDate = dtpProdUpdate.Value, SellEndDate = dtpSellEndDate.Value, ProductID = this.id }; //IInventoryUtility IProductUtility invUtil = DependencyInjectorUtility.GetProductsUtility(); //UpdateProduct try { invUtil.UpdateProduct(prodToUpdate); } catch (Exception ex) { //Logging* //Error Handling* } //Close the form this.Close(); }
private void viewProductsForm_Load(object sender, EventArgs e) { IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); List <Product> AllCustomers = prodUtil.GetProductList(); List <ProductViewModel> pVMCollection = new List <ProductViewModel>(); foreach (Product ProductDTO in AllCustomers) { //create new view model object ProductViewModel pVM = new ProductViewModel(ProductDTO); //add to pVMVollection collection pVMCollection.Add(pVM); } //datasource grid view dgvViewProducts.DataSource = null; dgvViewProducts.DataSource = pVMCollection; }
private void lnkChangePicture_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { //Show dialog openFileDialog1.Filter = "Image Files(*.BMP; *.JPG; *.GIF)| *.BMP; *.JPG; *.GIF | All files(*.*) | *.*"; openFileDialog1.CheckFileExists = true; var dialogResult = openFileDialog1.ShowDialog(); //Verify a file was selected string filePath = string.Empty; if (dialogResult == DialogResult.OK) { //Capture the file selected filePath = openFileDialog1.FileName; } else { MessageBox.Show("No file selected"); return; } //Read stream place the data into a buffer byte[] buffer; using (FileStream fStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { buffer = new byte[fStream.Length]; fStream.Read(buffer, 0, buffer.Length); } //Send the buffer, along with the product id to our Inventoryutility IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); prodUtil.UpdateProductPicture(id, buffer); //Show new picture ShowPicture(buffer); }
private void ProductUpdateForm_Load(object sender, EventArgs e) { //Variables Product product; //Load Product IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); product = prodUtil.GetProductList(id); //Populate the Form with the Product Data txtName.Text = product.Name; txtListPrice.Text = product.ListPrice.ToString(); txtStandardPrice.Text = product.StandardCost.ToString(); txtColor.Text = product.Color; txtWeight.Text = product.Weight.ToString(); //Load picture if (product.ThumbNailPhoto != null) { ShowPicture(product.ThumbNailPhoto); } }
private void buttonSearch_Click(object sender, EventArgs e) { flpProducts.Controls.Clear(); //removes existing controls IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); if (string.IsNullOrWhiteSpace(txtProductSearch.Text)) { MessageBox.Show("Product Search value required."); return; } //good search List <Product> prodSearchResults = prodUtil.ProductSearch(txtProductSearch.Text); List <ProductViewModel> psVMCollection = new List <ProductViewModel>(); foreach (Product prodDTO in prodSearchResults) { ucProdSearch puc = new ucProdSearch(prodDTO); flpProducts.Controls.Add(puc); } }
public ProductSearchService(ILogger <ProductSearchService> logger, IProductUtility productUtility) { _logger = logger; _productUtility = productUtility; }