/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.User.UserReservewords model) { var strSql = new StringBuilder(); strSql.Append("update userreservewords set "); strSql.Append("userId=@userId,"); strSql.Append("reservewords=@reservewords,"); strSql.Append("addTime=@addTime,"); strSql.Append("updateTime=@updateTime"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@userId", SqlDbType.Int, 4), new SqlParameter("@reservewords", SqlDbType.VarChar, 50), new SqlParameter("@addTime", SqlDbType.DateTime), new SqlParameter("@updateTime", SqlDbType.DateTime) }; parameters[0].Value = model.userId; parameters[1].Value = model.reservewords; parameters[2].Value = model.addTime; parameters[3].Value = model.updateTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } return(false); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.User.UserReservewords model) { var strSql = new StringBuilder(); strSql.Append("insert into userreservewords("); strSql.Append("userId,reservewords,addTime,updateTime)"); strSql.Append(" values ("); strSql.Append("@userId,@reservewords,@addTime,@updateTime)"); SqlParameter[] parameters = { new SqlParameter("@userId", SqlDbType.Int, 4), new SqlParameter("@reservewords", SqlDbType.VarChar, 50), new SqlParameter("@addTime", SqlDbType.DateTime), new SqlParameter("@updateTime", SqlDbType.DateTime) }; parameters[0].Value = model.userId; parameters[1].Value = model.reservewords; parameters[2].Value = model.addTime; parameters[3].Value = model.updateTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } return(false); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.User.UserReservewords DataRowToModel(DataRow row) { var model = new Model.User.UserReservewords(); if (row != null) { if (row["userId"] != null && row["userId"].ToString() != "") { model.userId = int.Parse(row["userId"].ToString()); } if (row["reservewords"] != null) { model.reservewords = row["reservewords"].ToString(); } if (row["addTime"] != null && row["addTime"].ToString() != "") { model.addTime = DateTime.Parse(row["addTime"].ToString()); } if (row["updateTime"] != null && row["updateTime"].ToString() != "") { model.updateTime = DateTime.Parse(row["updateTime"].ToString()); } } return(model); }
public bool Insert(Model.User.UserReservewords model) { try { return(dal.Insert(model)); } catch (Exception ex) { ExceptionHandler.HandleException(ex); throw; } }
public bool Insert(Model.User.UserReservewords model) { SqlParameter[] parameters = { new SqlParameter("@userId", SqlDbType.Int, 4), new SqlParameter("@reservewords", SqlDbType.VarChar, 50), new SqlParameter("@addTime", SqlDbType.DateTime) }; parameters[0].Value = model.userId; parameters[1].Value = model.reservewords; parameters[2].Value = model.addTime; int rows = DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_userreservewords_insert", parameters); if (rows > 0) { return(true); } return(false); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.User.UserReservewords GetModel(int userId) { //该表无主键信息,请自定义主键/条件字段 var strSql = new StringBuilder(); strSql.Append("select top 1 userId,reservewords,addTime,updateTime from userreservewords "); strSql.Append(" where userId=@userId"); SqlParameter[] parameters = { new SqlParameter("@userId", SqlDbType.Int, 4) }; parameters[0].Value = userId; var model = new Model.User.UserReservewords(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } return(null); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.User.UserReservewords model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.User.UserReservewords model) { return(dal.Add(model)); }