private void butSubmit_Click(object sender, EventArgs e) { bool te1 = true; bool te2 = true; bool te3 = true; int count = 1; List <LoginUser> loginUsers = NoteControl.getListLogin(); if (NoteControl.getListLogin().Count == 1) { count = 1; } else { count = NoteControl.getListLogin().Count; } for (int i = 0; i < loginUsers.Count; i++) { if (count == loginUsers[i].UserID) { count++; } } loginUser.UserID = count; loginUser.FullName = this.txtFirst.Text + " " + this.txtLast.Text; loginUser.DOB = this.dtpDOB.Value; loginUser.Gender = this.cbSex.Text.Trim(); loginUser.PhoneNum = this.txtPhone.Text.Trim(); for (int i = 0; i < loginUsers.Count; i++) { if (txtUser.Text == loginUsers[i].Username) { DialogResult dialog = MessageBox.Show("Username has existed", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); if (dialog == DialogResult.OK) { txtUser.Focus(); te1 = false; } } else { loginUser.Username = txtUser.Text; te1 = true; } } if (txtPass.Text == textBox5.Text && txtPass.Text != "") { loginUser.Password = this.txtPass.Text.Trim(); te2 = true; } else { DialogResult dialog = MessageBox.Show("You can confirm password again!!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (dialog == DialogResult.OK) { textBox5.Focus(); te2 = false; } } if (pictureBox1.Image == Properties.Resources.login__5_3) { te3 = false; } if (te3 == true && te1 == true && te2 == true) { if (NoteControl.RegisterUser(loginUser) == true) { this.pictureBox1.Image.Save(String.Format("{0}.jpg", loginUser.Username)); MessageBox.Show("Finish, you can login to use Easynote!!!"); this.Dispose(); } else { MessageBox.Show("Sorry, you need to fill full your information"); } } }