Exemplo n.º 1
0
        private void sauvegarderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String req = tb_requete.Text;

            String nom = PromptForQueryName();

            if (nom != null)
            {
                if (String.IsNullOrWhiteSpace(nom))
                {
                    nom = "Req " + DateTime.Now.Ticks;
                }

                int x = QueryLauncher.dbconfig.Execute("INSERT INTO requete (nom, req) VALUES ('" + nom + "','" + req.Replace("'", "''") + "')");

                Int64 id = (Int64)QueryLauncher.dbconfig.ExecuteScalar("SELECT last_insert_rowid()");

                Requete r = new Requete {
                    Id = id, Nom = nom, Req = req
                };
                requetes.Add(r);

                cb_query.Items.Add(r);
                status_message.Text = "Requête " + r.Nom + " sauvegardée";
                Log("Requête " + r.Nom + " sauvegardée");
            }
        }
Exemplo n.º 2
0
        private void GetConfigRequetes()
        {
            DataSet data = QueryLauncher.dbconfig.ReadData("SELECT ROWID, * FROM requete");

            foreach (DataRow row in data.Tables[0].Rows)
            {
                Requete re = new Requete {
                    Id = (Int64)row["ROWID"], Nom = row["nom"].ToString(), Req = row["req"].ToString()
                };
                requetes.Add(re);
            }
        }
Exemplo n.º 3
0
        private void supprimerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (cb_query.SelectedIndex > -1)
            {
                if (DialogResult.Yes == MessageBox.Show("Êtes vous sûr de supprimer cette requête ?", "Confirmation", MessageBoxButtons.YesNo))
                {
                    Requete r = (Requete)cb_query.SelectedItem;
                    QueryLauncher.dbconfig.Execute("DELETE FROM requete WHERE ROWID = " + r.Id);
                    cb_query.Items.RemoveAt(cb_query.SelectedIndex);
                    requetes.Remove(r);

                    status_message.Text = "Requête " + r.Nom + " supprimée";
                    Log("Requête " + r.Nom + " supprimée");
                }
            }
        }