Example #1
0
        private void listBoxDisciplina_SelectedIndexChanged(object sender, EventArgs e)
        {
            string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            string          query      = "Select * from Disciplina where Disciplina = '" + listBoxDisciplina.SelectedItem.ToString() + "'; ";
            MySqlConnection connection = new MySqlConnection(Conexao);

            try
            {
                connection.Open();
                MySqlCommand    MyCommand3 = new MySqlCommand(query, connection);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                while (MyReader3.Read())
                {
                    textBoxID_Disc.Text = MyReader3["ID_Disciplina"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                connection.Close();
            }
        }
Example #2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            MySqlConnection connection = new MySqlConnection(Conexao);
            string          Turma      = comboBox1.SelectedItem.ToString();
            string          query      = "SELECT * from Turma where Turma = '" + Turma + "';";


            if (comboBox1.SelectedItem != null)
            {
                try
                {
                    dataGridView1.DataSource = LoadDGV();
                    connection.Open();
                    MySqlCommand    MyCommand3 = new MySqlCommand(query, connection);
                    MySqlDataReader MyReader3;
                    MyReader3 = MyCommand3.ExecuteReader();
                    while (MyReader3.Read())
                    {
                        textBoxID_Turma.Text     = MyReader3["ID_Turma"].ToString(); //String com o valor ID_Turma
                        dataGridView1.DataSource = LoadDGV();
                    }
                    connection.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Example #3
0
        private void pictureBox6_Click(object sender, EventArgs e)
        {
            if (listBoxSelecAlunos.SelectedItem == null)
            {
                MessageBox.Show("Seleciona o aluno que queres remover");
            }
            else
            {
                listBoxIDAluno.Items.Clear();
                listBoxTdAlunos.Items.Add(listBoxSelecAlunos.SelectedItem);
                listBoxSelecAlunos.Items.Remove(listBoxSelecAlunos.SelectedItem);

                string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
                MySqlConnection connection = new MySqlConnection(Conexao);
                foreach (var listBoxItem in listBoxSelecAlunos.Items)
                {
                    connection.Open();
                    string i = listBoxItem.ToString();

                    string          query3     = "select * from Aluno where Nome = '" + i + "' ;";
                    MySqlCommand    MyCommand3 = new MySqlCommand(query3, connection);
                    MySqlDataReader MyReader3;
                    MyReader3 = MyCommand3.ExecuteReader();
                    while (MyReader3.Read())
                    {
                        listBoxIDAluno.Items.Add(MyReader3["ID_Aluno"].ToString());
                    }
                    connection.Close();
                }
            }
        }
Example #4
0
        private void pictureBox10_Click(object sender, EventArgs e)
        {
            if (listBoxAdicionar.SelectedItem != null)
            {
                string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
                MySqlConnection connection = new MySqlConnection(Conexao);
                connection.Open();

                string query = "select * from Aluno where Nome = '" + listBoxAdicionar.SelectedItem.ToString() + "'";

                MySqlCommand    MyCommand3 = new MySqlCommand(query, connection);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                while (MyReader3.Read())
                {
                    textBoxID_AlunoEspecifico.Text = MyReader3["ID_Aluno"].ToString();
                }
                connection.Close();

                textBoxValidacao.Text = "0"; //Inativo
                listBoxAluno.Items.Add(listBoxAdicionar.SelectedItem.ToString());
                listBoxAdicionar.Items.Remove(listBoxAdicionar.SelectedItem.ToString());
                listBoxID_AlunoEspecifico.Items.Remove(textBoxID_AlunoEspecifico.Text);
            }


            //if (textBoxValidacao.Text == "1")
            //{

            //}
        }
Example #5
0
 private void btCari_Click(object sender, EventArgs e)
 {
     {
         try
         {
             string          MyConnection3 = "datasource=localhost; port=3306; username=root; password=new_password; database=artrockdb;SslMode=none";
             string          Query         = "select* from gitar where Serial='" + this.tbCari.Text + "';";
             MySqlConnection MyConn3       = new MySqlConnection(MyConnection3);
             MySqlCommand    MyCommand3    = new MySqlCommand(Query, MyConn3);
             MySqlDataReader MyReader3;
             MyConn3.Open();
             MyReader3 = MyCommand3.ExecuteReader();
             StringBuilder sb = new StringBuilder();
             if (MyReader3.Read())
             {
                 FormUpdate fupdate = new FormUpdate();
                 fupdate.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Gitar tidak ditemukan!");
             }
             MyConn3.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Example #6
0
        void ID_Prof_Dentro()
        {
            string          Conexao       = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            string          query         = "Select * from Professor where nome = '" + dataGridViewProfDentro.SelectedCells[0].Value.ToString() + "'; ";
            MySqlConnection connection    = new MySqlConnection(Conexao);
            MySqlCommand    cmdconnection = new MySqlCommand(query, connection);

            try
            {
                connection.Open();
                MySqlCommand    MyCommand3 = new MySqlCommand(query, connection);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                while (MyReader3.Read())
                {
                    textBoxID_Prof.Text = MyReader3["ID_Professor"].ToString(); //String com o valor ID_Turma
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                connection.Close();
            }
        }
Example #7
0
        private void dataGridView2_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView2.SelectedCells.Count <= 0)
            {
                return;
            }
            string select = dataGridView2.SelectedCells[3].Value.ToString();

            string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            MySqlConnection connection = new MySqlConnection(Conexao);

            connection.Open();

            string          query     = "select * from Evento where ID_Evento = '" + select + "' ";
            MySqlCommand    MyCommand = new MySqlCommand(query, connection);
            MySqlDataReader MyReader;

            MyReader = MyCommand.ExecuteReader();
            while (MyReader.Read())
            {
                textBoxDt_Inicio.Text   = MyReader["Dt_Inicio"].ToString();
                textBoxDt_Final.Text    = MyReader["Dt_Final"].ToString();
                textBoxID_Disc2.Text    = MyReader["ID_Disciplina"].ToString();
                textBoxID_Turma2.Text   = MyReader["ID_Turma"].ToString();
                textBoxDesc_Agenda.Text = MyReader["Descricao"].ToString();
            }
            connection.Close();

            connection.Open();

            string          ID_Disc    = textBoxID_Disc2.Text;
            string          query2     = "select Disciplina from Disciplina where ID_Disciplina = '" + ID_Disc + "' ;";
            MySqlCommand    MyCommand2 = new MySqlCommand(query2, connection);
            MySqlDataReader MyReader2;

            MyReader2 = MyCommand2.ExecuteReader();
            while (MyReader2.Read())
            {
                textBoxDisciplina.Text = MyReader2["Disciplina"].ToString();
            }
            connection.Close();

            connection.Open();

            string          ID_Turma   = textBoxID_Turma2.Text;
            string          query3     = "select Turma from Turma where ID_Turma = '" + ID_Turma + "' ;";
            MySqlCommand    MyCommand3 = new MySqlCommand(query3, connection);
            MySqlDataReader MyReader3;

            MyReader3 = MyCommand3.ExecuteReader();
            while (MyReader3.Read())
            {
                textBoxTurmaAgenda.Text = MyReader3["Turma"].ToString();
            }
            connection.Close();
        }
        private void delete_btn_Click(object sender, EventArgs e)
        {
            del_confirm del = new del_confirm();

            del.ShowDialog();
            selectedItems2 = new ListBox.SelectedObjectCollection(project_list);
            selectedItems2 = project_list.SelectedItems;
            int selectedIndex = project_list.SelectedIndex;

            if (selectedIndex != -1)
            {
                if (del.Showconfirmation() == true)
                {
                    for (int i = selectedItems2.Count - 1; i >= 0; i--)
                    {
                        projIDii = selectedItems2[i].ToString();
                    }
                    projIDiii = projIDii.Split(',');
                    proID     = Convert.ToInt32(projIDiii[0]);
                    //proj.Remove(proj[selectedIndex]);
                    MySqlConnection connection = new MySqlConnection(connec);
                    connection.Open();
                    string          query  = "DELETE FROM `internal_communication_4`.`projects` WHERE(`project_id` = " + this.proID + "); ";
                    MySqlCommand    idused = new MySqlCommand(query, connection);
                    MySqlDataReader MyReader3;
                    MyReader3 = idused.ExecuteReader();
                    while (MyReader3.Read())
                    {
                    }
                    connection.Close();

                    //delete subject associated
                    connection.Open();
                    string          query7 = "DELETE FROM `internal_communication_4`.`subjects` WHERE(`Project_project_id` = " + this.proID + "); ";
                    MySqlCommand    comma  = new MySqlCommand(query7, connection);
                    MySqlDataReader MyReader6;
                    MyReader6 = comma.ExecuteReader();
                    while (MyReader6.Read())
                    {
                    }
                    connection.Close();
                    for (int i = selectedItems2.Count - 1; i >= 0; i--)
                    {
                        project_list.Items.Remove(selectedItems2[i]);
                    }
                    projectDA.Save(proj);
                }
                else
                {
                }
            }
            else
            {
                MessageBox.Show("You must select a project");
            }
        }
Example #9
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string          Query     = "insert into admitted_patient values('" + patient_name.Text + "','" + patient_age.Text + "','" + patient_contact_no.Text + "','" + comboboxBloodGroup.SelectedItem.ToString() + "','" + patient_address.Text + "','" + comboboxDisease.SelectedItem.ToString() + "','" + comboboxDoctorName.SelectedItem.ToString() + "','" + docId + "','" + textboxDoctorDept.Text + "','" + time_of_admission.Text + "','" + this.textboxWard.Text + "', '" + "Admitted" + "');";
                MySqlCommand    MyCommand = new MySqlCommand(Query, conn);
                MySqlDataReader MyReader;
                MyReader = MyCommand.ExecuteReader();
                MyReader.Close();

                string          Query1     = "DROP TABLE ward_bed;";
                MySqlCommand    MyCommand1 = new MySqlCommand(Query1, conn);
                MySqlDataReader MyReader1;
                MyReader1 = MyCommand1.ExecuteReader();
                MyReader1.Close();

                string          Query2     = "CREATE TABLE ward_bed AS SELECT ward.ward_name,bed.pat_contact_no,bed.bed_no,bed.bed_type,bed.bed_cost,bed.bed_status FROM ward,bed WHERE ward.ward_id=bed.ward_id;";
                MySqlCommand    MyCommand2 = new MySqlCommand(Query2, conn);
                MySqlDataReader MyReader2;
                MyReader2 = MyCommand2.ExecuteReader();
                MyReader2.Close();

                string          Query3     = "DROP TABLE allocate_patient_bed;";
                MySqlCommand    MyCommand3 = new MySqlCommand(Query3, conn);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                MyReader3.Close();

                string          Query4     = "CREATE TABLE allocate_patient_bed AS SELECT admitted_patient.patient_name,admitted_patient.patient_age,admitted_patient.patient_contact_no,ward_bed.ward_name,ward_bed.bed_no,ward_bed.bed_type,ward_bed.bed_cost,ward_bed.bed_status FROM admitted_patient,ward_bed WHERE admitted_patient.patient_contact_no=ward_bed.pat_contact_no AND admitted_patient.ward_name=ward_bed.ward_name;";
                MySqlCommand    MyCommand4 = new MySqlCommand(Query4, conn);
                MySqlDataReader MyReader4;
                MyReader4 = MyCommand4.ExecuteReader();
                MyReader4.Close();


                MessageBox.Show("Patient Addmitted!");

                patient_name.Text = ""; patient_address.Text = ""; patient_age.Text = ""; patient_contact_no.Text = "";
                comboboxBloodGroup.Items.Clear(); comboboxDoctorName.Items.Clear(); comboboxDisease.Items.Clear();
                textboxBed.Text = ""; textboxBedType.Text = ""; textboxWard.Text = ""; textboxDoctorDept.Text = "";
                load_blood_group(); load_disease(); load_doctor_name();

                patient_name.IsEnabled       = false; patient_address.IsEnabled = false; patient_age.IsEnabled = false; patient_contact_no.IsEnabled = false;
                comboboxBloodGroup.IsEnabled = false; comboboxDoctorName.IsEnabled = false; comboboxDisease.IsEnabled = false;
                textboxBed.IsEnabled         = false; textboxBedType.IsEnabled = false; textboxWard.IsEnabled = false; textboxDoctorDept.IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #10
0
        private void comboBoxDisc3_SelectedIndexChanged(object sender, EventArgs e)
        {
            string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            MySqlConnection connection = new MySqlConnection(Conexao);

            connection.Open();
            string          disciplina3 = comboBoxDisc3.SelectedItem.ToString();
            string          query3      = "select * from Disciplina where Disciplina = '" + disciplina3 + "' ";
            MySqlCommand    MyCommand3  = new MySqlCommand(query3, connection);
            MySqlDataReader MyReader3;

            MyReader3 = MyCommand3.ExecuteReader();
            while (MyReader3.Read())
            {
                textBoxIDDisc3.Text = MyReader3["ID_Disciplina"].ToString();
            }
            connection.Close();
        }
Example #11
0
        private void pictureBox1_Click(object sender, EventArgs e) // Adicionar professor à turma
        {
            if (comboBox2.SelectedItem == null)
            {
                MessageBox.Show("Escolha em que turma deseja inserir o professor.");
            }
            else
            {
                comboBox2.Enabled = false;
                string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
                string          i          = dataGridViewProfFora.SelectedCells[0].Value.ToString();
                string          query      = "Select * from Professor where nome = '" + i + "'; ";
                MySqlConnection connection = new MySqlConnection(Conexao);

                try
                {
                    connection.Open();
                    MySqlCommand    MyCommand3 = new MySqlCommand(query, connection);
                    MySqlDataReader MyReader3;
                    MyReader3 = MyCommand3.ExecuteReader();
                    while (MyReader3.Read())
                    {
                        textBoxID_Prof.Text = MyReader3["ID_Professor"].ToString(); //String com o valor ID_Turma
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    connection.Close();
                }



                listBoxID_Disciplina.Items.Clear();
                listBoxDisciplina.Items.Clear();
                panelDisciplina.Visible = true;
                LoadListBox();
                pictureBox1.Visible = false;
                pictureBox2.Visible = false;
            }
        }
Example #12
0
        private void button3_Click(object sender, EventArgs e)
        {
            Random rnd  = new Random();
            int    p_id = rnd.Next(1, 100000);

            try
            {
                string MyConnection2 = "datasource=localhost;port=3306;username=root;password=9490";


                //string Query = "insert into world.delivery values ('" + this.textBox1.Text + "','" + this.textBox2.Text + "','" + p_id + "','" + u_name +"');";
                string Query  = "insert into world.delivery values ('" + this.textBox1.Text + "','" + this.textBox2.Text + "','" + p_id + "','" + u_name + "');";
                string Query2 = "insert into world.transport values ('" + p_id + "','" + u_name + "','" + this.textBox1.Text + "');";


                MySqlConnection MyConn2    = new MySqlConnection(MyConnection2);
                MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.
                MessageBox.Show("Pay at the reception and collect paid_id");
                while (MyReader2.Read())
                {
                }
                MyConn2.Close();

                MySqlConnection MyConn3    = new MySqlConnection(MyConnection2);
                MySqlCommand    MyCommand3 = new MySqlCommand(Query2, MyConn3);
                MySqlDataReader MyReader3;
                MyConn3.Open();
                MyReader3 = MyCommand3.ExecuteReader();     // Here our query will be executed and data saved into the database.
                while (MyReader3.Read())
                {
                }
                MyConn3.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "---> RANDOM NUMBER REPREAT   ");
            }

            //now depending on the values of pickup and drop we pur check constrain in the transport table.
        }
Example #13
0
 private void btnAddress_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         con.Open();
         string          sql3       = "update staff set address='" + staffAddress.Text + "' where staff_id='" + textBox1.Text + "';";
         MySqlCommand    MyCommand3 = new MySqlCommand(sql3, con);
         MySqlDataReader MyReader3;
         MyReader3 = MyCommand3.ExecuteReader();
         MyReader3.Close();
         MessageBox.Show("Address Updated Succesfully");
         staffAddress.Text = "";
         con.Close();
     }
     catch (Exception eee)
     {
         MessageBox.Show(eee.Message.ToString());
     }
 }
Example #14
0
        private void EducandoCombo()
        {
            string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            MySqlConnection connection = new MySqlConnection(Conexao);


            connection.Open();
            string          ID_EE      = textBoxID_EE.Text;
            string          query3     = "select * from aluno where ID_EE = '" + ID_EE + "';";
            MySqlCommand    MyCommand3 = new MySqlCommand(query3, connection);
            MySqlDataReader MyReader3;

            MyReader3 = MyCommand3.ExecuteReader();
            while (MyReader3.Read())
            {
                comboBoxEducando.Items.Add(MyReader3["Nome"].ToString());
            }
            connection.Close();
        }
Example #15
0
        private void comboBoxTurma3_SelectedIndexChanged(object sender, EventArgs e)
        {
            string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            MySqlConnection connection = new MySqlConnection(Conexao);

            if (comboBoxTurma3.SelectedItem == null)
            {
            }
            else
            {
                connection.Open();
                string          Turma      = comboBoxTurma3.SelectedItem.ToString();
                string          query3     = "select * from Turma where Turma = '" + Turma + "' ;";
                MySqlCommand    MyCommand3 = new MySqlCommand(query3, connection);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                while (MyReader3.Read())
                {
                    textBoxID_Turma3.Text = MyReader3["ID_Turma"].ToString();
                }
                connection.Close();
                dataGridViewEventosTurma.DataSource = LoadEventosTurma();
                this.dataGridViewEventosTurma.Columns["ID_Evento"].Visible = false;

                listBoxAluno.Items.Clear();
                connection.Close();
                connection.Open();

                string          query     = "select Nome from Aluno where ID_Turma = '" + textBoxID_Turma3.Text + "'";
                MySqlCommand    MyCommand = new MySqlCommand(query, connection);
                MySqlDataReader MyReader;
                MyReader = MyCommand.ExecuteReader();
                while (MyReader.Read())
                {
                    listBoxAluno.Items.Add(MyReader.GetString("Nome"));
                }
                connection.Close();

                listBoxAdicionar.Items.Clear();
                listBoxID_AlunoEspecifico.Items.Clear();
            }
        }
Example #16
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            MySqlConnection connection = new MySqlConnection(Conexao);

            connection.Open();
            string Turma = comboBox1.SelectedItem.ToString();

            string          query3     = "select * from Turma where Turma = '" + Turma + "';";
            MySqlCommand    MyCommand3 = new MySqlCommand(query3, connection);
            MySqlDataReader MyReader3;

            MyReader3 = MyCommand3.ExecuteReader();
            while (MyReader3.Read())
            {
                textBoxID_Turma.Text = MyReader3["ID_Turma"].ToString();
            }
            connection.Close();

            dataGridViewTurma.DataSource = LoadTurma();
        }
 private void radiobtnVIP_Checked(object sender, RoutedEventArgs e)
 {
     comboboxChooseBed.Items.Clear();
     comboboxChooseWard.Items.Clear();
     try
     {
         string          Query      = "select distinct ward_name from ward_bed where bed_type='" + "VIP" + "';";
         MySqlCommand    MyCommand3 = new MySqlCommand(Query, conn);
         MySqlDataReader MyReader3;
         MyReader3 = MyCommand3.ExecuteReader();
         while (MyReader3.Read())
         {
             name = MyReader3.GetString(0);
             comboboxChooseWard.Items.Add(name);
         }
         MyReader3.Close();
     }
     catch
     {
     }
     this.comboboxChooseWard.IsEnabled = true;
 }
Example #18
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string          connetionString = null;
            MySqlConnection cnn;

            connetionString = "Server=localhost;Database=Scholendar;Uid=root";
            cnn             = new MySqlConnection(connetionString);
            string turma = comboBox2.SelectedItem.ToString();
            string Query = "select * from Turma where Turma ='" + turma + "'"; // QUERY VERIFICAÇÃO TURMA COMBOBOX

            if (comboBox2.SelectedItem != null)
            {
                try
                {
                    dataGridViewProfDentro.DataSource = LoadDGV();
                    dataGridViewProfFora.DataSource   = LoadDGV2();

                    cnn.Open();
                    MySqlCommand    MyCommand3 = new MySqlCommand(Query, cnn);
                    MySqlDataReader MyReader3;
                    MyReader3 = MyCommand3.ExecuteReader();
                    while (MyReader3.Read())
                    {
                        textBox1.Text = MyReader3["ID_Turma"].ToString(); //String com o valor ID_Turma
                    }
                    dataGridViewProfDentro.DataSource = LoadDGV();
                    cnn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    cnn.Close();
                }
            }
        }
Example #19
0
        private void LoadListBox()
        {
            listBoxID_Turma.Items.Clear();
            string          Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            MySqlConnection connection = new MySqlConnection(Conexao);


            connection.Open();
            string          ID_EE        = textBoxID_EE.Text;
            string          queryIDTurma = "select * from Aluno where ID_EE = '" + ID_EE + "';";
            MySqlCommand    MyCommand2   = new MySqlCommand(queryIDTurma, connection);
            MySqlDataReader MyReader2;

            MyReader2 = MyCommand2.ExecuteReader();
            while (MyReader2.Read())
            {
                listBoxID_Turma.Items.Add(MyReader2["ID_Turma"].ToString());
            }
            connection.Close();


            foreach (var listBoxItem in listBoxID_Turma.Items)
            {
                connection.Open();
                string i = listBoxItem.ToString();

                string          query3     = "select * from Turma where ID_Turma = '" + i + "' order by AnoEscolar;";
                MySqlCommand    MyCommand3 = new MySqlCommand(query3, connection);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                while (MyReader3.Read())
                {
                    comboBox1.Items.Add(MyReader3["Turma"].ToString());
                }
                connection.Close();
            }
        }
Example #20
0
        private void LoadListBox()
        {
            listBoxID_Disciplina.Items.Clear();
            string           Conexao    = "SERVER=localhost;" + "DATABASE=Scholendar;" + "UID=root;";
            MySqlConnection  connection = new MySqlConnection(Conexao);
            MySqlDataAdapter adapter    = new MySqlDataAdapter();


            connection.Open();
            string          ID_Prof      = textBoxID_Prof.Text;
            string          queryIDTurma = "select distinct * from Prof_Disc where ID_professor = '" + ID_Prof + "';";
            MySqlCommand    MyCommand2   = new MySqlCommand(queryIDTurma, connection);
            MySqlDataReader MyReader2;

            MyReader2 = MyCommand2.ExecuteReader();
            while (MyReader2.Read())
            {
                listBoxID_Disciplina.Items.Add(MyReader2["ID_Disciplina"].ToString());
            }
            connection.Close();

            foreach (var listBoxItem in listBoxID_Disciplina.Items)
            {
                connection.Open();
                string i = listBoxItem.ToString();

                string          query3     = "select * from Disciplina where ID_Disciplina = '" + i + "' ;";
                MySqlCommand    MyCommand3 = new MySqlCommand(query3, connection);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                while (MyReader3.Read())
                {
                    listBoxDisciplina.Items.Add(MyReader3["Disciplina"].ToString());
                }
                connection.Close();
            }
        }
Example #21
0
        private void refresh_Click(object sender, EventArgs e)
        {
            try
            {
                string          MyConnection = "datasource=localhost;port=3306;username=root;password=root";
                string          Query        = "delete from test.skillee ;";
                MySqlConnection MyConn2      = new MySqlConnection(MyConnection);
                MySqlCommand    MyCommand2   = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();
                //MessageBox.Show("Data Deleted");
                while (MyReader2.Read())
                {
                }
                MyConn2.Close();


                string          MyConnection3 = "datasource=localhost;port=3306;username=root;password=root";
                string          Query3        = "delete from test.qualificationee ;";
                MySqlConnection MyConn3       = new MySqlConnection(MyConnection3);
                MySqlCommand    MyCommand3    = new MySqlCommand(Query3, MyConn3);
                MySqlDataReader MyReader3;
                MyConn3.Open();
                MyReader3 = MyCommand3.ExecuteReader();
                MessageBox.Show("Data Deleted");
                while (MyReader3.Read())
                {
                }
                MyConn3.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnReleasePatient_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string          Query     = "insert into release_patient values('" + txtPatientName.Text + "','" + txtPatientAge.Text + "','" + txtContactNo.Text + "','" + txtPatientAddress.Text + "','" + txtDisease.Text + "','" + txtDocName.Text + "','" + txtDateOfAdmit.Text + "','" + txtDateOfRelease.Text + "','" + txtDays.Text + "','" + txtMedicineCost.Text + "','" + txtTestCost.Text + "', '" + txtBedCost.Text + "', '" + txtTotalCost.Text + "');";
                MySqlCommand    MyCommand = new MySqlCommand(Query, conn);
                MySqlDataReader MyReader;
                MyReader = MyCommand.ExecuteReader();
                MyReader.Close();
                MessageBox.Show("Patient Released!");

                string          Query1     = "update admitted_patient set checked_status='" + "Released" + "' where patient_contact_no='" + txtContactNo.Text + "';";
                MySqlCommand    MyCommand1 = new MySqlCommand(Query1, conn);
                MySqlDataReader MyReader1;
                MyReader1 = MyCommand1.ExecuteReader();
                MyReader1.Close();


                //These 3 block codes are responsible for free-ing the bed.
                string          Query2     = "update bed set pat_contact_no='" + "" + "', bed_status='" + "Free" + "' where pat_contact_no='" + txtContactNo.Text + "';";
                MySqlCommand    MyCommand2 = new MySqlCommand(Query2, conn);
                MySqlDataReader MyReader2;
                MyReader2 = MyCommand2.ExecuteReader();
                MyReader2.Close();

                //SELECT ward.ward_name,bed.pat_contact_no, bed.bed_no,bed.bed_type ,bed.bed_cost, bed.bed_status FROM ward,bed WHERE ward.ward_id = bed.ward_id

                string          Query3     = "DROP TABLE ward_bed;";
                MySqlCommand    MyCommand3 = new MySqlCommand(Query3, conn);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                MyReader3.Close();

                string          Query4     = "CREATE TABLE ward_bed AS SELECT ward.ward_name,bed.pat_contact_no, bed.bed_no,bed.bed_type ,bed.bed_cost, bed.bed_status FROM ward,bed WHERE ward.ward_id = bed.ward_id;";
                MySqlCommand    MyCommand4 = new MySqlCommand(Query4, conn);
                MySqlDataReader MyReader4;
                MyReader4 = MyCommand4.ExecuteReader();
                MyReader4.Close();


                string          Query5     = "DROP TABLE user.allocate_patient_bed;";
                MySqlCommand    MyCommand5 = new MySqlCommand(Query5, conn);
                MySqlDataReader MyReader5;
                MyReader5 = MyCommand5.ExecuteReader();
                MyReader5.Close();

                string          Query6     = "CREATE TABLE allocate_patient_bed AS SELECT admitted_patient.patient_name,admitted_patient.patient_age,admitted_patient.patient_contact_no,ward_bed.ward_name,ward_bed.bed_no,ward_bed.bed_type,ward_bed.bed_cost,ward_bed.bed_status FROM admitted_patient,ward_bed WHERE admitted_patient.patient_contact_no=ward_bed.pat_contact_no AND admitted_patient.ward_name=ward_bed.ward_name;";
                MySqlCommand    MyCommand6 = new MySqlCommand(Query6, conn);
                MySqlDataReader MyReader6;
                MyReader6 = MyCommand6.ExecuteReader();
                MyReader6.Close();

                txtContactNo.Text           = ""; txtPatientAge.Text = ""; txtPatientAddress.Text = ""; txtDateOfRelease.Text = "";
                txtPatientName.Text         = ""; txtDisease.Text = ""; txtDocName.Text = ""; txtDateOfAdmit.Text = "";
                txtMedicineCost.Text        = ""; txtBedCost.Text = ""; txtTestCost.Text = ""; txtTotalCost.Text = ""; txtDays.Text = "";
                btnReleasePatient.IsEnabled = false;

                /*string Query5 = "select quantity,days from user.admitted_medicine where product_name='" + comboboxMedicineName.SelectedItem + "';";
                 * MySqlCommand MyCommand5 = new MySqlCommand(Query5, conn);
                 * MySqlDataReader MyReader5;
                 * MyReader5 = MyCommand5.ExecuteReader();
                 * while (MyReader5.Read())
                 * {
                 *  string medquantyty = MyReader5.GetString(0);
                 *  x = Int32.Parse(medquantyty);
                 *  string c = this.quantity.Text;
                 *  y = Int32.Parse(c);
                 *
                 *  x = x - y;
                 * }
                 * MyReader5.Close();
                 *
                 * string Query6 = "update user.supplier set quantity='" + x.ToString() + "' where product_name='" + comboboxMedicineName.SelectedItem + "' ;";
                 * MySqlCommand MyCommand6 = new MySqlCommand(Query6, conn);
                 * MySqlDataReader MyReader6;
                 * MyReader6 = MyCommand6.ExecuteReader();
                 * MyReader6.Close();*/
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        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++;
        }
Example #24
0
        private void save_Click(object sender, EventArgs e)
        {
            Double t      = Convert.ToDouble(this.tel.Text);
            Double t2     = Convert.ToDouble(254000000000 + t);
            String newtel = "+" + t2.ToString();

            if (checkBox1.Checked == true)
            {
                //ADD NEW CUSTOMER
                string MyConnection2 = "datasource=localhost;port=3306;username=root";
                //This is my insert query in which i am taking input from the user through windows forms
                string Query = "insert into drawgift.customer(name,passport,address,idno,tel) values('" + this.name.Text + "','" + this.pass.Text + "','" + this.area.Text + "','" + this.idno.Text + "','" + newtel + "');";

                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
                //This is command class which will handle the query and connection object.
                MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.

                while (MyReader2.Read())
                {
                }
                MyReader2.Close();

                MyConn2.Close();
            }

            if (pass.Text != "N/A")
            {
                //UPDATE CUSTOMER DETAILS
                string MyConnection7 = "datasource=localhost;port=3306;username=root";
                //This is my insert query in which i am taking input from the user through windows forms
                string Query = "UPDATE drawgift.customer set passport='" + pass.Text + "'WHERE idno='" + idno.Text + "'|| tel='" + tel.Text + "' ";

                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn7 = new MySqlConnection(MyConnection7);
                //This is command class which will handle the query and connection object.
                MySqlCommand    MyCommand7 = new MySqlCommand(Query, MyConn7);
                MySqlDataReader MyReader7;
                MyConn7.Open();
                MyReader7 = MyCommand7.ExecuteReader();     // Here our query will be executed and data saved into the database.

                while (MyReader7.Read())
                {
                }
                MyReader7.Close();

                MyConn7.Close();
            }

            //GENERATE TOKEN
            string MyConnection4 = "datasource=localhost;port=3306;username=root";
            //This is my insert query in which i am taking input from the user through windows forms
            //This is  MySqlConnection here i have created the object and pass my connection string.
            MySqlConnection MyConn4 = new MySqlConnection(MyConnection4);

            //This is command class which will handle the query and connection object.
            MyConn4.Open();

            //get  account no
            string          q2   = "select COUNT(id) as idc from drawgift.entries ;";
            MySqlCommand    com4 = new MySqlCommand(q2, MyConn4);
            MySqlDataReader r2;

            r2 = com4.ExecuteReader();
            r2.Read();
            int    ab  = Convert.ToInt32(r2["idc"]) + 1;
            String raf = ("GALLERIA-" + ab).ToString();

            r2.Close();



            //ITERATE TRHOUGH ARRAY
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                object a        = dataGridView1.Rows[i].Cells["Total"].Value;
                int    aNumber  = 0;
                int    setlimit = 1000;
                if (a != null)
                {
                    aNumber = Convert.ToInt32(a.ToString());
                }
                int vouch = (aNumber / setlimit);
                dataGridView1.Rows[i].Cells["vouchers"].Value = vouch;


                //ASSIGN VALUABLES
                object va = dataGridView1.Rows[i].Cells["vouchers"].Value;
                String v  = va.ToString();
                object sh = dataGridView1.Rows[i].Cells["Shop"].Value;
                // String s = sh.ToString();
                //String tot = a.ToString();



                //SEARCH FOR SHOPNAME
                string shopconnection = "datasource=localhost;port=3306;username=root";
                //This is my insert query in which i am taking input from the user through windows forms
                string shopquery = "SELECT cname FROM drawgift.shop WHERE name='" + sh + "'";

                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection shopconn = new MySqlConnection(shopconnection);
                //This is command class which will handle the query and connection object.
                MySqlCommand    shopcommand = new MySqlCommand(shopquery, shopconn);
                MySqlDataReader shopreader;
                shopconn.Open();
                shopreader = shopcommand.ExecuteReader();     // Here our query will be executed and data saved into the database.
                shopreader.Read();
                String shopname = shopreader["cname"].ToString();
                shopreader.Close();

                shopconn.Close();

                //RUN INSERT SCRIPT
                try
                {
                    //ADD NEW RAFFLE ENTRY
                    string MyConnection3 = "datasource=localhost;port=3306;username=root";
                    //This is my insert query in which i am taking input from the user through windows forms
                    string Query = "insert into drawgift.entries(customername,passport,tel,address,raffleno,idno,shop,amount,points,dateadded)values('" + this.name.Text + "','" + this.pass.Text + "','" + newtel + "','" + this.area.Text + "','" + raf + "','" + this.idno.Text + "','" + shopname + "','" + a + "','" + vouch + "','" + this.datea.Text + "');";
                    //This is  MySqlConnection here i have created the object and pass my connection string.
                    MySqlConnection MyConn3 = new MySqlConnection(MyConnection3);
                    //This is command class which will handle the query and connection object.
                    MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn3);
                    MySqlDataReader MyReader3;
                    MyConn3.Open();
                    MyReader3 = MyCommand2.ExecuteReader();         // Here our query will be executed and data saved into the database.

                    while (MyReader3.Read())
                    {
                        // Find your Account Sid and Auth Token at twilio.com/user/account

                        /*  string AccountSid = "AC76b83713f0c7385af9352e3dfb902288";
                         * string AuthToken = "6e48fb10b5b82dd13f2eb663d6a3c210";
                         * var twilio = new TwilioRestClient(AccountSid, AuthToken);
                         *
                         * twilio.SendMessage("+17083283330","+254728944815","This is the ship that made the Kessel Run in fourteen parsecs?"
                         * );*/


                        // Specify your login credentials
                        string username = "******";
                        string apiKey   = "93f87c6f181904289e830c9fabda74e70cfcaef5d804e9811d9f097dee44989e";

                        // Specify the numbers that you want to send to in a comma-separated list
                        // Please ensure you include the country code (+254 for Kenya in this case)
                        string recipients = this.tel.Text;
                        // And of course we want our recipients to know what we really do
                        string message = "I'm a lumberjack and its ok, I sleep all night and I work all day";

                        // Create a new instance of our awesome gateway class
                        AfricasTalkingGateway gateway = new AfricasTalkingGateway(username, apiKey);
                        // Any gateway errors will be captured by our custom Exception class below,
                        // so wrap the call in a try-catch block
                        try
                        {
                            // Thats it, hit send and we'll take care of the rest
                            gateway.sendMessage(recipients, message);
                            dynamic results = gateway.sendMessage(recipients, message);

                            foreach (dynamic result in results)
                            {
                                Console.Write((string)result["number"] + ",");
                                Console.Write((string)result["status"] + ",");     // status is either "Success" or "error message"
                                Console.Write((string)result["messageId"] + ",");
                                Console.WriteLine((string)result["cost"]);
                            }
                        }
                        catch (AfricasTalkingGatewayException e1)
                        {
                            Console.WriteLine("Encountered an error: " + e1.Message);
                        }
                    }
                    MyReader3.Close();

                    MyConn3.Close();
                    //RESET EVERYTHING
                }


                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            MessageBox.Show("ENTRIES SAVED");
            tel.Enabled  = true;
            tel.Text     = "0";
            idno.Enabled = true;
            idno.Text    = "";
            name.Enabled = false;
            name.Text    = "";
            pass.Enabled = false;
            pass.Text    = "";
            area.Enabled = false;
            area.Text    = "";

            checkBox1.Checked = false;
            dataGridView1.Rows.Clear();
        }
Example #25
0
        private void save_Click(object sender, EventArgs e)
        {
            Double t  = Convert.ToDouble(this.tel.Text);
            Double t2 = Convert.ToDouble(254000000000 + t);

            String newtel = "+" + t2.ToString();

            if (checkBox1.Checked == true)
            {
                //ADD NEW CUSTOMER
                string MyConnection2 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017";
                //This is my insert query in which i am taking input from the user through windows forms
                string Query = "insert into techcube_galleria.customer(name,passport,address,idno,tel,gender) values('" + this.name.Text + "','" + this.pass.Text + "','" + this.area.Text + "','" + this.idno.Text + "','" + newtel + "','" + this.gender.Text + "');";

                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
                //This is command class which will handle the query and connection object.
                MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.

                while (MyReader2.Read())
                {
                }
                MyReader2.Close();

                MyConn2.Close();
            }

            if (pass.Text != "N/A")
            {
                //UPDATE CUSTOMER DETAILS
                string MyConnection7 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017";
                //This is my insert query in which i am taking input from the user through windows forms
                string Query = "UPDATE techcube_galleria.customer set passport='" + pass.Text + "'WHERE idno='" + idno.Text + "'|| tel='" + tel.Text + "' ";

                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn7 = new MySqlConnection(MyConnection7);
                //This is command class which will handle the query and connection object.
                MySqlCommand    MyCommand7 = new MySqlCommand(Query, MyConn7);
                MySqlDataReader MyReader7;
                MyConn7.Open();
                MyReader7 = MyCommand7.ExecuteReader();     // Here our query will be executed and data saved into the database.

                while (MyReader7.Read())
                {
                }
                MyReader7.Close();

                MyConn7.Close();
            }


            //GENERATE TOKEN
            string MyConnection4 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=root";
            //This is my insert query in which i am taking input from the user through windows forms
            //This is  MySqlConnection here i have created the object and pass my connection string.
            MySqlConnection MyConn4 = new MySqlConnection(MyConnection4);

            //This is command class which will handle the query and connection object.
            MyConn4.Open();

            //get  account no
            string          q2   = "select COUNT(id) as idc from techcube_galleria.entries where promo='VALENTINES2017' ;";
            MySqlCommand    com4 = new MySqlCommand(q2, MyConn4);
            MySqlDataReader r2;

            r2 = com4.ExecuteReader();
            r2.Read();
            int    ab  = Convert.ToInt32(r2["idc"]) + 1;
            String raf = ("GALLERIA-VALS-" + ab).ToString();

            r2.Close();



            //ITERATE TRHOUGH ARRAY
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                object a        = dataGridView1.Rows[i].Cells["Total"].Value;
                int    aNumber  = 0;
                int    setlimit = 1000;
                if (a != null)
                {
                    aNumber = Convert.ToInt32(a.ToString());
                }
                int vouch = (aNumber / setlimit);
                dataGridView1.Rows[i].Cells["vouchers"].Value = vouch;

                //ASSIGN VALUABLES
                object va = dataGridView1.Rows[i].Cells["vouchers"].Value;
                String v  = va.ToString();
                object sh = dataGridView1.Rows[i].Cells["Shop"].Value;
                // String s = sh.ToString();
                //String tot = a.ToString();

                //SEARCH FOR SHOPNAME
                string shopconnection = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017";
                //This is my insert query in which i am taking input from the user through windows forms
                string shopquery = "SELECT cname FROM techcube_galleria.shop WHERE name='" + sh + "'";

                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection shopconn = new MySqlConnection(shopconnection);
                //This is command class which will handle the query and connection object.
                MySqlCommand    shopcommand = new MySqlCommand(shopquery, shopconn);
                MySqlDataReader shopreader;
                shopconn.Open();
                shopreader = shopcommand.ExecuteReader();     // Here our query will be executed and data saved into the database.
                shopreader.Read();
                String shopname = shopreader["cname"].ToString();
                shopreader.Close();

                shopconn.Close();
                //VALIDATE TEL NO

                if (checkBox1.Checked == false)
                {
                    string phone = this.tel.Text;
                    //RUN INSERT SCRIPT
                    try
                    {
                        //ADD NEW RAFFLE ENTRY
                        string MyConnection3 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017";
                        //This is my insert query in which i am taking input from the user through windows forms
                        string Query = "insert into techcube_galleria.entries(customername,passport,tel,address,raffleno,idno,shop,amount,points,dateadded,promo)values('" + this.name.Text + "','" + this.pass.Text + "','" + phone + "','" + this.area.Text + "','" + raf + "','" + this.idno.Text + "','" + shopname + "','" + a + "','" + vouch + "','" + this.datea.Text + "','" + "VALENTINES2017');";
                        //This is  MySqlConnection here i have created the object and pass my connection string.
                        MySqlConnection MyConn3 = new MySqlConnection(MyConnection3);
                        //This is command class which will handle the query and connection object.
                        MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn3);
                        MySqlDataReader MyReader3;
                        MyConn3.Open();
                        MyReader3 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.

                        while (MyReader3.Read())
                        {
                        }
                        MyReader3.Close();

                        MyConn3.Close();
                        //RESET EVERYTHING
                    }


                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    //END INSERT
                }
                else if (checkBox1.Checked == true)
                {
                    //RUN INSERT SCRIPT
                    try
                    {
                        //ADD NEW RAFFLE ENTRY
                        string MyConnection3 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017";
                        //This is my insert query in which i am taking input from the user through windows forms
                        string Query = "insert into techcube_galleria.entries(customername,passport,tel,address,raffleno,idno,shop,amount,points,dateadded)values('" + this.name.Text + "','" + this.pass.Text + "','" + newtel + "','" + this.area.Text + "','" + raf + "','" + this.idno.Text + "','" + shopname + "','" + a + "','" + vouch + "','" + this.datea.Text + "');";
                        //This is  MySqlConnection here i have created the object and pass my connection string.
                        MySqlConnection MyConn3 = new MySqlConnection(MyConnection3);
                        //This is command class which will handle the query and connection object.
                        MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn3);
                        MySqlDataReader MyReader3;
                        MyConn3.Open();
                        MyReader3 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.

                        while (MyReader3.Read())
                        {
                        }
                        MyReader3.Close();

                        MyConn3.Close();
                        //RESET EVERYTHING
                    }


                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    //END INSERT
                }
            }

            MessageBox.Show("ENTRIES SAVED");
            tel.Enabled  = true;
            tel.Text     = "0";
            idno.Enabled = true;
            idno.Text    = "";
            name.Enabled = false;
            name.Text    = "";
            pass.Enabled = false;
            pass.Text    = "";
            area.Enabled = false;
            area.Text    = "";

            checkBox1.Checked = false;
            dataGridView1.Rows.Clear();
        }
