Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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();
         }
     }
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 public void updateBatteryType(int id, string name, string producer, decimal capacity, decimal exchangeCost)
 {
     BatteryTypeCtr tCtr = new BatteryTypeCtr();
     tCtr.updateRecord(id, name, producer, capacity, exchangeCost);
 }
Esempio n. 5
0
 public List<string> getAllInfoTypes()
 {
     BatteryTypeCtr tCtr = new BatteryTypeCtr();
     return tCtr.getAllInfo();
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 public int addBatteryType(string name, string producer, decimal capacity, decimal exchangeCost)
 {
     BatteryTypeCtr tCtr = new BatteryTypeCtr();
     return tCtr.addNewRecord(name, producer, capacity, exchangeCost);
 }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
 public void deleteBatteryType(int id)
 {
     BatteryTypeCtr tCtr = new BatteryTypeCtr();
     tCtr.deleteRecord(id);
 }