public Event buildEvent(DataRow Row) { selectedEvent = new Event() { ID = Convert.ToInt32(Row["ID"].ToString()), Name = Row["Name"].ToString(), Date = Convert.ToDateTime(Row["Date"].ToString()), Floor = Convert.ToBoolean(Row["Floor"].ToString()), Level1 = Convert.ToBoolean(Row["Level1"].ToString()), Level2 = Convert.ToBoolean(Row["Level2"].ToString()), BasePrice = Convert.ToDecimal(Row["BasePrice"].ToString()), MaxPrice = Convert.ToDecimal(Row["MaxPrice"].ToString()) }; return selectedEvent; }
public bool addEvent(string name, DateTime date, bool flr, bool l1, bool l2, Decimal bp, Decimal mp) { mEvent = new Event(); mEvent.Name = name; mEvent.Date = date; mEvent.Floor = flr; mEvent.Level1 = l1; mEvent.Level2 = l2; mEvent.BasePrice = bp; mEvent.MaxPrice = mp; if (mDBC.save(mEvent)) return true; else return false; }
public bool save(Event e) //save event to db { using (SqlConnection connection = new SqlConnection(_TicketingConnection)) { connection.Open(); using (SqlCommand command = new SqlCommand("saveEvent", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@eID", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@Date", SqlDbType.DateTime)); command.Parameters.Add(new SqlParameter("@Floor", SqlDbType.Bit)); command.Parameters.Add(new SqlParameter("@Level1", SqlDbType.Bit)); command.Parameters.Add(new SqlParameter("@Level2", SqlDbType.Bit)); command.Parameters.Add(new SqlParameter("@BasePrice", SqlDbType.Decimal)); command.Parameters.Add(new SqlParameter("@MaxPrice", SqlDbType.Decimal)); command.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar)); command.Parameters["@eID"].Value = e.ID; command.Parameters["@Date"].Value = e.Date; command.Parameters["@Floor"].Value = e.Floor; command.Parameters["@Level1"].Value = e.Level1; command.Parameters["@Level2"].Value = e.Level2; command.Parameters["@BasePrice"].Value = e.BasePrice; command.Parameters["@MaxPrice"].Value = e.MaxPrice; command.Parameters["@Name"].Value = e.Name; command.ExecuteNonQuery(); } } return true; }
public AddEventController() { mEvent = new Event(); mDBC = new DBConnector(); }