Exemple #1
0
 private UserCardInfo BuildEntity()
 {
     UserCardInfo card = new UserCardInfo();
     card.CardID = Request.Form["cardNo"];
     card.UserID = Request.Form["userId"];
     return card;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
        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;
        }
Exemple #4
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);
        }
Exemple #5
0
 public static bool Update(UserCardInfo card)
 {
     return UserCardDao.Update(card); ;
 }
Exemple #6
0
 public static int Add(UserCardInfo card)
 {
     return UserCardDao.Add(card);;
 }