Пример #1
0
        private void bLogin_Click(object sender, RoutedEventArgs e)
        {
            switch (radiosel)
            {
            case "Doctor":
                String           sSQL    = @"SELECT [DoctorId] from iatroi where [DoctorId] = " + tbLogin.Text;
                ISQLiteStatement dbstate = dbcoonection.Prepare(sSQL);
                while (dbstate.Step() == SQLiteResult.ROW)
                {
                    var itemId = tbLogin.Text;
                    this.Frame.Navigate(typeof(DoctorPage), itemId);
                }
                break;

            case "Drugstore":
                sSQL    = @"SELECT [Store_Id] from dragstores where [Store_Id] = " + tbLogin.Text;
                dbstate = dbcoonection.Prepare(sSQL);
                while (dbstate.Step() == SQLiteResult.ROW)
                {
                    var itemId = tbLogin.Text;
                    this.Frame.Navigate(typeof(DrugstorePage), itemId);
                }
                break;
            }
        }
Пример #2
0
        public static void LoadDatabase(SQLiteConnection db)
        {
            string sql = @"CREATE TABLE IF NOT EXISTS
                                Customer (Id      INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                                            Name    VARCHAR( 140 ),
                                            City    VARCHAR( 140 ),
                                            Contact VARCHAR( 140 ) 
                            );";
            using (var statement = db.Prepare(sql))
            {
                statement.Step();
            }

            sql = @"CREATE TABLE IF NOT EXISTS
                                Project (Id          INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                                         CustomerId  INTEGER,
                                         Name        VARCHAR( 140 ),
                                         Description VARCHAR( 140 ),
                                         DueDate     DATETIME,
                                         FOREIGN KEY(CustomerId) REFERENCES Customer(Id) ON DELETE CASCADE 
                            )";
            using (var statement = db.Prepare(sql))
            {
                statement.Step();
            }

            // Turn on Foreign Key constraints
            sql = @"PRAGMA foreign_keys = ON";
            using (var statement = db.Prepare(sql))
            {
                statement.Step();
            }
        }
Пример #3
0
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            var              Items   = new List <string>();
            String           sSQL    = @"SELECT [Store_Id],[Store_Name],[Address],[State],[Region],[ZIP],[Phone],[Email] from dragstores where [Store_Id] =" + tbId.Text;
            ISQLiteStatement dbstate = dbcoonection.Prepare(sSQL);

            while (dbstate.Step() == SQLiteResult.ROW)

            {
                Items.Add("Ονομασία: " + dbstate["Store_Name"] + " Διεύθυνση: " + dbstate["Address"] + " Πόλη: " + dbstate["Region"] + " Νομός: " + dbstate["State"] + " Τ.Κ.: " + dbstate["ZIP"] + " Τηλέφωνο: " + dbstate["Phone"] + " e-mail: " + dbstate["Email"]);
            }
            listdrugstrore.ItemsSource = Items;
        }
Пример #4
0
        public static int insertDebtLoan(DebtLoan debtLoan)
        {
            int    status      = 0;
            double amount      = debtLoan.Amount;
            String payer       = debtLoan.Person;
            String description = debtLoan.Description;
            String id          = debtLoan.Id;

            String[] dateArray = debtLoan.Date.ToString().Split(' ');
            String   date      = dateArray[0];

            bool isDebt = debtLoan.Debt;
            int  cond   = 0;

            if (isDebt)
            {
                cond = 1;
            }
            String accID = debtLoan.AccID;

            try
            {
                using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
                {
                    using (var statement = connection.Prepare(@"INSERT INTO DebtLoan (Amount, Person, 
                                                                Description, ID, Date, Debt, Acc_ID)
                                    VALUES(?,?,?,?,?,?,?);"))
                    {
                        statement.Bind(1, amount.ToString());
                        statement.Bind(2, payer);
                        statement.Bind(3, description);
                        statement.Bind(4, id);
                        statement.Bind(5, date.ToString());
                        statement.Bind(6, cond);
                        statement.Bind(7, accID);


                        SQLiteResult s = statement.Step();
                        statement.Reset();
                        statement.ClearBindings();
                        if ((s.ToString().Equals("DONE")))
                        {
                            Debug.WriteLine("Step done");
                            status = 1;
                        }
                        else
                        {
                            Debug.WriteLine("Step failed");
                            status = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(status);
        }
Пример #5
0
        public static ObservableCollection<Student> getValues()
        {
             ObservableCollection<Student> list = new ObservableCollection<Student>();

            using (var connection = new SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM Student;"))
                {
                    
                    while (statement.Step() == SQLiteResult.ROW)
                    {
 
                        list.Add(new Student()
                        {
                            Id = (string)statement[0],
                            Name = (string)statement[1],
                            Cgpa = statement[2].ToString()
                        });

                        Debug.WriteLine(statement[0]+" ---"+statement[1]+" ---"+statement[2]);
                    }
                }
            }
            return list;
        }
Пример #6
0
        public static ObservableCollection <DebtLoan> getDebtLoanValues()
        {
            ObservableCollection <DebtLoan> list = new ObservableCollection <DebtLoan>();

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM DebtLoan;"))
                {
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        int  value  = Convert.ToInt16(statement[5]);
                        bool isDebt = false;
                        if (value == 1)
                        {
                            isDebt = true;
                        }

                        list.Add(new DebtLoan()
                        {
                            Amount      = double.Parse(statement[0].ToString()),
                            Person      = (String)statement[1],
                            Description = (String)statement[2],
                            Id          = (String)statement[3],
                            Date        = (String)(statement[4]),
                            Debt        = isDebt,
                            AccID       = (String)statement[6]
                        });
                    }
                }
            }
            return(list);
        }
Пример #7
0
        //Receive info

        public static ObservableCollection <IncExp> getIncomeExpenseValues()
        {
            ObservableCollection <IncExp> list = new ObservableCollection <IncExp>();

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM IncExp;"))
                {
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        int  value    = Convert.ToInt16(statement[7]);
                        bool isIncome = false;
                        if (value == 1)
                        {
                            isIncome = true;
                        }

                        list.Add(new IncExp()
                        {
                            Name        = (String)statement[0],
                            Amount      = double.Parse(statement[1].ToString()),
                            Person      = (String)statement[2],
                            Category    = (String)statement[3],
                            Description = (String)statement[4],
                            Id          = (String)statement[5],
                            Date        = (String)statement[6],
                            Income      = isIncome,
                            AccID       = (String)statement[8]
                        });
                    }
                }
            }
            return(list);
        }
Пример #8
0
        public static int deleteSmallTrans(String id)
        {
            int status = 0;

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"DELETE FROM SmallTransactions WHERE TransactionID=?;"))
                {
                    statement.Bind(1, id);
                    SQLiteResult s = statement.Step();

                    if ((s.ToString().Equals("DONE")))
                    {
                        Debug.WriteLine("Step done");
                        status = 1;
                    }
                    else
                    {
                        Debug.WriteLine("Step failed");
                        status = 0;
                    }
                }
            }

            return(status);
        }
        public void SqliteInitializationTest()
        {
            string dbPath = Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, DB_FILE_NAME);

            using (SQLiteLocalStorage storage = new SQLiteLocalStorage())
            { }

            using (SQLiteConnection connection = new SQLiteConnection(dbPath))
            {

                var query = "SELECT name FROM sqlite_master WHERE type='table'";
                var tableName = new List<string>();

                using (var sqliteStatement = connection.Prepare(query))
                {
                    while(sqliteStatement.Step() == SQLiteResult.ROW)
                    {
                        tableName.Add(sqliteStatement.GetText(0));
                    }
                }

                Assert.IsTrue(tableName.Count == 2);
                Assert.IsTrue(tableName.Contains("datasets"));
                Assert.IsTrue(tableName.Contains("records")); 
            }
        }
