예제 #1
0
        // inserts a new membership in the db
        public static int NewMembership(Membership membership)
        {
            string query = "INSERT INTO Memberships (Member, [Plan], StartDate, EndDate) VALUES (@memberid, @planid, @startDate, @endDate)";

            using (SqlCeConnection con = DB.GetSqlCeConnection())
            {
                SqlCeCommand cmd = new SqlCeCommand(query, con);
                cmd.Parameters.AddWithValue("@memberid", membership.MemberId);
                cmd.Parameters.AddWithValue("@planid", membership.Plan);
                cmd.Parameters.AddWithValue("@startDate", membership.start);
                cmd.Parameters.AddWithValue("@endDate", membership.end);

                int rowsAffected = cmd.ExecuteNonQuery();
                return rowsAffected;
            }
        }
예제 #2
0
 // updates mrmbership with new data
 public static int UpdateMembership(Membership membership)
 {
     string query = "UPDATE Memberships SET [Plan] = @planid, StartDate = @startdate, EndDate = @enddate WHERE Id = @membership_id";
     using (SqlCeConnection con = DB.GetSqlCeConnection())
     {
         SqlCeCommand cmd = new SqlCeCommand(query, con);
         cmd.Parameters.AddWithValue("@planid", membership.Plan);
         cmd.Parameters.AddWithValue("@startdate", membership.start);
         cmd.Parameters.AddWithValue("@enddate", membership.end);
         cmd.Parameters.AddWithValue("@membership_id", membership.Id);
         int rowsAffected = cmd.ExecuteNonQuery();
         return rowsAffected;
     }
 }