Exemplo n.º 1
0
        /// <summary>
        /// 地址添加
        /// </summary>
        /// <returns></returns>
        protected string AddressSava()
        {
            string         str     = "";
            bool           isLogin = false;
            MYlHuiYuanInfo m       = null;

            isLogin = EyouSoft.Security.Membership.YlHuiYuanProvider.IsLogin(out m);

            #region 赋值
            string            Name     = Utils.GetFormValue("txtName");
            string            Tell     = Utils.GetFormValue("txtTell");
            int               province = Utils.GetInt(Utils.GetFormValue("sel_province"));
            int               city     = Utils.GetInt(Utils.GetFormValue("sel_city"));
            int               country  = Utils.GetInt(Utils.GetFormValue("sel_country"));
            string            Adress   = Utils.GetFormValue("txtAdress");
            string            Zip      = Utils.GetFormValue("txtZip");
            MHuiYuanDiZhiInfo model    = new MHuiYuanDiZhiInfo()
            {
                ShengFenId = province,
                ChengShiId = city,
                XianQuId   = country,
                DiZhi      = Adress,
                YouBian    = Zip,
                XingMing   = Name,
                DianHua    = Tell
            };
            #endregion

            #region 判断
            if (string.IsNullOrEmpty(model.XingMing))
            {
                str = "-收件人不能为空!</br>";
            }
            if (string.IsNullOrEmpty(model.DianHua))
            {
                str += "-联系电话不能为空!</br>";
            }
            if (model.ShengFenId == 0)
            {
                str += "-请选择省份!</br>";
            }
            if (model.ChengShiId == 0)
            {
                str += "-请选择城市!</br>";
            }
            if (model.XianQuId == 0)
            {
                str += "-请选择县区!</br>";
            }
            if (string.IsNullOrEmpty(model.DiZhi))
            {
                str += "-邮寄地址不能为空!</br>";
            }
            if (string.IsNullOrEmpty(model.YouBian))
            {
                str += "-邮政编码!</br>";
            }
            #endregion

            if (!string.IsNullOrEmpty(str))
            {
                return(UtilsCommons.AjaxReturnJson("0", str, new { FeiHuiYuanId = "", DiZhiId = "" }));
            }

            string feiHuiYuanId = string.Empty;
            if (isLogin)
            {
                model.HuiYuanId = m.HuiYuanId;
            }
            else
            {
                var feiHuiYuanInfo = GetFeiHuiYuanInfo();
                model.HuiYuanId = feiHuiYuanId = feiHuiYuanInfo.id;
            }

            var bllRetCode = new EyouSoft.BLL.YlStructure.BHuiYuan().InsertDiZhi(model);
            if (bllRetCode == 1)
            {
                return(UtilsCommons.AjaxReturnJson("1", model.DiZhiId, new { FeiHuiYuanId = feiHuiYuanId, DiZhiid = model.DiZhiId }));
            }
            else
            {
                return(UtilsCommons.AjaxReturnJson("0", "添加失败", new { FeiHuiYuanId = feiHuiYuanId, DiZhiId = string.Empty }));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 地址添加
        /// </summary>
        /// <returns></returns>
        protected string AddressSava()
        {
            string str = ""; int strId = 0;

            if (m != null)
            {
                #region 赋值
                string            Name     = Utils.GetFormValue("txtName");
                string            Tell     = Utils.GetFormValue("txtTell");
                int               province = Utils.GetInt(Utils.GetFormValue("sel_province"));
                int               city     = Utils.GetInt(Utils.GetFormValue("sel_city"));
                int               country  = Utils.GetInt(Utils.GetFormValue("sel_country"));
                string            Adress   = Utils.GetFormValue("txtAdress");
                string            Zip      = Utils.GetFormValue("txtZip");
                MHuiYuanDiZhiInfo model    = new MHuiYuanDiZhiInfo()
                {
                    HuiYuanId  = m.HuiYuanId,
                    ShengFenId = province,
                    ChengShiId = city,
                    XianQuId   = country,
                    DiZhi      = Adress,
                    YouBian    = Zip,
                    XingMing   = Name,
                    DianHua    = Tell
                };
                #endregion

                #region 判断
                if (string.IsNullOrEmpty(model.XingMing))
                {
                    str = "-收件人不能为空!</br>";
                }
                if (string.IsNullOrEmpty(model.DianHua))
                {
                    str += "-联系电话不能为空!</br>";
                }
                if (model.ShengFenId == 0)
                {
                    str += "-请选择省份!</br>";
                }
                if (model.ChengShiId == 0)
                {
                    str += "-请选择城市!</br>";
                }
                if (model.XianQuId == 0)
                {
                    str += "-请选择县区!</br>";
                }
                if (string.IsNullOrEmpty(model.DiZhi))
                {
                    str += "-邮寄地址不能为空!</br>";
                }
                if (string.IsNullOrEmpty(model.YouBian))
                {
                    str += "-邮政编码!</br>";
                }
                #endregion
                if (str != "")
                {
                    return(UtilsCommons.AjaxReturnJson("0", str));
                }
                EyouSoft.BLL.YlStructure.BHuiYuan bll = new EyouSoft.BLL.YlStructure.BHuiYuan();
                strId = bll.InsertDiZhi(model);
                if (strId > 0)
                {
                    return(UtilsCommons.AjaxReturnJson("1", "添加成功!", new { DiZhiid = model.DiZhiId }));
                }
                else
                {
                    return(UtilsCommons.AjaxReturnJson("0", "添加失败", new { DiZhiId = string.Empty }));
                }
            }
            return(UtilsCommons.AjaxReturnJson(strId > 0 ? "1" : "0", str));
        }