public void AddNewHardware() { Hardware aHardware = new Hardware(0) { Enabled = false }; hardwareRepository.Add(aHardware); Hardwares = CollectionViewSource.GetDefaultView(hardwareRepository.GetAll()); NotifyPropertyChanged("Hardwares"); }
public bool Remove(Hardware entity) { bool removed = false; if (data.ContainsKey(entity.ID)) { data.Remove(entity.ID); removed = true; } return removed; }
public bool Add(Hardware entity) { bool added = false; if (entity.ID == 0) { entity.SetID(InsertHardware(entity)); } if (!data.ContainsKey(entity.ID)) { data.Add(entity.ID, entity); if (AddedHardware != null) { AddedHardware(entity); } added = true; } return added; }
private Hardware BuildHardware(Panic.Repository.Linq.Hardware aHardware) { Hardware hardware = new Hardware(aHardware.HardwareID) { Enabled = (bool)aHardware.Enabled, Description = aHardware.Description, Make = aHardware.Make, ModelNumber = aHardware.ModelNumber, RXCapacity = (double)aHardware.RXCapacity, TXCapacity = (double)aHardware.TXCapacity, Notes = aHardware.Notes }; return hardware; }
private int InsertHardware(Hardware aHardware) { int lastID = 0; string query = string.Format(@"INSERT INTO HARDWARE (Description, Make, ModelNumber, TXCapacity, RXCapacity, Enabled, Notes) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", aHardware.Description, aHardware.Make, aHardware.ModelNumber, aHardware.TXCapacity, aHardware.RXCapacity, aHardware.Enabled, aHardware.Notes); SqlCeCommand command = new SqlCeCommand(query, connection); connection.Open(); int result = command.ExecuteNonQuery(); if (result > 0) { SqlCeCommand command1 = new SqlCeCommand("select @@identity ", connection); lastID = Convert.ToInt32(command1.ExecuteScalar()); } connection.Close(); return lastID; }