Пример #1
0
        public static SimpleJson GetWHInfo(ISession session, string area, string section)
        {
            if (string.IsNullOrEmpty(area) || area.Trim().Length <= 0)
            {
                return(new SimpleJson().HandleError("您没有选择库位"));
            }

            string     a    = area.Trim().ToUpper();
            string     sec  = string.IsNullOrEmpty(section) ? "" : section.Trim().ToUpper();
            SimpleJson json = new SimpleJson().Add("area", area).Add("section", sec);

            if (sec.Length <= 0)
            {
                //加载库位信息
                WHArea whArea = WHArea.Retrieve(session, a);
                if (whArea == null)
                {
                    return(json.HandleError("库位" + a + "不存在"));
                }
                json.Add("capacity", Cast.Int(whArea.AreaCapacity));
                int stoQty = Cast.Int(session.CreateObjectQuery(@"select sum(StockQty) from StockDetail where AreaCode=?area group by AreaCode")
                                      .Attach(typeof(StockDetail))
                                      .SetValue("?area", a, "AreaCode")
                                      .Scalar());
                json.Add("stored", stoQty);
            }
            else
            {
                //加载货架信息
                WHSection whSection = WHSection.Retrieve(session, a, sec);
                if (whSection == null)
                {
                    return(json.HandleError("库位" + a + "中不存在货架号" + sec));
                }
                json.Add("capacity", Cast.Int(whSection.SectionCapacity));
                int stoQty = Cast.Int(session.CreateObjectQuery(@"
select sum(StockQty) from StockDetail 
where AreaCode=?area and SectionCode=?section
group by AreaCode")
                                      .Attach(typeof(StockDetail))
                                      .SetValue("?area", a, "AreaCode")
                                      .SetValue("?section", sec, "SectionCode")
                                      .Scalar());
                json.Add("stored", stoQty);
            }
            return(json);
        }
Пример #2
0
        public static SimpleJson GetJSON(ISession session, string areaCode, string sectionCode)
        {
            WHSection section = WHSection.Retrieve(session, areaCode, sectionCode);

            if (section == null)
            {
                return(new SimpleJson().HandleError(string.Format("存储区域{0}中的货架{1}不存在", areaCode, sectionCode)));
            }
            SimpleJson json = new SimpleJson()
                              .Add("parent", section.AreaCode)
                              .Add("type", "s")
                              .Add("code", section.SectionCode)
                              .Add("status", (int)section.Status)
                              .Add("desc", section.Text)
                              .Add("cap", section.SectionCapacity)
                              .Add("allowdelete", "1")
                              .Add("allowchild", "0")
                              .Add("parentType", "a")
                              .Add("text", section.ToString());

            return(json);
        }