/// <summary> /// Handles the Load event of the AdminForm control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void AdminForm_Load(object sender, EventArgs e) { UsersDataAccess dataAccess = new UsersDataAccess(); AllResultsGrid.DataSource = dataAccess.GetUsers(); AllResultsGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); }
/// <summary> /// Rebinds all grids. /// </summary> protected void Rebind() { UsersDataAccess dataAccess = new UsersDataAccess(); AllStudents.DataSource = dataAccess.GetAllDisconectedStudents(_username); AllStudents.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); AssociatedStudents.DataSource = dataAccess.GetMyUsers(_username); AssociatedStudents.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); }
/// <summary> /// Handles the Click event of the btnAssociateStudents control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void btnAssociateStudents_Click(object sender, EventArgs e) { UsersDataAccess dataAccess = new UsersDataAccess(); List<int> students = new List<int>(); foreach (DataGridViewRow student in AllStudents.SelectedRows) { dataAccess.AssociateStudent((int)student.Cells["ID"].Value, _username); } // Refresh data sets. Rebind(); }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <returns></returns> public bool IsStudent(string username) { UsersDataAccess dataAccess = new UsersDataAccess(); return dataAccess.IsStudent(username); }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <returns></returns> public bool IsAdmin(string username) { UsersDataAccess dataAccess = new UsersDataAccess(); return dataAccess.IsAdmin(username); }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public bool Authenticate(string username, string password) { UsersDataAccess dataAccess = new UsersDataAccess(); return dataAccess.TryAuthenticateUser(username, password); }