private void DeleteBrand(BrandModel brand) { //Deletes given product from DB & list if (ConfirmDeleteItem(brand.BrandName) == true) { try { SQLiteDataAccess.DeleteBrand(brand.BrandId); LoadBrandList(); } catch (Exception ex) { MessageBox.Show(ex.Message, "FAILED TO DELETE!"); } } }
private void DeleteCategory(CategoryModel category) { //Deletes given category from DB & list if (ConfirmDeleteItem(category.CategoryName) == true) { try { SQLiteDataAccess.DeleteCategory(category.CategoryId); LoadCategoryList(); } catch (Exception ex) { MessageBox.Show(ex.Message, "FAILED TO DELETE!"); } } }
private void DeleteProduct(ProductModel product) { //Deletes given product from DB & list if (ConfirmDeleteItem(product.Description) == true) { try { SQLiteDataAccess.DeleteProduct(product.ProductId); Products.Remove(product); } catch (Exception ex) { MessageBox.Show(ex.Message, "FAILED TO DELETE!"); } } }
private void UpdateProduct() { //get Image from picturebox byte[] picture = null; if (pictureProduct.Image != null) { picture = ProductModel.ImageToByte( pictureProduct.Image, pictureProduct.Image.RawFormat ); } //get Brand & Category ID var brand = (BrandModel)comboBrand.SelectedItem; var category = (CategoryModel)comboCategory.SelectedItem; ProductModel product = new ProductModel { ProductId = Product.ProductId, CostPrice = decimal.Parse(textCost.Text), ListPrice = decimal.Parse(textList.Text), Quantity = int.Parse(textQuantity.Text), Description = textDescription.Text.Trim(), UpdatedOn = DateTime.Now, BrandName = brand.BrandName, CategoryName = category.CategoryName, Picture = picture }; //Update In DB, if successful assign to oldProduct try { SQLiteDataAccess.UpdateProduct( product, brand.BrandId, category.CategoryId); //copy each attribute back to Product from product CopyBackProperties(product); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, "FAILED TO UPDATE!"); DialogResult = DialogResult.Abort; } Close(); }
private void SaveProduct() { //Get Image from picturebox byte[] picture = null; if (pictureProduct.Image != null) { picture = ProductModel.ImageToByte( pictureProduct.Image, pictureProduct.Image.RawFormat ); } //Get Brand & Category var brand = (BrandModel)comboBrand.SelectedItem; var category = (CategoryModel)comboCategory.SelectedItem; ProductModel product = new ProductModel { CostPrice = decimal.Parse(textCost.Text), ListPrice = decimal.Parse(textList.Text), Quantity = int.Parse(textQuantity.Text), Description = textDescription.Text.Trim(), UpdatedOn = DateTime.Now, BrandName = brand.BrandName, CategoryName = category.CategoryName, Picture = picture }; //Add To DB & Refresh DGV try { product.ProductId = SQLiteDataAccess.SaveProduct(product, brand.BrandId, category.CategoryId); Products.Add(product); ResetProductInputs(); } catch (Exception ex) { MessageBox.Show(ex.Message, "FAILED TO SAVE!"); } }
private void btnUpdateCategory_Click(object sender, EventArgs e) { if (CanSaveCategory() == true) { Category.CategoryName = textName.Text.Trim(); try { SQLiteDataAccess.UpdateCategory(Category); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, "FAILED TO SAVE!"); DialogResult = DialogResult.Abort; } } else { DialogResult = DialogResult.Abort; } Close(); }
private void LoadCartList() { Cart = new BindingList <CartItemModel>(SQLiteDataAccess.ViewSale(Sale.SaleId)); WireUpCartDataGridView(); }
//Load sale objects from db private void LoadSaleList() { Sales = new BindingList <SaleModel>(SQLiteDataAccess.LoadSales()); WireUpSaleDataGridView(); }
private void LoadCategoryList() { Categories = SQLiteDataAccess.LoadCategories(); //display categories in combo box WireUpCategoryComboBox(); }
private void LoadBrandList() { Brands = SQLiteDataAccess.LoadBrands(); //display brands in combo box WireUpBrandComboBox(); }