public static TicketType VerwerkRij(IDataRecord rij) { TicketType type = new TicketType(); type.ID = Convert.ToInt32(rij["ID"].ToString()); type.AvailableTickets = Convert.ToInt32( rij["AvailableTickets"].ToString()); type.Name = rij["Name"].ToString(); type.Price = Convert.ToInt32(rij["Price"].ToString()); return type; }
public static void DeleteType(TicketType type) { try { DbParameter paramName = Database.AddParameter("@Name",type.Name ); Database.ModifyData("DELETE FROM TicketType WHERE Name = @Name", paramName); } catch (Exception e) { throw e; } }
public static void AddType(TicketType newticket) { try { DbParameter paramName = Database.AddParameter("@Name",newticket.Name ); DbParameter paramPrijs = Database.AddParameter("@Price",newticket.Price ); DbParameter paramTicket = Database.AddParameter("@AvailableTickets",newticket.AvailableTickets ); Database.ModifyData("INSERT INTO TicketType (Name,Price,AvailableTickets) values (@Name,@Price,@AvailableTickets)", paramName, paramPrijs, paramTicket); } catch (Exception e) { Console.WriteLine(e.Message); } }
public static TicketType GetTicketTypeByID(int p) { TicketType nieuw = new TicketType(); string sql = "SELECT * FROM TicketType WHERE ID like @ID"; DbParameter paramID = Database.AddParameter("@ID", p); DbDataReader reader = Database.GetData(sql, paramID); while (reader.Read()) { nieuw = VerwerkRij(reader); } return nieuw; }