예제 #1
0
 private void btAdd_Click(object sender, EventArgs e)
 {
     if ((cbCinema.Text == "") || (cbHall.Text == "") || (cbFilm.Text == ""))
     {
         MessageBox.Show("Вы заполнили не все поля!");
     }
     else
     {
         DateTime t = new DateTime(dtpDate.Value.Year, dtpDate.Value.Month, dtpDate.Value.Day, (int)nudHour.Value, (int)nudMin.Value, 0);
         if (add)
         {
             SessionWork.Add(db.HallSet.Find(((Hall)(cbHall.SelectedValue)).ID), t, db.FilmSet.Find(((Film)(cbFilm.SelectedValue)).ID), (short)nudPrice.Value);
         }
         else
         {
             DialogResult dialogResult = MessageBox.Show("Данные о сеансе будут сохранены. Вы уверены, что хотите изменить их?", "Сохранение изменений", MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 SessionWork.Change(db.HallSet.Find(((Hall)(cbHall.SelectedValue)).ID), t, db.FilmSet.Find(((Film)(cbFilm.SelectedValue)).ID), (short)nudPrice.Value, session.ID);
             }
         }
         db.SaveChanges();
         form.UpdateSession();
         saved = true;
     }
 }
예제 #2
0
        /// <summary>
        /// Удаление зала
        /// </summary>
        /// <param name="ID"></param>
        public static void Delete(int ID)
        {
            List <Session> h = (db.HallSet.Find(ID)).Session.ToList();

            foreach (Session x in h)
            {//удаляем все сеансы
                SessionWork.Delete(x.ID, db);
            }
            db.HallSet.Find(ID).Deleted = true;
            db.SaveChanges();
        }
예제 #3
0
        /// <summary>
        /// Удаление фильма
        /// </summary>
        /// <param name="ID"></param>
        public static void Delete(int ID)
        {
            Film           s   = db.FilmSet.Find(ID);
            List <Session> ses = s.Session.ToList();

            foreach (Session x in ses)
            {//удаляем все сеансы данного фильма
                SessionWork.Delete(x.ID, db);
            }
            db.FilmSet.Remove(s);
            db.SaveChanges();
        }
예제 #4
0
        private void DeleteSessions()
        {
            DialogResult dialogResult = MessageBox.Show("Сеансы будут удалены безвозвратно. Вы действительно хотите удалить сеансы?", "Удаление сеанса", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                for (int i = 0; i < dgvList.SelectedRows.Count; i++)
                {
                    Session s = db.SessionSet.Find(dgvList.SelectedRows[i].Cells[0].Value);
                    SessionWork.Delete(s.ID, db);
                }
            }
            db.SaveChanges();
            UpdateSession();
        }
예제 #5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     user = eUser.Клиент;
     BlockZapr();
     BlockNewEnt();
     btExit.Enabled = false;
     foreach (Session d in db.SessionSet)
     {
         if (d.Time < DateTime.Now)
         {
             SessionWork.Delete(d.ID, db);
         }
     }
     db.SaveChanges();
     ListNull();
     ListDB();
 }
