public int addNewRecord(int btID, int sID, int storageNumber) { IDBBatteryStorage dbStorage = new DBBatteryStorage(); BatteryTypeCtr bCtr = new BatteryTypeCtr(); int id = dbStorage.addNewRecord(btID, sID, storageNumber); PeriodCalculator pCalc = new PeriodCalculator(); pCalc.createFirstPeriod(id); return id; }
public void deleteRecordByType(int btID) { IDBBatteryStorage dbStorage = new DBBatteryStorage(); int bsID = dbStorage.getRecordByType(btID, true).id; BatteryTypeCtr bCtr = new BatteryTypeCtr(); bool success = false; using (TransactionScope scope = new TransactionScope()) { try { deleteRecord(bsID); bCtr.deleteRecord(btID); success = true; } catch (Exception) { throw new System.NullReferenceException("Can not delete battery."); //throw new SystemException("Can not find battery type"); } if (success) { scope.Complete(); } } }
public BatteryType getBatteryType(int id) { BatteryTypeCtr tCtr = new BatteryTypeCtr(); MBatteryType type = tCtr.getRecord(id, true); BatteryType bt = new BatteryType(); if (type != null) { bt.ID = type.id; bt.name = type.name; bt.producer = type.producer; bt.capacity = (int)type.capacity; bt.exchangeCost = (int)type.exchangeCost; } return bt; }
public void updateBatteryType(int id, string name, string producer, decimal capacity, decimal exchangeCost) { BatteryTypeCtr tCtr = new BatteryTypeCtr(); tCtr.updateRecord(id, name, producer, capacity, exchangeCost); }
public List<string> getAllInfoTypes() { BatteryTypeCtr tCtr = new BatteryTypeCtr(); return tCtr.getAllInfo(); }
public List<BatteryType> getAllBatteryTypes() { BatteryTypeCtr tCtr = new BatteryTypeCtr(); List<MBatteryType> types = tCtr.getAllRecord(true); List<BatteryType> bts = new List<BatteryType>(); foreach (MBatteryType type in types) { BatteryType bt = new BatteryType(); bt.ID = type.id; bt.name = type.name; bt.producer = type.producer; bt.capacity = (int)type.capacity; bt.exchangeCost = (int)type.exchangeCost; bts.Add(bt); } return bts; }
public int addBatteryType(string name, string producer, decimal capacity, decimal exchangeCost) { BatteryTypeCtr tCtr = new BatteryTypeCtr(); return tCtr.addNewRecord(name, producer, capacity, exchangeCost); }
public List<BatteryType> getAllBatteryType() { List<BatteryType> bts = new List<BatteryType>(); BatteryTypeCtr btCtr = new BatteryTypeCtr(); List<MBatteryType> bt = btCtr.getAllRecord(false); if (bt.Count != 0) { foreach (MBatteryType b in bt) { BatteryType btt = new BatteryType(); btt.ID = b.id; btt.name = b.name; btt.price = Convert.ToDouble(b.exchangeCost); bts.Add(btt); } } return bts; }
public void deleteBatteryType(int id) { BatteryTypeCtr tCtr = new BatteryTypeCtr(); tCtr.deleteRecord(id); }