/// <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; } } }
/// <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); }