/// <summary> /// Jonathan Sanborn /// /// Constructor /// /// </summary> /// <param name="mmControl">The controller object</param> public frmAdminControl(CtrlAdmin controller) { control = controller; InitializeComponent(); lblCurrentTime.Text = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString(); tmrClock.Start(); userBindingSource.DataSource = control.CurrentUser; control.KeepAlive = false; /////Set the bindings //studentBindingSource.DataSource = control.StudentList; //problemSetBindingSource.DataSource = control.ProblemSetList; //assignmentsBindingSource.DataSource = studentBindingSource; //incompletedAssignmentsBindingSource.DataSource = studentBindingSource; //ddlNewProblemSetAttempts.DataSource = control.NumberOfAttempts; //ddlDefaultsAttempts.DataSource = control.NumberOfAttemptsDefault; //UpdateBindings(); //loadProblemSetDefaults(); //tbcAdmin.SelectedIndexChanged += new EventHandler(tbcAdmin_SelectedIndexChanged); ///// Set the initial valid date ranges for repots tab //dtpStartDate.MinDate = DateTime.Now.AddYears(-120); //dtpStartDate.Value = DateTime.Now.AddYears(-5); //dtpStartDate.MaxDate = DateTime.Now; //dtpEndDate.MinDate = DateTime.Now.AddYears(-120); //dtpEndDate.Value = DateTime.Now; //dtpEndDate.MaxDate = DateTime.Now; //lblAdminName.Text = control.CurrentUser.GetFullName; //lblLoginDate.Text = control.CurrentUser.LastLogin().Date.ToString(); }
/// <summary> /// 22 March 2014 /// Jonathan Sanborn & Harvey Mercado /// Called to login the user currently set /// /// 21 April 2014 /// Jeff Bunce /// Refactored /// /// </summary> internal void UserLogin(object sender, EventArgs e) { if (currentUser == null) { MessageBox.Show("Please Select a user.", "Select User", MessageBoxButtons.OK, MessageBoxIcon.Information); return; // must select a user } TextBox txtPassword = loginForm.Controls.Find("txtPassword", true)[0] as TextBox; if (AuthenticateUser(CurrentUser, txtPassword.Text)) { txtPassword.Text = string.Empty; currentUser.Login(); } else { MessageBox.Show("Sorry that is not the right password", "Incorrect Password", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPassword.Text = String.Empty; return; // selected user must authenticate } loginForm.Hide(); loginForm.Close(); if (currentUser.UserType == UserType.Student) { currentStudent = StudentList.Where(w => currentUser.ID == w.ID).First(); problemSetList.Clear(); if (currentStudent.IncompleteAssignments > 0) { ctrlStudent = new CtrlStudent(this); ctrlStudent.TakeControl(this); UpdateLocalLists(); } else { MessageBox.Show(currentUser.ScreenName + " currently has no assignments. Please go see your teacher.", "Go See Teacher", MessageBoxButtons.OK, MessageBoxIcon.Information); keepAlive = true; currentUser.Logout(this); } } else if (currentUser.UserType == UserType.Administrator) { ctrlAdmin = new CtrlAdmin(this); ctrlAdmin.TakeControl(this); UpdateLocalLists(); } }