Exemplo 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;
 }
Exemplo n.º 2
0
 public bool deleteBookingForStation(int sId, int btId, int quantity, DateTime time)
 {
     bool success = false;
     IDBBatteryStorage dbStorage = new DBBatteryStorage();
     MBatteryStorage storage = dbStorage.getRecord(btId, sId, true);
     IDPeriod dbPeriod = new DBPeriod();
     PeriodCalculator pCalc = new PeriodCalculator();
     try
     {
         MPeriod period = pCalc.getBookingPeriod(storage, time);
         period.bookedBatteryNumber = period.bookedBatteryNumber - quantity;
         dbPeriod.updateRecord(storage.id, period.time, period.initBatteryNumber, period.bookedBatteryNumber);
         success = true;
     }
     catch (Exception)
     {
         throw new SystemException("Can not delete Booking");
     }
     return success;
 }
Exemplo n.º 3
0
 public bool validateUpdateBookingForStation(int sId, int btId, int updateQuantity, DateTime time)
 {
     bool validate = false;
     IDBBatteryStorage dbStorage = new DBBatteryStorage();
     MBatteryStorage storage = dbStorage.getRecord(btId, sId, true);
     PeriodCalculator pCalc = new PeriodCalculator();
     MPeriod period = pCalc.getBookingPeriod(storage, time);
     MPeriod previous = pCalc.getPreviousPeriod(storage, period);
     MPeriod next = pCalc.getNextPeriod(storage, period);
     int booked = period.bookedBatteryNumber + previous.bookedBatteryNumber;
     int available = period.initBatteryNumber - booked;
     int futureBooked = period.bookedBatteryNumber + next.bookedBatteryNumber;
     int futureAvailable = next.initBatteryNumber - futureBooked;
     if (available >= updateQuantity && futureAvailable >= updateQuantity)
     {
         validate = true;
     }
     return validate;
 }
Exemplo n.º 4
0
 public void updateRecord(int id, int btid, int sID, int storageNumber)
 {
     IDBBatteryStorage dbStorage = new DBBatteryStorage();
     dbStorage.updateRecord(id, btid, sID, storageNumber);
     IDPeriod dbPeriod = new DBPeriod();
     PeriodCalculator pCalc = new PeriodCalculator();
     MPeriod period = pCalc.getBookingPeriod(getRecord(id,true),DateTime.Now);
     List<MPeriod> periods = pCalc.getAllPeriodsAfter(getRecord(id, true), period);
     foreach (MPeriod p in periods)
     {
         dbPeriod.updateRecord(id, p.time, pCalc.getInitNumber(getRecord(id, true)));
     }
 }