Exemplo n.º 1
0
        private void Button3_Click(object sender, EventArgs e)
        {
            aruim = new List <Arucikk>();
            BinaryReader br = new BinaryReader(File.OpenRead("adat.dat"));

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                if (br.ReadString() == typeof(Ital).ToString())
                {
                    Ital it = new Ital();
                    it.Megnevezes = br.ReadString();
                    it.Egysegar   = br.ReadInt32();
                    it.Mennyiseg  = br.ReadDecimal();
                    it.SzensavasE = br.ReadBoolean();
                    it.AlkoholosE = br.ReadBoolean();
                    aruim.Add(it);
                }
                else
                {
                    Etel et = new Etel();
                    et.Megnevezes = br.ReadString();
                    et.Egysegar   = br.ReadInt32();
                    et.Mennyiseg  = br.ReadDecimal();
                    et.Eteltipus  =
                        (Eteltipusok)Enum.Parse(typeof(Eteltipusok), br.ReadString());
                    aruim.Add(et);
                }
            }
            br.Close();
            listBox1.Items.Clear();
            foreach (Arucikk item in aruim)
            {
                listBox1.Items.Add(item);
            }
        }
Exemplo n.º 2
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (radioButton1.Checked)
     {
         Etel et = new Etel();
         et.Megnevezes = textBox1.Text;
         et.Egysegar   = int.Parse(textBox2.Text);
         et.Mennyiseg  = decimal.Parse(textBox3.Text);
         // et.Eteltipus ToDo
         aruim.Add(et);
     }
     else
     {
         Ital it = new Ital();
         it.Megnevezes = textBox1.Text;
         it.Egysegar   = int.Parse(textBox2.Text);
         it.Mennyiseg  = decimal.Parse(textBox3.Text);
         if (checkBox1.Checked)
         {
             it.SzensavasE = true;
         }
         if (checkBox2.Checked)
         {
             it.AlkoholosE = true;
         }
         aruim.Add(it);
     }
 }