Example #1
0
 private void button7_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex == 2 && item6volt.Text == "")
     {
         MessageBox.Show("Enter Secific sport or 'General'");
     }
     else if (shop.GetItemByName(item1Name.Text) == null || !(shop.GetItemByName(item1Name.Text) is SportsItem))
     {
         MessageBox.Show("Sports Item not found!");
     }
     else
     {
         SportsItem si = (SportsItem)(shop.GetItemByName(item1Name.Text));
         si.AddSport(item6volt.Text);
     }
 }
Example #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            Item i = shop.GetItemByName(item1Name.Text);

            if (i == null)
            {
                MessageBox.Show("Item Not Found !!");
                ClearAllInfo();
            }
            else
            {
                bool b = false;
                if (comboBox1.SelectedIndex == 1) // electric
                {
                    ElectricItem ei = (ElectricItem)i;
                    ei.SetPrice(double.Parse(item3Price.Text));
                    ei.SetRecycable(checkBox1.Checked);
                    ei.SetUserInstructions(Item5Desc.Text);
                    b = shop.UpdateItem(i);
                }
                else if (comboBox1.SelectedIndex == 2) // sports
                {
                    SportsItem ei = (SportsItem)i;
                    ei.SetPrice(double.Parse(item3Price.Text));
                    ei.SetRecycable(checkBox1.Checked);
                    ei.SetUserInstructions(Item5Desc.Text);
                    b = shop.UpdateItem(i);
                }
                else // just item
                {
                    i.SetPrice(double.Parse(item3Price.Text));
                    i.SetRecycable(checkBox1.Checked);
                    b = shop.UpdateItem(i);
                }

                if (b)
                {
                    MessageBox.Show("Item Updated !!");
                    FillData(i);
                }
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ValidItem())
            {
                Item i;
                bool b = false;
                if (comboBox1.SelectedIndex == 1) // electric
                {
                    i = new ElectricItem(item2Company.Text, item1Name.Text, double.Parse(item3Price.Text), checkBox1.Checked, Item5Desc.Text);
                    b = shop.AddItem(i);
                }
                else if (comboBox1.SelectedIndex == 2) // sports
                {
                    i = new SportsItem(item2Company.Text, item1Name.Text, double.Parse(item3Price.Text), checkBox1.Checked, Item5Desc.Text);
                    b = shop.AddItem(i);
                }
                else // just item
                {
                    i = new Item(item2Company.Text, item1Name.Text, double.Parse(item3Price.Text), checkBox1.Checked);
                    b = shop.AddItem(i);
                }

                if (b)
                {
                    MessageBox.Show("Item Added !!");
                    toStringText.Text = shop.GetItemByName(item1Name.Text).ToString();
                }
                else
                {
                    MessageBox.Show("General or Duplicate Item Error!!");
                }
            }
            else
            {
                MessageBox.Show("Missing Basic Informathion...");
            }
        }