/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.OfferTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update OfferTable set "); strSql.Append("offerName=@offerName"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@offerName", SqlDbType.NVarChar, 50), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.offerName; parameters[1].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.OfferTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OfferTable("); strSql.Append("offerName)"); strSql.Append(" values ("); strSql.Append("@offerName)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@offerName", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.offerName; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.OfferTable DataRowToModel(DataRow row) { Model.OfferTable model = new Model.OfferTable(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["offerName"] != null) { model.offerName = row["offerName"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.OfferTable GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,offerName from OfferTable "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; Model.OfferTable model = new Model.OfferTable(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.OfferTable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.OfferTable model) { return(dal.Add(model)); }