Example #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);
        }
Example #2
0
        public SimpleJson GetJSON()
        {
            SimpleJson json = new SimpleJson()
                              .Add("type", "a")
                              .Add("code", this.AreaCode)
                              .Add("status", (int)this.Status)
                              .Add("name", this.Name)
                              .Add("desc", this.Text)
                              .Add("cap", this.AreaCapacity)
                              .Add("hassec", this.HasSection)
                              .Add("isqc", this.IsQC)
                              .Add("isnonformal", this.IsNonFormal)
                              .Add("isscrap", this.IsScrap)
                              .Add("allowdelete", this.AllowDelete)
                              .Add("allowchild", this.AllowChild)
                              .Add("text", this.ToString());

            if (!string.IsNullOrEmpty(this.ParentArea) && this.ParentArea.Trim().Length > 0)
            {
                json.Add("parentType", "a").Add("parent", this.ParentArea.Trim());
            }
            else
            {
                json.Add("parentType", "l").Add("parent", this.LocationCode.Trim());
            }
            return(json);
        }
Example #3
0
        public SimpleJson ToJSON()
        {
            SimpleJson json = new SimpleJson();

            json.Add("id", this.GroupId);
            json.Add("name", this.Name);
            json.Add("desc", this.Description);
            json.Add("parent", this.ParentId);
            json.Add("type", this.GroupType);
            return(json);
        }
Example #4
0
        public SimpleJson ToJSON()
        {
            SimpleJson json = new SimpleJson();

            json.Add("id", this.OperationId);
            json.Add("name", this.Name);
            json.Add("desc", this.Description);
            json.Add("parent", this.ParentId);
            json.Add("type", this.Type.ToString());
            json.Add("level", this.Level);
            json.Add("image", this.Image);
            json.Add("seq", this.SeqNo);
            json.Add("entry", this.Entry);
            json.Add("status", this.Status);
            return(json);
        }
Example #5
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);
        }
Example #6
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;
        }
Example #7
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;
 }
Example #8
0
        public static SimpleJson DeliverOrder4Check(ISession session, string orderNumber)
        {
            CRMSN shippingNotice = CRMSN.Retrieve(session, orderNumber);

            if (shippingNotice == null)
            {
                return(new SimpleJson().HandleError(string.Format("发货单{0}不存在", orderNumber)));
            }
            if (shippingNotice.Status != CRMSNStatus.Distributing)
            {
                return(new SimpleJson().HandleError(string.Format("发货单{0}不是已打印状态,无法进行核货作业", shippingNotice.OrderNumber)));
            }
            SimpleJson json = shippingNotice.ToJSon(session);
            //是否需要过滤掉不必要核货的发货明细?
            DataSet ds = session.CreateObjectQuery(@"
select s.BarCode as SKU,m.ItemCode as ItemCode,m.ItemName as ItemName
    ,s.ColorCode as ColorCode,color.ColorText as ColorText,s.SizeCode as SizeCode
    ,sum(l.Quantity) as Quantity
from CRMSNLine l
inner join ItemSpec s on l.SKUID=s.SKUID
inner join ItemMaster m on m.ItemID=s.ItemID
left join ItemColor color on color.ColorCode=s.ColorCode
group by s.BarCode,m.ItemCode,m.ItemName,s.ColorCode,color.ColorText,s.SizeCode
order by s.BarCode")
                         .Attach(typeof(CRMSNLine)).Attach(typeof(ItemSpec)).Attach(typeof(ItemMaster))
                         .Attach(typeof(ItemColor))
                         .Where(Exp.Eq("l.SNID", shippingNotice.ID))
                         .DataSet();
            IList <SimpleJson> lineJson = new List <SimpleJson>(ds.Tables[0].Rows.Count);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                lineJson.Add(new SimpleJson()
                             .Add("sku", row["SKU"])
                             .Add("itemCode", row["ItemCode"])
                             .Add("color", Cast.String(row["ColorCode"]) + " " + Cast.String(row["ColorText"]))
                             .Add("size", row["SizeCode"])
                             .Add("itemName", row["ItemName"])
                             .Add("qty", row["Quantity"]));
            }
            json.Add("lines", lineJson);
            return(json);
        }
