示例#1
0
        public ActionResult Insert(int produceId, string[] codes)
        {
            var produce = _produceDa.GetById(produceId);

            //produce.ProduceProductPrepares.Clear();
            foreach (var code in codes)
            {
                if (!_carProductDetailDa.CheckEsixt(code))
                {
                    return(Json(new JsonMessage()
                    {
                        Erros = true,
                        Message = $"Mã {code} không tồn tại"
                    }));
                }

                var item = new ProduceProductPrepare()
                {
                    ProductId  = produce.ProductId,
                    Code       = code,
                    UserId     = Userid.Value,
                    DateCreate = ConvertDate.TotalSeconds(DateTime.Now),
                    ProduceId  = produceId,
                    Isdelete   = false
                };
                produce.ProduceProductPrepares.Add(item);
            }

            produce.Status = (int)ProduceStatus.GetProduct;

            _produceDa.Save();
            return(Json(new JsonMessage()));
        }
示例#2
0
        public List <DNRequestWareHouseItem> GetListSimpleStaticByRequest(HttpRequestBase httpRequest, int area)
        {
            Request = new ParramRequest(httpRequest);
            var date = ConvertDate.TotalSeconds(DateTime.Today);

            var query = from o in FDIDB.DN_RequestWare
                        where (!o.IsDelete.HasValue || o.IsDelete == false) &&
                        (area == 0 || o.AreaID == area) && o.Today > date
                        group o by new
            {
                o.Hour,
                o.CateID
            } into g
            orderby g.Key descending
                select new DNRequestWareHouseItem
            {
                GID = g.Select(c => c.GID).FirstOrDefault(),
                //Marketname = g.Select(c => c.Market.Name).FirstOrDefault(),
                Today          = g.Select(c => c.Today).FirstOrDefault(),
                Hours          = g.Select(c => c.Hour).FirstOrDefault(),
                QuantityActive = g.Sum(c => c.QuantityActive),
                ProductName    = g.Select(c => c.Category.Name).FirstOrDefault(),
            };
            var hours = httpRequest["hours"];

            if (!string.IsNullOrEmpty(hours))
            {
                var h = int.Parse(hours);
                query = query.Where(c => c.Hours == h);
            }
            query = query.SelectByRequest(Request, ref TotalRecord);
            return(query.ToList());
        }
示例#3
0
        public SWItem GetStorageByID(int agencyId, int id)
        {
            var date  = ConvertDate.TotalSeconds(DateTime.Now.AddHours(12));
            var query = from o in FDIDB.StorageWarehousings
                        where o.AgencyId == agencyId && (!o.IsDelete.HasValue || !o.IsDelete.Value) && o.ID == id
                        select new SWItem
            {
                id      = o.ID,
                n       = o.Name,
                d       = o.DateRecive ?? 0,
                LstItem = o.DN_RequestWare.Select(m => new DNRWHItem
                {
                    //id = m.GID,
                    h = m.Hour ?? 0,
                    //d = m.Day ?? 0,
                    q = m.Quantity ?? 0,
                    s = date < (m.Today + m.Day * 86400 + m.Hour * 3600),
                })
            };
            var obj = query.FirstOrDefault() ?? new SWItem {
                d = ConvertDate.TotalSeconds(DateTime.Today.AddDays(1))
            };

            obj.LstTimes = TypeTime.Hours(obj.d, date);
            return(obj);
        }
