Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (radioButton1.Checked == true)
         {
             PKW pkw = new PKW();
             pkw.name           = textBox1.Text;
             pkw.PS             = Convert.ToInt32(textBox2.Text);
             pkw.kilometerstand = Convert.ToInt32(textBox3.Text);
             pkw.verbrauch      = Convert.ToDouble(textBox4.Text);
             pkw.tankinhalt     = Convert.ToInt32(textBox5.Text);
             pkw.personenzahl   = Convert.ToInt32(textBox6.Text);
             Auto_List.Add(pkw);
         }
         else
         {
             LKW lkw = new LKW();
             lkw.name           = textBox11.Text;
             lkw.PS             = Convert.ToInt32(textBox12.Text);
             lkw.kilometerstand = Convert.ToInt32(textBox10.Text);
             lkw.verbrauch      = Convert.ToDouble(textBox9.Text);
             lkw.tankinhalt     = Convert.ToInt32(textBox8.Text);
             lkw.Zuladung_Max   = Convert.ToInt32(textBox7.Text);
             Auto_List.Add(lkw);
         }
         refresh_listbox();
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }
Example #2
0
 private void refresh_listbox()
 {
     try
     {
         listBox1.Items.Clear();
         listBox1.Items.Add("Art: \t Name \t PS: \t Kilometerstand:");
         foreach (object x in Auto_List)
         {
             if (x is PKW)
             {
                 PKW tmp = (PKW)x;
                 listBox1.Items.Add("PKW: \t" + tmp.name + " \t" + tmp.PS + "PS \t" + tmp.kilometerstand);
                 listBox1.Refresh();
             }
             else if (x is LKW)
             {
                 LKW tmp = (LKW)x;
                 listBox1.Items.Add("LKW: \t" + tmp.name + " \t" + tmp.PS + "PS \t" + tmp.kilometerstand);
                 listBox1.Refresh();
             }
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }
Example #3
0
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string[] bekannt;
            var      list      = (ListBox)sender;
            int      itemIndex = list.IndexFromPoint(e.Location);

            if (listBox1.SelectedItem != null)
            {
                string unbekannt = listBox1.SelectedItem.ToString();
                bekannt = unbekannt.Split(' ');
                if (bekannt[0] == "PKW:")
                {
                    bildwechseln("PKW");
                    PKW tmp = (PKW)Auto_List[itemIndex - 1];
                    textBox1.Text = tmp.name;
                    textBox2.Text = tmp.PS.ToString();
                    textBox3.Text = tmp.kilometerstand.ToString();
                    textBox4.Text = tmp.verbrauch.ToString();
                    textBox5.Text = tmp.tankinhalt.ToString();
                    textBox6.Text = tmp.personenzahl.ToString();
                }
                else
                {
                    bildwechseln("LKW");
                    LKW tmp = (LKW)Auto_List[itemIndex - 1];
                    textBox11.Text = tmp.name;
                    textBox12.Text = tmp.PS.ToString();
                    textBox10.Text = tmp.kilometerstand.ToString();
                    textBox9.Text  = tmp.verbrauch.ToString();
                    textBox8.Text  = tmp.tankinhalt.ToString();
                    textBox7.Text  = tmp.Zuladung_Max.ToString();
                }
            }
        }