private void button1_ConfirmClick(object sender, EventArgs e) { Regexp(@"^.+$", textBox1Name, pictureBox1, labelname, "Name"); Regexp(@"^.+$", textBoxPassword, pictureBox2, labelPasswod, "Password"); Regexp(@textBoxPassword.Text, textBoxConfirmPass, pictureBox3, labelConfirm, "Confirmation"); Regexp(@"^.+$", textBoxAddress, pictureBox4, labelAddress, "Address"); Regexp(@"^(01)(([0-9]{3}){3})$", textBoxPhoneNo, pictureBox5, labelPhoneNo, "Phone"); // MessageBox.Show(comboBoxGender.Text.Length.ToString()); // MessageBox.Show(comboBox1AccType.Text.Length.ToString()); //If else start================================= if ((textBoxPassword.Text == textBoxConfirmPass.Text) && (textBox1Name.Text != "") && (textBox1Name.Text.Length > 4) && (textBoxAddress.Text.Length > 4) && (textBoxAddress.Text != "") && (textBoxPassword.Text != "") && (textBoxPassword.Text.Length > 3) && ((textBoxPhoneNo.Text.StartsWith("01")) && (textBoxPhoneNo.Text.Length == 11) && (comboBox1AccType.Text.Length > 0) && (comboBoxGender.Text.Length > 0))) { //MessageBox.Show("S"); //for user table User u = new User { name = textBox1Name.Text, address = textBoxAddress.Text, phoneno = textBoxPhoneNo.Text, password = textBoxPassword.Text, gender = comboBoxGender.Text, accounttype = comboBox1AccType.Text }; udc.Users.InsertOnSubmit(u); //add u object in temporary table in data contex udc.SubmitChanges(); //send the changes in database table //for account table Account a = new Account { AccountId = u.Id, Status = "Unblocked" }; udc.Accounts.InsertOnSubmit(a); //add a object in temporary table in data contex udc.SubmitChanges(); //send the changes in database table //for balance table Balance b = new Balance { BalanceId = u.Id, Accno = a.accountno, Account_Balance = 1000 }; udc.Balances.InsertOnSubmit(b); //add b object in temporary table in data contex udc.SubmitChanges(); //send the changes in database table string s = "Congratulations!!! Your Id:" + u.Id + "\n Account No:" + a.accountno; MessageBox.Show(s); button1.Hide(); } else if (textBoxPassword.Text != textBoxConfirmPass.Text) { MessageBox.Show("Password Mismatch!!!!!!!!!!"); } else if (textBoxPassword.Text.Length < 4) { MessageBox.Show("Password too small!!!!!!!!!!"); } else if (textBox1Name.Text.Length < 5) { MessageBox.Show("Name too small!!!!!!!!!!"); } else if (textBoxAddress.Text.Length < 5) { MessageBox.Show("Address too small!!!!!!!!!!"); } else { labelError.Show(); } }