private void Button_Register_Click(object sender, EventArgs e) { string tempUsername = TextBox_RegisterUsername.Text; string tempQuery = $"SELECT * from user WHERE username = '******'"; DataTable db = Connection.GetDbConn().GetDataTable(tempQuery); // Username error checks if (TextBox_RegisterUsername.TextLength == 0) { ShowRegisterUsernameError("Please enter a username."); } else if (TextBox_RegisterUsername.TextLength < 3) { ShowRegisterUsernameError("Please use 3 characters or more."); } else if (TextBox_RegisterUsername.TextLength > 30) { ShowRegisterUsernameError("Please use 30 characters or less."); } else if (db.Rows.Count != 0) { ShowRegisterUsernameError("Please choose a different username."); } // Password error checks else if (TextBox_RegisterPassword.TextLength == 0) { ShowRegisterPasswordError("Please enter a password."); } else if (TextBox_RegisterPassword.TextLength < 8) { ShowRegisterPasswordError("Please user 8 characters or more."); } else if (TextBox_RegisterPassword.TextLength < 8) { ShowRegisterPasswordError("Please enter a stronger password."); } // Email error checks else if (TextBox_RegisterEmail.TextLength == 0) { ShowRegisterEmailError("Please enter an email."); } else if (!TextBox_RegisterEmail.Text.Contains("@")) { ShowRegisterEmailError("Please enter a valid email address."); } // Successful registration else { string username = TextBox_RegisterUsername.Text; string email = TextBox_RegisterEmail.Text; string password = TextBox_RegisterPassword.Text; SqlUser newUser = new SqlUser(); newUser.InsertUser(username, email, password); } }
/// <summary> /// on login clicked, go to sqlUser class and attempt to find this user + make a UserObject instance of /// logged user with the details /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Login_Click(object sender, EventArgs e) { SqlUser loginUser = new SqlUser(); string tempUsername = TextBox_LoginUsername.Text; string tempPassword = TextBox_LoginPassword.Text; string tempQuery = $"SELECT * from user WHERE username = '******' AND password = '******'"; DataTable db = Connection.GetDbConn().GetDataTable(tempQuery); //login.GetUser(TextBox_LoginUsername.Text, TextBox_LoginPassword.Text); if (db.Rows.Count != 0) { UserObject.loggedUser.username = db.Rows[0].ItemArray[1].ToString(); UserObject.loggedUser.iduser = db.Rows[0].ItemArray[0].ToString(); if (CheckBox_StayLoggedIn.CheckState == CheckState.Checked) { Properties.Settings.Default.StayLoggedIn = true; Properties.Settings.Default.LoggedUserId = UserObject.loggedUser.iduser; Properties.Settings.Default.LoggedUsername = UserObject.loggedUser.username; Properties.Settings.Default.Save(); } else if (CheckBox_StayLoggedIn.CheckState == CheckState.Unchecked) { Properties.Settings.Default.StayLoggedIn = false; Properties.Settings.Default.LoggedUserId = null; Properties.Settings.Default.LoggedUsername = null; Properties.Settings.Default.Save(); } Hide(); loginPanel.Hide(); loginPanelBackTop.Hide(); loginPanelBackBottom.Hide(); SplashPage1.Hide(); SplashPage2.Hide(); SplashPage3.Hide(); SplashPage4.Hide(); Window window = new Window(); window.Show(); } else { Label_LoginUsernameSeparator.BackColor = Color.FromArgb(255, 85, 85); Label_LoginPasswordSeparator.BackColor = Color.FromArgb(255, 85, 85); TextBox_LoginUsername.ForeColor = Color.FromArgb(255, 85, 85); TextBox_LoginPassword.ForeColor = Color.FromArgb(255, 85, 85); PictureBox_LoginUsername.BackgroundImage = ERROR; PictureBox_LoginPassword.BackgroundImage = ERROR; Button_Login.BackColor = Color.FromArgb(255, 85, 85); } }
private void LoadProfileInfo(string userId) { //going to load user's projects, projects they're following and bugs they are following //bugs the user has posted on that aren't yet solved //bugs the user posted that have new posts //statistics: users posted, fixed, in progress //in progress, get all bugs with in progress status that user either made or posted on DataTable bugsPosted = Connection.GetDbConn().GetDataTable(SqlUser.GetNumberBugs(userId)); foreach (DataRow result in bugsPosted.Rows) { postedBugNo = result["total"].ToString(); solvedBugNo = result["solved"].ToString(); inProgressBugNo = result["progress"].ToString(); } Label_ProgressBugs.Text = inProgressBugNo; Label_SolvedBugs.Text = solvedBugNo; Label_TotalBugs.Text = postedBugNo; //to do list is 5 bugs user posted of high imprtance and oldest at the top DataTable toDoList = Connection.GetDbConn().GetDataTable(SqlBug.ToDoList(userId)); foreach (DataRow toDo in toDoList.Rows) { BugObject up = new BugObject(toDo["idbug"].ToString(), toDo["title"].ToString(), toDo["description"].ToString(), toDo["location"].ToString(), toDo["status"].ToString(), toDo["poster"].ToString(), toDo["project"].ToString(), toDo["priority"].ToString(), toDo["referencedBug"].ToString(), Convert.ToDateTime(toDo["timePosted"])); BugObject.toDoBugs.Add(up); } // the most recent bugs this user has posted, not ones they have updates on as notification bar does this DataTable recentList = Connection.GetDbConn().GetDataTable(SqlBug.RecentList(userId)); foreach (DataRow recent in recentList.Rows) { BugObject up = new BugObject(recent["idbug"].ToString(), recent["title"].ToString(), recent["description"].ToString(), recent["location"].ToString(), recent["status"].ToString(), recent["poster"].ToString(), recent["project"].ToString(), recent["priority"].ToString(), recent["referencedBug"].ToString(), Convert.ToDateTime(recent["timePosted"])); BugObject.recentBugs.Add(up); } //adds these 2 lists into a list bugLists.Add(BugObject.toDoBugs); bugLists.Add(BugObject.recentBugs); }
private void Button_Save_Click(object sender, EventArgs e) { string username = TextBox_Username.Text; string email = TextBox_Email.Text; string password = TextBox_Password.Text; SqlUser newUser = new SqlUser(); newUser.InsertUser(username, email, password); LoginForm lf = new LoginForm(); this.Hide(); lf.Show(); }
private void Button1_Click(object sender, EventArgs e) { SqlUser test = new SqlUser(); test.InsertUser(textBox1.Text, textBox2.Text, textBox3.Text); }