Beispiel #1
0
        public AccountingSettings GetAccountingSettings()
        {
            try {
                AccountingSettings result = new AccountingSettings();
                using (DbConnection = new SQLitePersistence(DbConnectionSettings)) {
                    if (DbConnection.IsConnected()) {
                        using (DbCommand = new SQLiteCommand()) {
                            string sql =
                                "SELECT InterfaceId, Setting1, Setting2, Setting3, Setting4, Setting5 from Accounting";

                            DbCommand.CommandText = sql;
                            DataTable returnDT = DbConnection.ExecuteQuery(DbCommand);
                            if (returnDT.Rows.Count > 0) {
                                DataRow row = returnDT.Rows[0];
                                result.InterfaceId = Convert.ToInt32(row["InterfaceId"]);
                                result.Setting1 = row["Setting1"].ToString();
                                result.Setting2 = row["Setting2"].ToString();
                                result.Setting3 = row["Setting3"].ToString();
                                result.Setting4 = row["Setting4"].ToString();
                                result.Setting5 = row["Setting5"].ToString();
                                row = null;
                            }
                            returnDT = null;
                        }
                    }else {
                        throw new Exception("Unable to Connect");
                    }
                }
                return result;
            }catch {
                throw;
            }
        }
Beispiel #2
0
        public int SaveAccountingSettings(AccountingSettings accountingSettings)
        {
            try {
                int result = -1;
                bool isNew = true;
                using (DbConnection = new SQLitePersistence(DbConnectionSettings)) {
                    if (DbConnection.IsConnected()) {
                        using (DbCommand = new SQLiteCommand()) {
                            string sql = "SELECT COUNT(*) AS COUNT FROM Accounting ";

                            DbCommand.CommandText = sql;
                            isNew = Convert.ToBoolean(DbConnection.ExecuteCommand(DbCommand));

                            if (isNew) {
                                sql = "insert into Accounting (InterfaceId,Setting1,Setting2,Setting3,Setting4,Setting5) Values(@InterfaceId,@Setting1,@Setting2,@Setting3,@Setting4,@Setting5)";
                            }else {
                                sql =
                                    @"UPDATE Accounting
                                    SET InterfaceId = @InterfaceId, Setting1 = @Setting1,Setting2 = @Setting2,Setting3 = @Setting3,Setting4 = @Setting4,Setting5 = @Setting5
                                    ";
                            }

                            DbCommand.CommandText = sql;
                            DbCommand.Parameters.Clear();
                            DbCommand.Parameters.AddWithValue("@InterfaceId", accountingSettings.InterfaceId);
                            DbCommand.Parameters.AddWithValue("@Setting1", accountingSettings.Setting1 ?? string.Empty);
                            DbCommand.Parameters.AddWithValue("@Setting2", accountingSettings.Setting2 ?? string.Empty);
                            DbCommand.Parameters.AddWithValue("@Setting3", accountingSettings.Setting3 ?? string.Empty);
                            DbCommand.Parameters.AddWithValue("@Setting4", accountingSettings.Setting4 ?? string.Empty);
                            DbCommand.Parameters.AddWithValue("@Setting5", accountingSettings.Setting5 ?? string.Empty);
                            result = DbConnection.ExecuteCommand(DbCommand);
                        }
                    }else {
                        throw new Exception("Unable to Connect");
                    }
                }
                return result;
            }catch {
                throw;
            }
        }
Beispiel #3
0
 public static void Startup(AccountingSettings settings)
 {
     Vars.ApplicationName = "Etech ServiceHost";
     Vars.AccountingSettings = settings;
     //@"C:\Users\Public\Documents\Intuit\QuickBooks\Company Files\Test Company.qbw";
 }