Exemplo n.º 1
0
        public object GetDetails(int page, int rows, string DeliverLineCode, string CustomCode, string DeliverLineName, string DistCode, string DeliverOrder, string IsActive)
        {
            IQueryable <DeliverLine> deliverLineQuery = DeliverLineRepository.GetQueryable();
            var deliverLine = deliverLineQuery.Where(c => c.DeliverLineCode.Contains(DeliverLineCode) &&
                                                     c.DeliverLineName.Contains(DeliverLineName) &&
                                                     c.IsActive.Contains(IsActive) &&
                                                     c.IsActive.Contains(IsActive));

            if (!CustomCode.Equals(string.Empty))
            {
                deliverLine = deliverLine.Where(d => d.CustomCode == CustomCode);
            }
            if (!DistCode.Equals(string.Empty))
            {
                deliverLine = deliverLine.Where(d => d.DistCode == DistCode);
            }
            deliverLine = deliverLine.OrderBy(h => h.DeliverLineCode);
            int total = deliverLine.Count();

            deliverLine = deliverLine.Skip((page - 1) * rows).Take(rows);

            var temp = deliverLine.ToArray().Select(c => new
            {
                DeliverLineCode = c.DeliverLineCode,
                CustomCode      = c.CustomCode,
                DeliverLineName = c.DeliverLineName,
                DistCode        = c.DistCode,
                DeliverOrder    = c.DeliverOrder,
                Description     = c.Description,
                IsActive        = c.IsActive == "1" ? "可用" : "不可用",
                UpdateTime      = c.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")
            });

            return(new { total, rows = temp.ToArray() });
        }
Exemplo n.º 2
0
        public bool Delete(string DeliverLineCode)
        {
            var deliver_Line = DeliverLineRepository.GetQueryable()
                               .FirstOrDefault(i => i.DeliverLineCode == DeliverLineCode);

            if (DeliverLineCode != null)
            {
                DeliverLineRepository.Delete(deliver_Line);
                DeliverLineRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
 public bool Edit(DeliverLine deliverLine, out string strResult)
 {
     strResult = string.Empty;
     try
     {
         var deliver_line = DeliverLineRepository.GetQueryable().FirstOrDefault(i => i.DeliverLineCode == deliverLine.DeliverLineCode);
         deliver_line.DeliverLineCode = deliverLine.DeliverLineCode;
         deliver_line.CustomCode      = deliverLine.CustomCode;
         deliver_line.DeliverLineName = deliverLine.DeliverLineName;
         deliver_line.DistCode        = deliverLine.DistCode;
         deliver_line.DeliverOrder    = deliverLine.DeliverOrder;
         deliver_line.Description     = deliverLine.Description;
         deliver_line.IsActive        = deliverLine.IsActive;
         deliver_line.UpdateTime      = DateTime.Now;
         DeliverLineRepository.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         strResult = "原因:" + ex.InnerException;
         return(false);
     }
 }
Exemplo n.º 4
0
        public bool DownDeliverLine(out string errorInfo)
        {
            errorInfo = string.Empty;
            bool result = false;

            try
            {
                var    deliverLineCodes = DeliverLineRepository.GetQueryable().Where(d => d.DeliverLineCode == d.DeliverLineCode).Select(s => new { s.DeliverLineCode }).ToArray();
                string deliverStrs      = "";
                for (int i = 0; i < deliverLineCodes.Length; i++)
                {
                    deliverStrs += deliverLineCodes[i].DeliverLineCode + ",";
                }
                DeliverLine[] deliverLines = DeliverLineDownService.GetDeliverLine(deliverStrs);
                foreach (var item in deliverLines)
                {
                    var deliverLine = new DeliverLine();
                    deliverLine.DeliverLineCode = item.DeliverLineCode;
                    deliverLine.DeliverLineName = item.DeliverLineName;
                    deliverLine.DeliverOrder    = item.DeliverOrder;
                    deliverLine.Description     = item.Description;
                    deliverLine.DistCode        = item.DistCode;
                    deliverLine.CustomCode      = item.CustomCode;
                    deliverLine.IsActive        = item.IsActive;
                    deliverLine.UpdateTime      = item.UpdateTime;
                    DeliverLineRepository.Add(deliverLine);
                }
                DeliverLineRepository.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
                errorInfo = "出错,原因:" + e.Message;
            }
            return(result);
        }