Example #1
0
 public AddHall(Form1 forma, bool add, Hall x)
 {
     InitializeComponent();
     form                   = forma;
     form.Enabled           = false;
     this.add               = add;
     hall                   = x;
     cbCinema.DataSource    = (from d in db.CinemaSet where d.Deleted == false select d).ToList();
     cbCinema.DisplayMember = "Name";
     cbCinema.Update();
     texts();
 }
 /// <summary>
 /// Редактирование сеанса
 /// </summary>
 /// <param name="hall"></param>
 /// <param name="date"></param>
 /// <param name="film"></param>
 /// <param name="price"></param>
 /// <param name="ID"></param>
 public static void Change(Hall hall, DateTime date, Film film, short price, int ID)
 {
     if (Check(hall, date, false, ID))
     {
         db.SessionSet.Find(ID).Film  = db.FilmSet.Find(film.ID);
         db.SessionSet.Find(ID).Hall  = db.HallSet.Find(hall.ID);
         db.SessionSet.Find(ID).Price = price;
         db.SessionSet.Find(ID).Date  = date;
         db.SessionSet.Find(ID).Time  = date;
         db.SaveChanges();
     }
 }
Example #3
0
 public FormBuyTickets()
 {
     InitializeComponent();
     Person.Load();
     Hall.Load();
     HallSector.Load();
     HallPlace.Load();
     HallPerson.Load();
     Film.Load();
     Person.Load();
     PersonTicket.Load();
     SessionFilm.Load();
 }
Example #4
0
        private void DeleteHall(Hall m)
        {
            DialogResult res = MessageBox.Show("Remove hall??", "Deleting a hall", MessageBoxButtons.YesNo);

            if (res == DialogResult.Yes)
            {
                Database.Halls.Remove(m);
                MessageBox.Show("Hall removed");
                Back();
                Back();
                HallsMenu();
            }
        }
Example #5
0
 /// <summary>
 /// Добавление зала
 /// </summary>
 /// <param name="cinema"></param>
 /// <param name="num"></param>
 /// <param name="type"></param>
 /// <param name="rows"></param>
 /// <param name="seats"></param>
 public static void Add(Cinema cinema, byte num, string type, byte rows, byte seats)
 {
     if (Check(cinema, num, true, 0))
     {
         Hall c = new Hall();
         c.Num           = num;
         c.Type          = type;
         c.AmountOfRow   = rows;
         c.AmountOfSeats = seats;
         c.Cinema        = db.CinemaSet.Find(cinema.ID);
         db.HallSet.Add(c);
         db.SaveChanges();
     }
 }
        static void Main(string[] args)
        {
            Cinema cinema  = new Cinema("zaqulba", "BUZOVNA");
            Hall   hall    = new Hall("Vip", 20);
            Person sirvan  = new Person(360);
            Seat   seat1   = new Seat(5, 6, sirvan);
            Cinema cinema1 = new Cinema("Nizami", "Semed vurgun");

            hall.AddPerson(seat1);
            Person flankes = new Person(25);
            Seat   seat2   = new Seat(10, 11, flankes);

            hall.AddPerson(seat2);
            Console.WriteLine(hall.Empty());
        }
Example #7
0
        private void Add_Session(Hall hall, Movie movie)
        {
            Console.Clear();
            Console.WriteLine("Enter data new sessions");
            Session session = new Session();

            Console.Write("Select Session:");
            session.hall  = hall;
            session.movie = movie;
            bool end = true;

            while (end)
            {
                end = false;
                try
                {
                    Console.WriteLine("Enter time");
                    Console.WriteLine("Enter day");
                    int day = Int32.Parse(Console.ReadLine());
                    Console.WriteLine("Enter Month");
                    int Month = Int32.Parse(Console.ReadLine());
                    Console.WriteLine("Enter Year");
                    int Year = Int32.Parse(Console.ReadLine());
                    Console.WriteLine("Enter Hour");
                    int Hour = Int32.Parse(Console.ReadLine());
                    Console.WriteLine("Enter Minute");
                    int Minute = Int32.Parse(Console.ReadLine());

                    session.time = new DateTime(Year, Month, day, Hour, Minute, 0);
                }
                catch (Exception)
                {
                    Console.Clear();
                    end = true;
                    Console.WriteLine("you entered an incorrect date");
                }
            }



            MessageBox.Show("Session added!!");

            dataBase.sessions.Add(session);
            dataBase.Write(dataBase);
            manager.Pop();
            manager.Pop();
        }
