Beispiel #1
0
        public static SimpleJson GetJSON(ISession session, string areaCode)
        {
            WHArea area = WHArea.Retrieve(session, areaCode);

            if (area == null)
            {
                return(new SimpleJson().HandleError(string.Format("存储区域{0}不存在", areaCode)));
            }
            SimpleJson json = new SimpleJson()
                              .Add("type", "a")
                              .Add("code", area.AreaCode)
                              .Add("status", (int)area.Status)
                              .Add("name", area.Name)
                              .Add("desc", area.Text)
                              .Add("cap", area.AreaCapacity)
                              .Add("hassec", area.HasSection)
                              .Add("isqc", area.IsQC)
                              .Add("isnonformal", area.IsNonFormal)
                              .Add("isscrap", area.IsScrap)
                              .Add("allowdelete", area.AllowDelete)
                              .Add("allowchild", area.AllowChild)
                              .Add("text", area.ToString());

            if (!string.IsNullOrEmpty(area.ParentArea) && area.ParentArea.Trim().Length > 0)
            {
                json.Add("parentType", "a").Add("parent", area.ParentArea.Trim());
            }
            else
            {
                json.Add("parentType", "l").Add("parent", area.LocationCode.Trim());
            }
            return(json);
        }
Beispiel #2
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);
        }