예제 #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;
 }
예제 #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();
         }
     }
 }
예제 #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;
 }
예제 #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);
 }
예제 #5
0
 public List<string> getAllInfoTypes()
 {
     BatteryTypeCtr tCtr = new BatteryTypeCtr();
     return tCtr.getAllInfo();
 }
예제 #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;
 }
예제 #7
0
 public int addBatteryType(string name, string producer, decimal capacity, decimal exchangeCost)
 {
     BatteryTypeCtr tCtr = new BatteryTypeCtr();
     return tCtr.addNewRecord(name, producer, capacity, exchangeCost);
 }
예제 #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;
        }
예제 #9
0
 public void deleteBatteryType(int id)
 {
     BatteryTypeCtr tCtr = new BatteryTypeCtr();
     tCtr.deleteRecord(id);
 }