Пример #1
0
        /// <summary>
        /// 修改一个实体
        /// </summary>
        /// <param name="_entity"></param>
        /// <returns></returns>
        public int Update(Models.APP.District model)
        {
            try
            {
                SqlParameter[] para =
                {
                    new SqlParameter("@Id",      model.Id),
                    new SqlParameter("@DisName", model.DisName),
                    new SqlParameter("@CityID",  model.CityID),
                    new SqlParameter("@DisSort", model.DisSort)
                };

                StringBuilder cmdText = new StringBuilder();
                cmdText.Append(@"UPDATE [App_District]
								SET [DisName]=@DisName
									   ,[CityID]=@CityID
							       ,[DisSort]=@DisSort
							  WHERE [Id]=@Id"                            );
                return(SqlHelper.ExecuteNonQuery(DefaultConnection.ConnectionStringByDefaultDB, CommandType.Text, cmdText.ToString(), para));
            }
            catch (ArgumentNullException ex)
            {
                logger.Error("调用方法Update()发生ArgumentNullException", ex);
            }
            catch (SqlException ex)
            {
                logger.Error("调用方法Update()发生SqlException", ex);
            }
            catch (Exception ex)
            {
                logger.Error("调用方法Update()发生Exception", ex);
            }
            return(-1);
        }
Пример #2
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model">数据实体</param>
        /// <returns></returns>
        public int Add(Models.APP.District model)
        {
            try
            {
                SqlParameter[] para =
                {
                    new SqlParameter("@DisName", model.DisName),
                    new SqlParameter("@CityID",  model.CityID),
                    new SqlParameter("@DisSort", model.DisSort)
                };
                StringBuilder cmdText = new StringBuilder();
                cmdText.Append(@"INSERT INTO App_District(
			                        DisName
						            ,CityID
						            ,DisSort
						  ) VALUES(
									@DisName
									,@CityID
									,@DisSort
					)"                    );

                return(SqlHelper.ExecuteNonQuery(DefaultConnection.ConnectionStringByDefaultDB, CommandType.Text, cmdText.ToString(), para));
            }
            catch (ArgumentNullException ex)
            {
                logger.Error("调用方法Add()发生ArgumentNullException", ex);
            }
            catch (SqlException ex)
            {
                logger.Error("调用方法Add()发生SqlException", ex);
            }
            catch (Exception ex)
            {
                logger.Error("调用方法Add()发生Exception", ex);
            }
            return(-1);
        }
Пример #3
0
 /// <summary>
 /// 修改一个实体
 /// </summary>
 /// <param name="_entity"></param>
 /// <returns></returns>
 public int Update(Models.APP.District model)
 {
     return(dal.Update(model));
 }
Пример #4
0
 /// <summary>
 /// 添加一条数据
 /// </summary>
 /// <param name="model">数据实体</param>
 /// <returns></returns>
 public int Add(Models.APP.District model)
 {
     return(dal.Add(model));
 }