示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Product       product = new Product();
            CreateProduct form    = new CreateProduct(product);

            form.Text = "Add Product";
            if (form.ShowDialog() == DialogResult.OK)
            {
                pro.Add(product);
                listBox1.Items.Add(product);
            }
        }
示例#2
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex >= 0)
     {
         Product       product = new Product();
         CreateProduct form1   = new CreateProduct(product);
         form1.label1.Text            = "Info Product";
         form1.button2.Text           = "OK";
         form1.Text                   = "Info Product";
         form1.textBox1.Enabled       = false;
         form1.textBox2.Enabled       = false;
         form1.comboBox1.Enabled      = false;
         form1.numericUpDown1.Enabled = false;
         form1.button2.Enabled        = true;
         form1.checkBox1.Visible      = false;
         form1.textBox1.Text          = pro[listBox1.SelectedIndex].Name.ToString();
         form1.textBox2.Text          = pro[listBox1.SelectedIndex].Amount.ToString();
         form1.comboBox1.Text         = pro[listBox1.SelectedIndex].Country.ToString();
         form1.numericUpDown1.Value   = pro[listBox1.SelectedIndex].Price;
         form1.ShowDialog();
     }
 }
示例#3
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex >= 0)
     {
         Product       product = new Product();
         CreateProduct form    = new CreateProduct(product);
         form.label1.Text          = "Edit Product";
         form.button2.Text         = "Edit";
         form.Text                 = "Edit Product";
         form.textBox1.Text        = pro[listBox1.SelectedIndex].Name.ToString();
         form.textBox2.Text        = pro[listBox1.SelectedIndex].Amount.ToString();
         form.comboBox1.Text       = pro[listBox1.SelectedIndex].Country.ToString();
         form.numericUpDown1.Value = pro[listBox1.SelectedIndex].Price;
         if (form.ShowDialog() == DialogResult.OK)
         {
             pro[listBox1.SelectedIndex].Name    = form.textBox1.Text;
             pro[listBox1.SelectedIndex].Amount  = Convert.ToInt32(form.textBox2.Text);
             pro[listBox1.SelectedIndex].Country = form.comboBox1.Text;
             pro[listBox1.SelectedIndex].Price   = form.numericUpDown1.Value;
             listBox1.Items.RemoveAt(listBox1.SelectedIndex);
             listBox1.Items.Add(product);
         }
     }
 }