Exemple #1
0
        private void btnUpdateAHall_Click(object sender, EventArgs e)
        {
            int  totalSeatNumber;
            bool checkInput = int.TryParse(txtTotalSeatNumber.Text, out totalSeatNumber);
            int  hallID;
            bool isEntryValueProper = int.TryParse(txtUpdateDeleteHall.Text, out hallID);

            if (!checkInput || !isEntryValueProper)
            {
                MessageBox.Show("Wrong Entry!");
            }
            else
            {
                for (int i = 0; i < listOfAllHalls.Count; i++)
                {
                    if (hallID.Equals(listOfAllHalls.ElementAt(i).getHallID()))
                    {
                        Hall hallz = new Hall(txtHallName.Text, totalSeatNumber);
                        hallz.setHallID(listOfAllHalls.ElementAt(i).getHallID());
                        listOfAllHalls.RemoveAt(i);
                        listOfAllHalls.Insert(i, hallz);
                    }
                }
                lbHalls.Items.Clear();
                lbProjectionHalls.Items.Clear();
                foreach (Hall hallz in listOfAllHalls)
                {
                    lbHalls.Items.Add(hallz);
                    lbProjectionHalls.Items.Add(hallz);
                }
                try
                {
                    using (Stream stream = File.Open("Halls.bin", FileMode.Create))
                    {
                        BinaryFormatter bin = new BinaryFormatter();
                        bin.Serialize(stream, listOfAllHalls);
                    }
                }
                catch (IOException)
                {
                    MessageBox.Show("Error, can't serialize to file.");
                }
            }
        }
Exemple #2
0
        private void btnAddAHall_Click(object sender, EventArgs e)
        {
            if (listOfAllHalls.Count() != 0)
            {
                int  hallID = listOfAllHalls.ElementAt(listOfAllHalls.Count - 1).getHallID();
                int  totalSeatNumber;
                bool checkInput   = int.TryParse(txtTotalSeatNumber.Text, out totalSeatNumber);
                bool isItSameHall = false;
                foreach (Hall hall in listOfAllHalls)
                {
                    if (txtHallName.Text.Equals(hall.getHallName()))
                    {
                        isItSameHall = true;
                    }
                }
                if (!checkInput)
                {
                    MessageBox.Show("Wrong Entry!");
                }
                else
                {
                    Hall hallz = new Hall(txtHallName.Text, totalSeatNumber);
                    hallz.setHallID(hallID + 1);
                    if (!isItSameHall)
                    {
                        listOfAllHalls.Add(hallz);
                        lbHalls.Items.Clear();
                        lbProjectionHalls.Items.Clear();
                        foreach (Hall hall in listOfAllHalls)
                        {
                            lbHalls.Items.Add(hall);
                            lbProjectionHalls.Items.Add(hall);
                        }

                        try
                        {
                            using (Stream stream = File.Open("Halls.bin", FileMode.Create))
                            {
                                BinaryFormatter bin = new BinaryFormatter();
                                bin.Serialize(stream, listOfAllHalls);
                            }
                        }
                        catch (IOException)
                        {
                            MessageBox.Show("Error, can't serialize to file.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The following hall: " + hallz + " already exists in database.");
                    }
                }
            }
            else
            {
                int  totalSeatNumber;
                bool checkInput = int.TryParse(txtTotalSeatNumber.Text, out totalSeatNumber);
                if (!checkInput)
                {
                    MessageBox.Show("Wrong Entry!");
                }
                else
                {
                    listOfAllHalls.Add(new Hall(txtHallName.Text, totalSeatNumber));
                    lbHalls.Items.Clear();
                    lbProjectionHalls.Items.Clear();
                    foreach (Hall hall in listOfAllHalls)
                    {
                        lbHalls.Items.Add(hall);
                        lbProjectionHalls.Items.Add(hall);
                    }

                    {
                        try
                        {
                            using (Stream stream = File.Open("Halls.bin", FileMode.Create))
                            {
                                BinaryFormatter bin = new BinaryFormatter();
                                bin.Serialize(stream, listOfAllHalls);
                            }
                        }
                        catch (IOException)
                        {
                            MessageBox.Show("Error, can't serialize to file.");
                        }
                    }
                }
            }
        }
Exemple #3
0
 public Projection(string projectionTime, Movie movie, Hall hall)
 {
     this.projectionTime = projectionTime;
     this.movie          = movie;
     this.hall           = hall;
 }