/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddLoc(ReservoirAreaModel model) { using (IDbConnection connection = new SqlConnection(DBConnectionStringConfig.Default.WechatServerDBReadConnStr)) { const string sql = @" INSERT INTO ReservoirArea(ReservoirAreaNo,AnotherName,VendName,Enable,CreateTime,UpdateTime) VALUES (@ReservoirAreaNo,@AnotherName,@VendName,@Enable,@CreateTime,@UpdateTime); SELECT CAST(SCOPE_IDENTITY() AS INT) "; model.Id = connection.Query <int>(sql, model).Single(); bool result = model.Id > 0; return(result); } }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateLoc(ReservoirAreaModel model) { StringBuilder strSql = new StringBuilder(); DynamicParameters dp = new DynamicParameters(); strSql.Append(" UPDATE ReservoirArea set "); strSql.Append(" AnotherName=@AnotherName, "); strSql.Append(" UpdateTime=@UpdateTime "); strSql.Append(" WHERE VendName=@VendName and ReservoirAreaNo=@ReservoirAreaNo "); dp.Add("@VendName", model.VendName, DbType.String, ParameterDirection.Input); dp.Add("@ReservoirAreaNo", model.ReservoirAreaNo, DbType.String, ParameterDirection.Input); dp.Add("@AnotherName", model.AnotherName, DbType.String, ParameterDirection.Input); dp.Add("@UpdateTime", model.UpdateTime, DbType.DateTime, ParameterDirection.Input); using (IDbConnection connection = new SqlConnection(DBConnectionStringConfig.Default.WechatServerDBReadConnStr)) { bool result = connection.Execute(strSql.ToString(), dp) > 0; return(result); } }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateLoc(ReservoirAreaModel model) { return(areadal.UpdateLoc(model)); }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddLoc(ReservoirAreaModel model) { return(areadal.AddLoc(model)); }