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 btnSave_Click(object sender, EventArgs e) { //Customer object //Copy the values from the textbox into the new customer object Customer custToUpdate = new Customer() { FirstName = txtFName.Text, MiddleName = txtMName.Text, LastName = txtLName.Text, EmailAddress = txtEmail.Text, CompanyName = txtCompName.Text, SalesPerson = txtSalesPerson.Text, Phone = txtPhone.Text, Suffix = txtSuffix.Text, CustomerID = this.id }; //ICustomerUtility ICustomerUtility custUtil = DependencyInjectorUtility.GetCustomerUtility(); //UpdateProduct try { custUtil.UpdateCustomer(custToUpdate); } catch (Exception ex) { //Logging* //Error Handling* } //Close the form this.Close(); }
private void btnAddCustomer_Click(object sender, EventArgs e) { //Customer object Customer custToAdd = new Customer() { FirstName = txtFName.Text, MiddleName = txtMName.Text, LastName = txtLName.Text, EmailAddress = txtEmail.Text, CompanyName = txtCompName.Text, SalesPerson = txtSalesPerson.Text, Phone = txtPhone.Text, Suffix = txtSuffix.Text, PasswordHash = txtPassHash.Text, PasswordSalt = txtPassSalt.Text }; //ICustomerUtility ICustomerUtility custUtil = DependencyInjectorUtility.GetCustomerUtility(); //UpdateCustomer try { custUtil.AddCustomerUtility(custToAdd); } catch (Exception ex) { //Logging* //Error Handling* this.Close(); } //Close the form this.Close(); }
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 CustomerUpdateForm_Load(object sender, EventArgs e) { //Variables Customer customer; FullAddress fulladdress; //Load Customer ICustomerUtility customerUtil = DependencyInjectorUtility.GetCustomerUtility(); customer = customerUtil.GetCustomers(id); //Populate the form txtFName.Text = customer.FirstName; txtMName.Text = customer.MiddleName; txtLName.Text = customer.LastName; txtEmail.Text = customer.EmailAddress; txtCompName.Text = customer.CompanyName; txtSalesPerson.Text = customer.SalesPerson; txtPhone.Text = customer.Phone; txtSuffix.Text = customer.Suffix; lblCustName.Text = customer.FirstName + " " + customer.LastName; //Load address fulladdress = customerUtil.GetFullAddress(id); //variables List <CustomerAddress> customeraddressList; List <string> FullAddress = new List <string>(); //Load customer address customeraddressList = customerUtil.GetCustomerAddress(id); //Populate groupbox if (customeraddressList != null)//As long as the customer in question has addresses { //loop through list of customer address objects, pulling the AddressType property and adding it to the list foreach (CustomerAddress custadd in customeraddressList) { //add Addresstype to the list FullAddress.Add(custadd.AddressType); } } cbAddressType.DropDownStyle = ComboBoxStyle.DropDownList; //combobox read only cbAddressType.DataSource = FullAddress; //Fill in groupbox labels lblAddressType.Text = fulladdress.AddressType; lblAddressLine1.Text = fulladdress.AddressLine1; lblCityStateZip.Text = fulladdress.City + "," + " " + fulladdress.StateProvince + " " + fulladdress.PostalCode; }
private void btnAddOrder_Click(object sender, EventArgs e) { //Decimal variables decimal newTax; decimal newFRT; int newID; if (!decimal.TryParse(txtTaxAmt.Text, out newTax)) { MessageBox.Show("Tax Amount must be a valid number. $0.00"); return; //Exit the event handler } if (!decimal.TryParse(txtFreight.Text, out newFRT)) { MessageBox.Show("Freight must be a decimal number"); return; //Exit the event handler } if (!int.TryParse(txtCustID.Text, out newID)) { MessageBox.Show("ID must be a valid number"); return; //Exit the event handler } //Customer object Order orderToAdd = new Order() { OrderDate = dtpOrderDate.Value, DueDate = dtpDueDate.Value, ShipMethod = txtShipMethod.Text, TaxAmt = newTax, Freight = newFRT, CustomerID = newID }; //ICustomerUtility IOrderUtility orderUtil = DependencyInjectorUtility.GetOrdersUtility(); //UpdateCustomer try { orderUtil.AddOrderUtility(orderToAdd); } catch (Exception ex) { //Logging* //Error Handling* return; } //Close the form this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { //decimal variables decimal udTax; decimal udFreight; if (!decimal.TryParse(txtTaxAmtUD.Text, out udTax)) { MessageBox.Show("Tax Amount must be a valid number. $0.00"); return; //Exit the event handler } if (!decimal.TryParse(txtFreightUD.Text, out udFreight)) { MessageBox.Show("Freight must be a decimal number"); return; //Exit the event handler } //Order object //Copy the values from the textbox into the new order object Order orderToUpdate = new Order() { DueDate = dtpDueDateUD.Value, OrderDate = dtpOrderDateUD.Value, ShipMethod = txtShipMethodUD.Text, TaxAmt = udTax, Freight = udFreight, CustomerID = this.id }; //ICustomerUtility IOrderUtility orderUtil = DependencyInjectorUtility.GetOrdersUtility(); //UpdateProduct try { orderUtil.UpdateOrder(orderToUpdate); } catch (Exception ex) { //Logging* //Error Handling* } //Close the form this.Close(); }
private void btnOrderSearch_Click(object sender, EventArgs e) { //Injector for both searches IOrderUtility orderUtil = DependencyInjectorUtility.GetOrdersUtility(); List <Order> AllOrders = orderUtil.GetSalesOrder(); string search = txtOrderSearch.Text; /*************************************Return all orders for blank search*******************************************/ if (search == "") { List <OrderSearchViewModel> osVMCollection = new List <OrderSearchViewModel>(); foreach (Order OrderDTO in AllOrders) { //create new view model object OrderSearchViewModel osVM = new OrderSearchViewModel(OrderDTO); //add to pVMVollection collection osVMCollection.Add(osVM); } //datasource grid view dgvOrderSearch.DataSource = null; dgvOrderSearch.DataSource = osVMCollection; } /*************************************Return orders for GOOD search************************************************/ else { int ordersearch = int.Parse(txtOrderSearch.Text); //good search List <Order> orderSearchResults = orderUtil.OrderSearch(ordersearch); List <OrderSearchViewModel> osNVMCollection = new List <OrderSearchViewModel>(); foreach (Order ordersDTO in orderSearchResults) { //create new view model object OrderSearchViewModel osVM = new OrderSearchViewModel(ordersDTO); //add to psVMVollection collection osNVMCollection.Add(osVM); } dgvOrderSearch.DataSource = null; dgvOrderSearch.DataSource = osNVMCollection; } }
private void OrderUpdateForm_Load(object sender, EventArgs e) { //Variables Order order; //Load Order IOrderUtility orderUtil = DependencyInjectorUtility.GetOrdersUtility(); order = orderUtil.GetOrderList(id); //Populate the Form with the Order Data txtFreightUD.Text = order.Freight.ToString(); txtShipMethodUD.Text = order.ShipMethod; txtTaxAmtUD.Text = order.TaxAmt.ToString(); dtpDueDateUD.Value = order.DueDate; dtpOrderDateUD.Value = order.OrderDate; }
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); } }