Exemplo n.º 1
0
        public void test()
        {
            String date = gd.getAnneeMoisPrecedent();

            // Ouverture de la connexion
            SqlCo.Open();


            // Instanciation de l’objet Command
            MySqlCommand SqlCom = new MySqlCommand("Select * from fichefrais where mois= '" + date + "'", SqlCo);

            if (GestionDate.majFicheMoisPrecedent())
            {
                SqlCom = new MySqlCommand("Select * from fichefrais where mois= '" + date + "' and idEtat = 'VA'", SqlCo);
            }
            if (GestionDate.verifIntervalle(1, 10))
            {
                SqlCom = new MySqlCommand("Select * from fichefrais where mois= '" + date + "' and idEtat != 'CL'", SqlCo);
            }

            // Instanciation de l’objet Command
            MySqlDataReader reader = SqlCom.ExecuteReader();

            dt = new DataTable();
            dt.Columns.Add(reader.GetName(0));
            dt.Columns.Add(reader.GetName(1));
            dt.Columns.Add(reader.GetName(2));
            dt.Columns.Add(reader.GetName(3));
            dt.Columns.Add(reader.GetName(4));
            dt.Columns.Add(reader.GetName(5));


            while (reader.Read())

            {
                DataRow dr = dt.NewRow();
                dr[0] = reader.GetValue(0);
                dr[1] = reader.GetValue(1);
                dr[2] = reader.GetValue(2);
                dr[3] = reader.GetValue(3);
                dr[4] = reader.GetValue(4);
                dr[5] = reader.GetValue(5);
                dt.Rows.Add(dr);
            }
            datagrid.DataSource = dt;
            SqlCo.Close();
        }
Exemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            SqlCo.Open();

            if (GestionDate.verifIntervalle(1, 10))
            {
                String date = gd.getAnneeMoisPrecedent();

                MySqlCommand    count       = new MySqlCommand("select count(*) from fichefrais where mois= '" + date + "' and idEtat != 'CL'", SqlCo);
                MySqlDataReader countReader = count.ExecuteReader();
                while (countReader.Read() && countReader.GetInt16(0) > 0)
                {
                    MessageBox.Show("Nb de fiches mises en CL: " + countReader.GetString(0));
                }

                SqlCo.Close();
                SqlCo.Open();

                MySqlCommand    SqlCom = new MySqlCommand("Update fichefrais set idEtat='CL' where mois= '" + date + "'", SqlCo);
                MySqlDataReader reader = SqlCom.ExecuteReader();
            }

            if (GestionDate.majFicheMoisPrecedent())
            {
                String date = gd.getAnneeMoisPrecedent();

                MySqlCommand    count       = new MySqlCommand("select count(*) from fichefrais where mois= '" + date + "' and idEtat = 'VA'", SqlCo);
                MySqlDataReader countReader = count.ExecuteReader();
                while (countReader.Read() && countReader.GetInt16(0) > 0)
                {
                    MessageBox.Show("Nb de fiches mises en RB: " + countReader.GetString(0));
                }

                SqlCo.Close();
                SqlCo.Open();

                MySqlCommand    SqlCom = new MySqlCommand("Update fichefrais set idEtat='RB' where mois= '" + date + "' and idEtat='VA'", SqlCo);
                MySqlDataReader reader = SqlCom.ExecuteReader();
            }

            SqlCo.Close();
        }