/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.UserCard model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "UserCard set "); strSql.Append(" CardId = @CardId , "); strSql.Append(" UserId = @UserId , "); strSql.Append(" CardCategoryId = @CardCategoryId "); strSql.Append(" where UserCardId=@UserCardId "); SqlParameter[] parameters = { new SqlParameter("@UserCardId", SqlDbType.Int, 4), new SqlParameter("@CardId", SqlDbType.Int, 4), new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@CardCategoryId", SqlDbType.Int, 4) }; parameters[0].Value = model.UserCardId; parameters[1].Value = model.CardId; parameters[2].Value = model.UserId; parameters[3].Value = model.CardCategoryId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DTcms.Model.UserCard model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "UserCard("); strSql.Append("CardId,UserId,CardCategoryId"); strSql.Append(") values ("); strSql.Append("@CardId,@UserId,@CardCategoryId"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CardId", SqlDbType.Int, 4), new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@CardCategoryId", SqlDbType.Int, 4) }; parameters[0].Value = model.CardId; parameters[1].Value = model.UserId; parameters[2].Value = model.CardCategoryId; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.UserCard GetModel(int UserCardId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select UserCardId, CardId, UserId, CardCategoryId "); strSql.Append(" from " + databaseprefix + "UserCard "); strSql.Append(" where UserCardId=@UserCardId"); SqlParameter[] parameters = { new SqlParameter("@UserCardId", SqlDbType.Int, 4) }; parameters[0].Value = UserCardId; DTcms.Model.UserCard model = new DTcms.Model.UserCard(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["UserCardId"].ToString() != "") { model.UserCardId = int.Parse(ds.Tables[0].Rows[0]["UserCardId"].ToString()); } if (ds.Tables[0].Rows[0]["CardId"].ToString() != "") { model.CardId = int.Parse(ds.Tables[0].Rows[0]["CardId"].ToString()); } if (ds.Tables[0].Rows[0]["UserId"].ToString() != "") { model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString()); } if (ds.Tables[0].Rows[0]["CardCategoryId"].ToString() != "") { model.CardCategoryId = int.Parse(ds.Tables[0].Rows[0]["CardCategoryId"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 获得数据列表 /// </summary> public List <DTcms.Model.UserCard> DataTableToList(DataTable dt) { List <DTcms.Model.UserCard> modelList = new List <DTcms.Model.UserCard>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { DTcms.Model.UserCard model; for (int n = 0; n < rowsCount; n++) { model = new DTcms.Model.UserCard(); if (dt.Rows[n]["UserCardId"].ToString() != "") { model.UserCardId = int.Parse(dt.Rows[n]["UserCardId"].ToString()); } if (dt.Rows[n]["CardId"].ToString() != "") { model.CardId = int.Parse(dt.Rows[n]["CardId"].ToString()); } if (dt.Rows[n]["UserId"].ToString() != "") { model.UserId = int.Parse(dt.Rows[n]["UserId"].ToString()); } if (dt.Rows[n]["CardCategoryId"].ToString() != "") { model.CardCategoryId = int.Parse(dt.Rows[n]["CardCategoryId"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.UserCard model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DTcms.Model.UserCard model) { return(dal.Add(model)); }