Esempio n. 1
0
        public static SimpleJson GetJSON(ISession session, string locationCode)
        {
            WHLocation location = WHLocation.Retrieve(session, locationCode);

            if (location == null)
            {
                return(new SimpleJson().HandleError(string.Format("²Ö´¢µØ{0}²»´æÔÚ", locationCode)));
            }
            SimpleJson json = new SimpleJson()
                              .Add("parent", "")
                              .Add("type", "l")
                              .Add("code", location.LocationCode)
                              .Add("name", location.Name)
                              .Add("status", (int)location.Status)
                              .Add("desc", location.Text)
                              .Add("addr", location.Address)
                              .Add("zipcode", location.ZipCode)
                              .Add("contact", location.Contact)
                              .Add("phone", location.Phone)
                              .Add("fax", location.FaxNumber)
                              .Add("allowdelete", "1")
                              .Add("allowchild", "1")
                              .Add("parentType", "")
                              .Add("text", location.ToString())
                              .Add("comp", location.CompanyID);

            return(json);
        }
Esempio n. 2
0
        public IList <WHLocation> GetLocations()
        {
            DataRow[]          rows  = _ds.Tables["l"].Select("", "LocationCode ASC");
            IList <WHLocation> lists = new List <WHLocation>();

            if (rows == null || rows.Length <= 0)
            {
                return(lists);
            }
            foreach (DataRow row in rows)
            {
                lists.Add(WHLocation.Row2Entity(row));
            }
            return(lists);
        }
Esempio n. 3
0
 public static WHLocation Row2Entity(DataRow row)
 {
     if (row == null) return null;
     WHLocation location = new WHLocation();
     location.LocationCode = Cast.String(row["LocationCode"]);
     location.CompanyID = Cast.Int(row["CompanyID"], -1);
     location.Name = Cast.String(row["Name"]);
     location.Status = Cast.Enum<WHStatus>(row["Status"], WHStatus.Disable);
     location.Address = Cast.String(row["Address"]);
     location.ZipCode = Cast.String(row["ZipCode"]);
     location.Contact = Cast.String(row["Contact"]);
     location.Phone = Cast.String(row["Phone"]);
     location.FaxNumber = Cast.String(row["FaxNumber"]);
     return location;
 }
Esempio n. 4
0
 public WHLocation GetLocation(string locationCode)
 {
     if (string.IsNullOrEmpty(locationCode) || locationCode.Trim().Length <= 0)
     {
         return(null);
     }
     DataRow[] rows = _ds.Tables["l"].Select("LocationCode='" + locationCode.Trim() + "'");
     if (rows != null && rows.Length > 0)
     {
         return(WHLocation.Row2Entity(rows[0]));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 5
0
 protected void drpLocationCode_SelectedIndexChanged(object sender, EventArgs e)
 {
     //如果已经填写送货地址,不再加载默认送货地址
     if (this.txtShippingAddress.Text.Trim().Length > 0 || this.drpLocationCode.SelectedValue == "")
     {
         return;
     }
     using (ISession session = new Session())
     {
         Magic.ERP.Core.WHLocation whLocation = Magic.ERP.Core.WHLocation.Retrieve(session, this.drpLocationCode.SelectedValue);
         if (whLocation != null)
         {
             this.txtShippingAddress.Text = whLocation.Address;
         }
     }
 }
Esempio n. 6
0
        public static WHLocation Row2Entity(DataRow row)
        {
            if (row == null)
            {
                return(null);
            }
            WHLocation location = new WHLocation();

            location.LocationCode = Cast.String(row["LocationCode"]);
            location.CompanyID    = Cast.Int(row["CompanyID"], -1);
            location.Name         = Cast.String(row["Name"]);
            location.Status       = Cast.Enum <WHStatus>(row["Status"], WHStatus.Disable);
            location.Address      = Cast.String(row["Address"]);
            location.ZipCode      = Cast.String(row["ZipCode"]);
            location.Contact      = Cast.String(row["Contact"]);
            location.Phone        = Cast.String(row["Phone"]);
            location.FaxNumber    = Cast.String(row["FaxNumber"]);
            return(location);
        }
Esempio n. 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;
 }