コード例 #1
0
ファイル: Form1.cs プロジェクト: a1exv/winf_dz_3
        private void button1_Click(object sender, EventArgs e)
        {
            tovar tov     = new tovar();
            Form2 addform = new Form2(tov, true);

            addform.ShowDialog();
            tovars.Add(tov);
            comboBox1.Items.Add(tov);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: a1exv/winf_dz_3
 private void button3_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedItem != null)
     {
         listBox1.Items.Add(comboBox1.SelectedItem);
         tovar tmp = (tovar)comboBox1.SelectedItem;
         textBox1.Text = tmp.Price.ToString();
         total        += tmp.Price;
         textBox2.Text = total.ToString();
     }
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: a1exv/winf_dz_3
        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem != null)
            {
                int   n        = comboBox1.SelectedIndex;
                tovar tmp      = (tovar)comboBox1.SelectedItem;
                Form2 editform = new Form2(tmp, false);
                editform.ShowDialog();
                comboBox1.Items.RemoveAt(n);

                comboBox1.Items.Insert(n, tmp);
                comboBox1.SelectedItem = comboBox1.Items[0];
            }
        }
コード例 #4
0
ファイル: Form2.cs プロジェクト: a1exv/winf_dz_3
 public Form2(tovar t, bool addnew)
 {
     temp = t;
     InitializeComponent();
     if (addnew == true)
     {
         button1.Text = "Add";
     }
     else
     {
         button1.Text  = "Edit";
         textBox1.Text = t.Name;
         textBox2.Text = t.Descr;
         textBox3.Text = t.Price.ToString();
     }
 }