Example #9
0
 public SimpleJson ToJSon(ISession session)
 {
     SimpleJson json = new SimpleJson()
         .Add("orderNumber", this.OrderNumber)
         .Add("saleOrder", this.SaleOrderNumber)
         .Add("memberId", this.MemberID);
     string memberName = " ";
     if (this.MemberID > 0)
     {
         Magic.Basis.Member member = Magic.Basis.Member.Retrieve(session, this.MemberID);
         if (member != null) memberName = member.Name;
     }
     json.Add("member", memberName);
     json.Add("contact", this.Contact)
         .Add("phone", this.Phone)
         .Add("mobile", this.Mobile)
         .Add("address", this.Address)
         .Add("district", this.Province + " " + this.City)
         .Add("shippingNumber", this.ShippingNumber)
         .Add("isInvoice", this.IsInvoice)
         .Add("invoice", Cast.String(this.InvoiceNumber, "").Trim())
         .Add("packageWeight", this.PackageWeight)
         .Add("logistics", this.LogisticsID)
         .Add("packageCount", this.PackageCount <= 0 ? 1 : this.PackageCount);
     string paymentMethod = " ";
     if (this.PaymentMethod > 0)
     {
         CRM.PaymentMethod pm = CRM.PaymentMethod.Retrieve(session, this.PaymentMethod);
         if (pm != null)
             paymentMethod = pm.Name;
     }
     json.Add("paymentMethod", paymentMethod);
     string deliverType = " ";
     if (this.DeliveryType > 0)
     {
         CRM.DeliverType dt = CRM.DeliverType.Retrieve(session, this.DeliveryType);
         if (dt != null) deliverType = dt.Name;
     }
     json.Add("deliverType", deliverType);
     string logisName = " ";
     if (this.LogisticsID > 0)
     {
         Logistics logis = Logistics.Retrieve(session, this.LogisticsID);
         if (logis != null) logisName = logis.ShortName;
     }
     json.Add("logisticsName", logisName);
     string packageType = " ";
     if (this.PackageType > 0)
     {
         CRM.PackageType pt = CRM.PackageType.Retrieve(session, this.PackageType);
         if (pt != null) packageType = pt.Name;
     }
     json.Add("packageType", packageType)
         .Add("note", string.IsNullOrEmpty(this.Remark) ? " " : this.Remark.Replace("</br>", " "));
     json.Add("packageUser", string.IsNullOrEmpty(this.PackagePerson) ? " " : this.PackagePerson);
     return json;
 }
Example #10
0
 public SimpleJson ToJSON()
 {
     SimpleJson json = new SimpleJson();
     json.Add("id", this.OperationId);
     json.Add("name", this.Name);
     json.Add("desc", this.Description);
     json.Add("parent", this.ParentId);
     json.Add("type", this.Type.ToString());
     json.Add("level", this.Level);
     json.Add("image", this.Image);
     json.Add("seq", this.SeqNo);
     json.Add("entry", this.Entry);
     json.Add("status", this.Status);
     return json;
 }
Example #11
0
 public SimpleJson ToJSON()
 {
     SimpleJson json = new SimpleJson();
     json.Add("id", this.GroupId);
     json.Add("name", this.Name);
     json.Add("desc", this.Description);
     json.Add("parent", this.ParentId);
     json.Add("type", this.GroupType);
     return json;
 }
Example #12
0
        public static SimpleJson GetOrgJSON(ISession session, Org org)
        {
            SimpleJson json = new SimpleJson();

            if (org == null)
            {
                json.HandleError("Org is null");
                return(json);
            }

            json.Add("id", org.OrgId)
            .Add("parent", org.ParentId)
            .Add("root", org.IsRoot)
            .Add("virtual", org.IsVirtual)
            .Add("seq", org.OrgSeq)
            .Add("code", org.OrgCode)
            .Add("name", org.OrgName)
            .Add("remark", org.Description)
            .Add("desc", org);

            if (org.CreateBy > 0)
            {
                User createBy = User.Retrieve(session, org.CreateBy);
                if (createBy != null)
                {
                    json.Add("createBy", string.IsNullOrEmpty(createBy.FullName) ? createBy.UserName : createBy.FullName);
                }
                else
                {
                    Log.Warn <Org>("User {0} (CreateBy) not found when loading org {1}:{2}", org.CreateBy, org.OrgId, org.OrgCode);
                }
            }
            else
            {
                json.Add("createBy", "");
            }
            json.Add("createTime", org.CreateDate);

            if (org.ModifyBy > 0)
            {
                User modefyBy = User.Retrieve(session, org.ModifyBy);
                if (modefyBy != null)
                {
                    json.Add("modifyBy", string.IsNullOrEmpty(modefyBy.FullName) ? modefyBy.UserName : modefyBy.FullName);
                }
                else
                {
                    Log.Warn <Org>("User {0} (ModifyBy) not found when loading org {1}:{2}", org.ModifyBy, org.OrgId, org.OrgCode);
                }
            }
            else
            {
                json.Add("modifyBy", "");
            }
            json.Add("modifyTime", org.ModifyDate);

            User manager = null;

            if (org.Manager > 0)
            {
                manager = User.Retrieve(session, org.Manager);
                if (manager == null)
                {
                    Log.Warn <Org>("User {0} (Manager) not found when loading org {1}:{2}", org.Manager, org.OrgId, org.OrgCode);
                }
            }
            if (manager != null)
            {
                json.Add("managerId", manager.UserId)
                .Add("manager", string.IsNullOrEmpty(manager.FullName) ? manager.UserName : manager.FullName);
            }
            else
            {
                json.Add("managerId", -1)
                .Add("manager", "");
            }

            if (OrgTypeRegistry.HasExtAttr(org.OrgType) && org.ExtAttr != null)
            {
                Type type = OrgTypeRegistry.ExtAttrType(org.OrgType);
                org.ExtAttr.Json(session, json);
            }

            return(json);
        }
