Exemplo n.º 1
0
 public Form2(list_of_postcards p, Image image)
 {
     this.postcards = p;
     InitializeComponent();
     pictureBox1.Image = image;
     label1.Text       = p.name_recipient;
     label2.Text       = p.text;
 }
Exemplo n.º 2
0
 public Form1(list_of_postcards p)
 {
     InitializeComponent();
     this.postcard      = p;
     this.textBox1.Text = postcard.name_sender;
     this.textBox2.Text = postcard.name_recipient;
     this.textBox4.Text = postcard.adress;
     this.textBox3.Text = postcard.text;
 }
        public static list_of_postcards postcardss(string sender, string recipient, string adress, string text)
        {
            PostcardListEntities db        = new PostcardListEntities();
            list_of_postcards    postcards = new list_of_postcards();

            if (db.list_of_postcards.Count() == 0)
            {
                postcards.id_postcards = 1;
            }
            else
            {
                postcards.id_postcards = db.list_of_postcards.Max(p => p.id_postcards);
            }
            postcards.name_sender    = sender;
            postcards.name_recipient = recipient;
            postcards.text           = text;
            postcards.adress         = adress;
            return(postcards);
        }
Exemplo n.º 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (list_of_postcards.ProverkaAdress(textBox4.Text))
     {
         if (radioButton1.Checked || radioButton2.Checked || radioButton3.Checked)
         {
             try
             {
                 postcard = list_of_postcards.postcardss(textBox1.Text, textBox2.Text, textBox4.Text, textBox3.Text);
                 Image image = null;
                 if (radioButton1.Checked)
                 {
                     image = radioButton1.Image;
                 }
                 else if (radioButton2.Checked)
                 {
                     image = radioButton2.Image;
                 }
                 else if (radioButton3.Checked)
                 {
                     image = radioButton3.Image;
                 }
                 Form2 f = new Form2(postcard, image); f.Show(); this.Hide();
             }
             catch { MessageBox.Show(" "); }
         }
         else
         {
             MessageBox.Show("Выберите одну из открыток");
         }
     }
     else
     {
         MessageBox.Show("Адрес электронной почты введен некорректно");
     }
 }
 public void Save(list_of_postcards postcards)
 {
     db.list_of_postcards.Add(postcards);
     db.SaveChanges();
 }