示例#4
0
        public List <StorageWarehousingItem> GetListSimpleByRequest(HttpRequestBase httpRequest)
        {
            Request = new ParramRequest(httpRequest);
            var from     = httpRequest["fromDate"];
            var to       = httpRequest["toDate"];
            var fromDate = !string.IsNullOrEmpty(from) ? ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(from)) : 0;
            var toDate   = !string.IsNullOrEmpty(from) ? ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(to)) : ConvertDate.TotalSeconds(DateTime.Now.AddDays(1));
            var query    = from o in FDIDB.StorageWarehousings
                           where o.DateCreated >= fromDate && o.DateCreated <= toDate &&
                           (!o.IsDelete.HasValue || o.IsDelete == false)
                           orderby o.ID descending
                           select new StorageWarehousingItem()
            {
                ID         = o.ID,
                Code       = o.Code,
                TotalPrice = o.TotalPrice ?? 0,
                //Payment = o.Payment ?? 0,
                DateCreated = o.DateCreated,
                //DateImport = o.DateImport,
                //UserID = o.UserID,
                //Note = o.Note,
                //HoursRecive = o.HoursRecive,
                IsDelete = o.IsDelete,
                //IsActive = o.IsActive,
                Status     = o.Status,
                DateRecive = o.DateRecive,
                Users      = o.StorageWarehousingUsers.Select(m => new UserItem()
                {
                    UserId = m.UserId.Value, Name = m.DN_Users.LoweredUserName, UserName = m.DN_Users.UserName
                }),
                //CustomerName = o.Customer.UserName
                AgencyName = o.DN_Agency.Name
                             //UsernameActive = o.DN_Users1.UserName,
                             //DateActive = o.DateActive,
                             //UsernameCreate = o.DN_Users.UserName,
            };
            var status = httpRequest["IsDelete"];

            if (!string.IsNullOrEmpty(status))
            {
                var tus = int.Parse(status);
                query = query.Where(c => c.Status == tus);
            }
            var hours = httpRequest["hours"];

            if (!string.IsNullOrEmpty(hours))
            {
                var h = int.Parse(hours);
                query = query.Where(c => c.HoursRecive == h);
            }

            //ParramRequest parramRequest = Request;
            //if (parramRequest.SearchInField.IsNullOrEmpty())
            //{
            //    query = query.Where(m=>m.CustomerName)
            //}
            query = query.SelectByRequest(Request, ref TotalRecord);
            return(query.ToList());
        }
示例#5
0
        //
        // GET: /Produce/

        public ActionResult Index(decimal?todayCode)
        {
            if (todayCode == null)
            {
                return(RedirectToAction("Index", new { todayCode = ConvertDate.TotalSeconds(DateTime.Now.AddDays(1).Date) }));
            }
            return(View(todayCode.Value));
        }
示例#6
0
        public IList <DNRequestWareHouseItem> GetRequestWareSummary(HttpRequestBase httpRequest)
        {
            Request = new ParramRequest(httpRequest);
            var toDay    = httpRequest["ToDay"];
            var fromDate = !string.IsNullOrEmpty(toDay) ? ConvertDate.TotalSeconds(ConvertDate.StringToDate(toDay)) : 0;

            var queryRequest = from c in FDIDB.DN_RequestWare
                               group c by new { c.Today, c.CateID, c.Category.Name }
            into g
                select new
            {
                ToDay       = g.Key.Today,
                CateID      = g.Key.CateID,
                ProductName = g.Key.Name,
                Quantity    = g.Sum(m => m.Quantity)
            };

            var queryBuy = from c in FDIDB.TotalProductToDays
                           group c by new { c.ToDayCode, c.ProductId, c.Category.Name } into g
                select new
            {
                ToDayCode   = g.Key.ToDayCode,
                ProductName = g.Key.Name,
                ProductId   = g.Key.ProductId,
                Quantity    = g.Sum(m => m.Quantity)
            };

            var query = queryRequest.GroupJoin(queryBuy, x =>
                                               new DNRequestWareHouseKey {
                ToDay = x.ToDay, ProductId = x.CateID
            },
                                               y => new DNRequestWareHouseKey {
                ToDay = y.ToDayCode, ProductId = y.ProductId
            },
                                               (a, b) => new
            {
                a,
                b
            }).SelectMany(x => x.b.DefaultIfEmpty(), (x, y) => new DNRequestWareHouseItem()
            {
                Today          = x.a.ToDay,
                CateID         = x.a.CateID,
                ProductName    = x.a.ProductName,
                QuantityActive = y.Quantity,
                Quantity       = x.a.Quantity
            });

            query = query.OrderByDescending(m => m.Today).SelectByRequest(Request, ref TotalRecord);
            return(query.ToList());
        }
