Пример #1
0
        public void SaveUpdates()
        {
            var dbHelper = new DatabaseHelper();

            using (var conn = dbHelper.GetDatabaseConnection())
            {
                using (var command = dbHelper.GetSQLiteCommand(conn))
                {
                    string query = "UPDATE ItemsSoldInfo SET DateTimeSold = @dateTime, QuantitySold = @quantity, Cost = @cost, " +
                                   "CostCurrencyID = @costCurrency, Paid = @paid, PaidCurrencyID = @paidCurrency, Change = @change, " +
                                   "ChangeCurrencyID = @changeCurrency, ProfitPerItem = @profit, ProfitPerItemCurrencyID = @profitCurrency, " +
                                   "InventoryItemID = @inventoryID, SoldByUserID = @userID " +
                                   " WHERE ID = @id";
                    command.CommandText = query;
                    command.Parameters.AddWithValue("@dateTime", DateTimeSold.ToString(Utilities.DateTimeToStringFormat()));
                    command.Parameters.AddWithValue("@quantity", QuantitySold);
                    command.Parameters.AddWithValue("@cost", Cost);
                    command.Parameters.AddWithValue("@costCurrency", CostCurrency?.ID);
                    command.Parameters.AddWithValue("@paid", Paid);
                    command.Parameters.AddWithValue("@paidCurrency", PaidCurrency?.ID);
                    command.Parameters.AddWithValue("@change", Change);
                    command.Parameters.AddWithValue("@changeCurrency", ChangeCurrency?.ID);
                    command.Parameters.AddWithValue("@profit", ProfitPerItem);
                    command.Parameters.AddWithValue("@profitCurrency", ProfitPerItemCurrency?.ID);
                    command.Parameters.AddWithValue("@inventoryID", InventoryItemID);
                    command.Parameters.AddWithValue("@userID", SoldByUserID);
                    command.Parameters.AddWithValue("@id", ID);
                    command.ExecuteNonQuery();
                    conn.Close();
                }
            }
        }
Пример #2
0
        public void CreateNewSoldInfo()
        {
            var dbHelper = new DatabaseHelper();

            using (var conn = dbHelper.GetDatabaseConnection())
            {
                using (var command = dbHelper.GetSQLiteCommand(conn))
                {
                    string query = "INSERT INTO ItemsSoldInfo (DateTimeSold, QuantitySold, Cost, CostCurrencyID, " +
                                   "Paid, PaidCurrencyID, Change, ChangeCurrencyID, ProfitPerItem, ProfitPerItemCurrencyID, InventoryItemID, SoldByUserID) " +
                                   " VALUES (@dateTime, @quantity, @cost, @costCurrency, @paid, @paidCurrency, @change, @changeCurrency, @profit, " +
                                   "@profitCurrency, @inventoryID, @userID) ";
                    command.CommandText = query;
                    command.Parameters.AddWithValue("@dateTime", DateTimeSold.ToString(Utilities.DateTimeToStringFormat()));
                    command.Parameters.AddWithValue("@quantity", QuantitySold);
                    command.Parameters.AddWithValue("@cost", Cost);
                    command.Parameters.AddWithValue("@costCurrency", CostCurrency?.ID);
                    command.Parameters.AddWithValue("@paid", Paid);
                    command.Parameters.AddWithValue("@paidCurrency", PaidCurrency?.ID);
                    command.Parameters.AddWithValue("@change", Change);
                    command.Parameters.AddWithValue("@changeCurrency", ChangeCurrency?.ID);
                    command.Parameters.AddWithValue("@profit", ProfitPerItem);
                    command.Parameters.AddWithValue("@profitCurrency", ProfitPerItemCurrency?.ID);
                    command.Parameters.AddWithValue("@inventoryID", InventoryItemID);
                    command.Parameters.AddWithValue("@userID", SoldByUserID);
                    command.ExecuteNonQuery();
                    ID = (int)conn.LastInsertRowId;
                    conn.Close();
                }
            }
        }