private void btnRemove_Click(object sender, EventArgs e) { OrderLinesTable orderLine = (OrderLinesTable)dgvList.SelectedRows[0].DataBoundItem; ProductsTable product = OrderingRepository.getInstance.GetProducts().First(c => c.Id == orderLine.ProductID); if (nudRemoveQuantity.Value == nudRemoveQuantity.Maximum) { orderList.Remove(orderLine); } else { orderLine.QuantityOrdered -= (int)nudRemoveQuantity.Value; orderLine.TotalForItem -= (double)nudRemoveQuantity.Value * product.Price; } //orderList.Remove(orderLine); RefreshOrderList(); nudRemoveQuantity.Maximum = orderLine.QuantityOrdered; nudRemoveQuantity.Value = nudRemoveQuantity.Maximum; btnRemove.Text = "Remove All"; float total = 0; foreach (var item in orderList) { total += (float)item.TotalForItem; } lblTotal.Text = total.ToString(); }
public ActionResult Edit(ProductsTable input, HttpPostedFileBase Photo) { if (Session["role"] == null || (int)Session["role"] < Editor) { return(Redirect("/CMS/Product")); } input.Image = null; if (Photo != null) { ProductsTable produkt = pf.Get(input.ID); if (produkt.Image != null) { string imagePath = Request.PhysicalApplicationPath + "/Images/Products/" + produkt.Image; if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } string newImagePath = Request.PhysicalApplicationPath + "/Images/Products/"; input.Image = ft.UploadFile(Photo, newImagePath); } pf.Update(input); return(Redirect("/CMS/Product")); }
public IHttpActionResult PutProductsTable(int id, ProductsTable productsTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != productsTable.Pid) { return(BadRequest()); } db.Entry(productsTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductsTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostProductsTable(ProductsTable productsTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ProductsTables.Add(productsTable); try { db.SaveChanges(); } catch (DbUpdateException) { if (ProductsTableExists(productsTable.Pid)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = productsTable.Pid }, productsTable)); }
public ActionResult Delete(int ID) { if (Session["role"] == null || (int)Session["role"] < Editor) { return(Redirect("/CMS/Product")); } ProductsTable produkt = pf.Get(ID); if (produkt.Image != null) { string imagePath = Request.PhysicalApplicationPath + "/Images/Products/" + produkt.Image; if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } pf.Delete(ID); return(Redirect("/CMS/Product")); }
public ProductCategory GetProductCategory(string code) { ProductCategory result = null; var batch = new BatchSql(); batch.Append(CategoriesTable.Select().Where(CategoriesTable.ColumnsQualified.Code, code)); batch.Append(ProductsTable.Select().Add("\r\nWHERE SKU in (SELECT SKU FROM Categories_Products WHERE Categories_Products.CategoryCode=@p0)")); var cmd = batch.BuildCommand(connectionStringName); using (var rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { if (rdr.Read()) { result = LoadProductCategory(rdr); if (result != null) { result.Products = new List <Product>(); if (rdr.NextResult()) { while (rdr.Read()) { result.Products.Add(LoadProduct(rdr)); } } } } } return(result); }
public ActionResult DeleteConfirmed(int id) { ProductsTable productsTable = db.ProductsTables.Find(id); db.ProductsTables.Remove(productsTable); db.SaveChanges(); return(RedirectToAction("Index")); }
private void init_params() { ProductGroup.DataSource = new ProductsBLL().getCustomerGroups(); ProductGroup.DataBind(); ProductsTable.DataSource = new ProductsBLL().getCustomerProducts(); ProductsTable.DataBind(); }
private void btnAdd_Click(object sender, EventArgs e) { ProductsTable newProduct = new ProductsTable(); EditProduct form = new EditProduct(newProduct, true); form.Show(); form.FormClosed += EditProduct_FormClosed; }
private void addProductToolStripMenuItem_Click(object sender, EventArgs e) { //EditProduct form = new EditProduct(); //form.Show(); ProductsTable newProduct = new ProductsTable(); EditProduct form = new EditProduct(newProduct, true); form.Show(); }
public IHttpActionResult GetProductsTable(int id) { ProductsTable productsTable = db.ProductsTables.Find(id); if (productsTable == null) { return(NotFound()); } return(Ok(productsTable)); }
private void btnEdit_Click(object sender, EventArgs e) { if (dgvAllProducts.SelectedRows.Count > 0) { //grab selected object ProductsTable currentProduct = (ProductsTable)dgvAllProducts.SelectedRows[0].DataBoundItem; //provided parameters will open an edit form for teacher //last parameter which is boolean is responsible for opening adding or editing form EditProduct editForm = new EditProduct(currentProduct, false); editForm.Show(); } }
private void btnAddList_Click(object sender, EventArgs e) { if (dgvAllProducts.SelectedRows.Count == 1) { ProductsTable product = (ProductsTable)dgvAllProducts.SelectedRows[0].DataBoundItem; OrderLinesTable line = new OrderLinesTable(); line.OrdersTable = _order; line.ProductsTable = product; line.ProductID = product.Id; line.QuantityOrdered = (int)nudQuantity.Value; line.SellingPrice = product.Price; line.TotalForItem = product.Price * (int)nudQuantity.Value; bool itemFound = false; if (orderList.Count > 0) { foreach (var item in orderList) { if (item.ProductID == product.Id) { //if there is id of product adding to the list is already in the list //quantity and total values are changed instead of adding the same product twice to the datagridview itemFound = true; item.QuantityOrdered += line.QuantityOrdered; item.TotalForItem += line.QuantityOrdered * product.Price; } } } if (itemFound == false) { orderList.Add(line); } RefreshOrderList(); nudQuantity.Value = 1; float total = 0; foreach (var item in orderList) { total += (float)item.TotalForItem; } lblTotal.Text = total.ToString(); } else { MessageBox.Show("Select product to add!"); } }
// GET: Products/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductsTable productsTable = db.ProductsTables.Find(id); if (productsTable == null) { return(HttpNotFound()); } return(View(productsTable)); }
public IHttpActionResult DeleteProductsTable(int id) { ProductsTable productsTable = db.ProductsTables.Find(id); if (productsTable == null) { return(NotFound()); } db.ProductsTables.Remove(productsTable); db.SaveChanges(); return(Ok(productsTable)); }
public ActionResult Edit([Bind(Include = "ProductID,ProductTypeID,TopID,BottomID,ShoeID,AccesoryID,PhotoLink")] ProductsTable productsTable) { if (ModelState.IsValid) { db.Entry(productsTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AccesoryID = new SelectList(db.AccessoriesTables, "AccessoryID", "Name", productsTable.AccesoryID); ViewBag.BottomID = new SelectList(db.BottomsTables, "BottomID", "Name", productsTable.BottomID); ViewBag.ProductTypeID = new SelectList(db.ProductTypeTables, "ProductTypeID", "ProductType", productsTable.ProductTypeID); ViewBag.ShoeID = new SelectList(db.ShoesTables, "ShoeID", "Name", productsTable.ShoeID); ViewBag.TopID = new SelectList(db.TopsTables, "TopID", "Name", productsTable.TopID); return(View(productsTable)); }
public IList <Product> GetProducts() { var sql = ProductsTable.Select(); var cmd = sql.BuildCommand(); List <Product> result = new List <Product>(); using (var rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { while (rdr.Read()) { result.Add(LoadProduct(rdr)); } } return(result); }
public IList <Product> GetProductsForCategory(string categoryCode) { var sql = ProductsTable.Select().Where(ProductsTable.ColumnsQualified.DateAvailable, Op.GreaterThan, DateTime.Now.AddDays(-7)); var cmd = sql.BuildCommand(); List <Product> result = new List <Product>(); using (var rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { while (rdr.Read()) { result.Add(LoadProduct(rdr)); } } return(result); }
public ActionResult FileUpload(ProductsTable model,HttpPostedFileBase file) { if (file!= null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Areas/cafeBlue/Images/"), fileName); file.SaveAs(path); } if(file != null) model.ProductImage = System.IO.Path.GetFileName(file.FileName); ProductModel pmodel = new ProductModel(); pmodel.newProduct(model); return RedirectToAction("Index",model.ProductCatigory); }
// GET: Products/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductsTable productsTable = db.ProductsTables.Find(id); if (productsTable == null) { return(HttpNotFound()); } ViewBag.AccesoryID = new SelectList(db.AccessoriesTables, "AccessoryID", "Name", productsTable.AccesoryID); ViewBag.BottomID = new SelectList(db.BottomsTables, "BottomID", "Name", productsTable.BottomID); ViewBag.ProductTypeID = new SelectList(db.ProductTypeTables, "ProductTypeID", "ProductType", productsTable.ProductTypeID); ViewBag.ShoeID = new SelectList(db.ShoesTables, "ShoeID", "Name", productsTable.ShoeID); ViewBag.TopID = new SelectList(db.TopsTables, "TopID", "Name", productsTable.TopID); return(View(productsTable)); }
internal Product LoadProduct(DbDataReader rdr) { return(new Product( ProductsTable.ReadSKU(rdr), ProductsTable.ReadProductName(rdr), ProductsTable.ReadBlurb(rdr), ProductsTable.ReadIsTaxable(rdr), ProductsTable.ReadWeightInPounds(rdr), ProductsTable.ReadAmountOnHand(rdr), ProductsTable.ReadDateAvailable(rdr), ProductsTable.ReadAllowBackOrder(rdr), ProductsTable.ReadAllowPreOrder(rdr)) { DefaultImage = new Image( ProductsTable.ReadDefaultImageFile(rdr), ProductsTable.ReadDefaultImageFile(rdr)), EstimatedDelivery = ProductsTable.ReadEstimatedDelivery(rdr), Price = ProductsTable.ReadBasePrice(rdr) }); }
public ActionResult AddNew(ProductsTable input, HttpPostedFileBase Photo) { if (Session["role"] == null || (int)Session["role"] < Editor) { return(Redirect("/CMS")); } input.Image = null; if (Photo != null) { string imagePath = Request.PhysicalApplicationPath + "/Images/Products/"; input.Image = ft.UploadFile(Photo, imagePath); } pf.Insert(input); return(Redirect("/CMS/Product")); }
public TestEnvironmentObject(TestEnvironmentCreateContext createContext, ITestMocks mocks) { _productsTable = createContext.Products; ElementInfos = new TestDbObjectList <string, ElementInfo>( k => { var p = Products.Get(k); return(new ElementInfo(p.Info, ItemId.New(), 1)); }); //Prices = new Dictionary<string, ElementPrice>(); SalesOrderEntities = createContext.Documents.SalesOrderEntities; DocumentFactories = new DocumentFactoryProvider(this); Products = new ProductsProvider(createContext.Products); Mocks = mocks; }
public static bool DeleteProduct(string productname) { try { using (productEntities db = new productEntities()) { ProductsTable Product = db.ProductsTables.FirstOrDefault(a => a.ProductName == productname); if (Product == null) { return(false); } db.ProductsTables.Remove(Product); db.SaveChanges(); return(true); } } catch { return(false); } }
public EditProduct(ProductsTable prod, bool New) { InitializeComponent(); MdiParent = Application.OpenForms["OrderManagement"]; isNew = New; _product = prod; //set form text if (isNew) { this.Text = "New Product"; } else { this.Text = "Edit Product"; } if (!isNew) { ShowDataInForm(); } }
public static Product GetOneProduct(string productname) { try { using (productEntities db = new productEntities()) { ProductsTable Product = db.ProductsTables.FirstOrDefault(a => a.ProductName == productname); if (Product == null) { return(null); } else { return(new Product { ProductName = Product.ProductName, ProductPrice = Product.ProductPrice }); } } } catch { return(null); } }
protected void ProductGroup_ItemCommand(object source, RepeaterCommandEventArgs e) { ProductsTable.DataSource = new ProductsBLL().getCustomerProducts(((LinkButton)e.CommandSource).Text); ProductsTable.DataBind(); }
public TestEnvironmentCreateContext(ProductsTable productsTable, DiscountStructureTable discountStructureTable, DocumentsTable documentsTable) { Products = productsTable; DiscountStructure = discountStructureTable; Documents = documentsTable; }
public void newCold(ProductsTable newproduct) { add_Product(newproduct); }
public ColdModel(ProductsTable product) { edit_Product(product); ProductList = getAll_ColdBeverage(); }
public ProductsProvider(ProductsTable productsTable) { _productsTable = productsTable; }
public JsonResult UpdateProduct(ProductsTable data) { new ProductModel().editProduct(data); return Json(null); }
public Product GetProduct(string sku) { Product result = null; var batch = new BatchSql(); batch.Append(ProductsTable.Select().Where(ProductsTable.ColumnsQualified.SKU, sku)); //desciptors batch.Append(ProductDescriptorsTable.Select() .Where(ProductDescriptorsTable.ColumnsQualified.SKU, sku) .And(ProductDescriptorsTable.ColumnsQualified.LanguageCode, System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName)); //images batch.Append(ProductImagesTable.Select().Where(ProductImagesTable.ColumnsQualified.SKU, sku)); //cross sells batch.Append(ProductsTable.Select().Add("\r\nWHERE sku in (SELECT CrossSku FROM Products_CrossSell WHERE Products_CrossSell.SKU=@p0)")); //TODO: Fix this //related batch.Append(ProductsTable.Select().Add("\r\nWHERE sku in (SELECT RelatedSKu FROM Products_Related WHERE Products_Related.SKU=@p0)")); var cmd = batch.BuildCommand(connectionStringName); using (var rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)){ if (rdr.Read()) { result = LoadProduct(rdr); } if (result != null) { //desciptors result.Descriptors = new List <ProductDescriptor>(); if (rdr.NextResult()) { while (rdr.Read()) { result.Descriptors.Add(new ProductDescriptor( ProductDescriptorsTable.ReadTitle(rdr), ProductDescriptorsTable.ReadBody(rdr) )); } } //images result.Images = new List <Image>(); if (rdr.NextResult()) { while (rdr.Read()) { result.Images.Add(new Image( ProductImagesTable.ReadThumbUrl(rdr), ProductImagesTable.ReadFullImageUrl(rdr))); } } //cross sells result.CrossSells = new List <Product>(); if (rdr.NextResult()) { while (rdr.Read()) { result.CrossSells.Add(LoadProduct(rdr)); } } //related result.RelatedProducts = new List <Product>(); if (rdr.NextResult()) { while (rdr.Read()) { result.RelatedProducts.Add(LoadProduct(rdr)); } } } } return(result); }
/// <summary> /// edit product /// </summary> /// <param name="editproduct"></param> public void editProduct(ProductsTable editproduct) { edit_Product(editproduct); }
public BundleInfoAssembler(ProductsTable products) { _products = products; _bundleInfo = new BundleInfo(new List <ProductDiscount>()); }
public HotMeal(ProductsTable edit_product) { }