コード例 #1
0
        public string SaveProvinceCity(ProvinceCityInfo model)
        {
            if (string.IsNullOrWhiteSpace(model.Named))
            {
                return(MessageContent.Submit_Params_InvalidError);
            }
            if (string.IsNullOrWhiteSpace(model.Pinyin))
            {
                return(MessageContent.Submit_Params_InvalidError);
            }
            if (string.IsNullOrWhiteSpace(model.FirstChar))
            {
                return(MessageContent.Submit_Params_InvalidError);
            }

            Guid gId = Guid.Empty;

            Guid.TryParse(model.Id.ToString(), out gId);
            model.Id = gId;

            Guid parentId = Guid.Empty;

            Guid.TryParse(model.ParentId.ToString(), out parentId);
            model.ParentId        = parentId;
            model.LastUpdatedDate = DateTime.Now;

            ProvinceCity bll    = new ProvinceCity();
            int          effect = -1;

            if (!gId.Equals(Guid.Empty))
            {
                effect = bll.Update(model);
            }
            else
            {
                effect = bll.Insert(model);
            }

            if (effect == 110)
            {
                return(MessageContent.Submit_Exist);
            }
            if (effect > 0)
            {
                return("1");
            }
            else
            {
                return(MessageContent.Submit_Error);
            }
        }
コード例 #2
0
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateProvinceCity(ProvinceCityInfo model)
        {
            ProvinceCity bll = new ProvinceCity();

            return(bll.Update(model));
        }
コード例 #3
0
        public string SaveProvinceCity(ProvinceCityInfo model)
        {
            string errorMsg = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(model.Named))
                {
                    return(MC.Submit_Params_InvalidError);
                }
                if (string.IsNullOrWhiteSpace(model.Pinyin))
                {
                    return(MC.Submit_Params_InvalidError);
                }
                if (string.IsNullOrWhiteSpace(model.FirstChar))
                {
                    return(MC.Submit_Params_InvalidError);
                }

                Guid gId = Guid.Empty;
                Guid.TryParse(model.Id.ToString(), out gId);
                model.Id = gId;

                Guid parentId = Guid.Empty;
                Guid.TryParse(model.ParentId.ToString(), out parentId);
                model.ParentId        = parentId;
                model.LastUpdatedDate = DateTime.Now;

                ProvinceCity bll    = new ProvinceCity();
                int          effect = -1;

                using (TransactionScope scope = new TransactionScope())
                {
                    if (!gId.Equals(Guid.Empty))
                    {
                        effect = bll.Update(model);
                    }
                    else
                    {
                        effect = bll.Insert(model);
                    }

                    scope.Complete();
                }

                if (effect == 110)
                {
                    return(MC.Submit_Exist);
                }
                if (effect > 0)
                {
                    return("1");
                }
                else
                {
                    return(MC.Submit_Error);
                }
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            return(MC.GetString(MC.Submit_Ex_Error, errorMsg));
        }