示例#1
0
        /// <summary>
        /// 修改一条记录
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns></returns>
        public bool Update(Common.Entity.CityDictionary model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("Update CityDictionary set ParentID=@ParentID,City=@City where PKID=@PKID");
            SqlParameter[] param =
            {
                new SqlParameter("@PKID",     model.PKID),
                new SqlParameter("@ParentID", model.ParentID),
                new SqlParameter("@City",     model.City),
            };
            object obj = SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), param);

            try
            {
                if (Convert.ToInt32(obj) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#2
0
        /// <summary>
        /// 获取实体对象
        /// </summary>
        /// <param name="cityId">PKID</param>
        /// <returns></returns>
        public Common.Entity.CityDictionary GetCityDictionaryByPKID(int cityId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"select * from  (select c.大区ID,d.ParentID as 省份ID,d.PKID as 城市ID, c.大区 as 大区,c.省份 as 省份,d.City as 城市 from 
										(select b.PKID as 省份ID,b.ParentID as 大区ID,a.City as 大区,b.City as 省份 from
										(select PKID,City from CityDictionary WHERE ParentID='0') a,
										CityDictionary b where a.PKID=b.ParentID) c,
										CityDictionary d where c.省份ID=d.ParentID) e where e.城市ID=@PKID"                                        );
            SqlParameter[] param =
            {
                new SqlParameter("@PKID", cityId)
            };
            DataTable dt = SqlHelper.GetDateTable(SqlHelper.connStr, CommandType.Text, strSql.ToString(), param);

            Common.Entity.CityDictionary model = null;
            if (dt.Rows.Count > 0)
            {
                model            = new Common.Entity.CityDictionary();
                model.PKID       = Convert.ToInt32(dt.Rows[0]["城市ID"]);
                model.ProvinceID = Convert.ToInt32(dt.Rows[0]["省份ID"]);
                model.CountryID  = Convert.ToInt32(dt.Rows[0]["大区ID"]);
                model.Country    = dt.Rows[0]["大区"].ToString();
                model.Province   = dt.Rows[0]["省份"].ToString();
                model.City       = dt.Rows[0]["城市"].ToString();
                return(model);
            }
            return(model);
        }
示例#3
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns></returns>
        public int Add(Common.Entity.CityDictionary model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("Insert into CityDictionary(ParentID,City,Sort,Code) Values");
            strSql.Append("(@ParentID,@City,@Sort,@Code)");
            strSql.Append(";SELECT @@IDENTITY");// 返回插入用户的主键
            SqlParameter[] param =
            {
                new SqlParameter("@ParentID", model.ParentID),
                new SqlParameter("@City",     model.City),
                new SqlParameter("@Sort",     model.Sort),
                new SqlParameter("@Code",     model.Code),
            };
            try
            {
                return(SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), param));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#4
0
 /// <summary>
 /// 修改一条记录
 /// </summary>
 /// <param name="model">实体类</param>
 /// <returns></returns>
 public bool Update(Common.Entity.CityDictionary model)
 {
     return(new DAL.CityManager().Update(model));
 }
示例#5
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <returns></returns>
 public int Add(Common.Entity.CityDictionary model)
 {
     return(new DAL.CityManager().Add(model));
 }