private void button1_Click(object sender, EventArgs e)
        {
            ORMDataContext db = new ORMDataContext();
            User_info      u1 = new User_info();

            if (textBox1.ReadOnly == false)
            {
                u1.First_name   = textBox1.Text;
                u1.Last_name    = textBox2.Text;
                u1.E_mail       = textBox4.Text;
                u1.Password     = textBox3.Text;
                u1.DOB          = textBox5.Text;
                u1.Account_type = "user";
                db.User_infos.InsertOnSubmit(u1);
                db.SubmitChanges();
                MessageBox.Show("Data inserted successfully");
            }
            else
            {
                User_info u2 = db.User_infos.SingleOrDefault();
                u2.First_name = textBox1.Text;
                u2.Last_name  = textBox2.Text;
                u2.E_mail     = textBox3.Text;
                u2.Password   = textBox4.Text;
                u2.DOB        = textBox5.Text;
                db.SubmitChanges();
                MessageBox.Show("Record updated");
            }
        }
Exemple #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == null || textBox2.Text == null || textBox3.Text == null || textBox4.Text == null || textBox5.Text == null)
     {
         MessageBox.Show("Please fill up the form properly");
     }
     else if (textBox4.Text.Equals(textBox5.Text))
     {
         ORMDataContext db = new ORMDataContext();
         User_info      u1 = new User_info();
         u1.First_name = textBox1.Text;
         u1.Last_name  = textBox2.Text;
         u1.E_mail     = textBox3.Text;
         u1.Password   = textBox5.Text;
         u1.DOB        = dateTimePicker1.Text;
         db.User_infos.InsertOnSubmit(u1);
         db.SubmitChanges();
         MessageBox.Show("Account created successfully");
     }
     else
     {
         MessageBox.Show("Password mismatch");
     }
 }