private void txtEmail_TextChanged(object sender, EventArgs e) { AuthenticationValidate validate = new AuthenticationValidate(); String email = txtEmail.Text.Trim(); Regex rex = new Regex(@"[a-zA-Z0-9]+([.-_][a-zA-Z0-9]+)*@[a-zA-Z0-9]+([.-_][a-zA-Z0-9]+)*([.-_][a-zA-Z0-9]{2,})+"); if (!rex.IsMatch(email)) { this.lblEmailCheck.Visible = false; isEmail = false; } else { if (validate.checkUserExist(email) == null) { this.lblEmailCheck.Show(); isEmail = true; } else { this.lblEmailCheck.Hide(); isEmail = false; } } }
private void btnSubmit_Click(object sender, EventArgs e) { AuthenticationValidate validate = new AuthenticationValidate(); SaleLaptopSystemEntities db = new SaleLaptopSystemEntities(); UserDAO uDAO = new UserDAO(); String fullname = txtFullname.Text.Trim(); String email = txtEmail.Text.Trim(); String password = txtPass.Text.Trim(); String confirm = txtConfirm.Text.Trim(); String phone = txtPhone.Text.Trim(); String address = txtAddress.Text.Trim(); String img = txtImage.Text.Trim(); String role = cbbRole.SelectedItem.ToString(); if (fullname == "" || email == "" || password == "" || confirm == "" || phone == "" || address == "") { MessageBox.Show("Input the fill", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (isAddress && isConfirm && isEmail && isName && isPass && isPhone) { if (img == "") { img = "user.png"; } if (!uDAO.registration(fullname, password, email, phone, address, "..\\SaleLaptopSystem\\SaleLaptopSystem\\SaleLaptopSystem\\img\\Brands_img\\" + img, role)) { MessageBox.Show("Registration error", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { frmLogin frmLogin = new frmLogin(null); frmLogin.Show(); this.Visible = false; } } else { MessageBox.Show("Invalid register", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }