示例#1
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            string    connectionString;
            DataTable users = new DataTable();

            connectionString = "provider=microsoft.jet.oledb.4.0;data source=" + Directory.GetCurrentDirectory() + "\\Stilinski.mdb;";
            using (OleDbConnection connection =
                       new OleDbConnection(connectionString))
            {
                OleDbDataAdapter adapter = new OleDbDataAdapter("Select * From Users WHERE UName = '" + txt_Uname.Text + "' AND PWord = '" + txt_Pword.Text + "'", connection);

                try
                {
                    connection.Open();
                    adapter.Fill(users);
                    if (users.Rows.Count > 0)
                    {
                        // login
                        //MessageBox.Show("archie");
                        frm_Dashboard f_dash = new frm_Dashboard(txt_Uname.Text);
                        f_dash.Show();
                        this.Visible = false;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                // The connection is automatically closed when the
                // code exits the using block.
            }
        }
        private void btn_Register_Click(object sender, EventArgs e)
        {
            if ((txt_Fname.Text.Length != 0) && (txt_Sname.Text.Length != 0) && (pword_Warning.Visible == false) &&
                (uname_Warning.Visible == false) && (box_Gender.Text.Length != 0) && (box_Gender.Text.Length != 0))
            {
                using (OleDbConnection connection = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + Directory.GetCurrentDirectory() + "\\Stilinski.mdb;"))
                {
                    // The insertSQL string contains a SQL statement that 
                    // inserts a new row in the source table.
                    string       quizID  = "**************";
                    OleDbCommand command = new OleDbCommand("Insert into Users (FirstName, LastName, UName, PWord, Gender, Bday, Country, QuizID) Values ('" + txt_Fname.Text + "','" + txt_Sname.Text + "','" + txt_Uname.Text + "','" + txt_Pword1.Text + "','" + box_Gender.Text + "','" + date_bday.Value + "','" + box_Country.Text + "','" + quizID + "')");
                    // Set the Connection to the new OleDbConnection.
                    command.Connection = connection;

                    // Open the connection and execute the insert command. 
                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    // The connection is automatically closed when the 
                    // code exits the using block.
                }

                frm_Dashboard dash = new frm_Dashboard(txt_Uname.Text);
                dash.Show();
                this.Hide();
            }
        }
示例#3
0
        private void tmr_Clock_Tick(object sender, EventArgs e)
        {
            test_Time--;
            int min, sec;

            if ((test_Time % 60) != 0)
            {
                min          = test_Time / 60;
                sec          = (test_Time - (min * 60));
                lbl_Min.Text = Convert.ToString(min);
                lbl_Sec.Text = Convert.ToString(sec);
            }
            else
            {
                min          = test_Time / 60;
                lbl_Min.Text = Convert.ToString(min);
                sec          = 00;
                lbl_Sec.Text = Convert.ToString(sec);
            }
            if ((min < 5))
            {
                lbl_Min.Text = "0" + lbl_Min.Text;
            }
            if (sec < 10)
            {
                lbl_Sec.Text = "0" + lbl_Sec.Text;
            }
            int    tokM = 0, tokA = 0, tokS = 0, tokD = 0;
            double tok = ((right_Items / items) * 100);

            if (items_mul != 0)
            {
                tokM = (right_mul / items_mul);
            }
            if (items_div != 0)
            {
                tokD = (right_div / items_div);
            }
            if (items_add != 0)
            {
                tokA = (right_add / items_add);
            }
            if (items_sub != 0)
            {
                tokM = (right_sub / items_sub);
            }
            if (test_Time == 0 && (tok > 65))
            {
                using (OleDbConnection connection = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + Directory.GetCurrentDirectory() + "\\Stilinski.mdb;"))
                {
                    // The insertSQL string contains a SQL statement that 
                    // inserts a new row in the source table.
                    OleDbCommand command = new OleDbCommand("INSERT INTO Diagnostic Values('" + DateTime.Now.Date + "','" + cpy + "','" + qLvl + "','" + addSpi + "','" + subSpi + "','" + divSpi + "','" + mulSpi + "','" + tok + "','" + tokA + "','" + tokS + "','" + tokD + "','" + tokM + "','" + uname + "')");
                    // Set the Connection to the new OleDbConnection.
                    command.Connection = connection;

                    // Open the connection and execute the insert command. 
                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                    }
                    // The connection is automatically closed when the 
                    // code exits the using block.
                }
                frm_Dashboard dash = new frm_Dashboard(uname);
                using (OleDbConnection connection = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + Directory.GetCurrentDirectory() + "\\Stilinski.mdb;"))
                {
                    // The insertSQL string contains a SQL statement that 
                    // inserts a new row in the source table.
                    OleDbCommand command = new OleDbCommand("UPDATE Users SET Status = 'Pascal' WHERE UName='" + uname + "'");
                    // Set the Connection to the new OleDbConnection.
                    command.Connection = connection;

                    // Open the connection and execute the insert command. 
                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                    }
                    // The connection is automatically closed when the 
                    // code exits the using block.
                }
                dash.Visible = true;
                this.Visible = false;
            }
            else
            {
                //failed
            }
            if (indi_Timer == true)
            {
                temp_Timer++;
            }
            if (indi_TimerA == true)
            {
                temp_TimerA++;
            }
            if (indi_TimerD == true)
            {
                temp_TimerD++;
            }
            if (indi_TimerM == true)
            {
                temp_TimerM++;
            }
            if (indi_TimerS == true)
            {
                temp_TimerS++;
            }
            if (indi_addSpi == true)
            {
                addSpi++;
            }
            if (indi_subSpi == true)
            {
                subSpi++;
            }
            if (indi_divSpi == true)
            {
                divSpi++;
            }
            if (indi_mulSpi == true)
            {
                mulSpi++;
            }
            if (indi_itemsTimer == true)
            {
                items_Timer++;
            }
        }