Пример #1
0
        //method changes the status of availability
        public void setAvailability()
        {
            MoviesForRent item = new MoviesForRent();
            string        shoppingCartItem;
            string        availChange = "CheckedOut";

            char[] delim = { ',' };

            for (int i = 0; i < lsBoxShoppingCart.Items.Count; i++)
            {
                lsBoxShoppingCart.SetSelected(i, true);
                shoppingCartItem = lsBoxShoppingCart.SelectedItem.ToString();
                string[] tokens = shoppingCartItem.Split(delim);
                item.category  = tokens[0];
                item.title     = tokens[1];
                item.movieType = tokens[2];
                item.movieCost = tokens[3];

                for (int j = 0; j < movieInventory.Count; j++)
                {
                    if (movieInventory.Contains(item))
                    {
                        movieInventory.RemoveAt(j);
                    }
                }

                item.availability = availChange;

                movieInventory.Add(item);
            }
        }
Пример #2
0
        //Method to create the struct object list
        private void ReadInventory()
        {
            StreamReader reader;
            string       newLine;

            try
            {
                MoviesForRent item = new MoviesForRent();
                reader = File.OpenText("Movies.dat");
                char[] delim = { ',' };

                while (!reader.EndOfStream)
                {
                    newLine = reader.ReadLine();
                    string[] tokens = newLine.Split(delim);

                    //struct object properties
                    item.category     = tokens[0];
                    item.title        = tokens[1];
                    item.movieType    = tokens[2];
                    item.movieCost    = tokens[3];
                    item.availability = tokens[4];

                    movieInventory.Add(item);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            categoryBxLoad();
        }