示例#7
0
        public List <StorageWarehousingItem> GetListExcel(HttpRequestBase httpRequest, int agencyId)
        {
            Request = new ParramRequest(httpRequest);
            var from     = httpRequest["fromDate"];
            var to       = httpRequest["toDate"];
            var fromDate = !string.IsNullOrEmpty(from) ? ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(from)) : 0;
            var toDate   = !string.IsNullOrEmpty(from) ? ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(to)) : ConvertDate.TotalSeconds(DateTime.Now.AddDays(1));
            var query    = from o in FDIDB.StorageWarehousings
                           where (!o.IsDelete.HasValue || o.IsDelete == false) && o.DateCreated >= fromDate && o.DateCreated <= toDate &&
                           o.Status == 1

                           orderby o.DateCreated descending
                           select new StorageWarehousingItem()
            {
                ID          = o.ID,
                TotalPrice  = o.TotalPrice ?? 0,
                DateCreated = o.DateCreated,
                IsDelete    = o.IsDelete,
                DateRecive  = o.DateRecive,
                Status      = o.Status,
                LstImport   = from v in o.DN_RequestWare
                              select new DNRequestWareHouseItem()
                {
                    GID         = v.GID,
                    Date        = v.Date,
                    ProductName = v.Category.Name,
                    CateID      = v.CateID,
                    Quantity    = v.Quantity,
                    Price       = v.Price,
                    IsDelete    = v.IsDelete,
                    TotalPrice  = v.TotalPrice,
                },
            };
            var status = httpRequest["IsDelete"];

            if (!string.IsNullOrEmpty(status))
            {
                var tus = int.Parse(status);
                query = query.Where(c => c.Status == tus);
            }
            var hours = httpRequest["hours"];

            if (!string.IsNullOrEmpty(hours))
            {
                var h = int.Parse(hours);
                query = query.Where(c => c.HoursRecive == h);
            }
            return(query.ToList());
        }
示例#8
0
        public List <SWItem> ListStorageByUser(HttpRequestBase httpRequest, int agencyId)
        {
            var date  = ConvertDate.TotalSeconds(DateTime.Now.AddHours(12));
            var query = from o in FDIDB.StorageWarehousings
                        where o.AgencyId == agencyId && (!o.IsDelete.HasValue || !o.IsDelete.Value)
                        orderby o.ID descending
                        select new SWItem
            {
                id = o.ID,
                n  = o.Name,
                d  = o.DateRecive ?? 0,
                s  = o.DN_RequestWare.Any(m => m.DateEnd > date)
            };

            return(query.SelectByRequest(Request, ref TotalRecord).ToList());
        }
示例#9
0
        public List <DNRequestWareHouseItem> GetListSimpleAllByRequest(HttpRequestBase httpRequest, int area)
        {
            Request = new ParramRequest(httpRequest);
            var from  = httpRequest["fromDate"];
            var query = from o in FDIDB.DN_RequestWare
                        where (!o.IsDelete.HasValue || o.IsDelete == false) &&
                        o.AreaID == area
                        //    && o.StorageProductID == 1
                        orderby o.Hour descending
                        select new DNRequestWareHouseItem
            {
                GID            = o.GID,
                ProductName    = o.Category.Name,
                Today          = o.Today,
                Hours          = o.Hour,
                DateUpdate     = o.DateUpdate,
                UserUpdate     = o.UserUpdate,
                Quantity       = o.Quantity,
                QuantityActive = o.QuantityActive,
                //Usercreate = o.StorageWarehousing.DN_Users.LoweredUserName,
                Date = o.Date,
            };

            if (!string.IsNullOrEmpty(from))
            {
                var fromDate = ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(from));
                query = query.Where(c => c.Today == fromDate);
            }
            var hours = httpRequest["hours"];

            if (!string.IsNullOrEmpty(hours))
            {
                var h = int.Parse(hours);
                query = query.Where(c => c.Hours == h);
            }
            query = query.SelectByRequest(Request, ref TotalRecord);
            return(query.ToList());
        }