예제 #1
0
        public Exception RemoveAppication(App a)
        {
            Exception rex = new EverythingIsFine();

            try
            {
                if (myConnection.State != System.Data.ConnectionState.Open)
                {
                    myConnection.Open();
                }

                SQLiteCommand cmd = new SQLiteCommand("DELETE FROM apps WHERE AppPath = @path", myConnection);
                cmd.Parameters.AddWithValue("@path", a.Path);

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                rex = ex;
            }
            finally
            {
                if (myConnection.State == System.Data.ConnectionState.Open)
                {
                    myConnection.Close();
                }
            }

            return(rex);
        }
예제 #2
0
        public Exception EditApplication(App oldA, App newA)
        {
            Exception rex = new EverythingIsFine();

            try
            {
                if (myConnection.State != System.Data.ConnectionState.Open)
                {
                    myConnection.Open();
                }

                SQLiteCommand cmd = new SQLiteCommand("UPDATE apps SET AppName=@name, AppPath=@path WHERE AppPath=@oldPath", myConnection);
                cmd.Parameters.AddWithValue("@path", newA.Path);
                cmd.Parameters.AddWithValue("@name", newA.Name);
                cmd.Parameters.AddWithValue("@oldPath", oldA.Path);

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                rex = ex;
            }
            finally
            {
                if (myConnection.State == System.Data.ConnectionState.Open)
                {
                    myConnection.Close();
                }
            }

            return(rex);
        }
예제 #3
0
        public Exception AddNewApplication(App a)
        {
            Exception rex = new EverythingIsFine("");

            try
            {
                if (myConnection.State != System.Data.ConnectionState.Open)
                {
                    myConnection.Open();
                }

                SQLiteCommand cmd = new SQLiteCommand("INSERT INTO apps VALUES(@path, @name)", myConnection);
                cmd.Parameters.AddWithValue("@path", a.Path);
                cmd.Parameters.AddWithValue("@name", a.Name);

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                rex = ex;
            }
            finally
            {
                if (myConnection.State == System.Data.ConnectionState.Open)
                {
                    myConnection.Close();
                }
            }

            return(rex);
        }