private void btnCreate_Click(object sender, EventArgs e) { try { string username = txtUsername.Text; string password = txtPassword.Text; string confirm = txtConfirm.Text; string fname = txtFName.Text; string lname = txtLName.Text; string mail = txtMail.Text; Users newUser = new Users(0, username, password, fname, lname, mail); if (password != confirm) { throw new Exception(Messages.PasswordAndConfirmationNotMatch); } else { long result = 0; result = Users_SP.Insert(newUser); if (result > 0) { MessageBox.Show(Messages.UserCreatedOK, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnLogin_Click(object sender, EventArgs e) { try { string username = txtUsername.Text; string password = txtPassword.Text; if (username.Length > 0 && password.Length > 0) { DataTable dtLogin = new DataTable(); dtLogin = Users_SP.Login(username, password); if (dtLogin != null && dtLogin.Rows.Count == 1) { iMovieBase.User.FetchSingleUser(dtLogin); iMovieBase.IsLogin = true; this.Close(); } else { iMovieBase.IsLogin = false; MessageBox.Show(Messages.UsernameAndPasswordNotMatch, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { iMovieBase.IsLogin = false; MessageBox.Show(Messages.InputUsernameAndPassword, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { iMovieBase.IsLogin = false; MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }