Está en la página 1de 3

Activeness

string[] name = new string[5]; int[] price = new int[5]; int[] quantity=new int [5]; string []a=new string [5]; int counter; private void Form1_Load(object sender, EventArgs e) { comboBox1.Items.Add("active"); comboBox1.Items.Add("nonactive"); } private void button1_Click(object sender, EventArgs e) { if(counter<5) { name[counter]=textBox1.Text; price[counter]=Convert.ToInt32(textBox2.Text); quantity [counter]=Convert.ToInt32(textBox3.Text); a[counter]=comboBox1.Text; counter++; } else { MessageBox.Show("array is full"); } } private void button2_Click(object sender, EventArgs e) { for(int i=0; i<5; i++) { if(a[i]=="active") {

listBox1.Items.Add(name[i]); } } for(int i=0; i<5; i++) { if (a[i] == "nonactive") {

listBox2.Items.Add(name[i]); } }

} } }

Dvd purchase
int d = 20; int g =20; int f =20; private void Form1_Load(object sender, EventArgs e) { comboBox1.Items.Add("master"); comboBox1.Items.Add("1080dvd"); comboBox1.Items.Add("simple"); textBox2.Text = Convert.ToString(d); textBox3.Text = Convert.ToString(g); textBox4.Text = Convert.ToString(f);

} private void button1_Click(object sender, EventArgs e) { int a = 35; int b = 40; int c = 55; if (comboBox1.Text == "master") { listBox1.Items.Add("master"); listBox2.Items.Add(Convert.ToString(a)); d--; textBox2.Text = Convert.ToString(d); if (textBox2.Text == Convert.ToString(0)) { MessageBox.Show("stock is finished"); } } else if (comboBox1.Text == "simple") { listBox1.Items.Add("simple"); listBox2.Items.Add(Convert.ToString(b)); g--; textBox3.Text = Convert.ToString(g); if (textBox3.Text == Convert.ToString(0)) { MessageBox.Show("stock is finished"); } } else if (comboBox1.Text == "1080dvd") { listBox1.Items.Add("1080dvd"); listBox2.Items.Add(Convert.ToString(c)); f--; textBox4.Text = Convert.ToString(f); if (textBox4.Text == Convert.ToString(0)) { MessageBox.Show("stock is finished");

} }

} private void button2_Click(object sender, EventArgs e) { int total = 0; double discount = 0; for (int i = 0; i < listBox2.Items.Count; i++) { total += Convert.ToInt32(listBox2.Items[i]); discount = total * 0.2; textBox5.Text = Convert.ToString(discount); textBox1.Text = Convert.ToString(total);

} } private void button3_Click(object sender, EventArgs e) { listBox1.Items.Clear(); listBox2.Items.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox1.Clear(); } } }

También podría gustarte