/*Working with user*/
 static public void InsertUser(User income)
 {
     if (SQConnection != null)
     {
         SQConnection.Insert(income);
     }
 }
Esempio n. 2
0
 /*Working with products*/
 static public void InsertAlcohol(Alcohol income)
 {
     if (SQConnectionAlcohol != null)
     {
         SQConnectionAlcohol.Insert(income);
     }
 }
 /*Working with products*/
 static public void InsertProduct(Product income)
 {
     if (SQConnectionProduct != null)
     {
         SQConnectionProduct.Insert(income);
     }
 }
Esempio n. 4
0
 public void AddToTable()
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var s = db.Insert(this);
     }
 }
        public NewGame()
        {
            this.InitializeComponent();
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            conn.CreateTable<Game>();

            var add = conn.Insert(game);
            Debug.WriteLine(path);
        }
Esempio n. 6
0
 public static void Insert(Object _Obj)
 {
     using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
     {
         conn.RunInTransaction(() =>
         {
             conn.Insert(_Obj);
         });
     }
 }
        private async void AddData(object sender, RoutedEventArgs e)
        {
            Checkout nnn = new Checkout();

            try
            {
                //string CDay = DateStamp.Date.Value.Day.ToString();
                //string CMonth = DateStamp.Date.Value.Month.ToString();
                //string CYear = DateStamp.Date.Value.Year.ToString();
                //string FinalDate = "" + CMonth + "/" + CDay + "/" + CYear;

                if (Desc.Text == "")
                {
                    MessageDialog dialog = new MessageDialog("Not entered Debt name");
                    await dialog.ShowAsync();
                }
                else
                {
                    double Money  = Convert.ToDouble(MoneyIn.Text);
                    double Dmoney = 0 - Money;
                    conn.Insert(new Appointments()
                    {
                        ApptName   = Desc.Text,
                        DebtAmount = Dmoney
                    });
                }
                Results();
            }
            catch (Exception ex)
            {
                if (ex is FormatException)
                {
                    MessageDialog dialog = new MessageDialog("You forgot to enter the Value or entered an invalid data", "Oops..!");
                    await dialog.ShowAsync();
                }
                else if (ex is SQLiteException)
                {
                    MessageDialog dialog = new MessageDialog("A Similar Debt Name already exists, try different name", "Oops..!");
                    await dialog.ShowAsync();
                }
            }
        }
        public NewGame()
        {
            this.InitializeComponent();
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            conn.CreateTable <Game>();

            var add = conn.Insert(game);

            Debug.WriteLine(path);
        }
Esempio n. 9
0
 //Adds a new record to the Sales table.
 public void AddRecordToTable()
 {
     if (Items != null && Date != null)
     {
         using (var db = new SQLite.Net.SQLiteConnection(new
                                                         SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
         {
             var s = db.Insert(this);
         }
     }
 }
Esempio n. 10
0
        public static string AddRecord(int age)
        {
            Console.WriteLine("Creating database, if it doesn't already exist");

            SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();

            string dbPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                "ormdemo.db3");

            var db = new SQLite.Net.SQLiteConnection(plat, dbPath);

            //db.CreateTable<Stock>();

            //if (db.Table<Stock>().Count() == 0)
            {
                // only insert the data if it doesn't already exist
                var newStock = new Stock();
                newStock.Symbol = "AAPL" + age.ToString();
                db.Insert(newStock);
                newStock        = new Stock();
                newStock.Symbol = "GOOG" + age.ToString();
                db.Insert(newStock);
                newStock        = new Stock();
                newStock.Symbol = "MSFT" + age.ToString();
                db.Insert(newStock);
            }
            Console.WriteLine("Reading data");
            var    table = db.Table <Stock>();
            string data  = string.Empty;

            foreach (var s in table)
            {
                Console.WriteLine(s.Id + " " + s.Symbol);

                data += s.Id + " " + s.Symbol + " :: ";
            }

            return(data);
        }
Esempio n. 11
0
 public static async Task InsertAsync(Object _Obj)
 {
     await Task.Run(() =>
     {
         using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH))
         {
             conn.RunInTransaction(() =>
             {
                 conn.Insert(_Obj);
             });
         }
     });
 }
