Esempio n. 1
0
        public List <v_saleforcast> GetSaleForcast(string CusID, string CusName, string SaleFocaNO, string State, string SDate, string EDate, int pagesize, int currentPage, string orderby, string order, out int total)
        {
            try
            {
                List <v_saleforcast> list = new List <v_saleforcast>();
                var tem = from f in erpsEntities.v_saleforcast.AsNoTracking()
                          select f;
                if (!string.IsNullOrEmpty(SaleFocaNO))
                {
                    tem = tem.Where(w => w.SaleFocaNO.Contains(SaleFocaNO));
                }
                if (!string.IsNullOrEmpty(CusID))
                {
                    tem = tem.Where(w => w.CusID.Contains(CusID));
                }
                if (!string.IsNullOrEmpty(CusName))
                {
                    tem = tem.Where(w => w.CusName.Contains(CusName));
                }
                if (!string.IsNullOrEmpty(State))
                {
                    tem = tem.Where(w => w.State.Contains(State));
                }
                if (!string.IsNullOrEmpty(SDate))
                {
                    DateTime date = Convert.ToDateTime(SDate);
                    tem = tem.Where(w => w.CreDate >= date);
                }
                if (!string.IsNullOrEmpty(EDate))
                {
                    DateTime date = Convert.ToDateTime(EDate);
                    date = date.AddDays(1);
                    tem  = tem.Where(w => w.CreDate < date);
                }
                if (string.IsNullOrEmpty(orderby) || string.IsNullOrEmpty(order)) // 没有排序信息,直接按预警排序
                {
                    tem = tem.OrderByDescending(o => o.CreateDate);
                }
                else
                {
                    string orderPhase = "ASC";
                    if (order.ToLower() == "descending")
                    {
                        orderPhase = "DESC";
                    }
                    tem = Tool.SetQueryableOrder(tem, orderby, orderPhase);
                }

                total = tem.Count();

                tem = tem
                      .Skip(pagesize * (currentPage - 1))
                      .Take(pagesize);
                list = tem.ToList();
                return(list);
            }
            catch (Exception)
            {
                throw;
            }
        }