Пример #1
0
        /// <summary>
        /// Lädt die Supplies eines Druckers aus der Datenbank
        /// </summary>
        /// <param name="printer">
        /// Das Drucker Objekt<remarks>Benötigt Datenbank Id</remarks></param>
        /// <returns>Die Liste der Verbrauchsteile</returns>
        public List<Supply> GetSupplyList(Printer printer)
        {
            List<Supply> supplies = new List<Supply>();

            using (IDbConnection connection = DatabaseInterface.CreateConnection(ConnectionString))
            using (IDbCommand command = DatabaseInterface.CreateCommand("SELECT * FROM supplies WHERE printerId = @PrinterId ORDER BY id", connection))
            {
                command.Parameters.Add(DatabaseInterface.CreateParameter("@PrinterId", printer.Id));
                connection.Open();
                //read the supplies
                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Supply newSupply = new Supply 
                        { 
                            Id = int.Parse(reader["id"].ToString()), 
                            Description = reader["description"].ToString(), 
                            Value = double.Parse(reader["value"].ToString()), 
                            GlobalAlertTriggered = bool.Parse(reader["globalAlertTriggered"].ToString()), 
                            NotificationValue = int.Parse(reader["notificationValue"].ToString()), 
                            Notified = bool.Parse(reader["notified"].ToString()), 
                            NotifyWhenLow = bool.Parse(reader["notifyWhenLow"].ToString()),
                        };

                        supplies.Add(newSupply);
                    }
                    return supplies;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Legt das Druckerobjekt und den Verbrauchsgegenstand fest
 /// </summary>
 /// <param name="supply">Der Verbrauchsgegenstand für den niedriger Füllstand auftrat</param>
 /// <param name="printer"></param>
 public SupplyEventArgs(Printer printer, Supply supply)
 {
     Printer = printer;
     Supply = supply;
 }