Ejemplo n.º 1
0
        private static HistoryParam CreateHistoryParameter(InOutParam param, double oldQty, double newQty)
        {
            HistoryParam p = new HistoryParam();

            p.InOrOut       = param.InOrOut;
            p.ItemToMonitor = param.Item;
            p.OldQty        = oldQty;
            p.NewQty        = newQty;

            p.InOutQty = param.Qty;
            p.Note     = param.Note;
            p.Name     = param.Name;

            return(p);
        }
Ejemplo n.º 2
0
        private static HistoryParam CreateHistoryParameterForReturnedItems(ReturnInOutParam param
                                                                           , double oldQty, double newQty)
        {
            HistoryParam p = new HistoryParam();

            p.InOrOut       = param.InOrOut;
            p.ItemToMonitor = param.ReturnedItem.Item;
            p.OldQty        = oldQty;
            p.NewQty        = newQty;

            p.InOutQty   = param.ReturnedItem.Qty;
            p.Note       = param.Note;
            p.DR         = param.ReturnedItem.ReturnedHistory.DR;
            p.IsMistaken = true;
            p.Name       = param.Name;

            return(p);
        }
Ejemplo n.º 3
0
        private static HistoryParam CreateHistoryParameterWithDr(InOutDRParam inParam
                                                                 , double oldQty, double newQty)
        {
            HistoryParam p = new HistoryParam();

            p.InOrOut       = inParam.InOrOut;
            p.ItemToMonitor = inParam.DRItem.Item;
            p.OldQty        = oldQty;
            p.NewQty        = newQty;

            p.InOutQty = inParam.DRItem.Qty;
            p.Note     = inParam.Note;
            p.DR       = inParam.DRItem.DR;
            p.Name     = inParam.Name;

            if (inParam.DRItem.DR != null)
            {
                p.Type = inParam.DRItem.DR.Type;
            }

            return(p);
        }
Ejemplo n.º 4
0
        public async Task <PagedList <ReceiveInformationModel> > SearchWithPaginations(PaginationParams param, string userLogin, HistoryParam filterParam)
        {
            var receives = await _repoReceive.GetAll().Where(x => x.Status.Trim() == "2").ToListAsync();

            var products = await _repoProduct.GetAll().ToListAsync();

            var users = await _repoUser.GetAll().ToListAsync();

            var userCurrent = users.Where(x => x.ID.Trim() == userLogin.Trim()).FirstOrDefault();

            if (userCurrent.RoleID == 1)
            {
            }
            else if (userCurrent.RoleID == 2)
            {
                receives = receives.Where(x => x.DepID.Trim() == userCurrent.DepID.Trim()).ToList();
            }
            else if (userCurrent.RoleID == 3)
            {
                receives = receives.Where(x => x.UserID.Trim() == userLogin).ToList();
            }

            if (filterParam.UserID != null && filterParam.UserID != string.Empty)
            {
                receives = receives.Where(x => x.UserID.Trim() == filterParam.UserID.Trim()).ToList();
            }
            if (filterParam.From_Date != "" && filterParam.To_Date != "")
            {
                receives = receives.Where(x => x.Register_Date >= Convert.ToDateTime(filterParam.From_Date + " 00:00:00.000") &&
                                          x.Register_Date <= Convert.ToDateTime(filterParam.To_Date + " 23:59:59.997")).ToList();
            }

            var data = (from a in receives join b in products on a.ProductID.Trim() equals b.ID.Trim()
                        select new ReceiveInformationModel()
            {
                ID = a.ID,
                UserID = a.UserID,
                Accept_ID = a.Accept_ID,
                DepID = a.DepID,
                ProductID = a.ProductID,
                ProductName = b.Name,
                Qty = a.Qty,
                Register_Date = a.Register_Date,
                Accept_Date = a.Accept_Date,
                Updated_By = a.Updated_By,
                Status = a.Status,
                Updated_Time = a.Updated_Time
            }).OrderByDescending(x => x.Register_Date).ToList();

            return(PagedList <ReceiveInformationModel> .Create(data, param.PageNumber, param.PageSize));
        }
Ejemplo n.º 5
0
        public async Task <PagedList <ReceiveInformationModel> > SearchWithPaginations(PaginationParams param, string userLogin, HistoryParam filterParam)
        {
            var receives    = _repoReceive.FindAll(x => x.Status.Trim() != "-1");
            var products    = _repoProduct.FindAll();
            var users       = _repoUser.FindAll();
            var departments = _repoDepartment.FindAll();
            var userCurrent = _repoUser.FindSingle(x => x.ID.Trim() == userLogin.Trim());

            if (userCurrent.RoleID == 0 || userCurrent.RoleID == 1)
            {
            }
            else if (userCurrent.RoleID == 2)
            {
                receives = receives.Where(x => x.DepID.Trim() == userCurrent.DepID.Trim() &&
                                          x.Status.Trim() != "2");
            }
            else if (userCurrent.RoleID == 3)
            {
                receives = receives.Where(x => x.UserID.Trim() == userLogin);
            }

            if (filterParam.UserID != null && filterParam.UserID != string.Empty)
            {
                receives = receives.Where(x => x.UserID.Trim() == filterParam.UserID.Trim());
            }
            if (filterParam.From_Date != "" && filterParam.To_Date != "")
            {
                receives = receives.Where(x => x.Register_Date >= Convert.ToDateTime(filterParam.From_Date + " 00:00:00.000") &&
                                          x.Register_Date <= Convert.ToDateTime(filterParam.To_Date + " 23:59:59.997"));
            }
            if (filterParam.ProductID != null && filterParam.ProductID != string.Empty)
            {
                var receiveDetails = _repoReceiveDetail.FindAll(x => x.ProductID.Trim() == filterParam.ProductID.Trim()).
                                     GroupBy(x => x.ReceiveID).Select(x => x.Key);
                receives = receives.Where(x => receiveDetails.Contains(x.ID.Trim()));
            }
            if (filterParam.Status != null && filterParam.Status != string.Empty)
            {
                receives = receives.Where(x => x.Status.Trim() == filterParam.Status.Trim());
            }
            var data = await(from a in receives
                             join c in departments on a.DepID.Trim() equals c.ID.Trim()
                             join d in users on a.UserID.Trim() equals d.ID.Trim()
                             select new ReceiveInformationModel()
            {
                ID            = a.ID,
                UserID        = a.UserID,
                UserName      = d.Name,
                Accept_ID     = a.Accept_ID,
                DepID         = a.DepID,
                DepName       = c.Name_LL,
                DepName_ZW    = c.Name_ZW,
                Register_Date = a.Register_Date,
                Accept_Date   = a.Accept_Date,
                Updated_By    = a.Updated_By,
                Status        = a.Status.Trim(),
                Updated_Time  = a.Updated_Time
            }).OrderByDescending(x => x.Register_Date).ToListAsync();

            foreach (var item in data)
            {
                if (item.Accept_ID != null)
                {
                    var userAccept = users.Where(x => x.ID.Trim() == item.Accept_ID.Trim()).FirstOrDefault();
                    if (userAccept != null)
                    {
                        item.AcceptName = userAccept.Name;
                    }
                }
            }
            return(PagedList <ReceiveInformationModel> .Create(data, param.PageNumber, param.PageSize));
        }
        public async Task <IActionResult> SearchHistory([FromQuery] PaginationParams param, HistoryParam filterParam)
        {
            var user = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var data = await _service.SearchWithPaginations(param, user, filterParam);

            Response.AddPagination(data.CurrentPage, data.PageSize, data.TotalCount, data.TotalPages);
            return(Ok(data));
        }