示例#1
0
 private void exitToolStripMenuItem_Click(object sender, EventArgs e)  //Exits the program with Admin approval
 {
     using (Form myform = new AdminLogin())
     {
         var result = myform.ShowDialog();
         if (result == DialogResult.OK)
         {
             clearLoginsToolStripMenuItem.PerformClick();
             this.Close();
         }
     }
 }
示例#2
0
        /*
         * The following region is composed of entries for the menu buttons to open other forms
         * Generally, all of these menu strip options first open the AdminLogin form to validate
         * the user
         * Some of the options specifically require a higher admin level than the Lab Assistant
         * these options are denoted by a decision statement that checks the authok value returned
         * by the AdminLogin form, this value denotes the admin type each login is assigned in the Admin DB
         *
         */

        #region MenuStripItems
        private void AddStudent_Click(object sender, EventArgs e) //Opens the add student form
        {
            using (Form myform = new AdminLogin())                //Opens the admin login form to control adding to DB
            {
                var result = myform.ShowDialog();
                if (result == DialogResult.OK)  //This generic dialog check looks for a successful
                {                               //admin login of any type
                    Form userform = new CreateUser();
                    userform.ShowDialog();
                    OpenFill();                 //repopulates the list after a student is added
                }
            }
        }
示例#3
0
 /*
  * Function for creating new admin accounts.  Validates that all required fields have been filled on
  * button press and calls the appropriate Valid class function to insert
  */
 private void createButton_Click(object sender, EventArgs e)
 {
     if (createNameBox.Text != string.Empty)
     {
         if (createPassBox.Text != string.Empty && createConfirmBox.Text == createPassBox.Text)
         {
             string type;
             if (labRadioButton.Checked) //if statement to determine the account type being created
             {
                 type = "LabAssist";
             }
             else
             {
                 type = "Admin";
             }
             using (var myform = new AdminLogin())   //calls the AdminLogin form as an additional authorization
             {
                 myform.ShowDialog();
                 if (myform.DialogResult == DialogResult.OK && (myform.authok == "Admin" || myform.authok == "Administrator"))
                 {
                     Valid Admin = new Valid();
                     if (Admin.InsertAdmin(createNameBox.Text, createPassBox.Text, type))
                     {
                         MessageBox.Show("New user created.");
                     }
                     ListFill(true);
                     ListFill(false);
                 }
             }
         }
         else
         {
             MessageBox.Show("Password confirmation invalid.");
             ClearThings();
             createNameBox.Focus();
         }
     }
     else
     {
         MessageBox.Show("Please enter a name for this user.");
         ClearThings();
         createNameBox.Focus();
     }
 }
示例#4
0
 private void AdminTasks_Click(object sender, EventArgs e)  //Opens Administrator form
 {
     using (var myform = new AdminLogin())
     {
         var result = myform.ShowDialog();
         //The following check uses the above mentioned method for determining if an admin
         //or a lab assistant is attempting to open the admin form as only admins should
         //be allowed access
         //The form is declared as a form instead of a var because we expect no return values
         if (result == DialogResult.OK && (myform.authok == "Admin" || myform.authok == "Administrator"))
         {
             Form adminform = new AdminTasks();
             adminform.ShowDialog();
             OpenFill();     //repopulates the student list as admins can remove students
         }
         else
         {
             MessageBox.Show("Incorrect username/password.");
         }
     }
 }
示例#5
0
 private void clearLoginsToolStripMenuItem_Click(object sender, EventArgs e)  //allows labassist/admins to log everyone out at end of day
 {
     if (currentLogins.Count != 0)
     {
         using (Form myform = new AdminLogin())
         {
             myform.ShowDialog();
             if (myform.DialogResult == DialogResult.OK)
             {
                 for (int i = 0; i < currentLogins.Count; i++)
                 {
                     string   logDir    = Path.Combine(Environment.CurrentDirectory, "Logs");
                     DateTime dt        = DateTime.Now;
                     string   date      = dt.ToShortDateString();
                     string   time      = dt.ToShortTimeString();
                     string[] newdate   = (dt.Date.ToString()).Split();
                     string[] dateparts = newdate[0].Split('/');
                     date = dateparts[0] + "-" + dateparts[1] + "-" + dateparts[2];
                     if (!Directory.Exists(logDir))
                     {
                         Directory.CreateDirectory(logDir);
                     }
                     string logpath = date + ".txt";
                     using (StreamWriter outputfile = new StreamWriter("Logs\\" + logpath, true))
                     {
                         string[] name = currentLogins[i].Split(',');
                         outputfile.WriteLine(Utility.Encrypt(name[1].Trim() + "," + name[0].Trim() + ",," + date + ",Force out: ," + time, false));
                         outputfile.Close();
                     }
                 }
                 currentLogins.Clear();
                 MessageBox.Show("All users logged out.");
                 OpenFill();
             }
         }
     }
 }