예제 #6
0
        /// <summary>
        /// Многопараметрический поиск
        /// </summary>
        /// <param name="ok"></param>
        public void Search(bool ok)
        {//функция для многопараметрического поиска
            switch (NowEnt)
            {
            case eEntity.Фильм:
            {
                if (ok)
                {
                    nowfilms = FilmWork.Find(nowfilms, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                else
                {
                    films.AddRange(nowfilms);
                    nowfilms = db.FilmSet.ToList();
                    nowfilms = FilmWork.Find(nowfilms, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                List <Film> vivod = new List <Film>();
                vivod.AddRange(films);
                vivod.AddRange(nowfilms);
                dgvList.DataSource = (from d in vivod select new { d.ID, d.Name, d.Year, d.Producer, d.length, d.AgeLimit }).Distinct().ToList();
                FilmsColomns();
                dgvList.Update();
                break;
            }

            case eEntity.Сеанс:
            {
                if (ok)
                {
                    nowsessions = SessionWork.Find(nowsessions, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                else
                {
                    sessions.AddRange(nowsessions);
                    nowsessions = db.SessionSet.ToList();
                    nowsessions = SessionWork.Find(nowsessions, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                List <Session> vivod = new List <Session>();
                vivod.AddRange(sessions);
                vivod.AddRange(nowsessions);
                dgvList.DataSource = (from d in vivod where d.Time > DateTime.Now select new { d.ID, d.Time, d.Film.Name, d.Hall.Cinema.City, d.Hall.Cinema.Adress, d.Price, d.Hall.Num }).Distinct().ToList();
                SessionColomns();
                dgvList.Update();
                break;
            }

            case eEntity.Кинотеатр:
            {
                if (ok)
                {
                    nowcinemas = CinemaWork.Search(nowcinemas, cbAtr.Text, cbSign.Text, tbEqv.Text).ToList();
                }
                else
                {
                    cinemas.AddRange(nowcinemas);
                    nowcinemas = db.CinemaSet.ToList();
                    nowcinemas = CinemaWork.Search(nowcinemas, cbAtr.Text, cbSign.Text, tbEqv.Text).ToList();
                }
                List <Cinema> vivod = new List <Cinema>();
                vivod.AddRange(cinemas);
                vivod.AddRange(nowcinemas);
                if (user != eUser.Админ)
                {
                    dgvList.DataSource = (from d in vivod where d.Deleted == false select new { d.ID, d.Name, d.City, d.Adress }).Distinct().ToList();
                }
                else
                {
                    dgvList.DataSource = (from d in vivod select new { d.ID, d.Name, d.City, d.Adress, d.Deleted }).Distinct().ToList();
                }
                CinemaColomns();
                dgvList.Update();
                break;
            }

            case eEntity.Зал:
            {
                if (ok)
                {
                    nowhalls = HallWork.Search(nowhalls, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                else
                {
                    halls.AddRange(nowhalls);
                    nowhalls = db.HallSet.ToList();
                    nowhalls = HallWork.Search(nowhalls, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                List <Hall> vivod = new List <Hall>();
                vivod.AddRange(halls);
                vivod.AddRange(nowhalls);
                if (user != eUser.Админ)
                {
                    dgvList.DataSource = (from d in vivod where d.Deleted == false select new { d.ID, d.Num, d.Cinema.Name, d.Cinema.City, d.Type, d.AmountOfRow, d.AmountOfSeats }).Distinct().ToList();
                }
                else
                {
                    dgvList.DataSource = (from d in vivod select new { d.ID, d.Num, d.Cinema.Name, d.Cinema.City, d.Type, d.AmountOfRow, d.AmountOfSeats, d.Deleted }).Distinct().ToList();
                }
                HallColomns();
                dgvList.Update();
                break;
            }

            case eEntity.Кассир:
            {
                if (ok)
                {
                    nowcashiers = CashierWork.Find(nowcashiers, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text);
                }
                else
                {
                    cashiers.AddRange(nowcashiers);
                    nowcashiers = db.СashierSet.ToList();
                    nowcashiers = CashierWork.Find(nowcashiers, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text);
                }
                List <Сashier> vivod = new List <Сashier>();
                vivod.AddRange(cashiers);
                vivod.AddRange(nowcashiers);
                dgvList.DataSource = (from d in vivod select new { d.ID, d.FIO, d.Cinema.City, d.Cinema.Name, d.Login, d.Password }).Distinct().ToList();
                CashierColomns();
                dgvList.Update();
                break;
            }

            case eEntity.Билет:
            {
                if (ok)
                {
                    nowtickets = TicketWork.Find(nowtickets, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                else
                {
                    tickets.AddRange(nowtickets);
                    nowtickets = db.TicketSet.ToList();
                    nowtickets = TicketWork.Find(nowtickets, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                List <Ticket> vivod = new List <Ticket>();
                vivod.AddRange(tickets);
                vivod.AddRange(nowtickets);
                dgvList.DataSource = (from d in vivod select new { d.Number, d.Seat.NumberOfRow, d.Seat.NumberOfSeat, d.Seat.Session.Time, d.Seat.Session.Film.Name, d.Seat.Session.Hall.Num, d.Seat.Session.Hall.Cinema.Adress }).Distinct().ToList();
                TBColomns();
                dgvList.Update();
                break;
            }

            case eEntity.Бронь:
            {
                if (ok)
                {
                    nowbookings = BookingWork.Find(nowbookings, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                else
                {
                    bookings.AddRange(nowbookings);
                    nowbookings = db.BookingSet.ToList();
                    nowbookings = BookingWork.Find(nowbookings, cbEnt.Text, cbAtr.Text, cbSign.Text, tbEqv.Text, cbEqv.Text);
                }
                List <Booking> vivod = new List <Booking>();
                vivod.AddRange(bookings);
                vivod.AddRange(nowbookings);
                dgvList.DataSource = (from d in vivod select new { d.Number, d.Seat.NumberOfRow, d.Seat.NumberOfSeat, d.Seat.Session.Time, d.Seat.Session.Film.Name, d.Seat.Session.Hall.Num, d.Seat.Session.Hall.Cinema.Adress }).Distinct().ToList();
                TBColomns();
                dgvList.Update();
                break;
            }

            default: { break; }
            }
        }
예제 #7
0
        /// <summary>
        /// Многопараметрический поиск билета
        /// </summary>
        /// <param name="f"></param>
        /// <param name="ent"></param>
        /// <param name="atr"></param>
        /// <param name="sign"></param>
        /// <param name="eqv"></param>
        /// <param name="eqv2"></param>
        /// <returns></returns>
        public static List <Ticket> Find(List <Ticket> f, string ent, string atr, string sign, string eqv, string eqv2)
        {
            List <Ticket> result = new List <Ticket>();

            switch (ent)
            {
            case "Место":
            {
                switch (atr)
                {
                case "Ряд":
                {
                    switch (sign)
                    {
                    case "=": { result = (from d in f where d.Seat.NumberOfRow == int.Parse(eqv) select d).ToList(); break; }

                    case "!=": { result = (from d in f where d.Seat.NumberOfRow != int.Parse(eqv) select d).ToList(); break; }

                    case ">": { result = (from d in f where d.Seat.NumberOfRow > int.Parse(eqv) select d).ToList(); break; }

                    case "<": { result = (from d in f where d.Seat.NumberOfRow < int.Parse(eqv) select d).ToList(); break; }

                    case ">=": { result = (from d in f where d.Seat.NumberOfRow >= int.Parse(eqv) select d).ToList(); break; }

                    case "<=": { result = (from d in f where d.Seat.NumberOfRow <= int.Parse(eqv) select d).ToList(); break; }
                    }
                    break;
                }

                case "Номер в ряду":
                {
                    switch (sign)
                    {
                    case "=": { result = (from d in f where d.Seat.NumberOfSeat == int.Parse(eqv) select d).ToList(); break; }

                    case "!=": { result = (from d in f where d.Seat.NumberOfSeat != int.Parse(eqv) select d).ToList(); break; }

                    case ">": { result = (from d in f where d.Seat.NumberOfSeat > int.Parse(eqv) select d).ToList(); break; }

                    case "<": { result = (from d in f where d.Seat.NumberOfSeat < int.Parse(eqv) select d).ToList(); break; }

                    case ">=": { result = (from d in f where d.Seat.NumberOfSeat >= int.Parse(eqv) select d).ToList(); break; }

                    case "<=": { result = (from d in f where d.Seat.NumberOfSeat <= int.Parse(eqv) select d).ToList(); break; }
                    }
                    break;
                }
                }
                break;
            }

            case "Билет":
            {
                switch (sign)
                {
                case "=": { result = (from d in f where d.Number == int.Parse(eqv) select d).ToList(); break; }

                case "!=": { result = (from d in f where d.Number != int.Parse(eqv) select d).ToList(); break; }

                case ">": { result = (from d in f where d.Number > int.Parse(eqv) select d).ToList(); break; }

                case "<": { result = (from d in f where d.Number < int.Parse(eqv) select d).ToList(); break; }

                case ">=": { result = (from d in f where d.Number >= int.Parse(eqv) select d).ToList(); break; }

                case "<=": { result = (from d in f where d.Number <= int.Parse(eqv) select d).ToList(); break; }
                }
                break;
            }

            default:
            {
                List <Session> cin  = SessionWork.Find(db.SessionSet.ToList(), ent, atr, sign, eqv, eqv2);
                List <Ticket>  cash = new List <Ticket>();
                foreach (Session x in cin)
                {
                    foreach (Seat y in x.Seat)
                    {
                        if (y.Ticket != null)
                        {
                            cash.Add(y.Ticket);
                        }
                    }
                }
                result = (from d in f select d).Intersect(from a in cash select a).ToList();
                break;
            }
            }
            return(result);
        }
예제 #8
0
        public void AddFromArr()
        {
            Cinema c     = null;
            Hall   h     = null;
            Film   f     = null;
            int    wrong = 0;

            for (int i = 1; i <= iLastRow; i++)
            {
                try
                {
                    bool ok = false;
                    foreach (Cinema x in db.CinemaSet)
                    {
                        if ((x.Name == dataArr[i, 1] as string) && (!x.Deleted))
                        {
                            ok = true;
                            c  = x;
                            break;
                        }
                    }
                    if (!ok)
                    {
                        wrong++;
                    }
                    else
                    {
                        ok = false;
                        foreach (Hall x in c.Hall)
                        {
                            if ((x.Num == (byte)Convert.ChangeType(dataArr[i, 2], typeof(byte))) && (!x.Deleted))
                            {
                                h  = x;
                                ok = true;
                                break;
                            }
                        }
                        if (!ok)
                        {
                            wrong++;
                            break;
                        }
                        else
                        {
                            ok = false;
                            foreach (Film x in db.FilmSet)
                            {
                                if (x.Name == dataArr[i, 3] as string)
                                {
                                    f  = x;
                                    ok = true;
                                    break;
                                }
                            }
                            if (!ok)
                            {
                                wrong++;
                                break;
                            }
                            else
                            {
                                short    p = (short)Convert.ChangeType(dataArr[i, 4], typeof(short));
                                DateTime t = new DateTime();
                                t = (DateTime)Convert.ChangeType(dataArr[i, 5], typeof(DateTime));
                                SessionWork.Add(h, t, f, p);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    wrong++;
                    MessageBox.Show("Ошибка при чтении информации о сеансе! Данный сеанс не буде добавлен");
                }
            }
        }