public ActionResult ProductDetail(PageFilterModel paging) { if (Session["PageFilterModel"] != null) { paging = (PageFilterModel)Session["PageFilterModel"]; } ProductDataContext db = new ProductDataContext(); List <ProductModel> lloProductModel = new List <ProductModel>(); try { int totalrecord = 0; var categoryobj = db.SP_SELECTProduct(paging.PageNo, paging.PageSize); foreach (var item in categoryobj) { totalrecord = item.TotalRow ?? 0; lloProductModel.Add(new ProductModel { ProductID = item.ProductId, ProductName = item.ProductName, CategoryID = item.CategoryId, CategoryName = item.CategoryName }); } int totalPages_pre = (totalrecord / 10); paging.totalpage = (totalrecord % 10) == 0 ? totalPages_pre : totalPages_pre + 1; paging.totalRecord = totalrecord; } catch (Exception) { throw; } ViewBag.paging = paging; return(View(lloProductModel)); }
public ActionResult Search(int id = 0) { ViewBag.CategoryID = id; List <Product> products = ProductDataContext.LoadProducts1(id); return(View(products)); }
public ActionResult Insert11(int id = 0) { ViewBag.CategoryID = id; List <Product> products = ProductDataContext.InsertProducts21(id); return(Json(products, JsonRequestBehavior.AllowGet)); }
public ActionResult Filter(int id = 0) { ViewBag.CategoryID = id; List <Product> Products = ProductDataContext.LoadProducts51(id); return(View(Products)); }
public ActionResult SaveCatagory(CategoryModel loCategoryModel) { try { // TODO: Add insert logic here ProductDataContext db = new ProductDataContext(); try { if (loCategoryModel.CategoryID > 0) { db.SP_UpdateCategory(loCategoryModel.CategoryID, loCategoryModel.CategoryName); } else { db.SP_InsertCategory(loCategoryModel.CategoryName); } } catch (Exception ex) { throw; } return(RedirectToAction("Category")); } catch { return(View()); } }
// // GET: /LiveUpdate/ public ActionResult LiveUpdate() { var DataSource = new ProductDataContext().GetProductData; ViewBag.datasource = DataSource; return(View()); }
// // GET: /Category/Create public ActionResult AddCategory() { string Categoryid = Request.QueryString["q"]; Session["PageFilterModel"] = new PageFilterModel(); ProductDataContext db = new ProductDataContext(); CategoryModel loCategoryModel = new CategoryModel(); loCategoryModel.CategoryID = 0; loCategoryModel.CategoryName = ""; try { if (!string.IsNullOrEmpty(Categoryid)) { var locategory = db.tblCategories.Where(x => x.CategoryId == Convert.ToInt32(Categoryid)).FirstOrDefault(); loCategoryModel.CategoryID = locategory.CategoryId; loCategoryModel.CategoryName = locategory.CategoryName; } } catch (Exception ex) { throw; } return(View(loCategoryModel)); }
public ActionResult Edit(FormCollection obj) { using (var db1 = new ProductDataContext()) { //var myData = db1.ProductMaterials.Where(x => x.MaterialId == material.MaterialId).ToList(); //myData.ForEach(m => m.MaterialId = int.Parse(obj["hidden1"])); //db.SaveChanges(); Int32 deleteId = int.Parse(obj["hidden1"]); Int32 keepId = int.Parse(obj["hidden2"]); var query = db1.ProductMaterials.Where(p => p.MaterialId == deleteId).ToList(); foreach (var post in query) { post.MaterialId = keepId; } db1.SaveChanges(); var itemToRemove = db.Materials.SingleOrDefault(x => x.MaterialId == deleteId); if (itemToRemove != null) { db.Materials.Remove(itemToRemove); db.SaveChanges(); } return(RedirectToAction("Index")); //material.Name = obj["hidden1"].ToString(); //db.Entry(material).State = EntityState.Modified; //db.SaveChanges(); //return RedirectToAction("Index"); } }
private void SaveProductImage(string file) { var splitedName = file.Split('.'); var extension = splitedName[splitedName.Length - 1]; var stream = File.OpenRead(file); byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); using (ProductDataContext db = new ProductDataContext("StoreAppB")) { var product = db.Set <Product>().Find(int.Parse(ProductIDTxt.Text)); ProductImage pi = new ProductImage { ImageData = buffer, ImageMimeType = extension, SequenceNumber = short.Parse(SequenceNumber.Text), Product = product }; db.Set <ProductImage>().Add(pi); db.SaveChanges(); } }
public ActionResult Index8(int id = 0) { ViewBag.CategoryID = id; List <Product> Products = ProductDataContext.LoadProducts53(id); return(Json(Products, JsonRequestBehavior.AllowGet)); }
public ActionResult Insert1(int id = 0) { ViewBag.CategoryID = id; List <Product> products = ProductDataContext.InsertProducts2(id); return(View(products)); }
public List <MyProduct> GetNRecentlyReviewedProductd(int howManyProducts) { using (ProductDataContext db = new ProductDataContext()) { var result = from myProduct in _myProductsList join review in db.ProductReviews on myProduct.ProductID equals review.ProductID orderby review.ReviewDate descending select myProduct; return(result.Take(howManyProducts).ToList()); } }
public void GetProductVendorString_MethodSyntaxTest() { using (ProductDataContext db = new ProductDataContext()) { List <Product> products = db.GetProducts(); List <ProductVendor> productVendors = db.GetProductVendors(); string result = products.GetProductVendorString_MethodSyntax(productVendors); string line = result.Substring(0, result.IndexOf('\n') - 1); Assert.AreEqual("Adjustable Race-Litware, Inc.", line); } }
public MyProductsRepository(int n) { using (ProductDataContext db = new ProductDataContext()) { _myProductsList = new List <MyProduct>(); List <Product> products = db.GetNProducts(n); foreach (Product product in products) { _myProductsList.Add(new MyProduct(product)); } } }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } // Specify the local database connection string. string DBConnectionString = "Data Source=isostore:/WSUASTIS_Inventory.sdf"; // Create database if it doesn't exist using (ProductDataContext db = new ProductDataContext(DBConnectionString)) { if (db.DatabaseExists() == false) { db.CreateDatabase(); db.SubmitChanges(); } } viewModel = new ProductViewModel(DBConnectionString); viewModel.LoadCollectionsFromDatabase(); /*if (!GlobalVars.DBHasBeenPopulated) ViewModel.PopulateProductDB(); */ }
public void GetProductsWithoutCategory_QuerySyntaxTest() { using (ProductDataContext db = new ProductDataContext()) { List <Product> products = db.GetProducts(); List <Product> result = products.GetProductsWithoutCategory_QuerySyntax(); Assert.AreEqual(209, result.Count); foreach (Product res in result) { Assert.IsNull(res.ProductSubcategory); } } }
public ActionResult Filter1(Models.Product login) { //ProductDataContext.InsertProducts22(login); if (Request.Form.Count > 0) { ProductDataContext.InsertProducts(login); //return RedirectToAction("Index"); } //return View(Request.Form.Count); //return Json(login, JsonRequestBehavior.AllowGet); //return Json("filter1"); return(View("Filter2")); }
public void GetPaginatedProducts_MethodSyntax() { using (ProductDataContext db = new ProductDataContext()) { List <Product> products = db.GetProducts(); List <Product> page0 = products.GetPaginatedProducts_MethodSyntax(20, 0); List <Product> page1 = products.GetPaginatedProducts_MethodSyntax(20, 1); Assert.AreEqual(20, page0.Count); Assert.AreEqual(20, page1.Count); Assert.AreEqual(1, page0[0].ProductID); Assert.AreEqual(332, page1[0].ProductID); } }
//private ProBYQ CheckSetting() //{ // RadComboBox cb1 = (RadComboBox)cbxBrand.Content; // if (cb1.SelectedIndex == -1) // { // MessageBox.Show("请设置上传款式对应的品牌"); // cb1.Focus(); // return null; // } // RadComboBox cb2 = (RadComboBox)cbxQuarter.Content; // if (cb2.SelectedIndex == -1) // { // MessageBox.Show("请设置上传款式对应的季度"); // cb2.Focus(); // return null; // } // RadDatePicker dp = (RadDatePicker)SYear.Content; // if (string.IsNullOrEmpty(dp.DateTimeText)) // { // MessageBox.Show("请设置上传款式对应的年份"); // dp.Focus(); // return null; // } // var byq = DomainLogicEncap.ProductLogic.GetBYQ((int)cb1.SelectedValue, dp.DateTimeText, (int)cb2.SelectedValue); // if (byq == null) // { // MessageBox.Show("不存在对应的品牌年份季度信息"); // return null; // } // return byq; //} /// <summary> /// 上传款式图片 /// </summary> /// <returns>是否上传成功</returns> private void UploadPictureForSingleStyle(ProBYQ byq, StylePictureFile file, RadProgressBar pbProgress, RadButton btn) { var filePath = file.FilePath; var image = System.Drawing.Image.FromFile(filePath); //BitmapImage image = new BitmapImage(new Uri(filePath)); var transfer = new LargeDataTransfer() { Data = image }; transfer.CallbackEvent += delegate(int progress) { this.Dispatcher.Invoke(new Action(() => { pbProgress.Value = progress; })); }; var func = new Func <ProBYQ, string, ILargeDataTransfer, bool>(UploadPictureForSingleStyle); AsyncCallback callback = new AsyncCallback(ar => { //var func = (Func<ProStyleBYQ, string, ILargeDataTransfer, bool>)ar.AsyncState; var flag = func.EndInvoke(ar); var result = ProductDataContext.SaveSCPicture(file); if (!flag || !result.IsSucceed) { btn.IsEnabled = true; btn.Content = "重新上传"; file.UploadProgress = 0; file.UploadStatus = "上传失败"; //MessageBox.Show("上传失败"); } else { //ProSCPicture scp = new ProSCPicture { SCCode = System.IO.Path.GetFileNameWithoutExtension(filePath), PictureName = System.IO.Path.GetFileName(filePath) }; file.UploadStatus = "上传成功"; //MessageBox.Show("上传成功"); } }); func.BeginInvoke(byq, filePath, transfer, callback, func); //IAsyncResult ar = func.BeginInvoke(byq, filePath, transfer, null, null); //WaitHandle waitHandle = ar.AsyncWaitHandle; //waitHandle.WaitOne();//主线程等待,这里将产生死锁 //bool flag = false;//func.EndInvoke(ar); //new System.Threading.Thread(() => // { // UploadPictureForSingleStyle(byq, filePath); // }).Start(); }
public ActionResult Edit() { Product _product = new Product(); _product.ProductID = Convert.ToInt32(Request.Form["ProductID"]); _product.ProductName = Request.Form["ProductName"]; _product.SupplierID = Convert.ToInt32(Request.Form["SupplierID"]); _product.CategoryID = Convert.ToInt32(Request.Form["CategoryID"]); _product.QuantityPerUnit = Request.Form["QuantityPerUnit"]; _product.UnitPrice = Convert.ToDecimal(Request.Form["UnitPrice"]); _product.UnitsInStock = Convert.ToInt16(Request.Form["UnitsInStock"]); _product.UnitsOnOrder = Convert.ToInt16(Request.Form["UnitsOnOrder"]); ProductDataContext.EditProduct(_product); return(RedirectToAction("Index")); }
public decimal HowMuchWillItCost(int productID, int howMany) { ProductDataContext pdc = new ProductDataContext(); decimal? cost = pdc.Products.Single( p => p.ProductID == productID).UnitPrice; decimal totalCost = 0; if (cost.HasValue) { totalCost = cost.Value * howMany; } return(totalCost); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ProductDataContext context = parameter as ProductDataContext; ProStyle style = value as ProStyle; if (style != null && style.ID != 0) { var byq = _byqCache.Find(o => o.ID == style.BYQID); if (byq == null) { byq = VMGlobal.SysProcessQuery.LinqOP.GetById <ProBYQ>(style.BYQID); _byqCache.Add(byq); } return(byq.Year + context.Quarters.Find(q => q.ID == byq.Quarter).Name); } return(null); }
public ActionResult DeleteProduct() { string productid = Request.QueryString["q"]; ProductDataContext db = new ProductDataContext(); try { if (!string.IsNullOrEmpty(productid)) { db.SP_DeleteProduct(Convert.ToInt32(productid)); } } catch (Exception ex) { throw; } return(RedirectToAction("Product")); }
public ActionResult AddProduct() { string productid = Request.QueryString["q"]; Session["PageFilterModel"] = new PageFilterModel(); ProductModel loProductModel = new ProductModel(); loProductModel.ProductID = 0; loProductModel.ProductName = ""; loProductModel.CategoryID = 0; loProductModel.CategoryName = ""; ProductDataContext db = new ProductDataContext(); List <SelectListItem> Category = new List <SelectListItem>(); try { if (!string.IsNullOrEmpty(productid)) { var loproduct = db.tblProducts.Where(x => x.ProductId == Convert.ToInt32(productid)).FirstOrDefault(); loProductModel.ProductID = loproduct.ProductId; loProductModel.ProductName = loproduct.ProductName; loProductModel.CategoryID = loproduct.CategoryId ?? 0; loProductModel.CategoryName = ""; } var llcategory = db.tblCategories.ToList(); Category.Add(new SelectListItem { Text = "Select Category", Value = "0" }); foreach (var item in llcategory) { Category.Add(new SelectListItem { Text = item.CategoryName, Value = item.CategoryName }); } } catch (Exception) { throw; } ViewBag.Category = Category; return(View(loProductModel)); }
public ActionResult Insert1() { if (Request.Form.Count > 0) { Product _product = new Product();; _product.SupplierID = Convert.ToInt32(Request.Form["SupplierID"]); _product.CategoryID = Convert.ToInt32(Request.Form["CategoryID"]); _product.CategoryName = Request.Form["CategoryName"]; _product.CompanyName = Request.Form["CompanyName"]; _product.ProductName = Request.Form["ProductName"]; _product.QuantityPerUnit = Request.Form["QuantityPerUnit"]; _product.UnitPrice = Convert.ToDecimal(Request.Form["UnitPrice"]); _product.UnitsInStock = Convert.ToInt16(Request.Form["UnitsInStock"]); _product.UnitsOnOrder = Convert.ToInt16(Request.Form["UnitsOnOrder"]); ProductDataContext.InsertProducts(_product); return(RedirectToAction("Index")); } return(View(Request.Form.Count)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ProductDataContext context) { // DbInitializer.Initialize(context); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public ActionResult SaveProduct(ProductModel loProductModel) { ProductDataContext db = new ProductDataContext(); try { if (loProductModel.ProductID > 0) { db.SP_UPDATEProduct(loProductModel.ProductID, loProductModel.CategoryID, loProductModel.ProductName); } else { db.SP_InsertProduct(loProductModel.CategoryID, loProductModel.ProductName); } } catch (Exception ex) { return(View()); } return(RedirectToAction("Product")); }
public ActionResult CategoryDetail(PageFilterModel paging) { ProductDataContext db = new ProductDataContext(); List <CategoryModel> lloCategoryModel = new List <CategoryModel>(); try { var categoryobj = db.SP_SELECTCategory(paging.PageNo, paging.PageSize); foreach (var item in categoryobj) { lloCategoryModel.Add(new CategoryModel { CategoryID = item.CategoryId, CategoryName = item.CategoryName }); } } catch (Exception) { throw; } return(View(lloCategoryModel)); }
public ProductInfo GetProductInfo(int productID) { ProductDataContext pdc = new ProductDataContext(); Product product = pdc.Products.Single(p => p.ProductID == productID); ProductInfo prodInfo = null; if (product != null) { prodInfo = new ProductInfo(); prodInfo.CategoryID = product.CategoryID; prodInfo.Discontinued = product.Discontinued; prodInfo.ProductID = product.ProductID; prodInfo.ProductName = product.ProductName; prodInfo.QuantityPerUnit = product.QuantityPerUnit; prodInfo.ReorderLevel = product.ReorderLevel; prodInfo.SupplierID = product.SupplierID; prodInfo.UnitPrice = product.UnitPrice; prodInfo.UnitsInStock = product.UnitsInStock; prodInfo.UnitsOnOrder = product.UnitsOnOrder; } return(prodInfo); }
public ReceiptsController(ProductDataContext context) { _context = context; }
public ProductViewModel(ProductDataContext db) { _InventoryDB = db; }
public void Setup() { _dataContext = new ProductDataContext(); }
// Class constructor, create the data context object. public ProductViewModel(string DBConnectionString) { _InventoryDB = new ProductDataContext(DBConnectionString); }