Пример #10
0
        public static void AddDownload(string filename,string path, string date, string size)
        {
            string path1 = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "User.db");

            try
            {
                using (var connection = new SQLiteConnection(path1))
                {
                    using (var statement = connection.Prepare(@"INSERT INTO DownloadList (FILENAME,PATH,DATE,SIZE)
                                    VALUES(?,?,?,?);"))
                    {
                       
                        statement.Bind(1, filename);
                        statement.Bind(2, path);
                        statement.Bind(3, date);
                        statement.Bind(4, size);
                    
                        // Inserts data.
                        statement.Step();
                       
                        statement.Reset();
                        statement.ClearBindings();
                        Debug.WriteLine("Download Added");
                    }
                }

            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception\n" + ex.ToString());
            }
        }
Пример #11
0
        public static ObservableCollection<Downloads> getDownloads()
        {
            string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "User.db");

            ObservableCollection<Downloads> list = new ObservableCollection<Downloads>();

            using (var connection = new SQLiteConnection(path))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM DownloadList;"))
                {

                    while (statement.Step() == SQLiteResult.ROW)
                    {

                        list.Add(new Downloads()
                        {
                            FileName = (string)statement[0],
                            Path = (string)statement[1],
                            Date = (string)statement[2],
                            Size = (string)statement[3]

                          
                        });

                        Debug.WriteLine(statement[0] + " ---" + statement[1] + " ---" + statement[2]);
                    }
                }
            }
            return list;
        }
Пример #12
0
        public static void insertData(string param1, string param2, string param3)
        {
            try 
            { 
            using (var connection = new SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"INSERT INTO Student (ID,NAME,CGPA)
                                            VALUES(?, ?,?);"))
                {
                    statement.Bind(1, param1);
                    statement.Bind(2, param2);
                    statement.Bind(3, param3);

                    // Inserts data.
                    statement.Step();

                  
                    statement.Reset();
                    statement.ClearBindings();


                }
            }

            }
            catch(Exception ex)
            {
                Debug.WriteLine("Exception\n"+ex.ToString());
            }
        }
Пример #13
0
		private void EnableForeignKeys(SQLiteConnection connection)
		{
			using (var statement = connection.Prepare(@"PRAGMA foreign_keys = ON;"))
			{
				statement.Step();
			}
		}
Пример #14
0
        public static ObservableCollection <SmallTransactions> getSmallTransactionValues()
        {
            ObservableCollection <SmallTransactions> list = new ObservableCollection <SmallTransactions>();

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM SmallTransactions;"))
                {
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        list.Add(new SmallTransactions()
                        {
                            Amount         = double.Parse(statement[0].ToString()),
                            Description    = (String)statement[1],
                            Type           = Convert.ToChar(statement[2].ToString()),
                            Id             = (String)statement[3],
                            Transaction_id = (String)statement[4],
                            Date           = (String)(statement[5]),
                            AccID          = (String)statement[6]
                        });
                    }
                }
            }
            return(list);
        }
Пример #15
0
        public static String[] findSpecificID(String id)
        {
            String[] idArray = new String[4];

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM IDTracking WHERE IEID=?;"))
                {
                    statement.Bind(1, id);
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        if (statement[0] != null)
                        {
                            idArray[0] = statement[0].ToString();
                        }
                        if (statement[1] != null)
                        {
                            idArray[1] = statement[1].ToString();
                        }
                        if (statement[2] != null)
                        {
                            idArray[2] = statement[2].ToString();
                        }
                        if (statement[3] != null)
                        {
                            idArray[3] = statement[3].ToString();
                        }
                    }
                    statement.Reset();
                    statement.ClearBindings();
                }
            }
            return(idArray);
        }
Пример #16
0
 public WordListDB()
 {
     connection_ = new SQLiteConnection(DB_NAME);
     using (var statement = connection_.Prepare(SQL_CREATE_TABLE))
     {
         statement.Step();
     }
 }
Пример #17
0
 public PlanetaDao(SQLiteConnection con)
 {
     this.con = con;
     string sql = "CREATE TABLE IF NOT EXISTS planeta (id INTEGER PRIMARY KEY AUTOINCREMENT, nombre TEXT, gravedad FLOAT)";
     using (var statement =con.Prepare(sql)) {
         statement.Step();
     }
 }
