Example #1
0
        // Show animal info
        protected void ListBox_Stock_SelectedIndexChanged(object sender, EventArgs e)
        {
            ViewState["selectedIndex"] = ListBox_Stock.SelectedIndex;
            controller = Persistence.PersistenceController.Instance();
            animals = controller.getStock();

            Bird b;
            Fish f;
            Animal a = (Animal) animals[(int)ViewState["selectedIndex"]];

            if (a.GetType() == typeof(Bird))
            {
                b = (Bird) animals[(int)ViewState["selectedIndex"]];
                a = (Animal)animals[(int)ViewState["selectedIndex"]];

                TextBox_AnimalInfo.Text = a.ToString() + b.ToString();
            }
            if (a.GetType() == typeof(Fish))
            {
                f = (Fish) animals[(int)ViewState["selectedIndex"]];
                a = (Animal)animals[(int)ViewState["selectedIndex"]];

                TextBox_AnimalInfo.Text = "";
                TextBox_AnimalInfo.Text = a.ToString() + f.ToString();
            }
        }
Example #2
0
        // Asynch Load data to database
        protected void loadData()
        {
            cartAnimals = new ArrayList();
            controller = Persistence.PersistenceController.Instance();
            controller.readData();
            animals = controller.getStock();

            foreach (Animal a in animals)
            {
                ListBox_Stock.Items.Add(a.type);
            }
        }