예제 #1
0
 private void saveBut_Click(object sender, EventArgs e)
 {
     this.lien = new Link(titreBox.Text, pathBox.Text);
     this.DialogResult = DialogResult.OK;
 }
예제 #2
0
        // Insertion d'un nouveau lien en base
        public String insertLink(Link lien)
        {
            String EncID = "";
            String titre = "'" + lien.Titre.Replace("'", "''") + "'";

            using (SQLiteConnection SQLC = new SQLiteConnection(this._connectionString))
            {
                if (File.Exists(this.path))
                    SQLC.Open();
                else
                    throw new Exception("Base inaccessible");

                using (SQLiteTransaction mytransaction = SQLC.BeginTransaction())
                {
                    using (SQLiteCommand SQLCmd = new SQLiteCommand(SQLC))
                    {
                        // Insertion du mail
                        SQLCmd.CommandText = "INSERT INTO Links (Titre,Path) ";
                        SQLCmd.CommandText += "VALUES(" + titre + "," + lien.urlSQL + ");";
                        SQLCmd.ExecuteNonQuery();

                        // Récupération du EncID
                        SQLCmd.CommandText = "SELECT max(id) FROM Links;";
                        EncID = SQLCmd.ExecuteScalar().ToString();
                    }
                    mytransaction.Commit();
                }
            }
            return EncID;
        }