private void glassButton1_Click(object sender, EventArgs e)
        {
            if (txtu.Text.Length < 6)
            {
                MessageBox.Show("Username must be atleast 6 characters long.", "User Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (txtP.Text.Length < 6)
            {
                MessageBox.Show("Password must be atleast 6 characters long.", "User Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (fname.Text.Length < 5)
            {
                MessageBox.Show("Please enter a valid name of the user.", "User Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (textBox3.Text != txtP.Text)
            {
                MessageBox.Show("Password verification did not match.\nPlease try again", "User Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                {
                    string query33;

                    StreamReader sr33 = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                    line = sr33.ReadLine();
                    StreamReader sr34 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                    dbP = sr34.ReadLine();
                    StreamReader sr35 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                    dbU = sr35.ReadLine();
                    string sConnection33 = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                    MySqlConnection sqlConnection33 = new MySqlConnection(sConnection33);
                    query33 = "Insert Into security Values('" + System.DateTime.Now.ToString() + "(" + System.DateTime.Now.Millisecond.ToString() + ")_" + txtu.Text + "','" + "Started using Inventory System" + "','" + System.DateTime.Now.ToString() + "','" + fname.Text + "','"+terms()+"')";

                    dbQuery(query33);

                }
                {
                    string query;

                    StreamReader sr = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                    line = sr.ReadLine();
                    StreamReader sr3 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                    dbP = sr3.ReadLine();
                    StreamReader sr4 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                    dbU = sr4.ReadLine();
                    string sConnection = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                    MySqlConnection sqlConnection = new MySqlConnection(sConnection);
                    query = "Insert Into logs Values('" + "U" + System.DateTime.Now.Year + System.DateTime.Now.Month + System.DateTime.Now.Day + System.DateTime.Now.Millisecond + "','" + txtu.Text.Trim() + "','" + txtP.Text.Trim() + "','" + fname.Text.ToUpper() + "','" + txtAdd.Text.Trim().ToUpper() + "','" + txtCon.Text.Trim() + "','" + txtEm.Text.Trim() + "','" + "ADMIN" + "' )";

                    dbQuery(query);
                    MessageBox.Show("You've just created this Inventory System's first account! \nFor questions and help, click System help on the Help menu.", "Welcome!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Workpane fm = new Workpane(txtu.Text);
                    fm.Show();
                    this.Close();

                }
            }
        }
        public void proceedNow()
        {
            bool dog = true;
            try
            {
                //    string query33;

                //    StreamReader sr33 = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                //    line = sr33.ReadLine();
                //    StreamReader sr34 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                //    dbP = sr34.ReadLine();
                //    StreamReader sr35 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                //    dbU = sr35.ReadLine();
                //    string sConnection33 = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                //    MySqlConnection sqlConnection33 = new MySqlConnection(sConnection33);
                //    query33 = "Select * from systime";
                //    dbFill(query33);
                //    while (dbReader.Read())
                //    {
                //        wrong = int.Parse(dbReader["tleft"].ToString());
                //        tryer =Convert.ToDateTime( dbReader["timeleft"].ToString());
                //    }
                //    dbReader.Close();
                //    dbConn.Close();
                //    newTime = tryer.AddMinutes(5);
                //    nowTime = System.DateTime.Now;
                //     ss = nowTime - newTime;
                //    MessageBox.Show(ss.ToString());
                //}
                //if ((wrong == 0)||(ss >TimeSpan.("00:05:00.0")))
                //{
                //    MessageBox.Show("System Block. \nPlease try again after "+ss.ToString()+" minutes", "Log-In", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                //}
                //else
                {
                    {
                        string username;
                        string password = "";
                        string types = "";
                        string name = "";

                        string query;

                        StreamReader sr = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                        line = sr.ReadLine();
                        StreamReader sr3 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                        dbP = sr3.ReadLine();
                        StreamReader sr4 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                        dbU = sr4.ReadLine();
                        string sConnection = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                        MySqlConnection sqlConnection = new MySqlConnection(sConnection);
                        query = "Select * from logs WHERE userna = '" + txtUser.Text + "'";
                        dbFill(query);
                        while (dbReader.Read())
                        {
                            username = dbReader["userna"].ToString();
                            password = dbReader["passw"].ToString();
                            name = dbReader["names"].ToString();
                            types = dbReader["types"].ToString();
                            if (password == txtPass.Text)
                            {
                                MessageBox.Show("Welcome " + name + " !", "Log In", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                                {
                                    string query33;

                                    StreamReader sr33 = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                                    line = sr33.ReadLine();
                                    StreamReader sr34 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                                    dbP = sr34.ReadLine();
                                    StreamReader sr35 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                                    dbU = sr35.ReadLine();
                                    string sConnection33 = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                                    MySqlConnection sqlConnection33 = new MySqlConnection(sConnection33);
                                    query33 = "Insert Into security Values('" + System.DateTime.Now.ToString() + "(" + System.DateTime.Now.Millisecond.ToString() + ")_" + txtUser.Text.Trim() + "','" + "The user logged in." + "','" + System.DateTime.Now.ToString() + "','" + name + "','"+terms()+"')";

                                    dbQuery(query33);
                                    del();
                                }
                                if (types == "ADMIN")
                                {
                                    Admin admin = new Admin(username);
                                    admin.Text = "Workpane [" + name + "]";
                                    admin.Show();
                                    this.Hide();
                                }
                                else
                                {
                                    Workpane admin = new Workpane(username);
                                    admin.Text = "Workpane [" + name + "]";
                                    admin.Show();
                                    this.Hide();
                                }

                                dog = false;
                                break;

                            }
                            //else
                            //{
                            //    MessageBox.Show("Username or password did not match.\nPlease try again.", "Log In", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            //    dog = false;
                            //    break;

                            //}
                        }
                        dbReader.Close();
                        dbConn.Close();
                        if ((txtPass.Text == "") || (txtUser.Text == ""))
                        {
                            MessageBox.Show("Missing field.\nPlease try again.", "Log In", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            dog = false;

                        }
                        if (dog == true)
                        {
                            MessageBox.Show("Username or password did not match.\nPlease try again.", "Log In", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            dog = false;
                            {
                                string query33;

                                StreamReader sr33 = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                                line = sr33.ReadLine();
                                StreamReader sr34 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                                dbP = sr34.ReadLine();
                                StreamReader sr35 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                                dbU = sr35.ReadLine();
                                string sConnection33 = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                                MySqlConnection sqlConnection33 = new MySqlConnection(sConnection33);
                                query33 = "Insert Into security Values('" + System.DateTime.Now.ToString() + "(" + System.DateTime.Now.Millisecond.ToString() + ")_" + "ANONYMOUS" + "','" + "Someone is trying to log-in a username [ " + txtUser.Text.Trim() + " ] but failed." + "','" + System.DateTime.Now.ToString() + "','" + "ANONYMOUS" + "','"+terms()+"')";

                                dbQuery(query33);

                            }

                            bool meron = false;
                            //{
                            //    string query33;

                            //    StreamReader sr33 = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                            //    line = sr33.ReadLine();
                            //    StreamReader sr34 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                            //    dbP = sr34.ReadLine();
                            //    StreamReader sr35 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                            //    dbU = sr35.ReadLine();
                            //    string sConnection33 = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                            //    MySqlConnection sqlConnection33 = new MySqlConnection(sConnection33);
                            //    query = "Select * from systime";
                            //    dbFill(query);
                            //    while (dbReader.Read())
                            //    {
                            //        wrong = int.Parse(dbReader["tleft"].ToString());
                            //        meron = true;
                            //    }
                            //    dbReader.Close();
                            //    dbConn.Close();
                            //}
                            //if (meron == true)
                            //{
                            //    if (wrong == 0)
                            //    {
                            //        MessageBox.Show("Username or password did not match. \nPlease try again after 5 minutes", "Log-In", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            //    }

                            //MessageBox.Show("Username or password did not match. \nYou have " + wrong.ToString() + " tries left.", "Log-In", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            //wrong--;
                            //{
                            //    string query33;

                            //    StreamReader sr33 = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                            //    line = sr33.ReadLine();
                            //    StreamReader sr34 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                            //    dbP = sr34.ReadLine();
                            //    StreamReader sr35 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                            //    dbU = sr35.ReadLine();
                            //    string sConnection33 = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                            //    MySqlConnection sqlConnection33 = new MySqlConnection(sConnection33);

                            //    query33 = " Update systime Set tleft = '" + wrong.ToString() + "' WHERE timeleft like '" + "2" + "%'";

                            //    dbQuery(query33);
                            //    //  MessageBox.Show("may update annu");
                            //}
                            //}
                            //else
                            //{
                            //    {
                            //        string query33;

                            //        StreamReader sr33 = new StreamReader(Application.StartupPath.ToString() + "//data.txt");
                            //        line = sr33.ReadLine();
                            //        StreamReader sr34 = new StreamReader(Application.StartupPath.ToString() + "//dataP.txt");
                            //        dbP = sr34.ReadLine();
                            //        StreamReader sr35 = new StreamReader(Application.StartupPath.ToString() + "//dataU.txt");
                            //        dbU = sr35.ReadLine();
                            //        string sConnection33 = "SERVER=" + line + ";" + "DATABASE=lamolinventory;" + "UID=" + dbU + ";" + "PASSWORD='******';";
                            //        MySqlConnection sqlConnection33 = new MySqlConnection(sConnection33);
                            //        query33 = "Insert Into systime Values('" + timecomponent() + "','" + wrong.ToString() + "')";

                            //        dbQuery(query33);

                            //    }
                        }
                    }

                }
            }
            catch
            {
                MessageBox.Show("There's something wrong with the database connection.\nPlease check your settings.", "Log In", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }
        }