Exemplo n.º 1
0
        public void GetLiveItemsQuantity()
        {
            try
            {
                ItemQuantityList = new List <ItemQuantityDTO>();

                var criteria = new SearchCriteria <ItemQuantityDTO>()
                {
                    CurrentUserId = Singleton.User.UserId
                };

                if (SelectedWarehouse != null && SelectedWarehouse.Id != -1)
                {
                    criteria.SelectedWarehouseId = SelectedWarehouse.Id;
                }

                int totalCount;
                ItemQuantityList = _itemQuantityService.GetAll(criteria, out totalCount).ToList();

                if (OnlyOnOrderChecked)
                {
                    ItemQuantityList = ItemQuantityList.Where(q => q.QuantityOnOrder > 0).ToList();
                }

                if (OnlyOnDeliveryChecked)
                {
                    ItemQuantityList = ItemQuantityList.Where(q => q.QuantityOnDelivery > 0).ToList();
                }

                if (OnlyOnReservationChecked)
                {
                    ItemQuantityList = ItemQuantityList.Where(q => q.QuantityReserved > 0).ToList();
                }

                //if (SelectedWarehouse != null && SelectedWarehouse.Id != -1)
                //{
                //    var items = new ItemService(true).GetAll().OrderBy(i => i.Id).ToList();
                //    var itemsQty = (from itemDTO in items
                //                    where ItemQuantityList.All(iq => iq.ItemId != itemDTO.Id)
                //                    select new ItemQuantityDTO()
                //                    {
                //                        Item = itemDTO,
                //                        QuantityOnHand = 0,
                //                        ItemId = itemDTO.Id,
                //                        Warehouse = SelectedWarehouse
                //                    }).ToList();

                //    ItemQuantityList = ItemQuantityList.Concat(itemsQty);
                //}

                ItemsQuantity = new ObservableCollection <ItemQuantityDTO>(ItemQuantityList.OrderBy(i => i.Item.CategoryId));
            }
            catch (Exception exception)
            {
                MessageBox.Show("Can't load inventory, please refresh window again..."
                                + Environment.NewLine + exception.Message, "Can't Load Inventory", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
        public void GetLiveItemsQuantity()
        {
            try
            {
                CleanUp();
                _itemQuantityService = new ItemQuantityService();

                ItemQuantityList = new List <ItemQuantityDTO>();

                var criteria = new SearchCriteria <ItemQuantityDTO>()
                {
                    CurrentUserId = Singleton.User.UserId
                };
                //criteria.FiList.Add(f => f.Item.ItemType == ItemTypes.PurchaseForSell || f.Item.ItemType == ItemTypes.ProcessForSell);

                if (SelectedWarehouse != null && SelectedWarehouse.Id != -1)
                {
                    criteria.SelectedWarehouseId = SelectedWarehouse.Id;
                }

                int totalCount;
                ItemQuantityList = _itemQuantityService.GetAll(criteria, out totalCount).ToList();

                //if (SelectedWarehouse != null && SelectedWarehouse.Id != -1)
                //{
                //    var items = new ItemService(true).GetAll().Where(i => i.ItemType == ItemTypes.PurchaseForSell || i.ItemType == ItemTypes.ProcessForSell).OrderBy(i => i.Id).ToList();
                //    var itemsQty = (from itemDto in items
                //                    where ItemQuantityList.All(iq => iq.ItemId != itemDto.Id)
                //                    select new ItemQuantityDTO()
                //                    {
                //                        Item = itemDto,
                //                        ItemId = itemDto.Id,
                //                        Warehouse = SelectedWarehouse,
                //                        QuantityOnHand = 0
                //                    }).ToList();

                //    ItemQuantityList = ItemQuantityList.Concat(itemsQty);
                //}

                var sNo = 1;
                foreach (var itemQuantityDTO in ItemQuantityList)
                {
                    itemQuantityDTO.SerialNumber = sNo;
                    sNo++;
                }

                ItemsQuantity = new ObservableCollection <ItemQuantityDTO>(ItemQuantityList);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Can't load inventory, please refresh window again..."
                                + Environment.NewLine + exception.Message, "Can't Load Inventory", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Exemplo n.º 3
0
        public ActionResult Index(string searchText, int?page, int?pageSize, int?ptype, string categoryId, string filterByQuantity, string warehouseId)
        {
            try
            {
                FilterByQuantityList();
                var criteria = new SearchCriteria <ItemQuantityDTO>()
                {
                    CurrentUserId = Singleton.User.UserId
                };

                #region Search Text

                if (!string.IsNullOrEmpty(searchText))
                {
                    ViewData["ItemSearch"]       = "search results for '<strong style='font-size:14px;'>" + searchText + "</strong>'";
                    ViewData["SearchText"]       = searchText;
                    ViewData["ItemSearchHidden"] = "visible";
                }
                else
                {
                    ViewData["ItemSearch"]       = string.Empty;
                    ViewData["SearchText"]       = string.Empty;
                    ViewData["ItemSearchHidden"] = "hidden";
                }

                if (!string.IsNullOrEmpty(searchText))
                {
                    criteria.FiList.Add(
                        i => i.Item.ItemCode.Contains(searchText) || i.Item.DisplayName.Contains(searchText));
                }

                #endregion

                #region Filter By Warehouse

                int wareId;
                if (int.TryParse(warehouseId, out wareId) && wareId != 0 && wareId != -1)
                {
                    criteria.SelectedWarehouseId = wareId;
                    ViewData["WarehouseId"]      = wareId;
                }
                else
                {
                    ViewData["WarehouseId"] = string.Empty;
                }

                #endregion

                #region Filter By Category

                int catId;
                if (int.TryParse(categoryId, out catId) && catId != 0 && catId != -1)
                {
                    ViewData["CategoryId"] = categoryId;
                    criteria.FiList.Add(i => i.Item.CategoryId == catId);
                }
                else
                {
                    ViewData["CategoryId"] = "0";
                }

                #endregion

                #region Filter By Quantity

                int filByQty;
                if (int.TryParse(categoryId, out filByQty) && filByQty != 0)
                {
                    ViewData["FilterByQuantity"] = filterByQuantity;

                    switch (filByQty)
                    {
                    case 1:
                        criteria.FiList.Add(i => i.QuantityOnHand == 0);
                        break;

                    case 2:
                        criteria.FiList.Add(i => i.QuantityOnHand > 0);
                        break;

                    case 3:
                        criteria.FiList.Add(i => i.QuantityOnHand < i.Item.SafeQuantity);
                        break;

                    case 4:
                        criteria.FiList.Add(i => i.QuantityOnHand >= i.Item.SafeQuantity);
                        break;
                    }
                }
                else
                {
                    ViewData["FilterByQuantity"] = "0";
                }

                #endregion

                #region Paging

                if (page != null && ptype != null && pageSize != null)
                {
                    criteria.Page     = (int)(page + ptype);
                    criteria.PageSize = (int)pageSize;

                    if (criteria.Page < 1)
                    {
                        criteria.Page = 1;
                    }
                }
                else
                {
                    criteria.Page     = 1;
                    criteria.PageSize = 25;
                }

                if (criteria.Page == 1)
                {
                    ViewData["prevDisabled"] = "none";
                }
                ViewData["Page"]     = criteria.Page;
                ViewData["PageSize"] = criteria.PageSize;

                #endregion

                var totalCount = 0;
                var itemQts    = _itemQuantityService.GetAll(criteria, out totalCount).ToList();
                @ViewData["totalNumber"] = totalCount;

                #region Paging

                var pages = HelperUtility.GetPages(totalCount, criteria.PageSize);
                ViewData["totalPages"] = pages;
                if (pages == 0)
                {
                    criteria.Page    = 0;
                    ViewData["Page"] = 0;
                }
                if (criteria.Page == pages)
                {
                    ViewData["nextDisabled"] = "none";
                }

                #endregion

                #region For Serial Number

                var sNo = (criteria.Page - 1) * criteria.PageSize + 1;
                foreach (var businessPartnerDTO in itemQts)
                {
                    businessPartnerDTO.SerialNumber = sNo;
                    sNo++;
                }

                #endregion

                if (Request.IsAjaxRequest())
                {
                    //Thread.Sleep(3000);
                    return(PartialView("_onHandInventory", itemQts));
                }
                return(View(itemQts));
            }
            catch
            {
                return(HttpNotFound());
            }
        }