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);
            }
        }
        // GET: Items
        public ActionResult Index()
        {
            int warehouseIdd = wbl.getWarehouseId(Convert.ToInt32(Session["UserID"]));

            ViewBag.PageName = "Consignments";
            return(View(db.Item_Warehouse.Where(a => a.warehouseId == warehouseIdd).ToList()));
        }
        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 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));
        }
Beispiel #5
0
        // 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 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));
        }
Beispiel #7
0
        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"));
        }
        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);
        }
Beispiel #9
0
        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"]) }));
        }
Beispiel #10
0
        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"));
        }
        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"));
        }