コード例 #1
0
ファイル: Form1.cs プロジェクト: DimPap99/University-Projects
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "")
                {
                    conc.addOnoma(textBox1.Text);
                    conc.addEpitheto(textBox2.Text);
                    conc.addKatoikia(textBox3.Text);
                    conc.addThlefwno(textBox5.Text);
                    conc.addEmail(textBox4.Text);
                    conc.addDate(dateTimePicker1.Text.ToString());


                    BinaryFormatter bf = new BinaryFormatter();
                    Stream          st = new FileStream("contacts\\" + conc.onoma + " " + conc.epitheto + ".txt", FileMode.OpenOrCreate);
                    bf.Serialize(st, conc);
                    st.Close();

                    MessageBox.Show("Epituxhs prosthiki!");
                }
                else
                {
                    MessageBox.Show("Gemiste ola ta pedia!");
                }
            }
            catch (ArithmeticException exc)
            {
                MessageBox.Show(exc.ToString() + "\n Wrong input!");
            }
        }
コード例 #2
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            contact editContact = new contact();
            string  contactName = listBox1.GetItemText(listBox1.SelectedItem);

            MessageBox.Show(textBoxes[0].Text);

            editContact.addOnoma(textBoxes[0].Text);
            editContact.addEpitheto(textBoxes[1].Text);
            editContact.addKatoikia(textBoxes[4].Text);
            editContact.addThlefwno(textBoxes[3].Text);
            editContact.addEmail(textBoxes[2].Text);
            editContact.addDate(dateTimePickers[0].Text);
            File.Delete("contacts\\" + contactName.Replace("\r\n", "") + ".txt");
            MessageBox.Show(editContact.onoma + " " + editContact.epitheto);
            BinaryFormatter bf2 = new BinaryFormatter();
            Stream          st2 = new FileStream("contacts\\" + editContact.onoma + " " + editContact.epitheto + ".txt", FileMode.OpenOrCreate);

            bf2.Serialize(st2, editContact);
            st2.Close();
            MessageBox.Show("EPITYXES EDIT THS EPAFHS!");
            PLOIGISI pl = new PLOIGISI();

            pl.Activate();
            pl.Show();

            this.Hide();
        }