Exemple #1
0
 private void button8_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex == 1 && item6volt.Text == "")
     {
         MessageBox.Show("Must Enter a number for volt!");
     }
     else if (shop.GetItemByName(item1Name.Text) == null || !(shop.GetItemByName(item1Name.Text) is ElectricItem))
     {
         MessageBox.Show("Electric Item not found!");
     }
     else
     {
         ElectricItem ei = (ElectricItem)(shop.GetItemByName(item1Name.Text));
         ei.AddVolt(int.Parse(item6volt.Text));
     }
 }
Exemple #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);
                }
            }
        }
Exemple #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...");
            }
        }