Example #1
0
 private void ContinueTeach()                                              // Method for making sure user selected a teacher
 {
     if (string.IsNullOrWhiteSpace(TchCh.GetItemText(TchCh.SelectedItem))) // Checks to make sure user selected a teacher
     {
         TeacherNull.Visible = true;                                       // Shows red text telling user to select a teacher if they haven't
     }
     else
     {
         ContinueSI();
     }                 // If user has entered in all required data on the Sign In panel, program will add their data to the DB
 }
Example #2
0
        private void ContinueSI()         // Method for adding users input to a database
        {
            string FName = PsiFName.Text; // Creates strings needed for inputting data into DB
            string LName = PsiLName.Text;
            string ID    = PsiID.Text;
            string Grade = "";

            if (G6.Checked)
            {
                Grade = G6.Text;
            }
            if (G7.Checked)
            {
                Grade = (G7.Text);
            }
            if (G8.Checked)
            {
                Grade = (G8.Text);
            }
            string          Teacher = TchCh.GetItemText(TchCh.SelectedItem);
            string          Date    = DateTime.Now.ToString("MM.dd.yyy");
            string          Time    = DateTime.Now.ToString("h:mm:ss");
            OleDbConnection conn    = new OleDbConnection();

            conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data source= C:\CheckIn\CheckIn.accdb";
            try
            {
                conn.Open();                                                                                                                                // Connects to database
                String WriteChkIn = "INSERT INTO Table1([Date],[First Name],[Last Name],[Student ID],Grade,[Here to see],[Time In])" +
                                    "VALUES('" + Date + "','" + FName + "','" + LName + "','" + ID + "','" + Grade + "','" + Teacher + "','" + Time + "')"; // Enters users info into DB
                OleDbCommand cmd = new OleDbCommand(WriteChkIn, conn);
                cmd.ExecuteNonQuery();
                PsiFName.Clear(); // Clears fields on Sign In panel so the next user doesn't see the previous user's input
                PsiLName.Clear();
                PsiID.Clear();
                G6.Checked         = false;
                G7.Checked         = false;
                G8.Checked         = false;
                TchCh.SelectedItem = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed due to" + ex.Message); // I mainly used this for debugging, however, if Faculty at South sees this message, they now to switch to paper until the problem is resolved
            }
            finally
            {
                conn.Close();
            }
            PSignout.Visible  = true;
            PSignedIn.Visible = true;
            SIWait5.Interval  = 5000;
            SIWait5.Start(); // Displays Signed Out panel for 5 seconds
        }