コード例 #1
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            buttonsExist = true;
            Label onomaLabel = new Label();

            onomaLabel.Text      = "ONOMA:";
            onomaLabel.BackColor = Color.LightSlateGray;
            onomaLabel.Location  = new Point(168, 100);
            onomaLabel.Height    = 20;
            onomaLabel.Width     = 51;
            Controls.Add(onomaLabel);

            TextBox onomaTextbox = new TextBox();

            onomaTextbox.Location = new Point(250, 100);
            onomaTextbox.Height   = 20;
            onomaTextbox.Width    = 209;
            Controls.Add(onomaTextbox);

            Label epithetoLabel = new Label();

            epithetoLabel.Text      = "EPITHETO:";
            epithetoLabel.BackColor = Color.LightSlateGray;
            epithetoLabel.Location  = new Point(168, 127);
            epithetoLabel.Height    = 20;
            epithetoLabel.Width     = 61;
            Controls.Add(epithetoLabel);

            TextBox epithetoTextbox = new TextBox();

            epithetoTextbox.Location = new Point(250, 127);
            epithetoTextbox.Height   = 20;
            epithetoTextbox.Width    = 209;
            Controls.Add(epithetoTextbox);

            Label tilefwnoLabel = new Label();

            tilefwnoLabel.Text      = "THLEFWNO:";
            tilefwnoLabel.BackColor = Color.LightSlateGray;
            tilefwnoLabel.Location  = new Point(168, 154);
            tilefwnoLabel.Height    = 20;
            tilefwnoLabel.Width     = 70;
            Controls.Add(tilefwnoLabel);

            TextBox tilefwnoTextbox = new TextBox();

            tilefwnoTextbox.Location = new Point(250, 154);
            tilefwnoTextbox.Height   = 20;
            tilefwnoTextbox.Width    = 209;
            Controls.Add(tilefwnoTextbox);

            Label emailLabel = new Label();

            emailLabel.Text      = "EMAIL:";
            emailLabel.BackColor = Color.LightSlateGray;
            emailLabel.Location  = new Point(168, 181);
            emailLabel.Height    = 20;
            emailLabel.Width     = 51;
            Controls.Add(emailLabel);

            TextBox emailTextbox = new TextBox();

            emailTextbox.Location = new Point(250, 181);
            emailTextbox.Height   = 20;
            emailTextbox.Width    = 209;
            Controls.Add(emailTextbox);

            Label katoikiaLabel = new Label();

            katoikiaLabel.Text      = "KATOIKIA:";
            katoikiaLabel.BackColor = Color.LightSlateGray;
            katoikiaLabel.Location  = new Point(168, 208);
            katoikiaLabel.Height    = 20;
            katoikiaLabel.Width     = 70;
            Controls.Add(katoikiaLabel);

            TextBox katoikiaTextbox = new TextBox();

            katoikiaTextbox.Location = new Point(250, 208);
            katoikiaTextbox.Height   = 20;
            katoikiaTextbox.Width    = 209;
            Controls.Add(katoikiaTextbox);

            Label dateLabel = new Label();

            dateLabel.Text      = "HMEROMINIA GENNHSHS:";
            dateLabel.BackColor = Color.LightSlateGray;
            dateLabel.Location  = new Point(168, 235);
            dateLabel.Height    = 20;
            dateLabel.Width     = 100;
            Controls.Add(dateLabel);

            DateTimePicker dateTimePicker = new DateTimePicker();

            dateTimePicker.MaxDate  = DateTime.MaxValue;
            dateTimePicker.MinDate  = DateTime.MinValue;
            dateTimePicker.Location = new Point(280, 235);
            dateTimePicker.Height   = 20;
            dateTimePicker.Width    = 209;
            dateTimePicker.Value    = DateTime.Today;
            Controls.Add(dateTimePicker);


            Button SaveButton = new Button();

            SaveButton.Text      = "SAVE THE NEW CREDENTIALS";
            SaveButton.Location  = new Point(490, 170);
            SaveButton.Height    = 70;
            SaveButton.Width     = 200;
            SaveButton.BackColor = Color.Chocolate;
            SaveButton.Click    += new EventHandler(saveButton_Click);
            Controls.Add(SaveButton);



            string contactName = listBox1.GetItemText(listBox1.SelectedItem);

            BinaryFormatter bf = new BinaryFormatter();
            Stream          st = new FileStream("contacts\\" + contactName.Replace("\r\n", "") + ".txt", FileMode.OpenOrCreate);
            contact         c  = (contact)bf.Deserialize(st);

            PropertyInfo[] pInfoArray = c.GetType().GetProperties();
            String         s          = "";

            onomaTextbox.Text    = c.onoma;
            epithetoTextbox.Text = c.epitheto;
            tilefwnoTextbox.Text = c.thlefwno;
            emailTextbox.Text    = c.email;
            katoikiaTextbox.Text = c.katoikia;
            dateTimePicker.Value = DateTime.Parse(c.date);
        }