Example #13
0
 public SimpleJson GetJSON()
 {
     SimpleJson json = new SimpleJson()
         .Add("type", "a")
         .Add("code", this.AreaCode)
         .Add("status", (int)this.Status)
         .Add("name", this.Name)
         .Add("desc", this.Text)
         .Add("cap", this.AreaCapacity)
         .Add("hassec", this.HasSection)
         .Add("isqc", this.IsQC)
         .Add("isnonformal", this.IsNonFormal)
         .Add("isscrap", this.IsScrap)
         .Add("allowdelete", this.AllowDelete)
         .Add("allowchild", this.AllowChild)
         .Add("text", this.ToString());
     if (!string.IsNullOrEmpty(this.ParentArea) && this.ParentArea.Trim().Length > 0)
         json.Add("parentType", "a").Add("parent", this.ParentArea.Trim());
     else
         json.Add("parentType", "l").Add("parent", this.LocationCode.Trim());
     return json;
 }
Example #14
0
 private static SimpleJson SelectUser()
 {
     string userName = WebUtil.Param("username");
     string fullName = WebUtil.Param("fullname");
     int orgid = WebUtil.ParamInt("orgid", -1);
     SimpleJson result = new SimpleJson();
     string path = "controls/SelectUserTable.ascx";
     try
     {
         string html = WebUtil.RenderUserControl(path, new string[] { "UserName", "FullName", "OrgId" }, new object[] { userName, fullName, orgid });
         result.Add("id", "user");
         result.Add("html", html);
         log.Info(html);
         return result;
     }
     catch (Exception ex)
     {
         log.Error(ex);
         return new SimpleJson().HandleError(ex);
     }
 }
