private void LoadOperationProductCompleted(LoadOperation <ProductManager.Web.Model.product> aLoadOperation) { ProductEntityList.Clear(); foreach (ProductManager.Web.Model.product product in aLoadOperation.Entities) { ProductEntity productEntity = new ProductEntity(); productEntity.Product = product; productEntity.Update(); ProjectEntity lProjectEntityTemp; if (ProjectEntityDictionary.TryGetValue(productEntity.ManufactureNumber, out lProjectEntityTemp)) { productEntity.ProjectName = lProjectEntityTemp.ProjectName; } if (ProjectNameSearch != null && ProjectNameSearch.Length > 0) { if (!productEntity.ProjectName.Contains(ProjectNameSearch)) { continue; } } ProductEntityList.Add(productEntity); } IsBusy = false; }
public ActionResult FetchProductIndexList() { string query = HotelCloud.Common.HCRequest.GetString("query").TrimEnd(); string select = HotelCloud.Common.HCRequest.GetString("select").TrimEnd(); int page = HotelCloud.Common.HCRequest.GetInt("page", 1); if (page < 1) { page = 1; } int pagesize = 2; int count = 0; int pagesum = 0; string key = HotelCloud.Common.HCRequest.GetString("key"); string hotelweixinId = key.Split('@')[0]; string userweixinId = key.Split('@')[1]; string sign = key.Split('@')[2]; if (!IsValidateUser(hotelweixinId, userweixinId, sign)) { return(View()); } ProductEntityList list_products = new ProductEntityList(); string cacheName = string.Format("{0}_{1}", hotelweixinId.ToLower(), "productindex"); if (cache[cacheName] != null) { list_products = (ProductEntityList)cache[cacheName]; count = list_products.Count; } else { list_products.ProductEntity_List = Models.Home.SaleProduct.GetSaleProductsListIndex(hotelweixinId, out count, page, pagesize, "", ""); list_products.Count = count; cache.Insert(cacheName, list_products, null, DateTime.Now.AddMinutes(30), TimeSpan.Zero); } pagesum = (count % pagesize == 0) ? count / pagesize : count / pagesize + 1; return(Json(new { data = list_products.ProductEntity_List, count = count, page = page, pagesum = pagesum }, JsonRequestBehavior.AllowGet)); }
public static List <ProductEntity> GetSaleProductsListToList(string weixinid, string search, string cityName, string price) { int count = 0; //ProductEntityList list_products = new ProductEntityList(); //var dt = CommodityService.GetSaleProductsListIndex(weixinid, out count, 1, 99, "", ""); //list_products.ProductEntity_List = ProductEntity.ConvertProductEntityIndexListMall(dt); //list_products.Count = count; //ViewData["products"] = list_products.ProductEntity_List; ProductEntityList list_products = new ProductEntityList(); var dt = CommodityService.GetSaleProductsListIndex(weixinid, out count, 1, 99, "ProductName", search, cityName, price); list_products.ProductEntity_List = ProductEntity.ConvertProductEntityIndexListMall(dt); //list_products.ProductEntity_List = SaleProduct.GetSaleProductsListIndexA(weixinid, out count, 1, 99, "", ""); list_products.Count = count; list_products.ProductEntity_List = TravelAgencyCommon.ProductListDo(list_products.ProductEntity_List); list_products.ProductEntity_List = list_products.ProductEntity_List.Where(c => c.List_SaleProducts_TC.Count > 0).ToList(); return(list_products.ProductEntity_List); }
public ActionResult ProductList() { string query = HotelCloud.Common.HCRequest.GetString("query").TrimEnd(); string select = HotelCloud.Common.HCRequest.GetString("select").TrimEnd(); int page = HotelCloud.Common.HCRequest.GetInt("page", 1); int pagesize = 50; if (page < 1) { page = 1; } int count = 0; string key = HotelCloud.Common.HCRequest.GetString("key"); string hotelweixinId = key.Split('@')[0]; string userweixinId = key.Split('@')[1]; string cacheName = string.Format("{0}_{1}", hotelweixinId.ToLower(), "productlist"); ProductEntityList list_products = new ProductEntityList(); list_products.ProductEntity_List = SaleProduct.GetSaleProductsListIndexA(hotelweixinId, out count, page, pagesize, "", ""); list_products.Count = count; List <ProductEntity> productEntity_List = new List <ProductEntity>(); foreach (var item in list_products.ProductEntity_List) { item.List_SaleProducts_TC = SaleProducts_TC.GetSaleProducts_TC(Convert.ToInt32(item.Id)); if (item.ProductType == "0") { item.List_SaleProducts_TC = item.List_SaleProducts_TC.Where(c => c.ProductNum > 0 && c.ProductPrice > 0).ToList(); } else if (item.ProductType == "1" && item.List_SaleProducts_TC.Count > 0) { List <int> tc_requestIds = item.List_SaleProducts_TC.Select(c => c.Id).ToList <int>(); var list_tcPrice = SaleProducts_TC_Price.GetSaleProducts_TC_Price(tc_requestIds); foreach (var item2 in item.List_SaleProducts_TC) { item2.List_SaleProducts_TC_Price = list_tcPrice.Where(c => c.RequestId == item2.Id).ToList(); } item.List_SaleProducts_TC = item.List_SaleProducts_TC.Where(c => c.List_SaleProducts_TC_Price.Count > 0).ToList(); } } list_products.ProductEntity_List = list_products.ProductEntity_List.Where(c => c.List_SaleProducts_TC.Count > 0).ToList(); int pagesum = (count % pagesize == 0) ? count / pagesize : count / pagesize + 1; //ViewData["products"] = ProductEntity.ConvertProductEntityList(products); ViewData["products"] = list_products.ProductEntity_List; ViewData["count"] = count; ViewData["page"] = page; ViewData["pagesize"] = pagesize; ViewData["pagesum"] = pagesum; return(View()); }
public ActionResult ProductList(string id) { return(RedirectToAction("ProductList", "ProductA", new { id = RouteData.Values["id"], key = HotelCloud.Common.HCRequest.GetString("key"), s = "1" })); string query = HotelCloud.Common.HCRequest.GetString("query").TrimEnd(); string select = HotelCloud.Common.HCRequest.GetString("select").TrimEnd(); int page = HotelCloud.Common.HCRequest.GetInt("page", 1); int pagesize = 5; if (page < 1) { page = 1; } int count = 0; string key = HotelCloud.Common.HCRequest.GetString("key"); string hotelweixinId = key.Split('@')[0]; string userweixinId = key.Split('@')[1]; string sign = ValidateUserSign(hotelweixinId, userweixinId); if (string.IsNullOrEmpty(sign)) { return(RedirectToAction("ProductErrMsg", "Product", new { id = RouteData.Values["id"], errmsg = "用户参数不合法", key = key })); } ViewData["key"] = key + "@" + sign; string cacheName = string.Format("{0}_{1}", hotelweixinId.ToLower(), "productlist"); ProductEntityList list_products = new ProductEntityList(); if (cache[cacheName] != null) { list_products = (ProductEntityList)cache[cacheName]; count = list_products.Count; } else { list_products.ProductEntity_List = Models.Home.SaleProduct.GetSaleProductsListIndex(hotelweixinId, out count, page, pagesize, "", ""); list_products.Count = count; cache.Insert(cacheName, list_products, null, DateTime.Now.AddMinutes(30), TimeSpan.Zero); } int pagesum = (count % pagesize == 0) ? count / pagesize : count / pagesize + 1; //ViewData["products"] = ProductEntity.ConvertProductEntityList(products); ViewData["products"] = list_products.ProductEntity_List; ViewData["count"] = count; ViewData["page"] = page; ViewData["pagesize"] = pagesize; ViewData["pagesum"] = pagesum; return(View()); }
private void OnImportCommand() { OpenFileDialog lOpenFile = new OpenFileDialog(); lOpenFile.Filter = "Excel (*.xls)|*.xls"; Dictionary <String, int> lHeaderDictionary = new Dictionary <String, int>(); if (lOpenFile.ShowDialog() == true) { ProductEntityList.Clear(); try { FileStream fs = lOpenFile.File.OpenRead(); Workbook book = Workbook.Open(fs); foreach (KeyValuePair <int, Row> rowPair in book.Worksheets[0].Cells.Rows) { if (rowPair.Key == 0) { try { foreach (KeyValuePair <int, Cell> cellPair in rowPair.Value) { lHeaderDictionary.Add(cellPair.Value.StringValue, cellPair.Key); } } catch (System.Exception ex) { Message.ErrorMessage("表头重复或超出范围!"); break; } continue; } ProductEntity lProductEntity = new ProductEntity(); lProductEntity.Product = new ProductManager.Web.Model.product(); lProductEntity.ProductEntityDictionary = ProductEntityDictionary; lProductEntity.ProjectEntityDictionary = ProjectEntityDictionary; //lProductEntity.ProductPartTypeEntityDictionary = ProductTypeEntityDictionary; int lManufactureNumberColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("生产令号", out lManufactureNumberColumn) && -1 != lManufactureNumberColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lManufactureNumberColumn))) { lProductEntity.ManufactureNumber = cell.StringValue; ProjectEntity projectEntityTemp; if (!ProjectEntityDictionary.TryGetValue(lProductEntity.ManufactureNumber, out projectEntityTemp)) { NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 系统中没有生产令号:" + lProductEntity.ManufactureNumber); lNotifyWindow.Show(); return; } } else { NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 系统中没有生产令号:" + lProductEntity.ManufactureNumber); lNotifyWindow.Show(); return; } } int lProjectNameColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("序列号", out lProjectNameColumn) && -1 != lProjectNameColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lProjectNameColumn))) { lProductEntity.ProductID = cell.StringValue; ProductEntity lProductEntityTemp; if (ProductEntityDictionary.TryGetValue(lProductEntity.ProductID, out lProductEntityTemp)) { NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 序列号重复:" + lProductEntity.ProductID); lNotifyWindow.Show(); return; } if (CurrentProductEntityDicationary.TryGetValue(lProductEntity.ProductID, out lProductEntityTemp)) { NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 序列号重复:" + lProductEntity.ProductID); lNotifyWindow.Show(); return; } } } int lModelNumberColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("产品类型", out lModelNumberColumn) && -1 != lModelNumberColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lModelNumberColumn))) { lProductEntity.ProductTypeString = cell.StringValue; int lId; if (ProductTypeIDDictionary.TryGetValue(lProductEntity.ProductTypeString, out lId)) { lProductEntity.ProductTypeID = lId; } else { NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 系统中无该产品类型:" + lProductEntity.ProductTypeString); lNotifyWindow.Show(); return; } } } int lRemarkColumn = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("名称", out lRemarkColumn) && -1 != lRemarkColumn && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lRemarkColumn))) { lProductEntity.ProductName = cell.StringValue; } } int lInputTimeColume = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("编制日期", out lInputTimeColume) && -1 != lInputTimeColume && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lInputTimeColume))) { lProductEntity.ProductIDCreateData = cell.DateTimeValue; } } int lOutputNumberColume = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("出厂编号", out lOutputNumberColume) && -1 != lOutputNumberColume && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lOutputNumberColume))) { lProductEntity.ProductOutputNumber = cell.StringValue; } } int lNote1 = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("备注1", out lNote1) && -1 != lNote1 && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lNote1))) { lProductEntity.ProductDescript1 = cell.StringValue; } } int lNote2 = -1; { Cell cell = Cell.EmptyCell; if (lHeaderDictionary.TryGetValue("备注1", out lNote2) && -1 != lNote2 && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lNote2))) { lProductEntity.ProductDescript2 = cell.StringValue; } } lProductEntity.DUpdate(); ProductEntityList.Add(lProductEntity); CurrentProductEntityDicationary.Add(lProductEntity.ProductID, lProductEntity); //ProductContext.projects.Add(lProjectEntity.Project); } } catch (System.Exception ex) { Message.ErrorMessage(ex.Message); } } }