Пример #18
0
 public FacturaDao(SQLiteConnection con)
 {
     this.con = con;
     string sql = "CREATE TABLE IF NOT EXISTS factura (id INTEGER PRIMARY KEY AUTOINCREMENT, nombre TEXT, vence DATETIME, alarma DATETIME, valor INTEGER, estado TEXT)";
     using (var statement = con.Prepare(sql))
     {
         statement.Step();
     }
 }
Пример #19
0
        public void Cleaup()
        {
            string dbPath = Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, DB_FILE_NAME);

            //drop all the tables from the db
            using (SQLiteConnection connection = new SQLiteConnection(dbPath))
            {
                using (var sqliteStatement = connection.Prepare("DROP TABLE IF EXISTS records"))
                {
                    var result = sqliteStatement.Step();
                }

                using (var sqliteStatement = connection.Prepare("DROP TABLE IF EXISTS datasets"))
                {
                    var result = sqliteStatement.Step();
                }
            }
        }
Пример #20
0
        /// <summary>
        /// Metoda czyszcząca bazę danych ze wszystkich informacji.
        /// </summary>
        /// <param name="db"></param>
        /// <returns></returns>
            public async static Task ResetDataAsync(SQLiteConnection db)
            {
                // Empty the Device and Comment tables 
                string sql = @"DELETE FROM Device";
                using (var statement = db.Prepare(sql))
                {
                    statement.Step();
                }

                sql = @"DELETE FROM Comment";
                using (var statement = db.Prepare(sql))
                {
                    statement.Step();
                }


           
        }
Пример #21
0
 public WordBookDB()
 {
     mutex_ = new object();
     connection_ = new SQLiteConnection(SQL_CREATE_TABLE);
     using (var statement = connection_.Prepare(SQL_CREATE_TABLE))
     {
         statement.Step();
     }
 }
Пример #22
0
        //Delete table

        public static void dropIncomeExpenseTable()
        {
            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"DROP TABLE IncExp;"))
                {
                    statement.Step();
                }
            }
        }
Пример #23
0
        public static void LoadDatabase()
        {
            // Get a reference to the SQLite database
            conn = new SQLiteConnection("SQLiteTODO.db");

            // NOTE - The Id character is actually a GUID which is 36 characters long.
            // Here we speacify it as VARCHAR(36) - but actually SQLite does not impose a length
            // limit on columns, nor rigidly enforce data types. 
            // Could have specified CHARACTER(10), VARCHAR(255), TEXT - all would work for a GUID.
            // SQLite just stores these as 'TEXT' - see http://www.sqlite.org/datatype3.html#expraff
            string sql = @"CREATE TABLE IF NOT EXISTS
                                ToDoList (Id      VARCHAR( 36 ) PRIMARY KEY NOT NULL,
                                          Title   VARCHAR( 140 ) 
                            );";
            using (var statement = conn.Prepare(sql))
            {
                statement.Step();
            }

            sql = @"CREATE TABLE IF NOT EXISTS
                                ToDoItem (Id         VARCHAR( 36 ) PRIMARY KEY NOT NULL,
                                         Title       VARCHAR( 140 ),
                                         DueDate     DATETIME,
                                         Details     VARCHAR( 140 ),
                                         IsFavorite  BOOLEAN,
                                         IsComplete  BOOLEAN,
                                         ListId      CHAR( 36 ),
                                         FOREIGN KEY(ListId) REFERENCES ToDoList(Id) ON DELETE CASCADE 
                            )";
            using (var statement = conn.Prepare(sql))
            {
                statement.Step();
            }

            // Turn on Foreign Key constraints
            sql = @"PRAGMA foreign_keys = ON";
            using (var statement = conn.Prepare(sql))
            {
                statement.Step();
            }
        }
Пример #24
0
        public async static Task ResetDataAsync(SQLiteConnection db)
        {
            // Empty the Customer and Project tables 
            string sql = @"DELETE FROM Project";
            using (var statement = db.Prepare(sql))
            {
                statement.Step();
            }

            sql = @"DELETE FROM Customer";
            using (var statement = db.Prepare(sql))
            {
                statement.Step();
            }

            List<Task> tasks = new List<Task>();

            // Add seed customers and projects
            var cust1Task = InsertCustomer(db, "Adventure Works", "Bellevue", "Mu Han");
            tasks.Add(cust1Task.ContinueWith((id) => InsertProject(db, id.Result, "Expense Reports", "Windows Store app", DateTime.Today.AddDays(4))));
            tasks.Add(cust1Task.ContinueWith((id) => InsertProject(db, id.Result, "Time Reporting", "Windows Store app", DateTime.Today.AddDays(14))));
            tasks.Add(cust1Task.ContinueWith((id) => InsertProject(db, id.Result, "Project Management", "Windows Store app", DateTime.Today.AddDays(24))));
            await Task.WhenAll(tasks.ToArray());

            tasks = new List<Task>();
            var cust2Task = InsertCustomer(db, "Contoso", "Seattle", "David Hamilton");
            tasks.Add(cust2Task.ContinueWith((id) => InsertProject(db, id.Result, "Soccer Scheduling", "Windows Phone app", DateTime.Today.AddDays(6))));
            await Task.WhenAll(tasks.ToArray());

            tasks = new List<Task>();
            var cust3Task = InsertCustomer(db, "Fabrikam", "Redmond", "Guido Pica");
            tasks.Add(cust3Task.ContinueWith((id) => InsertProject(db, id.Result, "Product Catalog", "MVC4 app", DateTime.Today.AddDays(4))));
            tasks.Add(cust3Task.ContinueWith((id) => InsertProject(db, id.Result, "Expense Reports", "Windows Store app", DateTime.Today.AddDays(-3))));
            tasks.Add(cust3Task.ContinueWith((id) => InsertProject(db, id.Result, "Expense Reports", "Windows Phone app", DateTime.Today.AddDays(45))));
            await Task.WhenAll(tasks.ToArray());

            tasks = new List<Task>();
            var cust4Task = InsertCustomer(db, "Tailspin Toys", "Kent", "Michelle Alexander");
            tasks.Add(cust4Task.ContinueWith((id) => InsertProject(db, id.Result, "Kids Game", "Windows Store app", DateTime.Today.AddDays(60))));
            await Task.WhenAll(tasks.ToArray());
        }
