Пример #1
0
        public fTickets(AuthorisedUser user)
        {
            InitializeComponent();
            this.user = user;
            ReadingFromDateBase reading = new ReadingFromDateBase();

            ticketsList      = reading.ReadTickets();
            percentsList     = reading.ReadPercentages();
            totalPercentList = reading.ReadTotalPercents();
            statusTicketList = reading.ReadStatusTickets();
            sessionList      = reading.ReadSessions();
            LoadDataGridView();
        }
Пример #2
0
 public fSessions(AuthorisedUser user)
 {
     this.user = user;
     InitializeComponent();
     if (user.GetType() == typeof(AdminUser))
     {
         ReadingFromDateBase reading = new ReadingFromDateBase();
         sessionsList = reading.ReadSessions();
         foreach (var i in sessionsList.Sessions)
         {
             filmIds.Add(i.FilmSession.FilmId);
             hallIds.Add(i.HallSession.HallId);
         }
         LoadDataGridView();
         filmList = reading.ReadFilms();
         hallList = reading.ReadHalls();
         FilmComboBox.DataSource    = filmList.Films;
         FilmComboBox.DisplayMember = "FilmName";
         FilmComboBox.ValueMember   = "FilmId";
         HallComboBox.DataSource    = hallList.Halls;
         HallComboBox.DisplayMember = "HallName";
         HallComboBox.ValueMember   = "HallId";
     }
     else
     {
         this.user = user;
         ReadingFromDateBase reading = new ReadingFromDateBase();
         sessionsList = reading.ReadSessions();
         foreach (var i in sessionsList.Sessions)
         {
             filmIds.Add(i.FilmSession.FilmId);
             hallIds.Add(i.HallSession.HallId);
         }
         for (int i = 0; i < sourceData.Count; i++)
         {
             dataGridViewSessions[2, i].Value = filmIds[i];
         }
         LoadDataGridView();
         filmList = reading.ReadFilms();
         hallList = reading.ReadHalls();
         FilmComboBox.DataSource    = filmList.Films;
         FilmComboBox.DisplayMember = "FilmName";
         FilmComboBox.ValueMember   = "FilmId";
         HallComboBox.DataSource    = hallList.Halls;
         HallComboBox.DisplayMember = "HallName";
         HallComboBox.ValueMember   = "HallId";
         AddButton.Visible          = false;
         UpdateButton.Visible       = false;
         DeleteButton.Visible       = false;
     }
 }
Пример #3
0
        public fTickets(AuthorisedUser user, Session session, int row, int placeNumber, double price)
        {
            InitializeComponent();
            this.user = user;
            ReadingFromDateBase reading = new ReadingFromDateBase();

            ticketsList      = reading.ReadTickets();
            percentsList     = reading.ReadPercentages();
            totalPercentList = reading.ReadTotalPercents();
            statusTicketList = reading.ReadStatusTickets();
            sessionList      = reading.ReadSessions();
            LoadDataGridView();
            SessionInput.Text     = session.FilmSession.FilmName;
            RowInput.Text         = row.ToString();
            PlaceNumberInput.Text = placeNumber.ToString();
            PriceInput.Text       = price.ToString();
            TicketInput.Text      = (ticketsList.Tickets.Count() + 1).ToString();
        }
Пример #4
0
        public ListOfSessions ReadSessions()
        {
            Hall               hall;
            Film               film;
            int                sessionId;
            int                filmId;
            int                hallId;
            DateTime           dateSession;
            TimeSpan           timeSession;
            List <PlaceInHall> places            = new List <PlaceInHall>();
            List <Session>     sessionList       = new List <Session>();
            ListOfSessions     sessions          = new ListOfSessions(sessionList);
            SqlConnection      connectToDateBase = new SqlConnection(pathOfDataBase);

            using (connectToDateBase)
            {
                SqlCommand command = new SqlCommand(
                    "SELECT SESSION_ID, [SESSIONS].[HALL_ID], [SESSIONS].[FILM_ID], DATE_SESSION, TIME_SESSION," +
                    "NAME_FILM, LENGTH_FILM, AGE_LIMIT, TICKET_PRICE, NAME_HALL, SEATING_CAPACITY, PLACES_IN_ROW FROM [SESSIONS], [FILMS], [HALLS]" +
                    "WHERE [SESSIONS].[HALL_ID] = [HALLS].[HALL_ID] AND [SESSIONS].[FILM_ID] = [FILMS].[FILM_ID];",
                    connectToDateBase);
                connectToDateBase.Open();
                SqlDataReader readerSession = command.ExecuteReader();
                if (readerSession.HasRows)
                {
                    while (readerSession.Read())
                    {
                        sessionId   = readerSession.GetInt32(0);
                        hallId      = readerSession.GetInt32(1);
                        filmId      = readerSession.GetInt32(2);
                        dateSession = readerSession.GetDateTime(3);
                        timeSession = readerSession.GetTimeSpan(4);
                        film        = new Film(filmId, readerSession.GetString(5), readerSession.GetInt32(6),
                                               readerSession.GetInt32(7), readerSession.GetInt32(8));
                        hall = new Hall(hallId, readerSession.GetString(9), readerSession.GetInt32(10), readerSession.GetInt32(11));
                        Session session = new Session(sessionId, film, hall, dateSession, timeSession);
                        sessionList.Add(session);
                    }
                }
                readerSession.Close();
            }
            return(sessions);
        }