Exemplo n.º 1
0
        private void DeleteHall()
        {
            Hall s = db.HallSet.Find(dgvList.SelectedRows[0].Cells[0].Value);

            if (!s.Deleted)
            {
                DialogResult dialogResult = MessageBox.Show("Зал будет помечен, как удаленный, пользователи не смогут его увидеть. Вы сможете вернуть его в любое время. Однако все сеансы будут удалены безвозвратно. Возможно, на них были куплены билеты! Вы действительно хотите удалить зал? ", "Удаление зала", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    HallWork.Delete(s.ID);
                }
            }
            else
            {
                if (!s.Cinema.Deleted)
                {
                    DialogResult dialogResult = MessageBox.Show("Зал будет восстановлен. Пользователи смогут его увидеть. Вы уверены, что хотите восстановить зал?", "Восстановление зала", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        HallWork.Restore(s.ID);
                    }
                }
                else
                {
                    MessageBox.Show("Зал не может быть восстановлен, так как удален кинотеатр. Сначала восстановите кинотеатр!");
                }
            }
            db.SaveChanges();
            UpdateHall();
            Information();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Восстановление кинотеатра
 /// </summary>
 /// <param name="ID"></param>
 public static void Restore(int ID)
 {
     foreach (Hall x in (db.CinemaSet.Find(ID)).Hall)
     {//восстанавливаем все кинотеатры данного фильма
         HallWork.Restore(x.ID);
     }
     db.CinemaSet.Find((db.CinemaSet.Find(ID)).ID).Deleted = false;
     db.SaveChanges();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Удаление кинотеатра
        /// </summary>
        /// <param name="ID"></param>
        public static void Delete(int ID)
        {
            List <Hall> h = (db.CinemaSet.Find(ID)).Hall.ToList();

            foreach (Hall x in h)
            {//удаляем все кинотеатры данного фильма
                HallWork.Delete(x.ID);
            }
            List <Сashier> c = (db.CinemaSet.Find(ID)).Сashier.ToList();

            foreach (Сashier x in c)
            {
                db.СashierSet.Remove(x);
            }
            db.CinemaSet.Find(ID).Deleted = true;
            db.SaveChanges();
        }
Exemplo n.º 4
0
 private void btAdd_Click(object sender, EventArgs e)
 {
     if ((dudType.Text == "") || (cbCinema.Text == ""))
     {
         MessageBox.Show("Вы заполнили не все поля!");
     }
     else
     {
         if (add)
         {
             HallWork.Add(db.CinemaSet.Find(((Cinema)cbCinema.SelectedValue).ID), (byte)nudNumber.Value, dudType.Text, (byte)nudRows.Value, (byte)nudSeats.Value);
         }
         else
         {
             HallWork.Change(hall.Cinema, (byte)nudNumber.Value, dudType.Text, (byte)nudRows.Value, (byte)nudSeats.Value, hall.ID);
         }
         form.UpdateHall();
         saved = true;
     }
 }
Exemplo n.º 5
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; }
            }
        }
Exemplo n.º 6
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 <Session> Find(List <Session> f, string ent, string atr, string sign, string eqv, string eqv2)
        {
            List <Session> result = new List <Session>();

            switch (ent)
            {
            case "Фильм":
            {
                List <Film>    cin  = FilmWork.Find(db.FilmSet.ToList(), atr, sign, eqv, eqv2);
                List <Session> cash = new List <Session>();
                foreach (Film x in cin)
                {
                    cash.AddRange(x.Session);
                }
                result = (from d in f select d).Intersect(from a in cash select a).ToList();
                break;
            }

            case "Сеанс":
            {
                switch (atr)
                {
                case "Дата":
                {
                    switch (sign)
                    {
                    case "=": { result = (from d in f where d.Time.Date == DateTime.Parse(eqv).Date select d).ToList(); break; }

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

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

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

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

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

                case "Цена":
                {
                    switch (sign)
                    {
                    case "=": { result = (from d in f where d.Price == int.Parse(eqv) select d).ToList(); break; }

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

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

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

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

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

                case "Время":
                {
                    switch (sign)
                    {
                    case "=": { result = (from d in f where d.Time.TimeOfDay == TimeSpan.Parse(eqv) select d).ToList(); break; }

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

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

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

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

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

            default:
            {
                List <Hall>    cin  = HallWork.Search(db.HallSet.ToList(), ent, atr, sign, eqv, eqv2);
                List <Session> cash = new List <Session>();
                foreach (Hall x in cin)
                {
                    cash.AddRange(x.Session);
                }
                result = (from d in f select d).Intersect(from a in cash select a).ToList();
                break;
            }
            }
            return(result);
        }