private void Add() { var form = new AddProductView(new AddProductViewModel(_dbContext, _supply)); form.Show(); form.Closed += OnFormClosed; }
public ActionResult AddProduct(AddProductView view) { var user = db.Users.Where(c => c.UserName == User.Identity.Name).FirstOrDefault(); if (ModelState.IsValid) { var ordetailtmp = db.OrderDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.ProductId == view.ProductId).FirstOrDefault(); if (ordetailtmp == null) { var product = db.Products.Find(view.ProductId); ordetailtmp = new OrderDetailTmp { Description = product.Description, Price = product.Price, ProductId = product.ProductId, Quantity = view.Quantity, TaxRate = product.Tax.Rate, UserName = User.Identity.Name, }; db.OrderDetailTmps.Add(ordetailtmp); } else { ordetailtmp.Quantity += view.Quantity; db.Entry(ordetailtmp).State = EntityState.Modified; } db.SaveChanges(); return(RedirectToAction("Create")); } ViewBag.ProductId = new SelectList(CombosHelper.GetProducts(user.CompanyId, false), "ProductId", "Description"); return(PartialView()); }
public ActionResult AddProduct(AddProductView addProduct, string time, int SaleID) { #region Check Cache var saleCache = CacheSale; if (IsCookieTimeEqual(time)) { MessageSetter.SetWarning("Sorry , previous transaction is not saved to the database."); if (saleCache != null) { if (IsToday(saleCache)) { // today return(RedirectToActionPermanent("Today")); } else { return(DetermineSaleDay(saleCache)); } } } #endregion if (addProduct.Cost < 0) { ModelState.AddModelError("Amount", "Amount can't be negative."); return(DetermineSaleDay(SaleID)); } var useraccExt = new UserAccountsExtension(); var accountOf = useraccExt.GetProductBoughtUser(); var accountBalance = new AccountBalance() { AccountOf = accountOf.UserID, AddBy = userinfo.GetUserID(), Amount = addProduct.Cost, AddedQuantity = addProduct.Quantity, QtyType = addProduct.QuantityType, Dated = DateTime.Now, CategoryProduct = addProduct.CategoryID, IsExpense = true, IsAddedMoney = false, IsBoughtProduct = true, IsVerified = false }; var inventoryEntension = new InventoryExtension(); if (inventoryEntension.InventoryAdd(db, accountBalance)) { db.SaveChanges(); MessageSetter.SetPositive("Product of " + addProduct.Cost + " successfully."); } else { MessageSetter.SetWarning("try again."); } return(DetermineSaleDay(SaleID)); }
public ActionResult AddProduct(AddProductView view) { var user = db.Users.Where(x => x.UserName == User.Identity.Name).FirstOrDefault(); if (ModelState.IsValid) { var orderDetailTemp = db.OrderDetailTemps.Where(o => o.UserName == User.Identity.Name && o.ProductID == view.ProductID).FirstOrDefault(); if (orderDetailTemp == null) { var product = db.Products.Find(view.ProductID); orderDetailTemp = new OrderDetailTemp { Description = product.Description, Price = product.Price, ProductID = product.ProductID, Quantity = view.Quantity, ImpuestoRate = product.Impuesto.Rate, UserName = User.Identity.Name, }; db.OrderDetailTemps.Add(orderDetailTemp); } else { orderDetailTemp.Quantity += view.Quantity; db.Entry(orderDetailTemp).State = EntityState.Modified; } db.SaveChanges(); return(RedirectToAction("Create")); } ViewBag.ProductID = new SelectList(comboHelper.GetProducts(user.CompanyID), "ProductID", "Description"); return(PartialView(view)); }
private void openAddWindow(object parameter) { AddProductView new_product = new AddProductView(null, HomeViewModel); new_product.ShowDialog(); refresh(); }
private void openEditWindow(object parameter) { AddProductView old_product = new AddProductView(SelectedProduct, HomeViewModel); old_product.ShowDialog(); refresh(); }
public ActionResult AddProduct(AddProductView addProductView) { if (ModelState.IsValid) { var product = db.Products.Find(addProductView.ProductId); var orderDetailTmp = new OrderDetailTmp { Description = product.Description, Price = product.Price, ProductId = product.ProductId, Quantity = addProductView.Quantity, TaxRate = product.Tax.Rate, UserName = User.Identity.Name }; db.OrderDetailTmps.Add(orderDetailTmp); db.SaveChanges(); return(RedirectToAction("Create")); } var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); ViewBag.ProductId = new SelectList(CombosHelpers.GetProducts(user.CompanyId), "ProductId", "Description"); return(View()); }
public AddProductViewModel(ProductModel model, AddProductView add_product_view, HomeViewModel home_view_model) { this.AddProductView = add_product_view; this.HomeViewModel = home_view_model; this.CreateOrUpdateCommand = new RelayCommand(addOrUpdateProduct); if (model != null) { this.UpdateOrCreate = "Update"; this.ID = Convert.ToInt32(model.ID.value); this.Name = model.Name.value; this.Code = Convert.ToInt32(model.Code.value); this.Description = model.Description.value; this.Barcode = model.Barcode.value; this.Price = model.Price.value; this.IsService = model.IsService.value; this.DateCreated = model.DateCreated.value; this.DateUpdated = model.DateUpdated.value; } else { this.UpdateOrCreate = "Create"; this.Code = ProductAccess.singleton.getLastProductCode() + 1; } CoreApp.logger.log("AddProductViewModel successfully initialized."); }
private void AddProductExecute() { AddProductView add = new AddProductView(); add.Show(); Products = productModel.GetAllProducts(); }
public void AddProductViewCreate() { AddProductView view = new AddProductView(); view.DataContext = addProductViewModel; view.ShowDialog(); }
public ActionResult AddProduct(AddProductView view) { if (ModelState.IsValid) { var purchaseDetailBk = db.PurchaseDetailBkps.Where(pdb => pdb.User == User.Identity.Name && pdb.ProductId == view.ProductId).FirstOrDefault(); if (purchaseDetailBk == null) { var product = db.Products.Find(view.ProductId); purchaseDetailBk = new PurchaseDetailBk { Description = product.Description, User = User.Identity.Name, Cost = product.Price, ProductId = product.ProductId, Quantity = view.Quantity, ManufacturingLot = view.ManufacturingLot, DueDate = view.DueDate }; db.PurchaseDetailBkps.Add(purchaseDetailBk); } else { purchaseDetailBk.Quantity += view.Quantity; db.Entry(purchaseDetailBk).State = EntityState.Modified; } db.SaveChanges(); return(RedirectToAction("Create")); } ViewBag.ProductId = new SelectList(db.Products.OrderBy(p => p.Description), "ProductId", "Description"); return(View()); }
private void AjouterProduct(object sender, RoutedEventArgs e) { AddProductView v = DataContext as AddProductView; if (v.Produit.Save()) { MessageBox.Show("produit ajouté avec numéro " + v.Produit.Id); } }
public IActionResult AddProduct(AddProductView product, int id) { if (ModelState.IsValid) { this.salonSvc.AddProduct(product, id); return(RedirectToAction(nameof(MySalon))); } return(View(product)); }
public IHttpActionResult RegisterNewProduct([FromBody] AddProductView newProduct) { if (ModelState.IsValid) { if (CheckIfSellerVerified.VerifySeller(newProduct.SellerId)) { BAL_iNewProduct.AddProduct(newProduct); Content(HttpStatusCode.OK, "Added"); } return(Content(HttpStatusCode.OK, "Not Authorized To Sell")); } return(Content(HttpStatusCode.BadRequest, "Request Failed")); }
/// <summary> /// This method invokes a method for showing a window for adding product. /// </summary> public void AddProductExecute() { try { AddProductView addProductView = new AddProductView(); addProductView.ShowDialog(); ProductList = products.ViewAllProduct(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void AddProduct(AddProductView product, int id) { var result = this.db.Salons.Include(p => p.Products).SingleOrDefault(s => s.Id == id); Product tempProdduct = new Product() { Name = product.Name, Price = product.Price, Discount = product.Discount }; result.Products.Add(tempProdduct); db.SaveChanges(); }
private void AddProductCommandExecuted() { RaisePropertyChanged("DisableParentWindow"); var view = new AddProductView(); view.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (view.DialogResult != null && view.DialogResult.Value) { Products.Add(view.ViewModel.Product.Product); } }
/// <summary> /// Обработчик команды "AddProductCommand" /// </summary> /// <param name="parameter">Параметр, переданный из View</param> private void OnAddProduct(object parameter) { // Создать окно добавления продукта var window = new AddProductView(); window.ShowDialog(); // Далее управление передается в ProductViewModel, // а по возвращении мы проверяем успешность выполнения if (window.DialogResult.Value) { // Если выполнение прошло гладко, обновляем Products OnPropertyChanged(nameof(Products)); } }
public ActionResult AddProduct(AddProductView newProduct) { var user = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name); if (ModelState.IsValid) { var orderDetailTmp = db.OrderDetailTmps.FirstOrDefault(odt => odt.UserName == User.Identity.Name && odt.ProductId == newProduct.ProductId); if (orderDetailTmp == null) { var product = db.Products.Find(newProduct.ProductId); orderDetailTmp = new OrderDetailTmp { Description = product.Description, Price = product.Price, ProductId = product.ProductId, Quantity = newProduct.Quantity, TaxRate = product.Tax.Rate, UserName = User.Identity.Name, }; db.OrderDetailTmps.Add(orderDetailTmp); } else { orderDetailTmp.Quantity += newProduct.Quantity; db.Entry(orderDetailTmp).State = EntityState.Modified; } var responseSave = DBHelper.SaveChanges(db); if (responseSave.Succeeded) { return(RedirectToAction("Create")); } ModelState.AddModelError(string.Empty, responseSave.Message); } var adminUser = WebConfigurationManager.AppSettings["AdminUser"]; if (adminUser == User.Identity.Name) { ViewBag.ProductId = new SelectList(CombosHelper.GetProducts(), "ProductId", "Description"); } else { ViewBag.ProductId = new SelectList(CombosHelper.GetProducts(user.CompanyId), "ProductId", "Description"); } return(PartialView(newProduct)); }
private void EditProductCommandExecuted(ProductModel productModel) { RaisePropertyChanged("DisableParentWindow"); SelectedProduct = productModel; var view = new AddProductView(productModel); view.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (view.DialogResult != null && view.DialogResult == true) { _reportsDataUnit.ProductsRepository.Refresh(); _eventsDataUnit.ProductsRepository.Refresh(); } }
public void AddProduct(AddProductView newProduct) { using (var db = new sdirecttestdbEntities1()) { db.spAddProduct_Sk(newProduct.ProductCategoryId, newProduct.ProductName, newProduct.Description, newProduct.Brand, this.ImageToByteArray(newProduct.Image), newProduct.SellerFullName, newProduct.SellerFullName, newProduct.PricePerUnit, newProduct.ProductCount, newProduct.SellerId ); db.SaveChanges(); } }
public ActionResult AddProduct(AddProductView view) { var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); if (ModelState.IsValid) { var OrderDetailTmp = db.OrderDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.ProductId == view.ProductId).FirstOrDefault(); if (OrderDetailTmp == null) { var product = db.Products.Find(view.ProductId); OrderDetailTmp = new OrderDetailTmp { Description = product.Description, Price = product.Price, ProductId = product.ProductId, Quantity = view.Quantity, TaxRate = product.Tax.Rate, UserName = User.Identity.Name, }; db.OrderDetailTmps.Add(OrderDetailTmp); } else { OrderDetailTmp.Quantity += view.Quantity; db.Entry(OrderDetailTmp).State = EntityState.Modified; } try { db.SaveChanges(); return(RedirectToAction("Create")); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); } } ViewBag.ProductId = new SelectList(CombosHelper.GetProducts(user.CompanyId), "ProductId", "Description"); return(PartialView()); }
public JsonResult AddProduct(AddProductView view) { if (ModelState.IsValid) { var orderDetailBk = db.OrderDetailBkps.Where(odb => odb.User == User.Identity.Name && odb.ProductId == view.ProductId).FirstOrDefault(); var bodega = db.CellarProducts.Where(cp => cp.ProductId == view.ProductId).FirstOrDefault(); if (orderDetailBk == null) { var product = db.Products.Find(view.ProductId); orderDetailBk = new OrderDetailBk { User = User.Identity.Name, Description = product.Description, Price = product.Price, ProductId = product.ProductId, Quantity = view.Quantity }; if (bodega.Stock > view.Quantity) { db.OrderDetailBkps.Add(orderDetailBk); } } else { if (bodega.Stock > view.Quantity) { orderDetailBk.Quantity += view.Quantity; db.Entry(orderDetailBk).State = EntityState.Modified; } } db.SaveChanges(); } return(Json(view)); }
private void AddProductCommandExecuted() { RaisePropertyChanged("DisableParentWindow"); var addProductView = new AddProductView(); addProductView.ShowDialog(); if (addProductView.DialogResult != null && addProductView.DialogResult == true) { if (Content != null) { var viewModel = Content.DataContext as ProductsViewModel; if (viewModel != null) { viewModel.AllProducts.Add(addProductView.ViewModel.Product); viewModel.RefreshProducts(); viewModel.SelectedProduct = addProductView.ViewModel.Product; } } } RaisePropertyChanged("EnableParentWindow"); }
public ActionResult AddProduct(AddProductView view) { var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); if (ModelState.IsValid) { var purchaseDetailTmps = db.PurchaseDetailTmps.Where(odt => odt.UserName == User.Identity.Name && odt.ProductId == view.ProductId).FirstOrDefault(); if (purchaseDetailTmps == null) { var product = db.Products.Find(view.ProductId); purchaseDetailTmps = new PurchaseDetailTmp { Description = product.Description, Price = product.Price, ProductId = product.ProductId, Quantity = view.Quantity, TaxRate = product.Tax.Rate, UserName = User.Identity.Name, }; db.PurchaseDetailTmps.Add(purchaseDetailTmps); var products = db.Products.Find(view.ProductId); var inventories = new Inventory { ProductId = product.ProductId, WareHouseId = view.WareHouseId, Stock = 0 }; db.Inventories.Add(inventories); db.SaveChanges(); } else { purchaseDetailTmps.Quantity += view.Quantity; db.Entry(purchaseDetailTmps).State = EntityState.Modified; } var quantity = view.Quantity; var inventory = db.Inventories.Where(i => i.ProductId == view.ProductId).FirstOrDefault(); inventory.Stock += quantity; if (purchaseDetailTmps.Product.Stock <= 50) { db.SaveChanges(); return(RedirectToAction("Create")); } else { return(RedirectToAction("InventoryValidate")); } } ViewBag.ProductId = new SelectList(CombosHelper.GetProducts(user.CompanyId), "ProductId", "Description"); ViewBag.WareHouseId = new SelectList(CombosHelper.GetWareHouse(user.CompanyId, true), "WareHouseId", "Name"); return(PartialView()); }
public AddProductViewModel(AddProductView addOpen) { addView = addOpen; Product = new tblProduct(); ProductList = service.GetAllProducts().ToList(); }
public AddProductViewModel(AddProductView addProductView) { this.addProductView = addProductView; Product = new vwProduct(); }
public AddProductViewModel(AddProductView addOpen, tblProduct editProduct) { addView = addOpen; Product = editProduct; ProductList = service.GetAllProducts().ToList(); }
public AddProductViewModel(AddProductView view) { apv = view; product = new Product(); }
public void AddProduct(AddProductView newProduct) { DAL_iNewProduct.AddProduct(newProduct); }