Пример #1
0
 public static WHSection Row2Entity(DataRow row)
 {
     if (row == null) return null;
     WHSection section = new WHSection();
     section.AreaCode = Cast.String(row["AreaCode"]);
     section.SectionCode = Cast.String(row["SectionCode"]);
     section.Text = Cast.String(row["Text"]);
     section.Status = Cast.Enum<WHStatus>(row["Status"], WHStatus.Disable);
     section.SectionCapacity = Cast.Decimal(row["SectionCapacity"], 99999999M);
     return section;
 }
Пример #2
0
        public static WHSection Row2Entity(DataRow row)
        {
            if (row == null)
            {
                return(null);
            }
            WHSection section = new WHSection();

            section.AreaCode        = Cast.String(row["AreaCode"]);
            section.SectionCode     = Cast.String(row["SectionCode"]);
            section.Text            = Cast.String(row["Text"]);
            section.Status          = Cast.Enum <WHStatus>(row["Status"], WHStatus.Disable);
            section.SectionCapacity = Cast.Decimal(row["SectionCapacity"], 99999999M);
            return(section);
        }
Пример #3
0
 public WHSection GetSection(string areaCode, string sectionCode)
 {
     if (string.IsNullOrEmpty(sectionCode) || sectionCode.Trim().Length <= 0 || string.IsNullOrEmpty(areaCode) || areaCode.Trim().Length <= 0)
     {
         return(null);
     }
     DataRow[] rows = _ds.Tables["s"].Select("AreaCode='" + areaCode.Trim() + "' and SectionCode='" + sectionCode.Trim() + "'");
     if (rows != null && rows.Length > 0)
     {
         return(WHSection.Row2Entity(rows[0]));
     }
     else
     {
         return(null);
     }
 }
Пример #4
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);
        }
Пример #5
0
        public IList <WHSection> GetSections(string areaCode)
        {
            IList <WHSection> lists = new List <WHSection>();

            if (string.IsNullOrEmpty(areaCode) || areaCode.Trim().Length <= 0)
            {
                return(lists);
            }
            DataRow[] rows = _ds.Tables["s"].Select("AreaCode='" + areaCode.Trim() + "'", "SectionCode ASC");
            if (rows == null || rows.Length <= 0)
            {
                return(lists);
            }
            foreach (DataRow row in rows)
            {
                lists.Add(WHSection.Row2Entity(row));
            }
            return(lists);
        }
Пример #6
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);
        }
