// Them gio hang public ActionResult addShoppingCart(int iMaSP, string strUrl, int txtSoLuong) { ProductTable product = db.ProductTables.SingleOrDefault(n => n.Watch_ID == iMaSP); if (txtSoLuong <= 0 || txtSoLuong.ToString().Trim().Equals(null)) { txtSoLuong = 1; } if (product == null) { Response.StatusCode = 404; return(null); } // Lấy ra session giỏ hàng List <ShoppingCart> lstCart = GetShoppingCart(); // Kiểm tra sản phẩm này đã tồn tại trong session[giohang] chưa ShoppingCart sp = lstCart.Find(n => n.iMaSP == iMaSP); if (sp == null) { sp = new ShoppingCart(iMaSP); sp.soLuong = txtSoLuong; lstCart.Add(sp); return(Redirect(strUrl)); } else { sp.soLuong = sp.soLuong + txtSoLuong; return(Redirect(strUrl)); } }
public void TestEdit_Product_fail() { var helper = new MockHelper(); var context = helper.MakeFakeContext(); // var controller = new Controllers.ProductManagerController(); var controller = new ProductManagerController(); controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller); var serverMock = new Mock <HttpServerUtilityBase>(); serverMock.Setup(x => x.MapPath("~/App_Data")).Returns(@"D:\Anh_Quoc\K\Năm 2\SOFTWARE TESTING\Team Project\Final project team\Code\FinalProj\ClockUniverse\ClockUniverse\App_Data"); context.Setup(x => x.Server).Returns(serverMock.Object); // var file1Mock = new Mock<HttpPostedFileBase>(); // file1Mock.Setup(x => x.FileName).Returns("30_0"); var Producttable = new ProductTable { Watch_ID = 1089, Watch_Name = "KhacHuy", Watch_Description = "dsadasdal", WatchType_ID = 1, //Original_Price = 1000, //Selling_Price = 100, InStock = 1, Watch_Static = "cc", }; var actual = controller.Edit(Producttable) as RedirectToRouteResult; Assert.IsNull(actual); }
public void LoadEditContent() { ComboBoxUnitQty.ItemsSource = CatalogTable.SelectFromCatalogTable(); ComboBoxUnitQty.DisplayMemberPath = "CatalogValue"; ComboBoxUnitQty.SelectedValuePath = "CatalogId"; var product = ProductTable.SelectSingleProduct(Pid); TxtTitle.Text = product.ProductName; TxtPrice.Text = product.ProductUnitPrice.ToString(); TxtQty.Text = product.ProductCount.ToString(); TxtDescription.Text = string.Empty; TxtDescription.AppendText(product.ProductDescription); var ppl = product.ProductPopularSupport; if (ppl) { YesToPpl.IsChecked = true; } else { NoToPpl.IsChecked = true; } if (product.Catalog != null) { ComboBoxUnitQty.SelectedValue = product.Catalog.CatalogId; } }
public ActionResult AddProduct(ProductTable PD) { ProductDatabaseEntities db = new ProductDatabaseEntities(); ProductTable pt = new ProductTable(); pt.ProductName = PD.ProductName; pt.Price = PD.Price; pt.Brand = PD.Brand; pt.Type = PD.Type; pt.Details = PD.Details; //pt.ImageData = PD.ImageData; //byte[] data = new byte[pt.File.ContentLength]; byte[] data = new byte[PD.File.ContentLength]; PD.File.InputStream.Read(data, 0, PD.File.ContentLength); pt.ImageData = data; using (ProductDatabaseEntities dc = new ProductDatabaseEntities()) { dc.ProductTables.Add(pt); dc.SaveChanges(); @ViewBag.Success = "Seccessfully Added!"; } return(RedirectToAction("AddProduct")); }
public bool DeleteProduct(int id) // ProductTable Methods { try { var deleteproduct = (from allproducts in ProductTable where allproducts.Pid == id select allproducts).First(); if (deleteproduct != null) { ProductTable.Remove(deleteproduct); SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
public override void ViewDidLoad() { base.ViewDidLoad(); // Create the Product Table Data Source and populate it var DataSource = new ProductTableDataSource(); DataSource.Products.Add(new Product("Xamarin.iOS", "Allows you to develop native iOS Applications in C#")); DataSource.Products.Add(new Product("Xamarin.Android", "Allows you to develop native Android Applications in C#")); DataSource.Products.Add(new Product("Xamarin.Mac", "Allows you to develop Mac native Applications in C#")); DataSource.Products.Add(new Product("Xamarin.tvOS", "Allows you to develop Apple TV native Applications in C#")); DataSource.Products.Add(new Product("Xamarin Studio Community", "A free, full-featured IDE for Mac users to create Android and iOS apps using Xamarin.")); DataSource.Products.Add(new Product("Visual Studio Community", "A free, full-featured and extensible IDE for Windows users to create Android and iOS apps with Xamarin, as well as Windows apps, web apps, and cloud services.")); DataSource.Products.Add(new Product("Visual Studio Professional", "Professional developer tools and services for individual developers or small teams.")); DataSource.Products.Add(new Product("Visual Studio Enterprise", "End-to-end solution for teams of any size with demanding quality and scale needs")); DataSource.Products.Add(new Product("Xamarin Test Cloud", "Automatically test your app on thousands of mobile devices.")); DataSource.Products.Add(new Product("HockyApp", "Bring Mobile DevOps to your apps and reliability to your users.")); DataSource.Products.Add(new Product("Xamarin University", "Take your mobile strategy and apps to the next level.")); DataSource.Sort("Title", true); // Populate the Product Table ProductTable.DataSource = DataSource; ProductTable.Delegate = new ProductTableDelegate(this, DataSource); // Auto select the first row ProductTable.SelectRow(0, false); }
public ActionResult Filter(ProductTable pd) { capacity = pd.ProductCapacityRange; budget = pd.ProductPriceRange; GetProductAsLoc(Session["Category"].ToString(), "Pune"); return(View("Recommendation")); }
private void addToCart(int pId) { // check if product is valid ProductTable product = Database.Products.FirstOrDefault(p => p.Id == pId); if (product != null && product.UnitsInStock > 0) { // check if product already existed ShoppingCartTable cart = Database.ShoppingCartDatas.FirstOrDefault(c => c.PID == pId); if (cart != null) { cart.Quantity++; } else { cart = new ShoppingCartTable { PName = product.ProductName, PID = product.Id, UnitPrice = (decimal)product.UnitPrice, Quantity = 1 }; Database.ShoppingCartDatas.Add(cart); } Database.SaveChanges(); } }
public ActionResult Edit(ProductTable producttable) { ValidateClock(producttable); if (ModelState.IsValid) { using (var scope = new TransactionScope()) { // add model to database db.Entry(producttable).State = EntityState.Modified; db.SaveChanges(); // save file to app_data var path = Server.MapPath("~/App_Data"); path = System.IO.Path.Combine(path, producttable.Watch_ID.ToString()); if (Request.Files["Image"].ContentLength != 0) { Request.Files["Image"].SaveAs(path + "_0"); } if (Request.Files["Image1"].ContentLength != 0) { Request.Files["Image1"].SaveAs(path + "_1"); } if (Request.Files["Image2"].ContentLength != 0) { Request.Files["Image2"].SaveAs(path + "_2"); } // all done successfully scope.Complete(); return(RedirectToAction("Index")); } } ViewBag.WatchType_ID = new SelectList(db.ProductTypes, "ProductType_ID", "ProductType_Name", producttable.WatchType_ID); return(View("Edit", producttable)); }
protected void RefreshGrid(ref DataGrid reportGrid) { Config config = Config.getConfig(menu.pathFolderName + "config.json"); ProductTable table = new ProductTable(false, false); if (menu.configInvent.version == 2) { table = new ProductTable(false, true); } else if (menu.configInvent.version == 3) { table = new ProductTable(true, false); } Sync sync = new Sync(config.url, menu.idClient, menu.pathFolderName); //sync.UpdatedDataBase(menu.rrfid.m_TagTable, menu.products.items); foreach (UpcInventory item in menu.rrfid.fillUPCsInventory(menu.products)) { if (menu.configInvent.version == 2) { table.addRow(item.upc, item.name, getNameWarehouse(item.place_id, menu.warehouses.collection)); } else if (menu.configInvent.version == 3) { table.addRow(item.upc, item.name, item.total); } } dataView = new DataView(table); reportGrid.DataSource = dataView; reportGrid.TableStyles.Clear(); reportGrid.TableStyles.Add(table.getStyle()); }
public ActionResult Create([Bind(Include = "Watch_ID,Watch_Name,Watch_Description,Watch_Static,WatchType_ID,Original_Price,Selling_Price,InStock")] ProductTable producttable) { ValidateClock(producttable); if (ModelState.IsValid) { using (var scope = new TransactionScope()) { // add model to database db.ProductTables.Add(producttable); db.SaveChanges(); // save file to app_data var path = Server.MapPath("~/App_Data"); path = System.IO.Path.Combine(path, producttable.Watch_ID.ToString()); Request.Files["Image"].SaveAs(path + "_0"); Request.Files["Image1"].SaveAs(path + "_1"); Request.Files["Image2"].SaveAs(path + "_2"); // all done successfully scope.Complete(); return(RedirectToAction("Index")); } } ViewBag.WatchType_ID = new SelectList(db.ProductTypes, "ProductType_ID", "ProductType_Name", producttable.WatchType_ID); return(View("Create", producttable)); }
private void ValidateClock(ProductTable model) { if (model.Original_Price == 0) { ModelState.AddModelError("Original_Price", Resource1.priceLess0); } }
public ActionResult Products_Destroy([DataSourceRequest] DataSourceRequest request, ProductTable productTable) { if (ModelState.IsValid) { using (var db = new _DatabseContextShop()) { var entity = new ProductTable { Id = productTable.Id, ProductName = productTable.ProductName, Description = productTable.Description, UnitPrice = productTable.UnitPrice, UnitsInStock = productTable.UnitsInStock, UnitsOnOrder = productTable.UnitsOnOrder, Discontinued = productTable.Discontinued, LastSupply = productTable.LastSupply }; db.Products.Attach(entity); db.Products.Remove(entity); db.SaveChanges(); } } return(Json(new[] { productTable }.ToDataSourceResult(request, ModelState))); }
public Item(ProductTable product) { this.ID = product.ProductID; this.Name = product.ProductName; this.Price = Convert.ToDouble(product.ProductCost); this.Quantity = product.Quantity; }
public IQueryable <ComboBoxResult> GetJobOrderHelpListForProduct(int filter, string term) { int CurrentSiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; int CurrentDivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; var list = (from p in _unitOfWork.Repository <ViewJobOrderBalance>().Instance join t in _unitOfWork.Repository <JobOrderHeader>().Instance on p.JobOrderHeaderId equals t.JobOrderHeaderId join t2 in _unitOfWork.Repository <JobOrderLine>().Instance on p.JobOrderLineId equals t2.JobOrderLineId join pt in _unitOfWork.Repository <Product>().Instance on p.ProductId equals pt.ProductId into ProductTable from ProductTab in ProductTable.DefaultIfEmpty() join D1 in _unitOfWork.Repository <Dimension1>().Instance on p.Dimension1Id equals D1.Dimension1Id into Dimension1Table from Dimension1Tab in Dimension1Table.DefaultIfEmpty() join D2 in _unitOfWork.Repository <Dimension2>().Instance on p.Dimension2Id equals D2.Dimension2Id into Dimension2Table from Dimension2Tab in Dimension2Table.DefaultIfEmpty() where p.BalanceQty > 0 && (string.IsNullOrEmpty(term) ? 1 == 1 : p.JobOrderNo.ToLower().Contains(term.ToLower()) || string.IsNullOrEmpty(term) ? 1 == 1 : Dimension1Tab.Dimension1Name.ToLower().Contains(term.ToLower()) || string.IsNullOrEmpty(term) ? 1 == 1 : Dimension2Tab.Dimension2Name.ToLower().Contains(term.ToLower())) && p.SiteId == CurrentSiteId && p.DivisionId == CurrentDivisionId orderby t.DocDate, t.DocNo select new ComboBoxResult { text = t.DocType.DocumentTypeName + "-" + p.JobOrderNo, id = p.JobOrderLineId.ToString(), TextProp1 = "Product: " + ProductTab.ProductName.ToString(), TextProp2 = "Qty: " + p.BalanceQty.ToString(), AProp1 = Dimension1Tab.Dimension1Name, AProp2 = Dimension2Tab.Dimension2Name }); return(list); }
// Cap nhat gio hang public ActionResult UpdateShoppingCart(int iMaSP, FormCollection f, int txtSoLuong) { // Kiem tra ma san pham ProductTable product = db.ProductTables.SingleOrDefault(n => n.Watch_ID == iMaSP); // Neu lay sai ma san pham thi tra ve loi if (product == null) { Response.StatusCode = 404; return(null); } // lay gio hang ra tu session List <ShoppingCart> lstCart = GetShoppingCart(); // Kiem tra san pham co ton tai tron session ShoppingCart sp = lstCart.SingleOrDefault(n => n.iMaSP == iMaSP); // Neu ton tai thi cho sua so luong if (sp != null) { if (product.InStock - txtSoLuong + sp.soLuong <= 0) { ModelState.AddModelError("InStock", Resource1.OverInStock); } else { sp.soLuong = txtSoLuong; } } return(RedirectToAction("ShoppingCart")); }
private ITablesProvider InitMockedDb() { CategoryTable categoryTable = new CategoryTable(); CurrencyTable currencyTable = new CurrencyTable(); PersonTable personTable = new PersonTable(); BidTable bidTable = new BidTable(); PersonBidderTable personBidderTable = new PersonBidderTable(bidTable); AuctionsTable auctionsTable = new AuctionsTable(); ProductTable productTable = new ProductTable(); PersonMarkTable personMarkTable = new PersonMarkTable(); PersonOfferorTable personOfferorTable = new PersonOfferorTable(); Mock <ITablesProvider> mock = new Mock <ITablesProvider>(); mock.Setup(x => x.GetCategoryTable()).Returns(categoryTable); mock.Setup(x => x.GetCurrencyTable()).Returns(currencyTable); mock.Setup(x => x.GetPersonTable()).Returns(personTable); mock.Setup(x => x.GetBidTable()).Returns(bidTable); mock.Setup(x => x.GetPersonBidderTable()).Returns(personBidderTable); mock.Setup(x => x.GetAuctionTable()).Returns(auctionsTable); mock.Setup(x => x.GetProductTable()).Returns(productTable); mock.Setup(x => x.GetPersonMarkTable()).Returns(personMarkTable); mock.Setup(x => x.GetPersonOfferorTable()).Returns(personOfferorTable); return(mock.Object); }
public bool AddProduct() // ProductTable Methods { try { Product newproduct = new Product(); newproduct.Itemname = HttpContext.Current.Session["add_pname"].ToString(); newproduct.Itemfor = HttpContext.Current.Session["add_pfor"].ToString(); newproduct.Category = HttpContext.Current.Session["add_category"].ToString(); newproduct.Sizes = HttpContext.Current.Session["add_sizes"].ToString(); newproduct.Available = Convert.ToInt32(HttpContext.Current.Session["add_available"].ToString()); newproduct.Price = Convert.ToInt32(HttpContext.Current.Session["add_price"].ToString()); newproduct.Currency = HttpContext.Current.Session["add_currency"].ToString(); newproduct.Cost = Convert.ToInt32(HttpContext.Current.Session["add_cost"].ToString()); newproduct.Offer = Convert.ToInt32(HttpContext.Current.Session["add_offer"].ToString()); ProductTable.Add(newproduct); SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
private void ShowAllProducts() { ProductTable.Clear(); var crops = GetProductRepo().GetAllProducts(); BuildTable(crops); }
private async Task OnConfirm() { _confirm = true; await Modal.Toggle(); await ProductTable.QueryAsync(); }
private void AddUpdateProduct(object parameter) { if (SelectedProduct == null) { AddProduct(parameter); } else { UpdateProduct(parameter); SelectedProduct = null; } if (ShowingAll) { ShowAllProducts(); } else { ShowProductsInStock(); } Name = CategoryName; Id = 0; Quantity = CategoryId = 0; ProductTable.Clear(); ShowProductsInStock(); HideForm(); }
public override List <ProductTable> SetProductData() { var excelFile = new ExcelQueryFactory(@"C:\Build school\HomeWork_2\Sales_Performance\bin\Debug\Sales.xlsx"); var excel = excelFile.Worksheet <Class3>("工作表2"); List <ProductTable> list = new List <ProductTable>(); List <int> ls = new List <int>() { 33 + 77 + 43, 32 + 33 + 55, 56 + 68 + 43, 45 + 45 + 67, 33 + 23 + 65 }; int i = 0; foreach (var items in excel) { var restaurant = new ProductTable { Product = items.產品, Price = int.Parse(items.價格), Total_sales = int.Parse(items.價格) * (ls[i]) }; list.Add(restaurant); i++; } return(list); }
// Xoa gio hang public ActionResult DeleteShoppingCart(int iMaSP) { // Kiem tra ma san pham ProductTable product = db.ProductTables.SingleOrDefault(n => n.Watch_ID == iMaSP); // Neu lay sai ma san pham thi tra ve loi if (product == null) { Response.StatusCode = 404; return(null); } // lay gio hang ra tu session List <ShoppingCart> lstCart = GetShoppingCart(); // Kiem tra san pham co ton tai tron session ShoppingCart sp = lstCart.SingleOrDefault(n => n.iMaSP == iMaSP); // Neu ton tai thi cho sua so luong if (sp != null) { lstCart.RemoveAll(n => n.iMaSP == iMaSP); } if (lstCart.Count == 0) { return(RedirectToAction("Index", "Home")); } return(RedirectToAction("ShoppingCart")); }
public ProductUidDetail FGetProductUidDetail(string ProductUidNo) { ProductUidDetail UidDetail = (from Pu in _productRepository.Instance join P in _unitOfWork.Repository <Product>().Instance on Pu.ProductId equals P.ProductId into ProductTable from Producttab in ProductTable.DefaultIfEmpty() join Pr in _unitOfWork.Repository <Process>().Instance on Pu.CurrenctProcessId equals Pr.ProcessId into ProcessTable from ProcessTab in ProcessTable.DefaultIfEmpty() join Pe in _unitOfWork.Repository <Person>().Instance on Pu.LastTransactionPersonId equals Pe.PersonID into PersonTable from PersonTab in PersonTable.DefaultIfEmpty() where Pu.ProductUidName == ProductUidNo select new ProductUidDetail { ProductUidId = Pu.ProductUIDId, ProductId = Pu.ProductId, ProductName = Producttab.ProductName, PrevProcessId = Pu.CurrenctProcessId, PrevProcessName = ProcessTab.ProcessName, LastTransactionDocNo = Pu.LastTransactionDocNo, LastTransactionDocDate = Pu.LastTransactionDocDate, LastTransactionPersonName = PersonTab.Name, CurrenctGodownId = Pu.CurrenctGodownId, Status = Pu.Status, GenDocTypeId = Pu.GenDocTypeId, DivisionId = Producttab.DivisionId }).FirstOrDefault(); return(UidDetail); }
public ActionResult Create(Order order) { if (ModelState.IsValid) { List <ShoppingCart> cart = GetShoppingCart(); order.Order_Date = DateTime.Now; order.Delivery_Date = DateTime.Now.AddDays(3); order.Deliver_Status = 1; db.Orders.Add(order); foreach (var item in cart) { Order_Detail order_Detail = new Order_Detail(); order_Detail.Order_ID = order.Order_ID; order_Detail.Watch_ID = item.iMaSP; order_Detail.Amount = (int)item.soLuong; order_Detail.Price = Convert.ToDecimal(item.thanhTien); db.Order_Detail.Add(order_Detail); order.Total_Price += Convert.ToDecimal(item.thanhTien); db.Orders.Add(order); ProductTable product = db.ProductTables.Find(item.iMaSP); product.InStock = product.InStock - item.soLuong; db.Entry(product).State = EntityState.Modified; } Session["GioHang"] = null; db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View("~/Views/CheckOut/Index.cshtml")); }
public IHttpActionResult PostProductTable(ProductTable productTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ProductTables.Add(productTable); try { db.SaveChanges(); } catch (DbUpdateException) { if (ProductTableExists(productTable.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = productTable.Id }, productTable)); }
public IHttpActionResult PutProductTable(int id, ProductTable productTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != productTable.Id) { return(BadRequest()); } db.Entry(productTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
protected override async void OnAppearing() { ProductTable objProd = await App.LocalDatabase.GetDetailProductAsync(ProductCode); objProd.LongDesc = Regex.Replace(objProd.LongDesc, @"<(.|\n)*?>", string.Empty); BindingContext = objProd; }
private void BtnCreateDocument_Click(object sender, RoutedEventArgs e) { var documentWindow = new DocumentWindow(); documentWindow.ShowDialog(); _allProducts = ProductTable.SelectAllProducts(); FillRadGridView(null, null); }
private void BtnNewProduct_Click(object sender, RoutedEventArgs e) { var addWindow = new AddNewProducts(); addWindow.ShowDialog(); _allProducts = ProductTable.SelectAllProducts(); FillRadGridView(null, null); }