Esempio n. 12
0
 private static void CreateDatabase()
 {
     try
     {
         string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
         System.IO.Directory.CreateDirectory(folderPath);
         string databaseFilePath = System.IO.Path.Combine(folderPath, "FinancialProfile.db");
         using (var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS(), databaseFilePath))
         {
             db.CreateTable <FinancialProfileDomain>();
             if (db.Table <FinancialProfileDomain>().Count() == 0)
             {
                 var FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "When is your birthday?",
                     DataType = "DateTime"
                 };
                 db.Insert(FinancialProfile);
                 var question = db.Get <FinancialProfileDomain>(1);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "What is your net worth?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "How much do you make each month after taxes including 1099, w2, 401k, and ira contributions?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "How much do you spend each month on your house?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "How much do you spend each month on your car?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "How much do you spend each month on everything else?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
             }
         }
     }
     catch (SQLiteException ex)
     {
         var t = ex;
     }
 }
Esempio n. 13
0
 private void Add_Page(object sender, RoutedEventArgs e)
 {
     try
     {
         var page = connect.Insert(new Page()
         {
             date        = DateResult.Text,
             image       = ImageResult.Source.ToString(),
             title       = TitleResult.Text,
             description = ContentResult1.Text,
         });
     }catch (Exception ex)
     {
     }
 }
Esempio n. 14
0
 //Inserts a new customer if the customer is not already in the table, if it is, it updates it.
 public void AddToTable()
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         //Look for customer in table
         Customer returnedCustomer = (from s in db.Table <Customer>() where s.Id.Equals(Id) select s).FirstOrDefault();
         if (returnedCustomer != null)
         {
             //Add new items to items in items column.
             this.Items = returnedCustomer.Items + "\r(" + DateTime.Now.ToLocalTime().ToString("d") + ")\r" + this.Items;
             db.Update(this);
         }
         else
         {
             db.Insert(this);
         }
     }
 }
Esempio n. 15
0
 public void AddMobile(string macAddress, string name, DateTime lastConnectionDate, string lastState)
 {
     Debug.WriteLine("Add Mobile to DB : " + macAddress + " " + name + " " + lastConnectionDate.ToString() + " " + lastState);
     try
     {
         var s = new Mobile {
             MACAddress = macAddress, Name = name, LastConnectionDate = lastConnectionDate, LastState = lastState
         };
         using (SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), this.DB_PATH))
         {
             conn.RunInTransaction(() =>
             {
                 conn.Insert(s);
             });
         }
         //conn.DeleteAll<Message> ();
     }
     catch
     {
         Debug.WriteLine("ERROR : Unable to add Message");
     }
 }
Esempio n. 16
0
 //Adds a new sale to the Sales table and to SalesByDay table. Updates customer if necessary.
 public void AddToTable()
 {
     Items = ItemsString;
     Date  = DateTime.Now;
     Total = TotalValue;
     //Insert new sale to Sale Table
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var s = db.Insert(this);
     }
     //Add each item in the cart to the sale of the day table and delete from the inventory.
     foreach (UniqueItem ui in CartList)
     {
         ui.DeleteFromInventory();
     }
     //If there is a customer set, add as debt instead.
     if (Customer != null)
     {
         foreach (UniqueItem ui in CartList)
         {
             ui.AddToSalesByDayAsDebt();
         }
         //Set all customer properties.
         Customer.Date  = DateTime.Now;
         Customer.Debt  = Customer.Debt + TotalValue;
         Customer.Total = Customer.PayedDebt - Customer.Debt;
         Customer.Items = ItemsString;
         Customer.AddToTable();
     }
     else
     {
         foreach (UniqueItem ui in CartList)
         {
             ui.AddToSalesByDay();
         }
     }
 }
Esempio n. 17
0
 public static SalesByDay Today()
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         String today = DateTime.Now.ToLocalTime().ToString("s").Substring(2, 8);
         new SalesByDay();
         var query = (from s in db.Table <SalesByDay>() where s.Day == today select s).FirstOrDefault();
         if (query == null)
         {
             SalesByDay newDay = new SalesByDay()
             {
                 Day = today, ItemsString = String.Empty, Total = 0, TotalOwed = 0
             };
             db.Insert(newDay);
             return(SalesByDay.Today());
         }
         else
         {
             return(query);
         }
     }
 }
Esempio n. 18
0
 public void Insert(Contato contato)
 {
     _connection.Insert(contato);
 }
