コード例 #1
0
ファイル: WHAreaImpl.cs プロジェクト: XtremeKevinChow/rdroad
 public static WHArea Row2Entity(DataRow row)
 {
     if (row == null) return null;
     WHArea area = new WHArea();
     area.AreaCode = Cast.String(row["AreaCode"]);
     area.LocationCode = Cast.String(row["LocationCode"]);
     area.ParentArea = Cast.String(row["ParentArea"]);
     area.Name = Cast.String(row["Name"]);
     area.Text = Cast.String(row["Text"]);
     area.Status = Cast.Enum<WHStatus>(row["Status"], WHStatus.Disable);
     area.AreaCapacity = Cast.Decimal(row["AreaCapacity"], 99999999M);
     area.HasSection = Cast.Bool(row["HasSection"], true);
     area.IsQC = Cast.Bool(row["IsQC"], false);
     area.IsNonFormal = Cast.Bool(row["IsNonFormal"], false);
     area.IsScrap = Cast.Bool(row["IsScrap"], false);
     area.IsTransArea = Cast.Bool(row["IsTransArea"], false);
     area.IsReservedArea = Cast.Bool(row["IsReservedArea"], false);
     area.AllowDelete = Cast.Bool(row["AllowDelete"], false);
     area.AllowChild = Cast.Bool(row["AllowChild"], false);
     area.UseFixCost = Cast.Bool(row["UseFixCost"], false);
     area.CostFixValue = Cast.Decimal(row["CostFixValue"], 0M);
     area.CostTransRate = Cast.Decimal(row["CostTransRate"], 1M);
     area.FixedComsumeValue = Cast.Decimal(row["FixedComsumeValue"], 0M);
     return area;
 }
コード例 #2
0
ファイル: MagicAjax.cs プロジェクト: XtremeKevinChow/rdroad
 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;
 }