Example #8
0
        private void Remove_Hall(Hall hall)
        {
            //Console.Clear();
            DialogResult res = MessageBox.Show("Remove Hall?", "Caption of window", MessageBoxButtons.YesNo);

            if (res == DialogResult.Yes)
            {
                //Console.WriteLine("Your answer is YES");
                dataBase.halls.Remove(hall);
                Pop_Back();
            }
            else
            {
                Show_Hall("Remove hall");
                // Console.WriteLine("Your answer is NO");
            }
        }
        public void GetHall()
        {
            Hall hall;

            allHallList.Clear();
            HallNameList.Clear();

            try
            {
                using (OracleConnection connection = new OracleConnection(OracleDatabaseConnection.connection_meneger))
                {
                    connection.Open();
                    OracleParameter us_cur = new OracleParameter
                    {
                        ParameterName = "us_cur",
                        Direction     = ParameterDirection.Output,
                        OracleDbType  = OracleDbType.RefCursor
                    };

                    using (OracleCommand command = new OracleCommand("admin.getHallList"))
                    {
                        command.Connection  = connection;
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddRange(new OracleParameter[] { us_cur });
                        var       reader = command.ExecuteReader();
                        DataTable dt     = new DataTable();
                        dt.Load(reader);

                        foreach (DataRow row in dt.Rows)
                        {
                            string name     = row["Name"].ToString();
                            string capacity = row["Capacity"].ToString();

                            hall = new Hall(name, capacity);
                            allHallList.Add(hall);
                            HallNameList.Add(name);
                        }
                    }
                }
            }
            catch (OracleException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #10
0
        private void FormBuyTickets_FormClosed(object sender, FormClosedEventArgs e)
        {
            Base <Person> .TextSave();

            Base <Person> .Json();

            Person.Save();
            Hall.Save();
            HallSector.Save();
            HallPlace.Save();
            HallSpace.Save();
            HallAdding.Save();
            HallPerson.Save();
            Film.Save();
            Person.Save();
            PersonTicket.Save();
            SessionFilm.Save();
        }
Example #11
0
        private void Add_Hall()
        {
            Console.Clear();
            Console.WriteLine("Entr data new hall");
            Hall hall = new Hall();

            Console.Write("Title:");
            hall.title = Console.ReadLine();
            Console.Write("Rows:");
            hall.num_rows = byte.Parse(Console.ReadLine());
            Console.Write("Seats by row:");
            hall.num_seats = byte.Parse(Console.ReadLine());
            Console.Write("Type(1. 2D, 2. 3D,  3. IMAX )");

            hall.enumType = Int32.Parse(Console.ReadLine());
            switch (hall.enumType)
            {
            case (int)Hall.types._2: hall.TypeStr = "2D"; break;

            case (int)Hall.types._3D: hall.TypeStr = "3D"; break;

            case (int)Hall.types._IMAX: hall.TypeStr = "IMAX"; break;
            }
            var results = new List <ValidationResult>();
            var context = new ValidationContext(hall);

            if (!Validator.TryValidateObject(hall, context, results, true))
            {
                foreach (var error in results)
                {
                    Console.WriteLine(error.ErrorMessage);
                }
            }


            MessageBox.Show("Hall added!!");
            dataBase.halls.Add(hall);
            dataBase.Write(dataBase);
        }
Example #12
0
        /// <summary>
        /// Изменение сеанса
        /// </summary>
        /// <param name="hall"></param>
        /// <param name="date"></param>
        /// <param name="add"></param>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static bool Check(Hall hall, DateTime date, bool add, int ID)
        {
            bool     ok = true;
            TimeSpan q  = new TimeSpan(4, 0, 0);

            foreach (Session x in db.SessionSet)
            {
                if ((x.Hall.Cinema.Name == hall.Cinema.Name) && (x.Hall.Num == hall.Num) && ((x.Time <= date) && ((x.Time + q) >= date) || (x.Time >= date) && ((date + q) >= x.Time)) && ((add) || (!add) && (ID != x.ID)))
                {
                    MessageBox.Show("В данном зале в это время уже идет сеанс!");
                    ok = false;
                    break;
                }
                if (date <= DateTime.Now)
                {
                    MessageBox.Show("Вы не можете добавить сеанс, который уже начался!");
                    ok = false;
                    break;
                }
            }
            return(ok);
        }
Example #13
0
 /// <summary>
 /// Добавление сеанса
 /// </summary>
 /// <param name="hall"></param>
 /// <param name="date"></param>
 /// <param name="film"></param>
 /// <param name="price"></param>
 public static void Add(Hall hall, DateTime date, Film film, short price)
 {
     if (Check(hall, date, true, 0))
     {
         Session c = new Session();
         c.Film  = db.FilmSet.Find(film.ID);
         c.Hall  = db.HallSet.Find(hall.ID);
         c.Price = price;
         c.Date  = date;
         c.Time  = date;
         db.SessionSet.Add(c);
         db.SaveChanges();
         for (int i = 1; i <= c.Hall.AmountOfRow; i++)
         {
             for (int j = 1; j <= c.Hall.AmountOfSeats; j++)
             {
                 SeatWork.Add(c.ID, (byte)i, (byte)j, db);
             }
         }
         db.SaveChanges();
     }
 }
Example #14
0
 public HallPerson(Hall hall, Person person)
 {
     this.Hall       = hall;
     this.Person     = person;
     this.Hall.DelId = this.Id;
 }
Example #15
0
        public void Places()
        {
            if (cBCinema.SelectedItem != null)
            {
                int size = 0;
                foreach (var item in ((Hall)cBCinema.SelectedItem).HallSectors)
                {
                    size += item.HallPlaces.Count;
                }
                Point  point  = new Point(50, 50);
                int    index1 = 0;
                int    count  = 0;
                int    Index  = 0;
                bool   ifSold = false;
                int    length = Convert.ToInt32(340 / Math.Sqrt(size));
                int    x      = 0;
                int    y      = 0;
                double result = Math.Sqrt(size);
                int    index  = 0;
                for (int i = 0; i < size; i++)
                {
                    if (Math.Sqrt(size) == (Int32)result)
                    {
                        x = (Int32)result;
                        y = x;
                        break;
                    }
                    else
                    {
                        index++;
                        size--;
                    }
                }
                for (int i = 0; x <= index; i++)
                {
                    index -= x;
                    x++;
                }
                Hall   h = (Hall)cBCinema.SelectedItem;
                double z = (x - index) / 2;
                for (int i = 0; i <= y; i++)
                {
                    for (int j = 0; j < x; j++)
                    {
                        Index++;
                        if (i < x)
                        {
                            if ((h).HallSectors.Count == index1)
                            {
                                break;
                            }
                            else
                            {
                                if ((h).HallSectors[index1].HallPlaces.Count != count)
                                {
                                    Square sq1 = null;
                                    foreach (var item in h.HallSectors[index1].HallPlaces)
                                    {
                                        if (item.Place == Index && item.IsSold == true)
                                        {
                                            ifSold = true;
                                        }
                                    }
                                    if (ifSold == true)
                                    {
                                        sq1 = new Square(Color.Red, length, length);
                                    }
                                    else if (ifSold == false)
                                    {
                                        sq1 = new Square(h.HallSectors[index1].Color, length, length);
                                    }
                                    Controls.Add(sq1);
                                    sq1.Location = new Point(point.X + j * (length + 1), point.Y + i * (length + 1));
                                    list.Add(sq1);
                                    ifSold = false;
                                    count++;
                                }
                                else
                                {
                                    index1++;
                                    if (j != 0)
                                    {
                                        j--;
                                    }
                                    else
                                    {
                                        i--;
                                        j = x - 1;
                                    }
                                    Index--;
                                    count = 0;
                                }
                            }
                        }

                        else
                        {
                            for (int k = 0; k < index; k++)
                            {
                                if (index1 != h.HallSectors.Count)
                                {
                                    Square sq1 = new Square(h.HallSectors[index1].Color, length, length);
                                    sq1.Height = length;
                                    sq1.Width  = length;
                                    Controls.Add(sq1);
                                    sq1.Location = new Point(point.X + (Int32)(length * z + k) + k * (length + 1), point.Y + (x) * (length + 1));
                                    list.Add(sq1);
                                }
                            }
                        }
                    }
                }
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].Index       = i;
                    list[i].MouseClick += Control_MouseClick;
                }
            }
        }
Example #16
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("Ошибка при чтении информации о сеансе! Данный сеанс не буде добавлен");
                }
            }
        }