Esempio n. 19
0
 public void Add(ItemCardapio itemCardapio)
 {
     sqlConnection.Insert(itemCardapio);
 }
Esempio n. 20
0
 public void AddBookToDB(Book book)
 {
     con.Insert(book);
 }
Esempio n. 21
0
 public void Insert <T>(T model)
 {
     connection.Insert(model);
 }
 public void Insert(Cliente cliente)
 {
     _conexao.Insert(cliente);
 }
Esempio n. 23
0
        SQLite.Net.SQLiteConnection conn;   //data connection

        /// <summary>
        /// Creates the database.
        /// </summary>
        public int createDatabase()
        {
            //create database local file name "HD_db.sqlite.sqlite"
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "HD_db.sqlite");
            if (!File.Exists(path))
            {
                //create database
                conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
                //Thêm bảng
                conn.CreateTable<Model_CHI_TIET_VAY_CHOVAY>();
                conn.CreateTable<Model_GHI_CHEP>();
                conn.CreateTable<Model_GUI_TIET_KIEM>();
                conn.CreateTable<Model_HANG_MUC_CHI>();
                conn.CreateTable<Model_HANG_MUC_CHI_CHA>();
                conn.CreateTable<Model_HANG_MUC_THU>();
                conn.CreateTable<Model_HANG_MUC_THU_CHA>();
                conn.CreateTable<Model_LOAI_TAI_KHOAN>();
                conn.CreateTable<Model_LOAI_TIEN>();
                conn.CreateTable<Model_TAI_KHOAN>();
                conn.CreateTable<Model_THIET_LAP>();
                conn.CreateTable<Model_USERS>();
                conn.CreateTable<Model_VAY_NGAN_HANG>();
                //Thêm record
                try
                {
                    EncryptPassword pass = new EncryptPassword();
                    conn.Insert(new Model_USERS()
                    {
                        Email = "*****@*****.**",
                        FirstName = "Heo Đất",
                        LastName = "Admin",
                        Password = pass.encrypt("admin"),
                        Type = "Admin",
                        Status = true
                    });
                    Debug.WriteLine("[QLTC] đã thêm admin");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("[QLTC] " + ex.Message);
                }

                try
                {
                    var listHangMucChiCha = new List<Model_HANG_MUC_CHI_CHA>()
                    {
                        new Model_HANG_MUC_CHI_CHA() {TenHangMucChiCha= "Trang phục"},
                        new Model_HANG_MUC_CHI_CHA() {TenHangMucChiCha="Ăn uống" }
                    };

                    foreach (var item in listHangMucChiCha)
                    {
                        conn.Insert(item);
                    }


                    var listHangMucChi = new List<Model_HANG_MUC_CHI>()
                    {
                        new Model_HANG_MUC_CHI() {IdHangMucChi=0, IdHangMucChiCha=1,TenHangMucChi="Quần áo",ChinhSuaHangMucChi=false,GhiChuHangMucChi="Mua sắm quần áo" },
                        new Model_HANG_MUC_CHI() {IdHangMucChi=1, IdHangMucChiCha=1,TenHangMucChi="Giầy dép",ChinhSuaHangMucChi=false,GhiChuHangMucChi="Mua sắm giầy dép" },
                        new Model_HANG_MUC_CHI() {IdHangMucChi=2, IdHangMucChiCha=1,TenHangMucChi="Khác",ChinhSuaHangMucChi=false,GhiChuHangMucChi="Mua sắm" },
                        new Model_HANG_MUC_CHI() {IdHangMucChi=3, IdHangMucChiCha=2,TenHangMucChi="Đi chợ/Siêu thị",ChinhSuaHangMucChi=false,GhiChuHangMucChi="Đi chợ, siêu thị" },
                        new Model_HANG_MUC_CHI() {IdHangMucChi=4, IdHangMucChiCha=2,TenHangMucChi="Ăn tiệm",ChinhSuaHangMucChi=false,GhiChuHangMucChi="Ăn tiệm" }
                    };

                    foreach (var item in listHangMucChi)
                    {
                        conn.Insert(item);
                    }


                }
                catch (Exception ex)
                {
                    Debug.WriteLine("[QLTC] " + ex.Message);
                }
            }
            else // if file exist
            {
                conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            }

            return 1;
        }