Пример #7
0
 private static SimpleJson SaveWHLoc()
 {
     string type = WebUtil.Param("type");
     if (type != "l" && type != "a" && type != "s")
         return new SimpleJson()
             .HandleError(string.Format("Invalidate type {0} in action SaveWHLoc", type));
     string opt = WebUtil.Param("opt");
     if (opt != "create" && opt != "update")
         return new SimpleJson()
             .HandleError("Invalidate operation in action SaveWHLoc");
     if (WebUtil.Param("code").Trim().Length <= 0)
         return new SimpleJson()
             .HandleError("Invalidate code in action SaveWHLoc");
     using (ISession session = new Session())
     {
         if (type == "l")
         {
             #region WHLocation
             WHLocation location = new WHLocation();
             location.LocationCode = WebUtil.Param("code").Trim();
             location.Name = WebUtil.Param("name").Trim();
             location.Status = Cast.Enum<WHStatus>(WebUtil.ParamInt("status", 1));
             location.Text = WebUtil.Param("desc").Trim();
             location.Address = WebUtil.Param("addr").Trim();
             location.ZipCode = WebUtil.Param("zipcode").Trim();
             location.Contact = WebUtil.Param("contact");
             location.Phone = WebUtil.Param("phone").Trim();
             location.FaxNumber = WebUtil.Param("fax").Trim();
             location.CompanyID = WebUtil.ParamInt("comp", 0);
             if (opt == "create")
             {
                 if (session.CreateEntityQuery<WHLocation>().Where(Exp.Eq("LocationCode", location.LocationCode)).Count() > 0)
                     return new SimpleJson().HandleError(string.Format("仓库代码{0}已经存在", location.LocationCode));
                 location.Create(session);
             }
             else
                 location.Update(session);
             return location.GetJSON();
             #endregion
         }
         else if (type == "a")
         {
             #region WHArea
             if (WebUtil.Param("parent").Trim().Length <= 0)
                 return new SimpleJson().HandleError("Invalidate parent in action SaveWHLoc");
             string parentType = WebUtil.Param("parentType");
             if (parentType != "l" && parentType != "a")
                 return new SimpleJson().HandleError("Invalidate parentType in action SaveWHLoc");
             WHArea area = new WHArea();
             WHArea parentArea = null;
             area.AreaCode = WebUtil.Param("code").Trim();
             if (parentType == "l") area.LocationCode = WebUtil.Param("parent").Trim();
             else
             {
                 parentArea = WHArea.Retrieve(session, WebUtil.Param("parent").Trim());
                 if (parentArea == null)
                     return new SimpleJson().HandleError(string.Format("Parent {0} not found", WebUtil.Param("parent").Trim()));
                 area.LocationCode = parentArea.LocationCode;
                 area.ParentArea = parentArea.AreaCode;
             }
             area.Name = WebUtil.Param("name").Trim();
             area.Text = WebUtil.Param("desc").Trim();
             area.Status = Cast.Enum<WHStatus>(WebUtil.ParamInt("status", 1));
             area.AreaCapacity = WebUtil.ParamDecimal("cap", 99999999M);
             area.HasSection = WebUtil.Param("hassec").Trim() == "1" ? true : false;
             area.IsQC = WebUtil.Param("isqc").Trim() == "1" ? true : false;
             area.IsScrap = WebUtil.Param("isscrap").Trim() == "1" ? true : false;
             if (opt == "create")
             {
                 if (session.CreateEntityQuery<WHArea>().Where(Exp.Eq("AreaCode", area.AreaCode)).Count() > 0)
                     return new SimpleJson().HandleError(string.Format("存储区域代码{0}已经存在", area.AreaCode));
                 if (parentArea != null)
                 {
                     area.CostTransRate = parentArea.CostTransRate;
                     area.CostFixValue = parentArea.CostFixValue;
                     area.UseFixCost = parentArea.UseFixCost;
                     area.AllowChild = true;
                     area.AllowDelete = true;
                     area.IsReservedArea = false;
                     area.IsTransArea = parentArea.IsTransArea;
                 }
                 else
                 {
                     area.CostTransRate = 1M;
                     area.CostFixValue = 0M;
                     area.UseFixCost = false;
                     area.AllowChild = true;
                     area.AllowDelete = true;
                     area.IsReservedArea = false;
                     area.IsTransArea = true;
                 }
                 area.Create(session);
             }
             else
             {
                 area.Update(session, "Name", "Text", "Status", "AreaCapacity", "HasSection", "IsQC", "IsScrap");
             }
             return area.GetJSON();
             #endregion
         }
         else if (type == "s")
         {
             #region WHSection
             if (WebUtil.Param("parent").Trim().Length <= 0)
                 return new SimpleJson().HandleError("Invalidate parent in action SaveWHLoc");
             WHSection section = new WHSection();
             section.SectionCode = WebUtil.Param("code").Trim();
             section.AreaCode = WebUtil.Param("parent").Trim();
             section.Status = Cast.Enum<WHStatus>(WebUtil.ParamInt("status", 1));
             section.SectionCapacity = WebUtil.ParamDecimal("cap", 99999999M);
             section.Text = WebUtil.Param("desc").Trim();
             if (opt == "create")
             {
                 if (session.CreateEntityQuery<WHSection>().Where(Exp.Eq("AreaCode", section.AreaCode) & Exp.Eq("SectionCode", section.SectionCode)).Count() > 0)
                     return new SimpleJson().HandleError(string.Format("存储区域{0}下面已经存在货架{1}", section.AreaCode, section.SectionCode));
                 section.Create(session);
             }
             else
             {
                 section.Update(session, "Status", "SectionCapacity", "Text");
             }
             return section.GetJSON();
             #endregion
         }
     }
     return null;
 }