Exemplo n.º 1
0
        public static void SaveCashpointSettings(Settings settings)
        {
            try
            {
                string query = "DELETE Config WHERE Name != 'BackupDestination';";
                query += "INSERT INTO Config (Name, Value) VALUES ('DoPrint', '" + settings.Cashpoint.DoPrint.ToString() + "');";
                query += "INSERT INTO Config (Name, Value) VALUES ('HoldLogoutDuration', '" + settings.Cashpoint.HoldLogoutDuration + "');";
                query += "INSERT INTO Config (Name, Value) VALUES ('IsEnabled', '" + settings.Cashpoint.IsEnabled.ToString() + "');";
                query += "INSERT INTO Config (Name, Value) VALUES ('IsServiceMode', '" + settings.Cashpoint.IsServiceMode.ToString() + "');";
                query += "INSERT INTO Config (Name, Value) VALUES ('OrganizationName', '" + settings.Cashpoint.OrganizationName.ToString() + "');";
                query += "INSERT INTO Config (Name, Value) VALUES ('AutoRefresh', '" + (settings.Cashpoint.IsAutoRefreshEnabled == true ? "Auto" : "Manual") + "');";
                query += "INSERT INTO Config (Name, Value) VALUES ('AutoRefreshInterval', '" + settings.Cashpoint.AutoRefreshInterval.ToString() + "');";

                SqlConnection connection = new SqlConnection(ConnectionString);
                SqlCommand cmd = new SqlCommand(query, connection);
                connection.Open();
                cmd.ExecuteNonQuery();
                connection.Close();
            }
            catch (Exception ex)
            {
                string errmsg = "Fehler beim Speichern der Kasseneinstellungen.\n\n";
                errmsg += "DatabaseHandler.SaveCashpointSettings(settings): " + ex.ToString();
                throw new Exception(errmsg);
            }
        }
Exemplo n.º 2
0
        public static void LoadCashpointSettings(Settings settings)
        {
            Dictionary<string, object> values = new Dictionary<string, object>();

            try
            {
                SqlConnection connection = new SqlConnection(ConnectionString);
                SqlCommand cmd = new SqlCommand("SELECT * FROM Config", connection);
                connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    values.Add(reader["Name"].ToString(), reader["Value"]);
                }
                connection.Close();

                settings.Cashpoint.Initialize(values);
            }
            catch (Exception ex)
            {
                string errmsg = "Fehler beim Abrufen Kasseneinstellungen.\n\n";
                errmsg += "DatabaseHandler.LoadCashpointSettings(settings): " + ex.ToString();
                throw new Exception(errmsg);
            }
        }