private void button1_Click(object sender, EventArgs e) { if (username.TextLength == 0) { ToolTip tt = new ToolTip(); tt.IsBalloon = true; tt.InitialDelay = 0; tt.Show("Please Enter Your Username", this, 200, 21, 2000); } if (password.TextLength == 0) { ToolTip tt = new ToolTip(); tt.IsBalloon = true; tt.InitialDelay = 0; tt.Show("Please Enter Your Password", this, 200, 50, 2000); } if (username.TextLength == 0 || password.TextLength == 0) { return; } int userId = -1; userId = controllerObj.checkUser(username.Text, password.Text); string user = "******"; string role = "n/a"; controllerObj.getUserDataFromID(userId, ref user, ref role); if (userId == -1) { incorrect.Visible = true; } else { string message = user + " " + role + " " + userId; MessageBox.Show(message); if (role == "Store") { Hide(); Form foo = new Store_Dashboard(userId, 1, username.Text); foo.Show(); } else if (role == "Store_WAITING_APPROVAL") { Form foo = new Store_Dashboard(userId, 0, username.Text); Hide(); foo.Show(); } else if (role == "User") { Form foo = new Search(userId.ToString()); Hide(); foo.Show(); } else if (role == "Admin") { Admin_Dashboard ad = new Admin_Dashboard(userId); Hide(); ad.Show(); } } }
private void signUser_Click(object sender, EventArgs e) { if (user.TextLength == 0) { ToolTip tt = new ToolTip(); tt.IsBalloon = true; tt.InitialDelay = 0; tt.Show("Please Enter Username", this, 200, 70, 2000); } if (password.TextLength == 0) { ToolTip tt = new ToolTip(); tt.IsBalloon = true; tt.InitialDelay = 0; tt.Show("Please Enter Password", this, 200, 110, 2000); } if (email.TextLength == 0) { ToolTip tt = new ToolTip(); tt.IsBalloon = true; tt.InitialDelay = 0; tt.Show("Please Enter Email", this, 200, 30, 2000); } if (user.TextLength == 0 || password.TextLength == 0 || email.TextLength == 0) { return; } if (controllerObj.checkUser(user.Text) != -1 && controllerObj.checkMail(email.Text) == -1) { ERR.Visible = true; ERR.Text = "Username Already Exists"; return; } if (controllerObj.checkUser(user.Text) == -1 && controllerObj.checkMail(email.Text) != -1) { ERR.Visible = true; ERR.Text = "Email Already Exists"; return; } if (controllerObj.checkUser(user.Text) != -1 && controllerObj.checkMail(email.Text) != -1) { ERR.Visible = true; ERR.Text = "Email And Username Already Exist"; return; } if (!validator.email(email.Text)) { ERR.Visible = true; ERR.Text = "Please Enter A Valid Email"; return; } if (controllerObj.signUp(email.Text, user.Text, password.Text, consent.Checked, "User") == 1) { MessageBox.Show("Welcome To LDBS, " + user.Text + "."); Form search = new Search("new", user.Text); this.Hide(); search.Show(); } else { MessageBox.Show("An Error has occured while creating a new account."); } }