Пример #25
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                conn = App.conn;
                string req = @"Create Table if not exists  
                                                User (Id integer primary key autoincrement not null,
                                                      Login varchar(50),
                                                      Passeword varchar(50)
                                                      )";
                using (var Statement = conn.Prepare(req))
                {
                    Statement.Step();
                }

                req = @"select Login from User where Login='******'";
                using (var Statement = conn.Prepare(req))
                {
                    //if (SQLiteResult.DONE == Statement.Step())
                    //{
                        Statement.Step();
                        if (Statement.DataCount == 0)
                        {
                            req = @"insert into User(Login,Passeword) values('Admin','Admin')";
                            using (var Statement1 = conn.Prepare(req))
                            {
                                Statement1.Step();
                            }
                        }
                    //}
                }

              
            }
            catch (Exception ex)
            {
                MessageDialog Msg = new MessageDialog(ex.ToString());
                await Msg.ShowAsync();

            }
        }
Пример #26
0
        public static int insertSmallTransactions(SmallTransactions sTrans)
        {
            int    status      = 0;
            double amount      = sTrans.Amount;
            String description = sTrans.Description;
            char   type        = sTrans.Type;
            String id          = sTrans.Id;
            String trans_id    = sTrans.Transaction_id;

            String[] dateArray = sTrans.Date.ToString().Split(' ');
            String   date      = dateArray[0];
            String   accID     = sTrans.AccID;

            try
            {
                using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
                {
                    using (var statement = connection.Prepare(@"INSERT INTO SmallTransactions (Amount, Description, Type,
                                                              ID, TransactionID, Date, Acc_ID)
                                                              VALUES(?,?,?,?,?,?,?);"))
                    {
                        statement.Bind(1, amount.ToString());
                        statement.Bind(2, description);
                        statement.Bind(3, type.ToString());
                        statement.Bind(4, id);
                        statement.Bind(5, trans_id);
                        statement.Bind(6, date);
                        statement.Bind(7, accID);

                        SQLiteResult s = statement.Step();
                        statement.Reset();
                        statement.ClearBindings();

                        if ((s.ToString().Equals("DONE")))
                        {
                            Debug.WriteLine("Step done");
                            status = 1;
                        }
                        else
                        {
                            Debug.WriteLine("Step failed");
                            status = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(status);
        }
Пример #27
0
        public static int insertIDs(String incexpID, String otherID)
        {
            int status = 0;
            int number = 0;

            String[] array = otherID.Split(' ');

            if (array[0].Equals("sa"))
            {
                number = 3;
            }
            else if (array[0].Equals("dl"))
            {
                number = 2;
            }
            else if (array[0].Equals("st"))
            {
                number = 4;
            }

            try
            {
                using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
                {
                    using (var statement = connection.Prepare(@"INSERT INTO IDTracking (IEID, DLID, SAID, STID)VALUES(?,?,?,?);"))
                    {
                        statement.Bind(1, incexpID);
                        statement.Bind(number, otherID);

                        SQLiteResult s = statement.Step();
                        statement.Reset();
                        statement.ClearBindings();

                        if ((s.ToString().Equals("DONE")))
                        {
                            Debug.WriteLine("ID insert step done");
                            status = 1;
                        }
                        else
                        {
                            Debug.WriteLine("ID insert step failed");
                            status = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(status);
        }
Пример #28
0
            /// <summary>
            /// Metoda ma na celu utworzenie Tabeli w bazie danych (jeżeli nie istnieją i stworzenie odpowiednich relacji.
            /// Ważnym elementem metody jest włączenie opcji relacyjnej bazy danych.
            /// </summary>
            /// <param name="db"></param>
            public static void LoadDatabase(SQLiteConnection db)
            {
                string sql = @"CREATE TABLE IF NOT EXISTS
                                Device (Id      INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                                            Name    VARCHAR( 140 ),
                                            Manufacturer    VARCHAR( 140 ),
                                            Others VARCHAR( 140 ) 
                            );";
                using (var statement = db.Prepare(sql))
                {
                    statement.Step();
                }

                sql = @"CREATE TABLE IF NOT EXISTS
                                Comment (Id          INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                                         DeviceId   INTEGER,
                                         Zalety        VARCHAR( 140 ),
                                         Wady VARCHAR( 140 ),
                                         Autor VARCHAR( 140 ),
                                         TekstOpinii VARCHAR( 500 ),
                                         Gwiazdki VARCHAR( 1 ),
                                         Data VARCHAR( 140 ),
                                         Polecam VARCHAR( 20 ),
                                         Przydatnosc VARCHAR( 140 ),
                                         Pochodzenie VARCHAR( 140 ),
                                         FOREIGN KEY(DeviceId) REFERENCES Device(Id) ON DELETE CASCADE 
                            )";

            using (var statement = db.Prepare(sql))
                {
                    statement.Step();
                }

                // Turn on Foreign Key constraints
                sql = @"PRAGMA foreign_keys = ON";
                using (var statement = db.Prepare(sql))
                {
                    statement.Step();
                }
            }
 public static void ExecuteNonQuery(string dbName, string sql)
 {
     using (var connection = new SQLiteConnection(dbName))
     {
         using (var statement = connection.Prepare(sql))
         {
             if (statement.Step() != SQLiteResult.DONE)
             {
                 throw new InvalidOperationException();
             }
         }
     }
 }
Пример #30
0
        /// <summary>
        /// 하나의 트랜젝션으로 묶어 처리를 수행한다.
        /// </summary>
        /// <param name="func">처리할 함수</param>
        /// <returns>DB수행 결과</returns>
        public SQLiteResult Transactional(Func <SQLiteResult> func)
        {
            var result = SQLitePCL.SQLiteResult.EMPTY;

            try
            {
                using (var stmt = conn.Prepare(TCL_BEGIN)) { stmt.Step(); }
                //결과가 Done이 아니면 롤백 처리
                if (func.Invoke() != SQLiteResult.DONE)
                {
                    throw new Exception();
                }
                //커밋
                using (var stmt = conn.Prepare(TCL_COMMIT)) { result = stmt.Step(); }
            }
            catch (Exception)
            {
                using (var stmt = conn.Prepare(TCL_ROLLBACK)) { stmt.Step(); }
            }

            return(result);
        }
Пример #31
0
 public static void createTable()
 {
     using (var connection = new SQLiteConnection("Storage.db"))
     {
         using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS Student (
                                         ID NVARCHAR(10),
                                         NAME NVARCHAR(50),
                                         CGPA NVARCHAR(10));"))
         {
             statement.Step();
         }
     }
 }
Пример #32
0
		public void Init()
		{
			using (var connection = new SQLiteConnection(DatabaseFilename))
			{
				EnableForeignKeys(connection);

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SAVED_STREAM_ITEM (ID TEXT PRIMARY KEY NOT NULL, 
																			TITLE TEXT, 
																			PUBLISHED TEXT, 
																			WEBURI TEXT, 
																			SHORT_CONTENT TEXT, 
																			CONTENT TEXT, 
																			IMAGE_FOLDER TEXT);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS TAG_ACTION (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
							ITEM_ID TEXT,
							TAG TEXT,
							ACTION_KIND INTEGER);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SUB_ITEM (ID TEXT PRIMARY KEY NOT NULL, 
										SORT_ID TEXT, TITLE TEXT, UNREAD_COUNT INTEGER, URL TEXT, HTML_URL TEXT, ICON_URL TEXT, FIRST_ITEM_MSEC INTEGER);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SUB_CAT (ID TEXT PRIMARY KEY NOT NULL, 
										SORT_ID TEXT, TITLE TEXT, UNREAD_COUNT INTEGER);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SUB_CAT_SUB_ITEM (CAT_ID TEXT, ITEM_ID TEXT);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS STREAM_COLLECTION (STREAM_ID TEXT PRIMARY KEY NOT NULL, CONTINUATION TEXT, SHOW_NEWEST_FIRST INTEGER, STREAM_TIMESTAMP INTEGER, FAULT INTEGER);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS STREAM_ITEM (ID TEXT PRIMARY KEY NOT NULL, STREAM_ID TEXT REFERENCES STREAM_COLLECTION(STREAM_ID) ON DELETE CASCADE, PUBLISHED TEXT, TITLE TEXT, WEB_URI TEXT, CONTENT TEXT, UNREAD INTEGER, NEED_SET_READ_EXPLICITLY INTEGER, IS_SELECTED INTEGER, STARRED INTEGER, SAVED INTEGER);"))
				{
					statement.Step();
				}
			}
		}
Пример #33
0
 public static void LoadDatabase(SQLiteConnection db)
 {
     string sql = @"CREATE TABLE IF NOT EXISTS
                             UserLocation (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
                                           DateCreated  VARCHAR( 140 ),
                                           Lat  VARCHAR( 140 ),
                                           Lon  VARCHAR( 140 ),
                                           Att  VARCHAR( 140 )
                             );";
     using (var statement = db.Prepare(sql))
     {
         statement.Step();
     }
 }
Пример #34
0
 public static void createIDTrackingTable()
 {
     using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
     {
         using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS IDTracking (
                                 IEID NVARCHAR(10),
                                 DLID NVARCHAR(10),
                                 SAID NVARCHAR(10),
                                 STID NVARCHAR(10));"))
         {
             statement.Step();
         }
     }
 }
Пример #35
0
        private void LoadDatabase()
        {
            conn = new SQLiteConnection("record_list.db");
            string sql_create = @"CREATE TABLE IF NOT EXISTS
                                    Record (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                                          Name VARCHAR(200),
                                          FinishTime INTEGER,
                                          Date VARCHAR(200))";

            using (var statement = conn.Prepare(sql_create))
            {
                statement.Step();
            }
        }
        public static long CountRows(string dbName, string tableName)
        {
            long count;
            using (var connection = new SQLiteConnection(dbName))
            {
                using (var statement = connection.Prepare("SELECT COUNT(1) from " + tableName))
                {
                    statement.Step();

                    count = (long)statement[0];
                }
            }
            return count;
        }
Пример #37
0
        public static List<SimpleGeoData> GetAllLocation(SQLiteConnection db)
        {
            var ret = new List<SimpleGeoData>();
            using (var stmt = db.Prepare("SELECT Id, DateCreated, Lat, Long, Att FROM UserLocation"))
            {
                while(stmt.Step()== SQLiteResult.ROW)
                {
                    var item = CreateSimpleGeo(stmt);
                    ret.Add(item);
                }
            }

                return ret;
        }
Пример #38
0
        public static int updateSaving(Savings saving)
        {
            int    status  = 0;
            String name    = saving.Name;
            double goal    = saving.Goal;
            double initial = saving.Initial;
            String id      = saving.Id;
            String accID   = saving.AccID;

            try
            {
                using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
                {
                    using (var statement = connection.Prepare(@"UPDATE Savings SET Name=?, Goal=?, Initial=?,
                                                                ID=?, Acc_ID=?
                                                                WHERE ID=?;"))
                    {
                        statement.Bind(1, name);
                        statement.Bind(2, goal.ToString());
                        statement.Bind(3, initial.ToString());
                        statement.Bind(4, id);
                        statement.Bind(5, accID);
                        statement.Bind(6, id);


                        SQLiteResult s = statement.Step();
                        statement.Reset();
                        statement.ClearBindings();

                        if ((s.ToString().Equals("DONE")))
                        {
                            Debug.WriteLine("Update done");
                            status = 1;
                        }
                        else
                        {
                            Debug.WriteLine("Update failed");
                            status = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(status);
        }
Пример #39
0
        private void SetupDatabase()
        {
#if __IOS__
            SQLitePCL.CurrentPlatform.Init();
#endif

            string dbPath = Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, DB_FILE_NAME);

            connection = new SQLiteConnection(dbPath);

            string createDatasetTable = "CREATE TABLE IF NOT EXISTS " + TABLE_DATASETS + "("
                        + DatasetColumns.IDENTITY_ID + " TEXT NOT NULL,"
                        + DatasetColumns.DATASET_NAME + " TEXT NOT NULL,"
                        + DatasetColumns.CREATION_TIMESTAMP + " TEXT DEFAULT '0',"
                        + DatasetColumns.LAST_MODIFIED_TIMESTAMP + " TEXT DEFAULT '0',"
                        + DatasetColumns.LAST_MODIFIED_BY + " TEXT,"
                        + DatasetColumns.STORAGE_SIZE_BYTES + " INTEGER DEFAULT 0,"
                        + DatasetColumns.RECORD_COUNT + " INTEGER DEFAULT 0,"
                        + DatasetColumns.LAST_SYNC_COUNT + " INTEGER NOT NULL DEFAULT 0,"
                        + DatasetColumns.LAST_SYNC_TIMESTAMP + " INTEGER DEFAULT '0',"
                        + DatasetColumns.LAST_SYNC_RESULT + " TEXT,"
                        + "UNIQUE (" + DatasetColumns.IDENTITY_ID + ", "
                        + DatasetColumns.DATASET_NAME + ")"
                        + ")";

            using (var sqliteStatement = connection.Prepare(createDatasetTable))
            {
                sqliteStatement.Step();
            }

            string createRecordsTable = "CREATE TABLE IF NOT EXISTS " + TABLE_RECORDS + "("
                        + RecordColumns.IDENTITY_ID + " TEXT NOT NULL,"
                        + RecordColumns.DATASET_NAME + " TEXT NOT NULL,"
                        + RecordColumns.KEY + " TEXT NOT NULL,"
                        + RecordColumns.VALUE + " TEXT,"
                        + RecordColumns.SYNC_COUNT + " INTEGER NOT NULL DEFAULT 0,"
                        + RecordColumns.LAST_MODIFIED_TIMESTAMP + " TEXT DEFAULT '0',"
                        + RecordColumns.LAST_MODIFIED_BY + " TEXT,"
                        + RecordColumns.DEVICE_LAST_MODIFIED_TIMESTAMP + " TEXT DEFAULT '0',"
                        + RecordColumns.MODIFIED + " INTEGER NOT NULL DEFAULT 1,"
                        + "UNIQUE (" + RecordColumns.IDENTITY_ID + ", " + RecordColumns.DATASET_NAME
                        + ", " + RecordColumns.KEY + ")"
                        + ")";

            using (var sqliteStatement = connection.Prepare(createRecordsTable))
            {
                sqliteStatement.Step();
            }
        }
Пример #40
0
 public static void createSavingsTable()
 {
     using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
     {
         using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS Savings (
                                 Name NVARCHAR(50),    
                                 Goal DOUBLE(20),
                                 Initial DOUBLE(20),          
                                 ID NVARCHAR(10),
                                 Acc_ID NVARCHAR(10));"))
         {
             statement.Step();
         }
     }
 }
Пример #41
0
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            //not login
            login = false;
            login_user = null;

            conn = new SQLiteConnection("sqlitetodo.db");
            string sql_user = @"CREATE TABLE IF NOT EXISTS User (Username VARCHAR(20) PRIMARY KEY,Password VARCHAR(20),Root INTERGER(1))";
            using (var statement = conn.Prepare(sql_user))
            {
                statement.Step();
            }

            string sql_task = @"CREATE TABLE IF NOT EXISTS TaskItem (Id INTEGER PRIMARY KEY AUTOINCREMENT,Title VARCHAR(140),Detail VARCHAR(1000),Datetime DATETIME(140),Filepath VARCHAR(1400),Username VARCHAR(1400),Comment VARCHAR(1400))";
            using (var statement = conn.Prepare(sql_task))
            {
                statement.Step();
            }
        }
Пример #42
0
        /// <summary>
        /// Sets up SQLite database.
        /// </summary>
        private static void SetupSQLiteEventStore()
        {
            string vacuumCommand = "PRAGMA auto_vacuum = 1";
            string sqlCommand = string.Format(CultureInfo.InvariantCulture, "CREATE TABLE IF NOT EXISTS {0} ({1} TEXT NOT NULL,{2} TEXT NOT NULL UNIQUE,{3} TEXT NOT NULL, {4}  INTEGER NOT NULL DEFAULT 0 )",
                TABLE_NAME, EVENT_COLUMN_NAME, EVENT_ID_COLUMN_NAME, MA_APP_ID_COLUMN_NAME, EVENT_DELIVERY_ATTEMPT_COUNT_COLUMN_NAME);

            lock (_lock)
            {
#if __IOS__
                SQLitePCL.CurrentPlatform.Init();
#endif
                using (var connection = new SQLiteConnection(_dbFileFullPath))
                {
                    using (var statement = connection.Prepare(vacuumCommand))
                    {
                        statement.Step();
                    }
                    using (var createTableStmt = connection.Prepare(sqlCommand))
                    {
                        createTableStmt.Step();
                    }
                }
            }
        }
Пример #43
0
        public static int insertSavings(Savings savings)
        {
            int    status  = 0;
            String name    = savings.Name;
            double goal    = savings.Goal;
            double initial = savings.Initial;
            String id      = savings.Id;
            String accID   = savings.AccID;

            try
            {
                using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
                {
                    using (var statement = connection.Prepare(@"INSERT INTO Savings (Name, Goal, Initial,
                                                                ID, Acc_ID)
                                    VALUES(?,?,?,?,?);"))
                    {
                        statement.Bind(1, name);
                        statement.Bind(2, goal.ToString());
                        statement.Bind(3, initial.ToString());
                        statement.Bind(4, id);
                        statement.Bind(5, accID);


                        SQLiteResult s = statement.Step();
                        statement.Reset();
                        statement.ClearBindings();

                        if ((s.ToString().Equals("DONE")))
                        {
                            Debug.WriteLine("Step done");
                            status = 1;
                        }
                        else
                        {
                            Debug.WriteLine("Step failed");
                            status = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(status);
        }
Пример #44
0
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            login = false;

            conn = new SQLiteConnection("sqlitetodo.db");
            string sql = @"CREATE TABLE IF NOT EXISTS User (Username VARCHAR(20) PRIMARY KEY,Password VARCHAR(20),Root INTERGER(1))";
            using (var statement = conn.Prepare(sql))
            {
                statement.Step();
            }
        }
Пример #45
0
        public static String getLastID(String table)
        {
            String id   = "";
            String text = "ID";

            if (table.Equals("SmallTransactions"))
            {
                text = "TransactionID";
            }

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM " + table + " ORDER BY " + text + " DESC LIMIT 1;"))
                {
                    if (table.Equals("IncExp"))
                    {
                        while (statement.Step() == SQLiteResult.ROW)
                        {
                            id = statement[5].ToString();
                        }
                    }
                    else if (table.Equals("Savings"))
                    {
                        while (statement.Step() == SQLiteResult.ROW)
                        {
                            id = statement[3].ToString();
                        }
                    }
                    else if (table.Equals("DebtLoan"))
                    {
                        while (statement.Step() == SQLiteResult.ROW)
                        {
                            id = statement[3].ToString();
                        }
                    }
                    else if (table.Equals("SmallTransactions"))
                    {
                        while (statement.Step() == SQLiteResult.ROW)
                        {
                            id = statement[4].ToString();
                        }
                    }
                }
            }
            return(id);
        }
Пример #46
0
 public static void createDebtLoanTable()
 {
     using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
     {
         using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS DebtLoan (
                                 Amount DOUBLE(20),
                                 Person NVARCHAR(60),
                                 Description NVARCHAR(200),
                                 ID NVARCHAR(10),
                                 Date NVARCHAR(20),
                                 Debt TINYINT(1),
                                 Acc_ID NVARCHAR(10));"))
         {
             statement.Step();
         }
     }
 }
Пример #47
0
 public static void createSmallTransactionsTable()
 {
     using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
     {
         using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SmallTransactions (
                                 Amount DOUBLE(20),
                                 Description NVARCHAR(200),
                                 Type NVARCHAR(10),
                                 ID NVARCHAR(10),
                                 TransactionID NVARCHAR(10),
                                 Date NVARCHAR(20),
                                 Acc_ID NVARCHAR(10));"))
         {
             statement.Step();
         }
     }
 }
        /// <summary>
        /// Öffnet eine Verbindung zur Datenbank und gibt diese zurück.
        /// </summary>
        /// <returns>Ein SQLiteConnection Objekt.</returns>
        public static SQLiteConnection GetConnection()
        {
            string sqliteFilename = "UlmUniversityNews.db";
            string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename);

            // Erzeuge die Connection.
            var conn = new SQLiteConnection(path);

            // Schalte Foreign-Key Constraints ein.
            string sql = @"PRAGMA foreign_keys = ON";
            using (var statement = conn.Prepare(sql))
            {
                statement.Step();
            }

            return conn;
        }
Пример #49
0
        public static int deleteIDTracking(String id)
        {
            String[] array = id.Split(' ');
            String   idType;

            if (array[0].Equals("ie"))
            {
                idType = "IEID";
            }
            else if (array[0].Equals("sa"))
            {
                idType = "SAID";
            }
            else if (array[0].Equals("dl"))
            {
                idType = "DLID";
            }
            else
            {
                idType = "STID";
            }

            int status = 0;

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"DELETE FROM IDTracking WHERE " + idType + "=?;"))
                {
                    statement.Bind(1, id);
                    SQLiteResult s = statement.Step();

                    if ((s.ToString().Equals("DONE")))
                    {
                        Debug.WriteLine("Step done");
                        status = 1;
                    }
                    else
                    {
                        Debug.WriteLine("Step failed");
                        status = 0;
                    }
                }
            }

            return(status);
        }
Пример #50
0
        /*
        public static void ResetTable()
        {
            using (var connection = new SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Dispose
                {

                }
            }
        }
        */
        public static void CreateTable()
        {
            string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "User.db");

            using (var connection = new SQLiteConnection(path))
            {
                using (var statement = connection.Prepare(@"CREATE TABLE DownloadList (
                                       
                                        FILENAME NVARCHAR(10),
                                        PATH NVARCHAR(1000),
                                        DATE NVARCHAR(100),
                                        SIZE NVARCHAR(100));"))
                {
                    statement.Step();
                }
            }

        }
Пример #51
0
        //Create Tables

        public static void createIncomeExpenseTable()
        {
            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS IncExp (
                                        Name NVARCHAR(50),
                                        Amount DOUBLE(20),
                                        Person NVARCHAR(60),
                                        Category NVARCHAR(60),
                                        Description NVARCHAR(200),
                                        ID NVARCHAR(10),
                                        Date NVARCHAR(20),
                                        Income TINYINT(1),
                                        Acc_ID NVARCHAR(10));"))
                {
                    statement.Step();
                }
            }
        }
Пример #52
0
 public static ObservableCollection<Model.Placar> MontaRanking(int categoria)
 {
     SQLiteConnection con = new SQLiteConnection("quiz.db");
     ObservableCollection<Model.Placar> res = new ObservableCollection<Model.Placar>();
     string strQuery = @"SELECT * FROM Ranking WHERE Categoria = " + categoria + " ORDER BY Pontuação DESC, Chances DESC LIMIT 5;";
     var statement = con.Prepare(strQuery);
     while (statement.Step() == SQLiteResult.ROW)
     {
         Model.Placar obj = new Model.Placar();
         obj.Nome = statement[0].ToString();
         obj.Pontuação = Int32.Parse(statement[1].ToString());
         obj.Chances = Int32.Parse(statement[2].ToString());
         obj.Categoria = Int32.Parse(statement[3].ToString());
         obj.NomeCategoria = statement[4].ToString();
         obj.Data = DateTime.Parse(statement[5].ToString());
         res.Add(obj);
     }
     return res;
 }
Пример #53
0
        public static ObservableCollection <String> getAllIEIDs(String id)
        {
            ObservableCollection <String> list = new ObservableCollection <String>();

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM IDTracking WHERE SAID=?;"))
                {
                    statement.Bind(1, id);
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        list.Add(statement[0].ToString());
                    }
                    statement.Reset();
                    statement.ClearBindings();
                }
            }
            return(list);
        }
Пример #54
0
        public static String findIEID(String otherId, String idType)
        {
            String id = null;

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM IDTracking WHERE " + idType + "=?;"))
                {
                    statement.Bind(1, otherId);
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        if (statement[0] != null)
                        {
                            id = statement[0].ToString();
                        }
                    }
                    statement.Reset();
                    statement.ClearBindings();
                }
            }
            return(id);
        }
Пример #55
0
        public static int insertMoreIDs(String incexpID, String saID, String stID)
        {
            int status = 0;

            try
            {
                using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
                {
                    using (var statement = connection.Prepare(@"INSERT INTO IDTracking (IEID, DLID, SAID, STID)VALUES(?,?,?,?);"))
                    {
                        statement.Bind(1, incexpID);
                        statement.Bind(3, saID);
                        statement.Bind(4, stID);

                        SQLiteResult s = statement.Step();
                        statement.Reset();
                        statement.ClearBindings();

                        if ((s.ToString().Equals("DONE")))
                        {
                            Debug.WriteLine("ID insert step done");
                            status = 1;
                        }
                        else
                        {
                            Debug.WriteLine("ID insert step failed");
                            status = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(status);
        }
Пример #56
0
        public static ObservableCollection <Savings> getSavingsValues()
        {
            ObservableCollection <Savings> list = new ObservableCollection <Savings>();

            using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM Savings;"))
                {
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        list.Add(new Savings()
                        {
                            Name    = (String)statement[0],
                            Goal    = double.Parse(statement[1].ToString()),
                            Initial = double.Parse(statement[2].ToString()),
                            Id      = (String)statement[3],
                            AccID   = (String)statement[4]
                        });
                    }
                }
            }
            return(list);
        }
Пример #57
0
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            String           sSQL    = @"SELECT [DoctorId],[LastNmae],[FirstName],[Specialty],[Phone] from iatroi where [DoctorId] = " + tbId.Text;
            ISQLiteStatement dbstate = dbcoonection.Prepare(sSQL);

            while (dbstate.Step() == SQLiteResult.ROW)
            {
                tbname.Text       = dbstate["LastNmae"] as string + " " + dbstate["FirstName"] as string;
                tbSpeciality.Text = dbstate["Specialty"] as string;
                tbPhone.Text      = dbstate["Phone"] as string;
            }

            var Items = new List <string>();

            sSQL    = @"SELECT [EOF_CODE],[DESCRIPTION],[INCREMET] from DRAGS";
            dbstate = dbcoonection.Prepare(sSQL);
            while (dbstate.Step() == SQLiteResult.ROW)
            {
                Items.Add(dbstate["EOF_CODE"] + " " + dbstate["DESCRIPTION"] + " " + dbstate["INCREMET"]);
            }
            listDrugsDescription.ItemsSource = Items;
        }
Пример #58
0
        //Insert info

        public static int insertIncome(IncExp incExp)
        {
            int    status      = 0;
            String name        = incExp.Name;
            double amount      = incExp.Amount;
            String payer       = incExp.Person;
            String category    = incExp.Category;
            String description = incExp.Description;
            String id          = incExp.Id;

            String[] dateArray = incExp.Date.ToString().Split(' ');
            String   date      = dateArray[0];

            bool isIncome = incExp.Income;
            int  cond     = 0;

            if (isIncome)
            {
                cond = 1;
            }
            String accID = incExp.AccID;

            try
            {
                using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
                {
                    using (var statement = connection.Prepare(@"INSERT INTO IncExp (Name, Amount, Person,
                                                                Category, Description, ID, Date, Income, Acc_ID)
                                    VALUES(?,?,?,?,?,?,?,?,?);"))
                    {
                        statement.Bind(1, name);
                        statement.Bind(2, amount.ToString());
                        statement.Bind(3, payer);
                        statement.Bind(4, category);
                        statement.Bind(5, description);
                        statement.Bind(6, id);
                        statement.Bind(7, date.ToString());
                        statement.Bind(8, cond);
                        statement.Bind(9, accID);


                        SQLiteResult s = statement.Step();
                        statement.Reset();
                        statement.ClearBindings();
                        if ((s.ToString().Equals("DONE")))
                        {
                            Debug.WriteLine("Step done");
                            status = 1;
                        }
                        else
                        {
                            Debug.WriteLine("Step failed");
                            status = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(status);
        }
Пример #59
0
        //Update info

        public static int updateIncome(IncExp incExp)
        {
            int    status      = 0;
            String name        = incExp.Name;
            double amount      = incExp.Amount;
            String payer       = incExp.Person;
            String category    = incExp.Category;
            String description = incExp.Description;
            String id          = incExp.Id;
            String date        = incExp.Date;
            bool   isIncome    = incExp.Income;
            int    cond        = 0;

            if (isIncome)
            {
                cond = 1;
            }
            String accID = incExp.AccID;

            try
            {
                using (var connection = new SQLitePCL.SQLiteConnection("Storage.db"))
                {
                    using (var statement = connection.Prepare(@"UPDATE IncExp SET Name=?, Amount=?, Person=?,
                                                                Category=?, Description=?, ID=?, Date=?, Income=?, Acc_ID=?
                                                                WHERE ID=?;"))
                    {
                        statement.Bind(1, name);
                        statement.Bind(2, amount.ToString());
                        statement.Bind(3, payer);
                        statement.Bind(4, category);
                        statement.Bind(5, description);
                        statement.Bind(6, id);
                        statement.Bind(7, date.ToString());
                        statement.Bind(8, cond);
                        statement.Bind(9, accID);
                        statement.Bind(10, id);


                        SQLiteResult s = statement.Step();
                        statement.Reset();
                        statement.ClearBindings();

                        if ((s.ToString().Equals("DONE")))
                        {
                            Debug.WriteLine("Update done");
                            status = 1;
                        }
                        else
                        {
                            Debug.WriteLine("Update failed");
                            status = 0;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(status);
        }