private void BCl(object sender, RoutedEventArgs e)
        {
            int             count = Mylist.Count / 3;
            int             counter = 0;
            string          MyConnection2 = "datasource=localhost;port=3306;username=root;password=;database=gpcenter;";
            double          x = 0, y = 0, z = 0;
            MySqlConnection MyConn2     = new MySqlConnection(MyConnection2);
            int             User_id     = 1;
            int             movement_id = 1;

            string code = "GP1.3gam3a_pre";

            codenum++;
            string          co         = code + Convert.ToString(codenum);
            string          q          = "INSERT INTO `video` (`Id`, `Code`, `GroupId`, `MovementId`) VALUES (NULL, '" + co + "','" + User_id + "','" + movement_id + "');";
            MySqlCommand    MyCommand1 = new MySqlCommand(q, MyConn2);
            MySqlDataReader MyReader1;


            MyConn2.Open();
            //int id = (int)MyCommand1.ExecuteScalar();
            MyReader1 = MyCommand1.ExecuteReader();
            while (MyReader1.Read())
            {
                //string rid = MyReader1["Id"].ToString();
            }


            MyConn2.Close();
            MyConn2.Open();

            string          q2          = "SELECT Id FROM `video` WHERE Id=LAST_INSERT_ID()";
            MySqlCommand    MyCommand12 = new MySqlCommand(q2, MyConn2);
            MySqlDataReader MyReader12;

            MyReader12 = MyCommand12.ExecuteReader();
            while (MyReader12.Read())
            {
            }
            //int id =  rid;
            int rid = (int)MyReader12["Id"];
            int id  = rid;

            MyConn2.Close();


            int jointid = 1;

            for (int j = 0; j < count; j++)
            {
                if (counter <= Mylist.Count)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (i == 0)
                        {
                            x = Mylist[counter];
                            counter++;
                        }
                        if (i == 1)
                        {
                            y = Mylist[counter];
                            counter++;
                        }
                        if (i == 2)
                        {
                            z = Mylist[counter];
                            counter++;
                        }
                    }
                }

                string Query = "INSERT INTO `videopoint`( `VideoId`, `JointId`, `x`, `y`, `z`) VALUES ('" + id + "','" + jointid + "','" + x + "','" + y + "','" + z + "');";



                MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();
                //MessageBox.Show("Save Data");
                while (MyReader2.Read())
                {
                }
                MyConn2.Close();
                jointid++;
                if (jointid == 7)
                {
                    jointid = 1;
                }
            }
            Mylist.Clear();
            string          qtest          = "INSERT INTO `checkvideo` (`Id`, `VideoId`, `Value`, `CoachCheck`) VALUES (NULL, '" + id + "', NULL , '0');";
            MySqlCommand    MyCommand3test = new MySqlCommand(qtest, MyConn2);
            MySqlDataReader MyReader3;


            MyConn2.Open();
            //int id = (int)MyCommand1.ExecuteScalar();
            MyReader3 = MyCommand3test.ExecuteReader();
            while (MyReader3.Read())
            {
                //string rid = MyReader1["Id"].ToString();
            }


            MyConn2.Close();
            //sw.Close();
            //filenum++;
        }