Example #15
0
    private static SimpleJson QueryUnreadMsgByUser()
    {
        try
        {
            SimpleJson result = new SimpleJson();
            using (ISession session = new Session())
            {
                //当前5天的消息
                DataTable msgList = Message.QueryUnreadMessageByUser(session, SecuritySession.CurrentUser.UserId, DateTime.Now.AddDays(-5), DateTime.Now);

                string controlPath = "controls/MsgBoard.ascx";

                result.Add("time", DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss"));
                result.Add("html", WebUtil.RenderUserControl(controlPath, new string[] { "DataSource" }, new object[] { msgList }));

                return result;
            }

        }
        catch (Exception ex)
        {
            log.Error("Magic.Ajax.QueryUnreadMsgByUser", ex);
            return new SimpleJson().HandleError(ex);
        }
    }
Example #16
0
        public SimpleJson ToJSon(ISession session)
        {
            SimpleJson json = new SimpleJson()
                              .Add("orderNumber", this.OrderNumber)
                              .Add("saleOrder", this.SaleOrderNumber)
                              .Add("memberId", this.MemberID);
            string memberName = " ";

            if (this.MemberID > 0)
            {
                Magic.Basis.Member member = Magic.Basis.Member.Retrieve(session, this.MemberID);
                if (member != null)
                {
                    memberName = member.Name;
                }
            }
            json.Add("member", memberName);
            json.Add("contact", this.Contact)
            .Add("phone", this.Phone)
            .Add("mobile", this.Mobile)
            .Add("address", this.Address)
            .Add("district", this.Province + " " + this.City)
            .Add("shippingNumber", this.ShippingNumber)
            .Add("isInvoice", this.IsInvoice)
            .Add("invoice", Cast.String(this.InvoiceNumber, "").Trim())
            .Add("packageWeight", this.PackageWeight)
            .Add("logistics", this.LogisticsID)
            .Add("packageCount", this.PackageCount <= 0 ? 1 : this.PackageCount);
            string paymentMethod = " ";

            if (this.PaymentMethod > 0)
            {
                CRM.PaymentMethod pm = CRM.PaymentMethod.Retrieve(session, this.PaymentMethod);
                if (pm != null)
                {
                    paymentMethod = pm.Name;
                }
            }
            json.Add("paymentMethod", paymentMethod);
            string deliverType = " ";

            if (this.DeliveryType > 0)
            {
                CRM.DeliverType dt = CRM.DeliverType.Retrieve(session, this.DeliveryType);
                if (dt != null)
                {
                    deliverType = dt.Name;
                }
            }
            json.Add("deliverType", deliverType);
            string logisName = " ";

            if (this.LogisticsID > 0)
            {
                Logistics logis = Logistics.Retrieve(session, this.LogisticsID);
                if (logis != null)
                {
                    logisName = logis.ShortName;
                }
            }
            json.Add("logisticsName", logisName);
            string packageType = " ";

            if (this.PackageType > 0)
            {
                CRM.PackageType pt = CRM.PackageType.Retrieve(session, this.PackageType);
                if (pt != null)
                {
                    packageType = pt.Name;
                }
            }
            json.Add("packageType", packageType)
            .Add("note", string.IsNullOrEmpty(this.Remark) ? " " : this.Remark.Replace("</br>", " "));
            json.Add("packageUser", string.IsNullOrEmpty(this.PackagePerson) ? " " : this.PackagePerson);
            return(json);
        }
Example #17
0
        public static SimpleJson GetOrgJSON(ISession session, Org org)
        {
            SimpleJson json = new SimpleJson();
            if (org == null)
            {
                json.HandleError("Org is null");
                return json;
            }

            json.Add("id", org.OrgId)
                .Add("parent", org.ParentId)
                .Add("root", org.IsRoot)
                .Add("virtual", org.IsVirtual)
                .Add("seq", org.OrgSeq)
                .Add("code", org.OrgCode)
                .Add("name", org.OrgName)
                .Add("remark", org.Description)
                .Add("desc", org);

            if (org.CreateBy > 0)
            {
                User createBy = User.Retrieve(session, org.CreateBy);
                if (createBy != null)
                    json.Add("createBy", string.IsNullOrEmpty(createBy.FullName) ? createBy.UserName : createBy.FullName);
                else
                    Log.Warn<Org>("User {0} (CreateBy) not found when loading org {1}:{2}", org.CreateBy, org.OrgId, org.OrgCode);
            }
            else
                json.Add("createBy", "");
            json.Add("createTime", org.CreateDate);

            if (org.ModifyBy > 0)
            {
                User modefyBy = User.Retrieve(session, org.ModifyBy);
                if (modefyBy != null)
                    json.Add("modifyBy", string.IsNullOrEmpty(modefyBy.FullName) ? modefyBy.UserName : modefyBy.FullName);
                else
                    Log.Warn<Org>("User {0} (ModifyBy) not found when loading org {1}:{2}", org.ModifyBy, org.OrgId, org.OrgCode);
            }
            else
                json.Add("modifyBy", "");
            json.Add("modifyTime", org.ModifyDate);

            User manager = null;
            if (org.Manager > 0)
            {
                manager = User.Retrieve(session, org.Manager);
                if (manager == null)
                    Log.Warn<Org>("User {0} (Manager) not found when loading org {1}:{2}", org.Manager, org.OrgId, org.OrgCode);
            }
            if (manager != null)
                json.Add("managerId", manager.UserId)
                    .Add("manager", string.IsNullOrEmpty(manager.FullName) ? manager.UserName : manager.FullName);
            else
                json.Add("managerId", -1)
                    .Add("manager", "");

            if (OrgTypeRegistry.HasExtAttr(org.OrgType) && org.ExtAttr != null)
            {
                Type type = OrgTypeRegistry.ExtAttrType(org.OrgType);
                org.ExtAttr.Json(session, json);
            }

            return json;
        }