Example #26
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string MyConnection2 = "datasource=localhost;port=3306;username=root;password=9490";
                //get curr location before updating and check it from the set....

                string           Query1     = "select current_location from world.transport where paid_id= " + this.textBox1.Text + ";";
                MySqlConnection  MyConn2    = new MySqlConnection(MyConnection2);
                MySqlCommand     MyCommand2 = new MySqlCommand(Query1, MyConn2);
                MySqlDataAdapter adapt      = new MySqlDataAdapter(MyCommand2);
                DataTable        ds         = new DataTable();
                adapt.Fill(ds);
                string   prev_loc = ds.Rows[0][0].ToString();
                string   next_loc = this.textBox2.Text;
                string[] South    = { "Chennai", "Manipal", "Mangalore", "Udupi", "Goa", "Hyderabad" };
                string[] North    = { "Mumbai", "Delhi", "Ahemdabad", "Agra", "Goa" };
                MessageBox.Show("Previous Location: " + prev_loc + "  Current Location: " + next_loc);

                //Final location check
                string           Query3     = "select drop_location from world.delivery where paid_id= " + this.textBox1.Text + ";";
                MySqlConnection  MyConn3    = new MySqlConnection(MyConnection2);
                MySqlCommand     MyCommand3 = new MySqlCommand(Query3, MyConn3);
                MySqlDataAdapter adapt1     = new MySqlDataAdapter(MyCommand3);
                DataTable        dt         = new DataTable();
                adapt1.Fill(dt);
                string final_loc = ds.Rows[0][0].ToString();

                if (final_loc == next_loc)
                {
                    this.Hide();
                    Form1 f1 = new Form1();
                    MessageBox.Show("The Location has been reached.");
                }

                if (South.Contains(prev_loc) && South.Contains(next_loc))
                {
                    try
                    {
                        string          Query      = "Update world.transport set current_location = '" + this.textBox2.Text + "' where paid_id = " + this.textBox1.Text;
                        MySqlConnection MyConn7    = new MySqlConnection(MyConnection2);
                        MySqlCommand    MyCommand7 = new MySqlCommand(Query, MyConn7);
                        MySqlDataReader MyReader3;
                        MyConn7.Open();
                        MyReader3 = MyCommand7.ExecuteReader();     // Here our query will be executed and data saved into the database.
                        MessageBox.Show("Note: Updated the current location");
                        while (MyReader3.Read())
                        {
                        }
                        MyConn3.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                //Previous UPDATE ROUTE

                /* try
                 * {
                 * MessageBox.Show("FIRST ELSE");
                 *       string Query = "select * from world.path_finder where paid_id ="+this.textBox1.Text;
                 *       MySqlConnection MyConn6 = new MySqlConnection(MyConnection2);
                 *       MySqlCommand MyCommand6 = new MySqlCommand(Query, MyConn6);
                 *       MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
                 *       MyAdapter.SelectCommand = MyCommand6;
                 *       DataTable dTable = new DataTable();
                 *       MyAdapter.Fill(dTable);
                 *       dataGridView1.DataSource = dTable;
                 *       //MyConn2.Close();
                 *
                 *   }
                 *   catch (Exception ex)
                 *   {
                 *       MessageBox.Show(ex.Message);
                 *   }
                 *   //BACKTRACKING SHOW ROUTE IN GRID.*/

                if (North.Contains(prev_loc) && North.Contains(next_loc))
                {
                    try
                    {
                        string          Query      = "Update world.transport set current_location= '" + this.textBox2.Text + "' where paid_id=" + this.textBox1.Text;
                        MySqlConnection MyConn4    = new MySqlConnection(MyConnection2);
                        MySqlCommand    MyCommand4 = new MySqlCommand(Query, MyConn4);
                        MySqlDataReader MyReader4;
                        MyConn4.Open();
                        MyReader4 = MyCommand4.ExecuteReader();     // Here our query will be executed and data saved into the database.
                        MessageBox.Show("Note: Updated the current location");
                        while (MyReader4.Read())
                        {
                        }
                        MyConn4.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                try
                {
                    string Query2 = "select * from world.path_finder where paid_id =" + this.textBox1.Text;

                    MySqlConnection  MyConn5    = new MySqlConnection(MyConnection2);
                    MySqlCommand     MyCommand5 = new MySqlCommand(Query2, MyConn5);
                    MySqlDataAdapter MyAdapter1 = new MySqlDataAdapter();
                    MyAdapter1.SelectCommand = MyCommand5;
                    DataTable dTable1 = new DataTable();
                    MyAdapter1.Fill(dTable1);
                    dataGridView2.DataSource = dTable1;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }
Example #27
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            MySqlConnection connection = new MySqlConnection("datasource = mysql5044.site4now.net; username=a6f6c3_ibernal; password=sIyNbvYEf8H0; database=db_a6f6c3_ibernal;"
                                                             );
            MySqlCommand    command; //Establecemos variables de tipo comando
            MySqlDataReader mdr;     //Establecemos variables de tipo DataReader

            connection.Open();       //Abrimos la coneccion con la BD
            string selectQuery = "SELECT * FROM usuarios WHERE Nombre = '" + txtUsuario.Text + "' AND Contrasena = '" + txtContra.Text + "';";

            //Establecemos una secuencia SQL
            command = new MySqlCommand(selectQuery, connection);
            //La mandamos en conjunto de la conexion a la BD
            mdr = command.ExecuteReader(); //Vemos si la secuencia arrpjp datos de regreso
            if (mdr.Read())                //si lo encontro datos
            {
                string MyConnection2 = "datasource = mysql5044.site4now.net; username=a6f6c3_ibernal; password=sIyNbvYEf8H0; database=db_a6f6c3_ibernal;"
                ;
                string          Query   = "update usuarios set LastLogin='******' where Nombre='" + this.txtUsuario.Text + "';";
                MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
                //Establecemos una nueva coneccion pero esta vez vamos a grabar la ultima fecha de coneccion del usuario
                MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();
                MyConn2.Close();

                MessageBox.Show("Bienvenido!", "Acceso comprobado", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Una vez comprobado el acceso procedemos a ver que tipo de usuario es
                string          idtenti       = @"SELECT Tipo FROM usuarios WHERE Nombre='" + this.txtUsuario.Text + "';";//realizamos la consulta
                MySqlCommand    Identificador = new MySqlCommand(idtenti, MyConn2);
                MySqlDataReader MyReader3;
                MyConn2.Open();
                MyReader3 = Identificador.ExecuteReader();

                string tipo;
                if (MyReader3.Read())                    //si MyrRader3 lee datos entonces
                {
                    tipo = MyReader3["Tipo"].ToString(); //asignamos en la variable string el tipo de usuario
                    //MessageBox.Show(tipo);
                    tipoCompartido = tipo;

                    Form jefe = new ImpresosBernal.DashBoard_Jefe();
                    txtContra.Text  = " ";
                    txtUsuario.Text = "";

                    if (tipo == "Jefe")
                    {
                        jefe.Show();
                    }
                    this.Visible = false;
                }

                MyConn2.Close();
            }
            else
            {
                if (!(string.IsNullOrEmpty(txtUsuario.Text) || string.IsNullOrEmpty(txtContra.Text)))//Nos aseguramos que no esten vacias los textbox
                {
                    MessageBox.Show("Credenciales incorrectas, por favor intente nuevamente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            connection.Close();
        }
Example #28
0
        private void btnAddmore_Click(object sender, EventArgs e)
        {
            int   p_code = int.Parse(txtCode.Text);
            int   p_qty  = int.Parse(txtQty.Text);
            float p_unitPrice;
            int   p_stock_id, p_stock_qty;

            //find stock record by barcode
            try
            {
                //This is my connection string i have assigned the database file address path
                string MyConnection2 = "datasource=127.0.0.1;port=3306;username=root;password=;database=supermarket";
                //This is my insert query in which i am taking input from the user through windows forms
                string Query = "Select * from stock where barcode= '" + p_code + "'";
                //This is  MySqlConnection here i have created the object and pass my connection string.
                MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
                //This is command class which will handle the query and connection object.
                MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn2);
                MySqlDataReader MyReader2;
                MyConn2.Open();
                MyReader2 = MyCommand2.ExecuteReader();     // Here our query will be executed and data saved into the database.
                while (MyReader2.Read())
                {
                    p_unitPrice = float.Parse(MyReader2.GetString(3));
                    p_stock_id  = int.Parse(MyReader2.GetString(0));
                    p_stock_qty = int.Parse(MyReader2.GetString(5));
                    int   new_stock_qty = p_stock_qty - p_qty;
                    float amount        = p_qty * p_unitPrice;

                    //remove qty from stock
                    try
                    {
                        //This is my connection string i have assigned the database file address path
                        string MyConnection4 = "datasource=127.0.0.1;port=3306;username=root;password=;database=supermarket";
                        //This is my update query in which i am taking input from the user through windows forms and update the record.
                        string Query4 = "update stock set total_qty='" + new_stock_qty + "' where barcode='" + p_code + "';";
                        //This is  MySqlConnection here i have created the object and pass my connection string.
                        MySqlConnection MyConn4    = new MySqlConnection(MyConnection4);
                        MySqlCommand    MyCommand4 = new MySqlCommand(Query4, MyConn4);
                        MySqlDataReader MyReader4;
                        MyConn4.Open();
                        MyReader4 = MyCommand4.ExecuteReader();
                        while (MyReader4.Read())
                        {
                        }
                        MyConn4.Close();//Connection closed here
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }



                    //insert sale record

                    try
                    {
                        //This is my connection string i have assigned the database file address path
                        string MyConnection3 = "datasource=127.0.0.1;port=3306;username=root;password=;database=supermarket";
                        //This is my insert query in which i am taking input from the user through windows forms
                        string Query3 = "insert into `sale` (stock_id,qty,amount) values('" + p_stock_id + "','" + p_qty + "','" + amount + "');";
                        //This is  MySqlConnection here i have created the object and pass my connection string.
                        MySqlConnection MyConn3 = new MySqlConnection(MyConnection3);
                        //This is command class which will handle the query and connection object.
                        MySqlCommand    MyCommand3 = new MySqlCommand(Query3, MyConn3);
                        MySqlDataReader MyReader3;
                        MyConn3.Open();
                        MyReader3 = MyCommand3.ExecuteReader();     // Here our query will be executed and data saved into the database.

                        while (MyReader3.Read())
                        {
                        }

                        MyConn3.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                MyConn2.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            updateData();
        }
        private void new_btn_Click(object sender, EventArgs e)
        {
            //create a random number TO CHANGE TO ENUMERATE
            Random rnd       = new Random();
            int    projectid = rnd.Next(1, 100000);

            if (int.TryParse(nwyr_txtbx.Text, out year))

            {
                year = int.Parse(nwyr_txtbx.Text);
            }
            else
            {
                MessageBox.Show("Please input a correct project year");
            }

            //In case the project ID already exist
            MySqlConnection connection = new MySqlConnection(connec);

            connection.Open();
            string          query0 = "SELECT project_id FROM internal_communication_4.projects WHERE ( project_id = " + projectid + ")";
            MySqlCommand    idused = new MySqlCommand(query0, connection);
            MySqlDataReader MyReader3;

            MyReader3 = idused.ExecuteReader();
            while (MyReader3.Read())
            {
                if (MyReader3.GetString(0) != null)
                {
                    Random rrnd = new Random();
                    projectid = rrnd.Next(1, 100000);
                }
            }



            connection.Close();

            //text file saved
            Projects_class pro = new Projects_class();

            pro.ID           = projectid;
            pro.Project_name = nwnm_txtbx.Text;
            pro.Year         = year;
            pro.Category     = nwcat_txtbx.Text;


            proj.Add(pro);
            projectDA.Save(proj);

            //databased saved
            connection.Open();
            string          query   = "INSERT INTO internal_communication_4.projects(project_id,project_name,project_year,project_category) VALUES('" + projectid + "','" + this.nwnm_txtbx.Text + "','" + this.year + "','" + this.nwcat_txtbx.Text + "')";
            MySqlCommand    command = new MySqlCommand(query, connection);
            MySqlDataReader MyReader2;

            MyReader2 = command.ExecuteReader();
            while (MyReader2.Read())
            {
            }
            connection.Close();
            MessageBox.Show("project " + pro.Project_name + "  successfully created!");
            nwnm_txtbx.Text  = "";
            nwyr_txtbx.Text  = "";
            nwcat_txtbx.Text = "";

            this.Close();
            project_selection_form pr = new project_selection_form();

            pr.ShowDialog();
        }
Example #30
0
        private void button2_Click(object sender, EventArgs e)
        {
            string sql        = null;
            string nome       = textBoxnome.Text;
            string email      = textBoxEmail.Text;
            string telemovel  = textBoxTel.Text;
            string dn         = textBoxDN.Text;
            string utilizador = textBoxUtilizador.Text;
            string hex        = textBoxHex.Text;
            string dec        = textBoxDec.Text;

            string connetionString = null;

            connetionString = "Server=localhost;Database=Scholendar;Uid=root";
            MySqlConnection  cnn;
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            cnn = new MySqlConnection(connetionString);

            if (comboBox1.SelectedItem.ToString() == "EE")
            {
                //ClearTxt();
                if (string.IsNullOrEmpty(textBoxEmail.Text) || string.IsNullOrEmpty(textBoxnome.Text) || string.IsNullOrEmpty(textBoxTel.Text) || string.IsNullOrEmpty(textBoxUtilizador.Text))
                {
                    MessageBox.Show("Preencha todos os campos!");
                }
                else
                {
                    sql = "insert into EE (Nome, Email, Telemovel, Utilizador, Pass) values('" + nome + "', '" + email + "', '" + telemovel + "', '" + utilizador + "' , 'EE123A' )";
                    try
                    {
                        cnn.Open();
                        adapter.InsertCommand = new MySqlCommand(sql, cnn);
                        adapter.InsertCommand.ExecuteNonQuery();
                        MessageBox.Show("Encarregado de Educação Inserido!");
                        ClearTxt();
                        comboBoxEE.Items.Clear();
                        FillcomboboxEE();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        cnn.Close();
                    }
                }
            }
            else if (comboBox1.SelectedItem.ToString() == "Aluno")
            {
                //ClearTxt();
                if (string.IsNullOrEmpty(textBoxEmail.Text) || string.IsNullOrEmpty(textBoxnome.Text) || string.IsNullOrEmpty(textBoxTel.Text) || string.IsNullOrEmpty(textBoxUtilizador.Text) || string.IsNullOrEmpty(textBoxDN.Text) || string.IsNullOrEmpty(textBoxDec.Text) || string.IsNullOrEmpty(textBoxHex.Text) || comboBoxTurma.SelectedItem == null || comboBoxEE.SelectedItem == null)
                {
                    MessageBox.Show("Preencha todos os campos!");
                }
                else
                {
                    try
                    {
                        cnn.Open();
                        string          turma      = comboBoxTurma.SelectedItem.ToString();
                        string          Query3     = "select * from Turma where Turma ='" + turma + "'";
                        MySqlCommand    MyCommand3 = new MySqlCommand(Query3, cnn);
                        MySqlDataReader MyReader3;
                        MyReader3 = MyCommand3.ExecuteReader();
                        while (MyReader3.Read())
                        {
                            textBoxIDTurma.Text = MyReader3["ID_Turma"].ToString();
                        }
                        cnn.Close();

                        cnn.Open();
                        string          aluno      = comboBoxEE.SelectedItem.ToString();
                        string          QueryA     = "select * from EE where Nome ='" + aluno + "'";
                        MySqlCommand    MyCommand4 = new MySqlCommand(QueryA, cnn);
                        MySqlDataReader MyReader4;
                        MyReader4 = MyCommand4.ExecuteReader();
                        while (MyReader4.Read())
                        {
                            textBoxAluno.Text = MyReader4["ID_EE"].ToString();
                        }
                        cnn.Close();

                        cnn.Open();
                        string IDTurma = textBoxIDTurma.Text;
                        string ID_EE   = textBoxAluno.Text;
                        sql = "insert into Aluno (Nome, Email, Telemovel, Utilizador,DataDeNascimento,Hex,De,Pass,ID_Turma, ID_EE) values('" + nome + "', '" + email + "', '" + telemovel + "', '" + utilizador + "', '" + dn + "', '" + hex + "', '" + dec + "' , 'Aluno123A', '" + IDTurma + "' , '" + ID_EE + "' )";
                        adapter.InsertCommand = new MySqlCommand(sql, cnn);
                        adapter.InsertCommand.ExecuteNonQuery();
                        MessageBox.Show("Aluno Inserido!");
                        ClearTxt();
                        comboBoxEE.SelectedItem    = null;
                        comboBoxTurma.SelectedItem = null;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        cnn.Clone();
                    }
                }
            }
            else if (comboBox1.SelectedItem.ToString() == "Professor")
            {
                if (string.IsNullOrEmpty(textBoxEmail.Text) || string.IsNullOrEmpty(textBoxnome.Text) || string.IsNullOrEmpty(textBoxTel.Text) || string.IsNullOrEmpty(textBoxUtilizador.Text) || string.IsNullOrEmpty(textBoxDec.Text) || string.IsNullOrEmpty(textBoxHex.Text) || comboBoxDisc.SelectedItem == null)
                {
                    MessageBox.Show("Preencha todos os campos!");
                }
                else
                {
                    try
                    {
                        cnn.Open();
                        sql = "insert into Professor (Nome, Email, Telemovel, Utilizador, Pass, Hex, De) values('" + nome + "', '" + email + "', '" + telemovel + "', '" + utilizador + "', 'Prof123A' , '" + hex + "', '" + dec + "')";
                        adapter.InsertCommand = new MySqlCommand(sql, cnn);
                        adapter.InsertCommand.ExecuteNonQuery();
                        MessageBox.Show("Professor Inserido!");

                        cnn.Close();

                        cnn.Open();
                        string          professor = textBoxnome.Text;
                        string          query     = "select * from Professor where nome = '" + professor + "' ";
                        MySqlCommand    MyCommand = new MySqlCommand(query, cnn);
                        MySqlDataReader MyReader;
                        MyReader = MyCommand.ExecuteReader();
                        while (MyReader.Read())
                        {
                            textBoxIDProf.Text = MyReader["ID_Professor"].ToString();
                        }
                        cnn.Close();

                        string Disc1     = textBoxIDDisc.Text;
                        string Disc2     = textBoxIDDisc2.Text;
                        string Disc3     = textBoxIDDisc3.Text;
                        string Disc4     = textBoxIDDisc4.Text;
                        string Professor = textBoxIDProf.Text;

                        cnn.Open();
                        string query2 = "insert into Prof_Disc values ('" + Disc1 + "', '" + Professor + "')";
                        adapter.InsertCommand = new MySqlCommand(query2, cnn);
                        adapter.InsertCommand.ExecuteNonQuery();
                        cnn.Close();

                        if (comboBoxDisc2.SelectedItem != null)
                        {
                            cnn.Open();
                            string query3 = "insert into Prof_Disc values('" + Disc2 + "', '" + Professor + "')";
                            adapter.InsertCommand = new MySqlCommand(query3, cnn);
                            adapter.InsertCommand.ExecuteNonQuery();
                            cnn.Close();
                            if (comboBoxDisc3.SelectedItem != null)
                            {
                                cnn.Open();
                                string query4 = "insert into Prof_Disc values('" + Disc3 + "', '" + Professor + "')";
                                adapter.InsertCommand = new MySqlCommand(query4, cnn);
                                adapter.InsertCommand.ExecuteNonQuery();
                                cnn.Close();
                                if (comboBoxDisc4.SelectedItem != null)
                                {
                                    cnn.Open();
                                    string query5 = "insert into Prof_Disc values('" + Disc4 + "', '" + Professor + "')";
                                    adapter.InsertCommand = new MySqlCommand(query5, cnn);
                                    adapter.InsertCommand.ExecuteNonQuery();
                                    cnn.Close();
                                }
                            }
                        }


                        ClearTxt();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        cnn.Close();
                    }
                }
            }
            else if (comboBox1.SelectedItem.ToString() == "Admin")
            {
                if (string.IsNullOrEmpty(textBoxEmail.Text) || string.IsNullOrEmpty(textBoxnome.Text) || string.IsNullOrEmpty(textBoxTel.Text) || string.IsNullOrEmpty(textBoxUtilizador.Text) || string.IsNullOrEmpty(textBoxDec.Text) || string.IsNullOrEmpty(textBoxHex.Text))
                {
                    MessageBox.Show("Preencha todos os campos!");
                }
                else
                {
                    try
                    {
                        cnn.Close();
                        cnn.Open();
                        sql = "insert into Admin (Nome, Email, Telemovel, Utilizador, Pass, Hex, De) values('" + nome + "', '" + email + "', '" + telemovel + "', '" + utilizador + "', 'adm123' , '" + hex + "', '" + dec + "')";
                        adapter.InsertCommand = new MySqlCommand(sql, cnn);
                        adapter.InsertCommand.ExecuteNonQuery();
                        MessageBox.Show("Admin Inserido!");
                        ClearTxt();
                        cnn.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        cnn.Close();
                    }
                }
            }
        }