Ejemplo n.º 2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string conexao    = "Server=localhost;Database=Scholendar;Uid=root";
            var    connection = new MySqlConnection(conexao);
            //var command = connection.CreateCommand();
            MySqlCommand query = new MySqlCommand("select count(*) from Admin where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection);

            connection.Open();
            DataTable        dataTable = new DataTable();
            MySqlDataAdapter da        = new MySqlDataAdapter(query);
            MySqlDataAdapter adapter   = new MySqlDataAdapter();

            da.Fill(dataTable);

            connection.Close();


            //QUERY'S
            MySqlCommand queryAl   = new MySqlCommand("select * from Aluno where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection);
            MySqlCommand queryAd   = new MySqlCommand("select * from Admin where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection);
            MySqlCommand queryProf = new MySqlCommand("select * from Professor where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection);
            MySqlCommand queryEE   = new MySqlCommand("select * from EE where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection);

            connection.Open();

            //DATATABLES
            DataTable dataTable1 = new DataTable();
            DataTable dataTable2 = new DataTable();
            DataTable dataTable3 = new DataTable();
            DataTable dataTable4 = new DataTable();


            //ADAPATERS
            MySqlDataAdapter daAl   = new MySqlDataAdapter(queryAl);
            MySqlDataAdapter daAd   = new MySqlDataAdapter(queryAd);
            MySqlDataAdapter daProf = new MySqlDataAdapter(queryProf);
            MySqlDataAdapter daEE   = new MySqlDataAdapter(queryEE);


            daAl.Fill(dataTable1);
            daAd.Fill(dataTable2);
            daProf.Fill(dataTable3);
            daEE.Fill(dataTable4);


            connection.Close();


            foreach (DataRow list in dataTable1.Rows) // Aluno
            {
                if (Convert.ToInt32(list.ItemArray[0]) > 0)
                {
                    textBoxVar.Text = "1";
                }
                else
                {
                }
            }

            foreach (DataRow list2 in dataTable2.Rows) // Admin
            {
                if (Convert.ToInt32(list2.ItemArray[0]) > 0)
                {
                    textBoxVar.Text = "2";
                }
                else
                {
                }
            }

            foreach (DataRow list3 in dataTable3.Rows) //Professor
            {
                if (Convert.ToInt32(list3.ItemArray[0]) > 0)
                {
                    textBoxVar.Text = "3";
                }
                else
                {
                }
            }


            foreach (DataRow list4 in dataTable4.Rows) //EE
            {
                if (Convert.ToInt32(list4.ItemArray[0]) > 0)
                {
                    textBoxVar.Text = "4";
                }
                else
                {
                }
            }

            string Utilizador = textBoxUtilizador.Text;

            if (textBoxVar.Text == "1") // Aluno
            {
                connection.Open();

                string          queryAlHex = "select * from Aluno where Utilizador = '" + Utilizador + "' ";
                MySqlCommand    MyCommand  = new MySqlCommand(queryAlHex, connection);
                MySqlDataReader MyReader;
                MyReader = MyCommand.ExecuteReader();
                while (MyReader.Read())
                {
                    textBoxID_Aluno.Text = MyReader["ID_Aluno"].ToString();
                }
                connection.Close();

                connection.Open();
                string          query1     = "select * from Aluno where ID_aluno = '" + textBoxID_Aluno.Text + "' ;";
                MySqlCommand    MyCommand1 = new MySqlCommand(query1, connection);
                MySqlDataReader MyReader1;
                MyReader1 = MyCommand1.ExecuteReader();
                while (MyReader1.Read())
                {
                    textBoxVarPass.Text = MyReader1["var"].ToString();
                }
                connection.Close();

                try
                {
                    string ID_Aluno = textBoxID_Aluno.Text;
                    connection.Open();

                    string sql = "Update VAR set var = ('" + ID_Aluno + "') where ID_Var = 1;";
                    adapter.InsertCommand = new MySqlCommand(sql, connection);
                    adapter.InsertCommand.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    connection.Close();
                }

                connection.Open();
                string sql1 = "Update VAR set var = '1' where ID_Var = 2;";
                adapter.InsertCommand = new MySqlCommand(sql1, connection);
                adapter.InsertCommand.ExecuteNonQuery();
                connection.Close();

                if (textBoxVarPass.Text == "1")
                {
                    this.Hide();
                    MudarPass newform = new MudarPass();
                    newform.Show();
                }
                else if (textBoxVarPass.Text == "0")
                {
                    this.Hide();
                    Aluno Form = new Aluno();
                    Form.Show();
                }
            }
            else if (textBoxVar.Text == "2") // Admin
            {
                connection.Open();

                string          queryAlHex = "select * from Admin where Utilizador = '" + Utilizador + "' ";
                MySqlCommand    MyCommand  = new MySqlCommand(queryAlHex, connection);
                MySqlDataReader MyReader;
                MyReader = MyCommand.ExecuteReader();
                while (MyReader.Read())
                {
                    textBoxID_Admin.Text = MyReader["ID_Admin"].ToString();
                }
                connection.Close();

                connection.Open();
                string          query1     = "select * from Admin where ID_Admin = '" + textBoxID_Admin.Text + "' ;";
                MySqlCommand    MyCommand1 = new MySqlCommand(query1, connection);
                MySqlDataReader MyReader1;
                MyReader1 = MyCommand1.ExecuteReader();
                while (MyReader1.Read())
                {
                    textBoxVarPass.Text = MyReader1["var"].ToString();
                }
                connection.Close();

                try
                {
                    string ID_Admin = textBoxID_Admin.Text;
                    connection.Open();

                    string sql = "Update VAR set var = ('" + ID_Admin + "') where ID_Var = 1;";
                    adapter.InsertCommand = new MySqlCommand(sql, connection);
                    adapter.InsertCommand.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    connection.Close();
                }
                connection.Open();
                string sql1 = "Update VAR set var = '2' where ID_Var = 2;";
                adapter.InsertCommand = new MySqlCommand(sql1, connection);
                adapter.InsertCommand.ExecuteNonQuery();
                connection.Close();
                if (textBoxVarPass.Text == "1")
                {
                    this.Hide();
                    MudarPass newform = new MudarPass();
                    newform.Show();
                }
                else if (textBoxVarPass.Text == "0")
                {
                    this.Hide();
                    Admin Form = new Admin();
                    Form.Show();
                }
            }
            else if (textBoxVar.Text == "3") // Professor
            {
                connection.Open();

                string          queryAlHex = "select * from Professor where Utilizador = '" + Utilizador + "' ";
                MySqlCommand    MyCommand  = new MySqlCommand(queryAlHex, connection);
                MySqlDataReader MyReader;
                MyReader = MyCommand.ExecuteReader();
                while (MyReader.Read())
                {
                    textBoxIDProf.Text = MyReader["ID_Professor"].ToString();
                }
                connection.Close();

                connection.Open();
                string          query1     = "select * from Professor where ID_Professor = '" + textBoxIDProf.Text + "' ;";
                MySqlCommand    MyCommand1 = new MySqlCommand(query1, connection);
                MySqlDataReader MyReader1;
                MyReader1 = MyCommand1.ExecuteReader();
                while (MyReader1.Read())
                {
                    textBoxVarPass.Text = MyReader1["var"].ToString();
                }
                connection.Close();

                try
                {
                    string ID_Prof = textBoxIDProf.Text;
                    connection.Open();

                    string sql = "Update VAR set var = ('" + ID_Prof + "') where ID_Var = 1;";
                    adapter.InsertCommand = new MySqlCommand(sql, connection);
                    adapter.InsertCommand.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    connection.Close();
                }
                connection.Open();
                string sql1 = "Update VAR set var = '3' where ID_Var = 2;";
                adapter.InsertCommand = new MySqlCommand(sql1, connection);
                adapter.InsertCommand.ExecuteNonQuery();
                connection.Close();
                if (textBoxVarPass.Text == "1")
                {
                    this.Hide();
                    MudarPass newform = new MudarPass();
                    newform.Show();
                }
                else if (textBoxVarPass.Text == "0")
                {
                    this.Hide();
                    Professor Form = new Professor();
                    Form.Show();
                }
            }

            if (textBoxVar.Text == "4") // EE
            {
                connection.Open();

                string          ID_EE      = textBoxID_EE.Text;
                string          queryAlHex = "select * from EE where Utilizador = '" + Utilizador + "' ";
                MySqlCommand    MyCommand  = new MySqlCommand(queryAlHex, connection);
                MySqlDataReader MyReader;
                MyReader = MyCommand.ExecuteReader();
                while (MyReader.Read())
                {
                    textBoxID_EE.Text = MyReader["ID_EE"].ToString();
                }
                connection.Close();

                connection.Open();
                string          query1     = "select * from EE where ID_EE = '" + ID_EE + "' ;";
                MySqlCommand    MyCommand1 = new MySqlCommand(query1, connection);
                MySqlDataReader MyReader1;
                MyReader1 = MyCommand1.ExecuteReader();
                while (MyReader1.Read())
                {
                    textBoxVarPass.Text = MyReader1["var"].ToString();
                }
                connection.Close();

                try
                {
                    connection.Open();

                    string sql = "Update VAR set var = ('" + ID_EE + "') where ID_Var = 1;";
                    adapter.InsertCommand = new MySqlCommand(sql, connection);
                    adapter.InsertCommand.ExecuteNonQuery();

                    connection.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    connection.Close();
                }
                connection.Open();

                string sql1 = "Update VAR set var = '4' where ID_Var = 2;";
                adapter.InsertCommand = new MySqlCommand(sql1, connection);
                adapter.InsertCommand.ExecuteNonQuery();
                connection.Close();

                if (textBoxVarPass.Text == "1")
                {
                    this.Hide();
                    MudarPass newform = new MudarPass();
                    newform.Show();
                }
                else if (textBoxVarPass.Text == "0")
                {
                    this.Hide();
                    EE Form = new EE();
                    Form.Show();
                }
            }
            else if (textBoxPass.Text == "" || textBoxUtilizador.Text == "")
            {
                MessageBox.Show("Insira o utilizador e a Password");
            }
            else if (textBoxVar.Text == "")
            {
                MessageBox.Show("Utilizador Incorreto");
            }
        }
Ejemplo n.º 3
0
        private void txtContactNo_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                //conn.Open();
                string          Query     = "select product_name,quantity,days from user.admitted_medicine where patient_contact_no='" + txtContactNo.Text + "'";
                MySqlCommand    MyCommand = new MySqlCommand(Query, conn);
                MySqlDataReader MyReader;
                MyReader = MyCommand.ExecuteReader();
                while (MyReader.Read())
                {
                    product_name = MyReader.GetString(0);
                    quantity     = MyReader.GetString(1);
                    days         = MyReader.GetString(2);
                    //conn.Open();
                    string          Query1     = "select selling_price from user.supplier where product_name='" + product_name + "'";
                    MySqlCommand    MyCommand1 = new MySqlCommand(Query1, conn2);
                    MySqlDataReader MyReader1;
                    MyReader1 = MyCommand1.ExecuteReader();
                    while (MyReader1.Read())
                    {
                        per_quantity_price = MyReader1.GetString(0);
                    }

                    quantity_int             = Int32.Parse(quantity);
                    days_int                 = Int32.Parse(days);
                    per_quantity_price_int   = Int32.Parse(per_quantity_price);
                    total_medicine_cost_int += quantity_int * days_int * per_quantity_price_int;
                }
                conn.Close();

                MessageBox.Show("Product Name: " + product_name + "\n" + "Days: " + days + "\n" + "Quantity: " + quantity);

                /*conn.Open();
                 * string Query1 = "select selling_price from user.supplier where product_name='" + product_name + "'";
                 * MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn);
                 * MySqlDataReader MyReader1;
                 * MyReader1 = MyCommand1.ExecuteReader();
                 * while (MyReader1.Read())
                 * {
                 *  per_quantity_price = MyReader1.GetString(0);
                 * }
                 * conn.Close();*/

                MessageBox.Show("Selling price: " + per_quantity_price);

                /* quantity_int = Int32.Parse(quantity);
                 * days_int = Int32.Parse(days);
                 * per_quantity_price_int = Int32.Parse(per_quantity_price);
                 *
                 * total_medicine_cost_int = quantity_int * days_int * per_quantity_price_int;*/
                total_medicine_cost = total_medicine_cost_int.ToString();

                txtMedicineCost.Text = total_medicine_cost;

                //conn.Open();

                /*string Query = "select product_name,quantity,days from user.admitted_medicine where patient_contact_no='" + txtContactNo.Text + "'";
                 * MySqlCommand MyCommand = new MySqlCommand(Query, conn);
                 * MySqlDataReader MyReader;
                 * MyReader = MyCommand.ExecuteReader();
                 * while (MyReader.Read())
                 * {
                 *  product_name = MyReader.GetString(0);
                 *  quantity = MyReader.GetString(1);
                 *  days = MyReader.GetString(2);
                 * }
                 * conn.Close();
                 *
                 * // MessageBox.Show("Product Name: " + product_name + "\n" + "Days: " + days + "\n" + "Quantity: " + quantity);
                 *
                 * conn.Open();
                 * string Query1 = "select selling_price from user.supplier where product_name='" + product_name + "'";
                 * MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn);
                 * MySqlDataReader MyReader1;
                 * MyReader1 = MyCommand1.ExecuteReader();
                 * while (MyReader1.Read())
                 * {
                 *  per_quantity_price = MyReader1.GetString(0);
                 * }
                 * conn.Close();
                 *
                 * //MessageBox.Show("Selling price: " + per_quantity_price);
                 *
                 * quantity_int = Int32.Parse(quantity);
                 * days_int = Int32.Parse(days);
                 * per_quantity_price_int = Int32.Parse(per_quantity_price);
                 *
                 * total_medicine_cost_int = quantity_int * days_int * per_quantity_price_int;
                 * total_medicine_cost = total_medicine_cost_int.ToString();
                 *
                 * txtMedicineCost.Text = total_medicine_cost;*/
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 4
0
        unsafe private void button2_Click_1(object sender, EventArgs e)
        {
            UInt32 uiLength, uiRead, uiResult, uiWritten;

            byte[] ReadBuffer  = new byte[0x40];
            byte[] WriteBuffer = new byte[] { 0x2, 0x2, 0x1, 0x1 }; //Command {STX, LEN, CMD, DATA1, DATA2.....}

            byte[] sResponse = null;
            sResponse = new byte[21];

            EasyPOD.VID = 0xe6a;
            EasyPOD.PID = 0x317;
            Index       = 1;
            uiLength    = 64;

            fixed(MW_EasyPOD *pPOD = &EasyPOD)
            {
                dwResult = PODfuncs.ConnectPOD(pPOD, Index);

                if ((dwResult != 0))
                {
                    MessageBox.Show("Ligue o leitor de cartões");
                }
                else
                {
                    EasyPOD.ReadTimeOut  = 200;
                    EasyPOD.WriteTimeOut = 200;

                    dwResult = PODfuncs.WriteData(pPOD, WriteBuffer, 4, &uiWritten);                         //Send a request command to reader
                    uiResult = PODfuncs.ReadData(pPOD, ReadBuffer, uiLength, &uiRead);                       //Read the response data from reader

                    textBoxHex.Text = BitConverter.ToString(ReadBuffer, 4, (Int32)uiRead).Replace("-", " "); //HEX
                    textBoxDe.Text  = BitConverter.ToInt32(ReadBuffer, 4).ToString();                        //DEC
                                                                                                             //textBox1.PasswordChar = '*';


                    string           conexao    = "Server=localhost;Database=Scholendar;Uid=root";
                    var              connection = new MySqlConnection(conexao);
                    var              command    = connection.CreateCommand();
                    MySqlDataAdapter adapter    = new MySqlDataAdapter();

                    //QUERY'S
                    MySqlCommand queryAl   = new MySqlCommand("select * from Aluno where Hex = '" + textBoxHex.Text + "' or De = '" + textBoxDe.Text + "'", connection);
                    MySqlCommand queryAd   = new MySqlCommand("select * from Admin where Hex = '" + textBoxHex.Text + "' or De = '" + textBoxDe.Text + "'", connection);
                    MySqlCommand queryProf = new MySqlCommand("select * from Professor where Hex = '" + textBoxHex.Text + "' or De = '" + textBoxDe.Text + "'", connection);

                    connection.Open();

                    //DATATABLES
                    DataTable dataTable1 = new DataTable();
                    DataTable dataTable2 = new DataTable();
                    DataTable dataTable3 = new DataTable();

                    //ADAPATERS
                    MySqlDataAdapter daAl   = new MySqlDataAdapter(queryAl);
                    MySqlDataAdapter daAd   = new MySqlDataAdapter(queryAd);
                    MySqlDataAdapter daProf = new MySqlDataAdapter(queryProf);

                    daAl.Fill(dataTable1);
                    daAd.Fill(dataTable2);
                    daProf.Fill(dataTable3);

                    connection.Close();


                    foreach (DataRow list in dataTable1.Rows) // Aluno
                    {
                        if (Convert.ToInt32(list.ItemArray[0]) > 0)
                        {
                            textBoxVar.Text = "1";
                        }
                        else
                        {
                            MessageBox.Show("Teste");
                        }
                    }

                    foreach (DataRow list in dataTable2.Rows) // Admin
                    {
                        if (Convert.ToInt32(list.ItemArray[0]) > 0)
                        {
                            textBoxVar.Text = "2";
                        }
                        else
                        {
                            MessageBox.Show("Teste");
                        }
                    }

                    foreach (DataRow list3 in dataTable3.Rows) //Professor
                    {
                        if (Convert.ToInt32(list3.ItemArray[0]) > 0)
                        {
                            textBoxVar.Text = "3";
                        }
                        else
                        {
                            MessageBox.Show("Teste");
                        }
                    }



                    if (textBoxVar.Text == "1")//ALUNO
                    {
                        connection.Open();
                        string          Hex       = textBoxHex.Text;
                        string          query     = "select * from Aluno where Hex = '" + Hex + "' ";
                        MySqlCommand    MyCommand = new MySqlCommand(query, connection);
                        MySqlDataReader MyReader;
                        MyReader = MyCommand.ExecuteReader();
                        while (MyReader.Read())
                        {
                            textBoxID_Aluno.Text = MyReader["ID_Aluno"].ToString();
                        }
                        connection.Close();

                        try
                        {
                            string ID_Aluno = textBoxID_Aluno.Text;
                            connection.Open();

                            string sql = "Update VAR set var = ('" + ID_Aluno + "') where ID_Var = 1;";
                            adapter.InsertCommand = new MySqlCommand(sql, connection);
                            adapter.InsertCommand.ExecuteNonQuery();
                            connection.Close();

                            connection.Open();
                            string          query1     = "select * from Aluno where ID_Aluno = '" + ID_Aluno + "' ;";
                            MySqlCommand    MyCommand1 = new MySqlCommand(query1, connection);
                            MySqlDataReader MyReader1;
                            MyReader1 = MyCommand1.ExecuteReader();
                            while (MyReader1.Read())
                            {
                                textBoxVarPass.Text = MyReader1["var"].ToString();
                            }
                            connection.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        finally
                        {
                            connection.Close();
                        }

                        try
                        {
                            connection.Open();

                            string sql = "Update VAR set var = '1' where ID_Var = 2;";
                            adapter.InsertCommand = new MySqlCommand(sql, connection);
                            adapter.InsertCommand.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        finally
                        {
                            connection.Close();
                        }

                        if (textBoxVarPass.Text == "1")
                        {
                            this.Hide();
                            MudarPass newform1 = new MudarPass();
                            newform1.Show();
                            form.textBoxUtilizador.Text = "Aluno";
                        }
                        else
                        {
                            this.Hide();
                            Aluno newform = new Aluno();
                            newform.Show();
                        }
                    }
                    else if (textBoxVar.Text == "2")//ADMIN
                    {
                        connection.Open();
                        string          Hex       = textBoxHex.Text;
                        string          query     = "select * from Admin where Hex = '" + Hex + "' ";
                        MySqlCommand    MyCommand = new MySqlCommand(query, connection);
                        MySqlDataReader MyReader;
                        MyReader = MyCommand.ExecuteReader();
                        while (MyReader.Read())
                        {
                            textBoxID_Admin.Text = MyReader["ID_Admin"].ToString();
                        }
                        connection.Close();

                        try
                        {
                            string ID_Admin = textBoxID_Admin.Text;
                            connection.Open();

                            string sql = "Update VAR set var = ('" + ID_Admin + "') where ID_Var = 1;";
                            adapter.InsertCommand = new MySqlCommand(sql, connection);
                            adapter.InsertCommand.ExecuteNonQuery();

                            connection.Close();

                            connection.Open();
                            string          query1     = "select * from Admin where ID_Admin = '" + ID_Admin + "' ;";
                            MySqlCommand    MyCommand1 = new MySqlCommand(query1, connection);
                            MySqlDataReader MyReader1;
                            MyReader1 = MyCommand1.ExecuteReader();
                            while (MyReader1.Read())
                            {
                                textBoxVarPass.Text = MyReader1["var"].ToString();
                            }
                            connection.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        finally
                        {
                            connection.Close();
                        }

                        try
                        {
                            connection.Open();

                            string sql = "Update VAR set var = '2' where ID_Var = 2;";
                            adapter.InsertCommand = new MySqlCommand(sql, connection);
                            adapter.InsertCommand.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        finally
                        {
                            connection.Close();
                        }

                        if (textBoxVarPass.Text == "1")
                        {
                            this.Hide();
                            MudarPass newform = new MudarPass();
                            newform.Show();
                            form.textBoxUtilizador.Text = "Administrador";
                        }
                        else if (textBoxVarPass.Text == "0")
                        {
                            this.Hide();
                            Admin Form = new Admin();
                            Form.Show();
                        }
                    }
                    else if (textBoxVar.Text == "3")//PROFESSOR
                    {
                        connection.Open();
                        string          Hex       = textBoxHex.Text;
                        string          query     = "select * from Professor where Hex = '" + Hex + "' ";
                        MySqlCommand    MyCommand = new MySqlCommand(query, connection);
                        MySqlDataReader MyReader;
                        MyReader = MyCommand.ExecuteReader();
                        while (MyReader.Read())
                        {
                            textBoxIDProf.Text = MyReader["ID_Professor"].ToString();
                        }
                        connection.Close();
                        string ID_Prof = textBoxIDProf.Text;
                        try
                        {
                            connection.Open();

                            string sql = "Update VAR set var = ('" + ID_Prof + "') where ID_Var = 1;";
                            adapter.InsertCommand = new MySqlCommand(sql, connection);
                            adapter.InsertCommand.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        finally
                        {
                            connection.Close();
                        }

                        connection.Open();
                        string          query1     = "select * from Professor where ID_Professor = '" + ID_Prof + "' ;";
                        MySqlCommand    MyCommand1 = new MySqlCommand(query1, connection);
                        MySqlDataReader MyReader1;
                        MyReader1 = MyCommand1.ExecuteReader();
                        while (MyReader1.Read())
                        {
                            textBoxVarPass.Text = MyReader1["var"].ToString();
                        }
                        connection.Close();

                        try
                        {
                            connection.Open();

                            string sql = "Update VAR set var = '3' where ID_Var = 2;";
                            adapter.InsertCommand = new MySqlCommand(sql, connection);
                            adapter.InsertCommand.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        finally
                        {
                            connection.Close();
                        }

                        if (textBoxVarPass.Text == "1")
                        {
                            this.Hide();
                            MudarPass newform = new MudarPass();
                            newform.Show();
                            form.textBoxUtilizador.Text = "Professor";
                        }
                        else if (textBoxVarPass.Text == "0")
                        {
                            this.Hide();
                            Professor Form = new Professor();
                            Form.Show();
                        }
                    }
                    else if (textBoxDe.Text == "0")
                    {
                    }
                    else
                    {
                        MessageBox.Show("Cartão não registado");
                    }
                }
                dwResult = PODfuncs.ClearPODBuffer(pPOD);
                dwResult = PODfuncs.DisconnectPOD(pPOD);
            }
        }