//[AdminFilter] public ActionResult Warehouse(int?page) { WarehouseViewModel warehouseViewModel = new WarehouseViewModel(); //判断是否是管理人员,是则有权限进行修改 if (Convert.ToInt32(Session["level"]) == Convert.ToInt32(level.Admin)) { warehouseViewModel.display = ""; } else { warehouseViewModel.display = "display:none"; } warehouseViewModel.UserName = Session["User"].ToString(); //第几页 int pageNumber = page ?? 1; if (NoChangePage) { pageNumber = HomeController.page; NoChangePage = false; } HomeController.page = pageNumber; //每页显示多少条 int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]); WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer(); warehouseViewModel.warehouses = warehouseBusinessLayer.GetWarehouse().ToPagedList(pageNumber, pageSize); return(View("Warehouse", warehouseViewModel)); }
public JsonResult GetSpecificItem(string id) { try { WarehouseDBEntities wdb = new WarehouseDBEntities(); WarehouseBusinessLayer ware = new WarehouseBusinessLayer(); int warehouseID = ware.getWarehouseId(Convert.ToInt32(Session["UserID"])); // Shelf shelf = wdb.Shelves.FirstOrDefault(a => a.shelfName == sname); Item item = wdb.Items.Find(Convert.ToInt32(id)); List <String> sitems = new List <String>(); sitems.Add(item.Manufacturer); sitems.Add(item.itemCode); sitems.Add(item.itemDetail.dimensions); sitems.Add(item.itemDetail.weight); sitems.Add(item.itemDetail.picture); sitems.Add(item.Country); return(new JsonResult { Data = sitems, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { return(null); } }
public ActionResult SaveExist(Exist exist, string W_name, string U_name) { //通过key查询到要改变的exit //通过W_name和U_name分别获得仓库编号和用户编号 //整合信息 UserBusinessLayer userBusinessLayer = new UserBusinessLayer(); if ((exist.U_id = userBusinessLayer.GetId(U_name)) == -1) { return(RedirectToAction("RedirectStorage")); } WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer(); if ((exist.W_id = warehouseBusinessLayer.GetId(W_name)) == -1) { return(RedirectToAction("RedirectStorage")); } //修改信息 ExistBusinessLayer existBusinessLayer = new ExistBusinessLayer(); existBusinessLayer.InputExist(exist.IO_Id, exist); //重定向 return(RedirectToAction("RedirectStorage")); }
public JsonResult GetAllItems(string id) { try { WarehouseDBEntities wdb = new WarehouseDBEntities(); WarehouseBusinessLayer ware = new WarehouseBusinessLayer(); int warehouseID = ware.getWarehouseId(Convert.ToInt32(Session["UserID"])); Warehouse warehouse = wdb.Warehouses.FirstOrDefault(k => k.id == warehouseID); int palletsInOneRow = ((int)warehouse.shelfSlots / (int)warehouse.sections) / (int)warehouse.shelfRows; string sname = warehouseID.ToString() + id; Shelf shelf = wdb.Shelves.FirstOrDefault(a => a.shelfName == sname); shelf.shelfName = id; shelf.warehouse_id = palletsInOneRow; shelf.slotsRemaining = warehouse.sections; List <Shelf> sitems = new List <Shelf>(); sitems.Add(shelf); return(new JsonResult { Data = sitems, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { return(null); } }
public ActionResult RegisterCustomer(string fullname, string email, string number, string organizationname, string organizationaddress, string username, string password, string password2, string[] warehouses) { WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); Customer useracc = new Customer(); useracc.fullName = fullname; useracc.email = email; useracc.contact = number; useracc.password = password; useracc.userName = username; useracc.organizationAddress = organizationaddress; useracc.organizationName = organizationname; useracc.selectedWarehouse = JsonConvert.SerializeObject(warehouses); WarehouseDBEntities wdb = new WarehouseDBEntities(); wdb.Customers.Add(useracc); wdb.SaveChanges(); Session["UserID"] = wbl.getRecentlyId(); Session["Username"] = username; return(RedirectToAction("LoggedIn")); }
public ActionResult searchWarehouse(string wareName) { WarehouseViewModel warehouseViewModel = new WarehouseViewModel(); //判断是否是管理人员,是则有权限进行修改 if (Convert.ToInt32(Session["level"]) == Convert.ToInt32(level.Admin)) { warehouseViewModel.display = ""; } else { warehouseViewModel.display = "display:none"; } warehouseViewModel.UserName = Session["User"].ToString(); WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer();//第几页 int pageNumber = 1; //每页显示多少条 int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]); warehouseViewModel.warehouses = warehouseBusinessLayer.GetWarehouse(wareName).ToPagedList(pageNumber, pageSize); return(View("Warehouse", warehouseViewModel)); }
public ActionResult SaveWarehouse(Warehouse model, string BtnSubmit) { //如果是按键操作,返回重定向 WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer(); if (BtnSubmit == "添加") { //添加页面 warehouseBusinessLayer.InsertWarehouse(model); return(RedirectToAction("Warehouse")); } else if (BtnSubmit == "提交更改") { //修改页面 NoChangePage = true; warehouseBusinessLayer.InputWarehouse(model.Wa_name, model); return(RedirectToAction("Warehouse")); } //如果不是按键操作,刷新本页面 CreateWarehouseViewModel createWarehouseViewModel = new CreateWarehouseViewModel(); createWarehouseViewModel.warehouse = new Warehouse(); return(PartialView("CreateWarehouse", createWarehouseViewModel)); }
public ActionResult Start(WarehouseBL warehouse) { WarehouseBusinessLayer warehouseBL = new WarehouseBusinessLayer(); warehouse.managerId = Convert.ToInt32(Session["UserID"]); warehouseBL.UpdateStartWareHouse(warehouse); return(RedirectToAction("LoggedIn", "Account")); }
public ActionResult Settings() { WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); DataSet ds = new DataSet(); ds = wbl.getWarehouseDetails(Convert.ToInt32(Session["UserID"])); return(View(ds)); }
// GET: Consignments public ActionResult Index() { ViewBag.PageName = "Consignments"; WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); int warehouseIdd = wbl.getWarehouseId(Convert.ToInt32(Session["UserID"])); return(View(db.Consignments.Where(u => u.warehouseId == warehouseIdd))); }
public ActionResult OrderInstruction() { WarehouseDBEntities wdb = new WarehouseDBEntities(); WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); int id = wbl.getWarehouseId(Convert.ToInt32(Session["UserID"])); List <Order> orders = wdb.Orders.Where(a => a.warehouseId == id && a.orderStatus == "Dispatched").ToList(); return(View(orders)); }
public ActionResult GetOrders() { WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); WarehouseDBEntities wdb = new WarehouseDBEntities(); int warehouseIdd = wbl.getWarehouseId(Convert.ToInt32(Session["UserID"])); List <Order> orderNew = wdb.Orders.Where(a => a.warehouseId == warehouseIdd).ToList(); return(View(orderNew)); }
public ActionResult LoggedIn() { if (Session["UserID"] != null) { int id = Convert.ToInt32(Session["UserID"]); String ss; WarehouseBusinessLayer warehouseBL = new WarehouseBusinessLayer(); Byte[] dataInBytes = warehouseBL.getWarehouse(id); Boolean value = warehouseBL.getWarehouseAttr(id); WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); DataSet ds = wbl.getWarehouseDetails(id); DataRow dr = ds.Tables[0].Rows[0]; string imageDataURL = ""; if (dr["warehouseLogo"].ToString() != "") { imageDataURL = string.Format("data:image;base64,{0}", dr["warehouseLogo"].ToString()); } else { imageDataURL = "/images/logo.png"; } Session["logo"] = imageDataURL; try { ss = System.Text.Encoding.UTF8.GetString(dataInBytes); } catch (Exception ex) { if (value) { ss = ""; } else { ss = null; } } ViewBag.HtmlStr = ss; return(View()); } else { return(RedirectToAction("Login")); } }
public ActionResult Update(List <Item> ware, List <Item_Consignment> itemcon, List <Consignment> con) { foreach (Consignment conn in con) { WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); int warehouseIdd = wbl.getWarehouseId(Convert.ToInt32(Session["UserID"])); conn.warehouseId = warehouseIdd; try { cbl.UpdateConsignment(conn); int index = 0; foreach (Item_Consignment ic in itemcon) { Item items = ware.ElementAt(index); ic.itemId = getNewOrOldId(items); ic.consignmentId = conn.id; List <Item_Consignment> itc = db.Item_Consignment.Where(i => i.itemId == ic.itemId && i.consignmentId == ic.consignmentId).ToList(); if (itc.Count > 0) { cbl.UpdateItem_Consignment(ic); } else { cbl.addItem_Consignment(ic); } index++; } } catch (Exception ex) { } int count = db.Item_Consignment.Where(u => u.consignmentId == conn.id).Count(); cbl.updateItemsCount(count, conn.id); break; } return(RedirectToAction("Create", "Consignments")); }
//[MultiButton("入库")] public ActionResult MakeTableSubmit(string Sumbit) { if (Sumbit == null && IsIntoOutWaretor) { return(new EmptyResult()); } Session["Table_Id"] = null; //string Sumbit = "入库"; Out_Into_ware out_Into_Ware = new Out_Into_ware(); out_Into_Ware.Make_date = DateTime.Now;//时间 UserBusinessLayer userBusinessLayer = new UserBusinessLayer(); WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer(); OutIntoWareBusinessLayer outIntoWareBusinessLayer1 = new OutIntoWareBusinessLayer(); User user = userBusinessLayer.GetUser(Session["User"].ToString()); out_Into_Ware.User_id = user.U_Id; //负责人编号 out_Into_Ware.Ware_id = warehouseBusinessLayer.GetId(user.U_point); //仓库编号 //创建表单号 Table_Id = "12343"; if (Sumbit == "商品入库") { I_type = "入库"; IsIntoOutWaretor = true; out_Into_Ware.type = IO_Type.INTO; //out_Into_Ware.Table_Id = "INTO" + Table_Id; out_Into_Ware.Table_Id = outIntoWareBusinessLayer1.GetMaxTable(IO_Type.INTO); } else if (Sumbit == "商品出库") { I_type = "出库"; IsIntoOutWaretor = true; out_Into_Ware.type = IO_Type.OUT; //out_Into_Ware.Table_Id = "OUT" + Table_Id; out_Into_Ware.Table_Id = outIntoWareBusinessLayer1.GetMaxTable(IO_Type.OUT); } //Session["Table_Id"] = out_Into_Ware.Table_Id; Table_Id = out_Into_Ware.Table_Id; //存入数据库 OutIntoWareBusinessLayer outIntoWareBusinessLayer = new OutIntoWareBusinessLayer(); outIntoWareBusinessLayer.InsertOut_Into_ware(out_Into_Ware); return(RedirectToAction("RedirectInOutWarehouse")); }
public ActionResult viewWarehouse() { ViewBag.PageName = "View Warehouse"; String ss; WarehouseBusinessLayer warehouseBL = new WarehouseBusinessLayer(); Byte[] dataInBytes = warehouseBL.getWarehouse(Convert.ToInt32(Session["UserID"])); try { ss = System.Text.Encoding.UTF8.GetString(dataInBytes); } catch (Exception ex) { ss = null; } ViewBag.HtmlStr = ss; return(View()); }
public ActionResult DeleteWarehouse(string Wa_name, string BtnSubmit) { if (BtnSubmit == "确定") { WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer(); warehouseBusinessLayer.DeleteWarehouse(Wa_name); return(RedirectToAction("Warehouse")); } else if (BtnSubmit == "取消") { return(RedirectToAction("Warehouse")); } //如果不是按键操作,刷新本页面 CreateWarehouseViewModel createWarehouseViewModel = new CreateWarehouseViewModel(); createWarehouseViewModel.warehouse = new Warehouse(); return(PartialView("CreateWarehouse", createWarehouseViewModel)); }
/// <summary> /// 返回在存的全部数据 /// </summary> /// <param name="U_name"></param> /// <returns></returns> public StorageViewModel GetStorageViewModel(bool Display, string U_name, int pageNumber = 1) { StorageViewModel storageViewModel = new StorageViewModel(); storageViewModel.UserName = U_name; storageViewModel.existTableListViewModel = new ExistTableListViewModel(); storageViewModel.existTableListViewModel.Display = Display ? "" : "none"; //storageViewModel.existTableListViewModel.existTableViewModels = new List<ExistTableViewModel>(); List <ExistTableViewModel> existTableViewModels = new List <ExistTableViewModel>(); ExistBusinessLayer existBusinessLayer = new ExistBusinessLayer(); CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer(); OutIntoWareBusinessLayer outIntoWareBusinessLayer = new OutIntoWareBusinessLayer(); UserBusinessLayer userBusinessLayer = new UserBusinessLayer(); WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer(); //得到全部在存表中的数据 List <Exist> exists = existBusinessLayer.GetExist(); //Out_Into_ware out_Into_Ware; ExistTableViewModel existTableViewModel; foreach (Exist item in exists) { existTableViewModel = new ExistTableViewModel(); existTableViewModel.exist = item; //out_Into_Ware = outIntoWareBusinessLayer.GetOut_Into_ware(item.IO_Id); //得到姓名 existTableViewModel.U_name = userBusinessLayer.GetUsers("员工编号", item.U_id.ToString()).FirstOrDefault().U_name; //得到仓库名 existTableViewModel.W_name = warehouseBusinessLayer.GetWarehouse("仓库编号", item.W_id.ToString()).FirstOrDefault().Wa_name; existTableViewModel.commodity = commodityBusinessLayer.GetCommodity("商品编号", item.Co_id.ToString()).FirstOrDefault(); //storageViewModel.existTableListViewModel.existTableViewModels.Add(existTableViewModel); existTableViewModels.Add(existTableViewModel); } //每页显示多少条 //int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]); storageViewModel.existTableListViewModel.existTableViewModels = existTableViewModels; return(storageViewModel); }
public void DispatchOrders(string id) { WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); int warehouseId = wbl.getWarehouseId(Convert.ToInt32(Session["UserID"])); int oid = Convert.ToInt32(id); WarehouseDBEntities wde = new WarehouseDBEntities(); List <Order> orders = wde.Orders.Where(a => a.warehouseId == warehouseId && a.orderId == oid && (a.orderStatus == "Unseen" || a.orderStatus == "Seen")).OrderBy(a => a.totalOrderQuanitity).ToList(); int i = 0; //Sorting items according to quantity foreach (var order in orders) { var neworder = order.item_Order; neworder = neworder.OrderBy(a => a.quantity).ToList(); orders.ElementAt(i).item_Order = neworder; i++; } Slotting slotting = new Slotting(); List <Item_Warehouse> itemWarehouse = wde.Item_Warehouse.Where(a => a.warehouseId == warehouseId).ToList(); List <Shelf> shelfs = wde.Shelves.Where(a => a.warehouse_id == warehouseId).ToList(); Dictionary <int, List <ShelfItems> > shelfItems = new Dictionary <int, List <ShelfItems> >(); foreach (Shelf shelf in shelfs) { List <ShelfItems> shelves = slotting.covert_to_object(shelf.shelfItems); shelfItems.Add(shelf.id, shelves); } List <Item> items = new List <Item>(); foreach (Item_Warehouse item_Warehouse in itemWarehouse) { items.Add(item_Warehouse.Item); } OrderPicking orderPick = new OrderPicking(); orderPick.getFirstOrder(orders, shelfItems); }
public JsonResult GetAllUser() { try { List <WarehouseBL> allUser = new List <WarehouseBL>(); WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); DataSet ds = wbl.getWarehouseDetails(Convert.ToInt32(Session["UserID"])); DataRow dr = ds.Tables[0].Rows[0]; WarehouseBL w = new WarehouseBL(); w.scaledShelfLength = dr["scaledShelfLength"].ToString(); w.scaledShelfWidth = dr["scaledShelfWidth"].ToString(); allUser.Add(w); return(new JsonResult { Data = allUser, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { return(null); } }
public ActionResult Create([Bind(Include = "id,warehouseId,supplier,totalItems,arrivalDate,consignmentName")] Consignment consignment) { //Yaha pe Manager Id add Kardena //Select id from Warehouse where managerId = Session[id] //Increase Session Timeout WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); consignment.warehouseId = wbl.getWarehouseId(Convert.ToInt32(Session["UserID"])); //if (ModelState.IsValid) //{ // //db.Consignments.Add(consignment); // // db.SaveChanges(); // TempData["ConsignmentDetails"] = consignment; // return RedirectToAction("De", "Consignments"); //} List <String> instructionsList = new List <string>(); ViewBag.Instructions = instructionsList; return(RedirectToAction("Details", new { id = Convert.ToInt32(Session["ConsignmentID"]) })); }
public ActionResult Save(WarehouseBL ware, List <Shelves> shel, List <Depot> depot) { WarehouseDBEntities wdb = new WarehouseDBEntities(); Shelves s = new Shelves(); WarehouseBusinessLayer warehouseBL = new WarehouseBusinessLayer(); ware.managerId = Convert.ToInt32(Session["UserID"]); warehouseBL.UpdateWareHouse(ware); int shelfCount = shel.Count; int zoneA = s.ZoneAshelf(shelfCount); int zoneB = s.ZoneBshelf(shelfCount); int zoneC = s.ZoneCshelf(shelfCount, zoneA, zoneB); shel = s.ShelvesWithDistance(shel, depot); shel = s.SortShelves(shel); shel = s.assignZones(shel, zoneA, zoneB, zoneC); foreach (Shelves shelve in shel) { shelve.warehouse_id = warehouseBL.getWarehouseId(Convert.ToInt32(Session["UserID"])); int myid = warehouseBL.getWarehouseId(Convert.ToInt32(Session["UserID"])); bool isExist = wdb.Shelves.Any(u => u.shelfName == myid.ToString() + shelve.shelveID); if (isExist) { shelve.shelveID = shelve.warehouse_id + shelve.shelveID; warehouseBL.UpdateShelf(shelve); } else { shelve.shelveID = shelve.warehouse_id + shelve.shelveID; int warehouseID = warehouseBL.getWarehouseId(Convert.ToInt32(Session["UserID"])); JavaScriptSerializer jss = new JavaScriptSerializer(); Warehouse warehouse = wdb.Warehouses.Find(warehouseID); List <ShelfItems> shelfItems = new List <ShelfItems>(); int z = 1; for (int i = 1; i <= warehouse.shelfSlots; i++) { ShelfItems si = new ShelfItems(); si.slot_id = i; si.item_id = -1; si.item_name = ""; si.expiry_date = ""; si.status = 0; if (i - warehouse.sections <= 0) { si.section_id = i; } else if (i - warehouse.sections > 0 && i - warehouse.sections * z <= warehouse.sections) { si.section_id = i - (int)warehouse.sections * z; } else { z += 1; si.section_id = i - ((int)warehouse.sections * z); } shelfItems.Add(si); } string output = JsonConvert.SerializeObject(shelfItems); shelve.slotsRemaining = warehouse.shelfSlots; shelve.shelfItems = output; warehouseBL.AddShelf(shelve); } } return(RedirectToAction("LoggedIn", "Account")); }
public ActionResult RegisterManager(string fullname, string email, string number, string warehousename, string warehouseaddress, string username, string password, string password2, HttpPostedFileBase warehouselogo, string countries) { string thePictureDataAsString = ""; if (warehouselogo != null) { string theFileName = Path.GetFileName(warehouselogo.FileName); byte[] thePictureAsBytes = new byte[warehouselogo.ContentLength]; using (BinaryReader theReader = new BinaryReader(warehouselogo.InputStream)) { thePictureAsBytes = theReader.ReadBytes(warehouselogo.ContentLength); } thePictureDataAsString = Convert.ToBase64String(thePictureAsBytes); } WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); UserAccount useracc = new UserAccount(); useracc.Name = fullname; useracc.Email = email; useracc.Contact = number; useracc.Password = password; useracc.ConfirmPassword = password; useracc.Registered = DateTime.Now.ToShortDateString(); useracc.Role = "Manager"; useracc.UserName = username; // ConsignmentBusinessLayer cbl = new ConsignmentBusinessLayer(); // cbl.addAccount(useracc); WarehouseDBEntities wde = new WarehouseDBEntities(); wde.UserAccounts.Add(useracc); try { wde.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } int Managerid = wbl.getRecentlyId(); wbl.createWarehouse(Managerid, warehousename, warehouseaddress, thePictureDataAsString, countries); Session["UserID"] = wbl.getRecentlyId(); Session["Username"] = username; return(RedirectToAction("LoggedIn")); }
/// <summary> /// 得到符合条件的在存数据 /// </summary> /// <param name="U_name">登陆人</param> /// <param name="Select">属性</param> /// <param name="name">属性值</param> /// <returns></returns> public StorageViewModel GetStorageViewModel(bool Display, string U_name, string Select, string name, int pageNumber = 1) { StorageViewModel storageViewModel = new StorageViewModel(); storageViewModel.UserName = U_name; storageViewModel.existTableListViewModel = new ExistTableListViewModel(); storageViewModel.existTableListViewModel.Display = Display ? "" : "none"; //storageViewModel.existTableListViewModel.existTableViewModels = new List<ExistTableViewModel>(); List <ExistTableViewModel> existTableViewModels = new List <ExistTableViewModel>(); ExistBusinessLayer existBusinessLayer = new ExistBusinessLayer(); CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer(); OutIntoWareBusinessLayer outIntoWareBusinessLayer = new OutIntoWareBusinessLayer(); UserBusinessLayer userBusinessLayer = new UserBusinessLayer(); WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer(); //得到全部在存表中的数据 List <Exist> exists; if (Select == "入库单号" || Select == "商品编号") { exists = existBusinessLayer.GetExist(Select, name); } else { exists = existBusinessLayer.GetExist(); } //Out_Into_ware out_Into_Ware; ExistTableViewModel existTableViewModel; foreach (Exist item in exists) { existTableViewModel = new ExistTableViewModel(); existTableViewModel.exist = item; //out_Into_Ware = outIntoWareBusinessLayer.GetOut_Into_ware(item.IO_Id); //得到姓名 existTableViewModel.U_name = userBusinessLayer.GetUsers("员工编号", item.U_id.ToString()).FirstOrDefault().U_name; if (Select == "入库员工" && existTableViewModel.U_name != name) { continue; } //得到仓库名 existTableViewModel.W_name = warehouseBusinessLayer.GetWarehouse("仓库编号", item.W_id.ToString()).FirstOrDefault().Wa_name; if (Select == "存储仓库" && existTableViewModel.W_name != name) { continue; } //existTableViewModel.commodity = commodityBusinessLayer.GetCommodity("商品编号", item.Co_id.ToString()).FirstOrDefault(); CommodityMember commodityMember = new CommodityMember(); switch (Select) { case "商品编号": commodityMember.Co_Id = name; break; case "商品名称": commodityMember.Co_name = name; break; case "条码编号": commodityMember.Co_bar_code = name; break; case "商品分类": commodityMember.Co_type = name; break; } existTableViewModel.commodity = commodityBusinessLayer.GetCommodities(commodityMember).FirstOrDefault(); //storageViewModel.existTableListViewModel.existTableViewModels.Add(existTableViewModel); existTableViewModels.Add(existTableViewModel); } //每页显示多少条 //int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]); storageViewModel.existTableListViewModel.existTableViewModels = existTableViewModels; return(storageViewModel); }
//[HttpGet] public ActionResult RedirectStorage(int?page) { MyStorageBusinessLayer storageBusinessLayer = new MyStorageBusinessLayer(); //判断是否为管理员,是管理员则为空,不是则为none,对应修改按钮是否显示 bool Display = (level.Admin == (level)Session["level"]); //获取显示的数据 StorageViewModel storageViewMode1; int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]); int pageNumber = page ?? 1; while (IsSearchExist) { //获取user id string U_id = null; if (!S_userMember.Equals(new UserMember())) { if (S_userMember.U_Id != "" || S_userMember.U_name != "") { UserBusinessLayer userBusinessLayer = new UserBusinessLayer(); List <User> users = userBusinessLayer.GetUsers(S_userMember); if (users == null) { break; } U_id = users.FirstOrDefault().U_Id.ToString(); } } //获取全部exist的数据 storageViewMode1 = storageBusinessLayer.GetStorageViewModel(Display, Session["User"].ToString(), pageNumber); //获取comm id集合 List <Commodity> commodities = new List <Commodity>(); if (!S_commodityMember.Equals(new CommodityMember())) { CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer(); commodities = commodityBusinessLayer.GetCommodities(S_commodityMember); } //获取ware id集合 List <Warehouse> warehouses = new List <Warehouse>(); if (!S_warehouseMember.Equals(new WarehouseMember())) { WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer(); warehouses = warehouseBusinessLayer.GetWarehouse(S_warehouseMember); } bool[] k = new bool[4]; ExistTableViewModel existTableViewModel; for (int i = storageViewMode1.existTableListViewModel.existTableViewModels.Count() - 1; i >= 0; i--) { k[0] = k[1] = k[2] = k[3] = true; existTableViewModel = storageViewMode1.existTableListViewModel.existTableViewModels[i]; //是否符合物品条件 if (U_id == null || existTableViewModel.exist.U_id.ToString() == U_id) { k[0] = false; } //是否符合物品条件 if (commodities != null && commodities.Count() > 0) { foreach (Commodity commodity in commodities) { if (commodity.Co_Id == existTableViewModel.exist.Co_id) { k[1] = false; break; } } } else { k[1] = false; } //是否符合仓库条件 if (warehouses != null && warehouses.Count() > 0) { foreach (Warehouse warehouse in warehouses) { if (warehouse.Wa_Id == existTableViewModel.exist.W_id) { k[2] = false; break; } } } else { k[2] = false; } //是否符合时间区间 DateTime dateTime = new DateTime(); if ((S_existMember.Star_date.Equals(dateTime.ToString()) || DateTime.Compare(Convert.ToDateTime(S_existMember.Star_date), existTableViewModel.exist.IntoDate) != 1) && (S_existMember.End_date.Equals(dateTime.ToString()) || DateTime.Compare(Convert.ToDateTime(S_existMember.End_date), existTableViewModel.exist.IntoDate) != -1)) { k[3] = false; } //整合条件 if (k[0] || k[1] || k[2] || k[3]) { storageViewMode1.existTableListViewModel.existTableViewModels.Remove(existTableViewModel); } } // storageViewMode1 = storageBusinessLayer.GetStorageViewModel(Display, Session["User"].ToString()); storageViewMode1.existTableListViewModel.iPagedLists = storageViewMode1.existTableListViewModel.existTableViewModels.ToPagedList(pageNumber, pageSize); return(View("Storage", storageViewMode1)); } storageViewMode1 = storageBusinessLayer.GetStorageViewModel(Display, Session["User"].ToString()); storageViewMode1.existTableListViewModel.iPagedLists = storageViewMode1.existTableListViewModel.existTableViewModels.ToPagedList(pageNumber, pageSize); return(View("Storage", storageViewMode1)); }
public ActionResult Save(List <Item> ware, List <Item_Consignment> itemcon, List <Consignment> con) { int conid = -1; List <ItemsSlotter> isl = new List <ItemsSlotter>(); foreach (Consignment conn in con) { WarehouseBusinessLayer wbl = new WarehouseBusinessLayer(); int warehouseIdd = wbl.getWarehouseId(Convert.ToInt32(Session["UserID"])); conn.warehouseId = warehouseIdd; conn.consignmentStatus = "Added"; try { conid = db.Consignments.Max(u => u.id) + 1; } catch (Exception ex) { conid = 1; } conn.id = conid; cbl.addConsignment(conn); int index = 0; foreach (Item_Consignment ic in itemcon) { Item items = ware.ElementAt(index); ic.itemId = getNewOrOldId(items); ItemsSlotter itemslot = new ItemsSlotter(); itemslot.item_id = ic.itemId; itemslot.quantity = (int)ic.quantity; // itemslot.expiry_date = ic.expiry.Value.ToShortDateString(); Item it = db.Items.FirstOrDefault(a => a.id == itemslot.item_id); itemslot.item_name = it.itemName; bool val = db.Item_Warehouse.Any(o => o.itemId == ic.itemId && o.warehouseId == warehouseIdd); if (val == true) { Item_Warehouse iw = db.Item_Warehouse.FirstOrDefault(a => a.itemId == ic.itemId && a.warehouseId == warehouseIdd); iw.quantity += ic.quantity; cbl.updateItemWarehouse(iw); itemslot.quantity = (int)iw.quantity; // found = true; //TODO: ADO.NET CODE } else { Item_Warehouse iw = new Item_Warehouse(); iw.warehouseId = warehouseIdd; iw.itemId = ic.itemId; iw.quantity = ic.quantity; iw.orders = 0; cbl.addItemWarehouse(iw); itemslot.quantity = (int)iw.quantity; } ic.consignmentId = conid; cbl.addItem_Consignment(ic); isl.Add(itemslot); index++; } //Yaha pe SLotting Horae ha List <Shelf> newShelf = db.Shelves.Where(a => a.warehouse_id == warehouseIdd).ToList(); Slotting slotting = new Slotting(); bool isError = slotting.slotting(newShelf, isl); if (isError) { ViewBag.throwError = "Unfortunately, there is no space in warehouse for the new items"; } List <String> instructionList = slotting.instructionsList; JavaScriptSerializer jss = new JavaScriptSerializer(); string inst = jss.Serialize(instructionList); SlottingBusinessLayer sbl = new SlottingBusinessLayer(); sbl.UpdateConsignmentInstruction(conid, inst); List <String> shelfInserted = slotting.shelfInserted.Distinct().ToList(); string insertedShelfJSON = jss.Serialize(shelfInserted); WarehouseDBEntities wdb = new WarehouseDBEntities(); Consignment consignment = wdb.Consignments.Find(conid); consignment.consignmentStatus = "Added"; consignment.shelfInserted = insertedShelfJSON; wdb.Entry(consignment).State = EntityState.Modified; wdb.SaveChanges(); Session["consignmentID"] = conid; break; } return(RedirectToAction("LoggedIn", "Account")); }