private UserCardInfo BuildEntity() { UserCardInfo card = new UserCardInfo(); card.CardID = Request.Form["cardNo"]; card.UserID = Request.Form["userId"]; return card; }
public static bool Save(UserCardInfo card) { if (card == null || String.IsNullOrEmpty(card.UserID)) { return false; } bool success = UserCardDao.Update(card); if (!success) { int id = UserCardDao.Add(card); success = id > 0; } return success; }
public static bool Update(UserCardInfo card) { SqlParameter[] parameters = new SqlParameter[2]; parameters[0] = new SqlParameter("@CardID", SqlDbType.VarChar, 50); parameters[0].Value = card.CardID; parameters[1] = new SqlParameter("@UserID", SqlDbType.VarChar, 6); parameters[1].Value = card.UserID; StringBuilder sql = new StringBuilder(); sql.AppendLine("UPDATE UserCard SET cardId = @CardID WHERE userId = @UserID"); int affectedRows = (int)helper.ExecuteNonQuery(sql.ToString(), parameters); return affectedRows>0; }
public static int Add(UserCardInfo card) { SqlParameter[] parameters = new SqlParameter[2]; parameters[0] = new SqlParameter("@CardID", SqlDbType.VarChar, 50); parameters[0].Value = card.CardID; parameters[1] = new SqlParameter("@UserID", SqlDbType.VarChar, 6); parameters[1].Value = card.UserID; StringBuilder sql = new StringBuilder(); sql.AppendLine("INSERT INTO UserCard (cardId, userId)"); sql.AppendLine("VALUES (@CardID, @UserID)"); sql.AppendLine("SELECT SCOPE_IDENTITY();"); object newID = helper.ExecuteScalar(sql.ToString(), parameters); return Convert.ToInt32(newID); }
public static bool Update(UserCardInfo card) { return UserCardDao.Update(card); ; }
public static int Add(UserCardInfo card) { return UserCardDao.Add(card);; }