public void ChargeTimeEntered(object sender, ChargePhone.ChargeTimeEventArgs e) { //Transact PaymentForm = sender as Transact; ChargePhone ChargePhoneForm = sender as ChargePhone; NextStageEventArgs nextStageEvent = new NextStageEventArgs(); EventHandler <NextStageEventArgs> GoToNextHandler = gotoNextStage; if (GoToNextHandler == null) { return; //error } CurrentUIstageState = e_CurrentUIstageState.USER_SELECTED; nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; GoToNextHandler(this, nextStageEvent); //log Status //Check that current STAGE is the slot selection STAGE if (CurrentUIstage == e_CurrentUIstage.CHARGE_TIME_STAGE) { this.CurrentSlotChargeTime = e.ChargeTime; this.MoneyCharged = this.getMoneyCharged(); Console.WriteLine("Passed this part"); CurrentUIstageState = e_CurrentUIstageState.PROCESSING_INPUT; //log Status //Check that the current mode is charging if (ChargingOrRetrieving == e_ChargingOrRetrieving.CHARGING) { // m_Slot[CurrentSlot].setChargeTime(CurrentSlotChargeTime); CurrentUIstage = e_CurrentUIstage.PASSWORD_GENERATION_STAGE; CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT; //log Status nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; GoToNextHandler(this, nextStageEvent); // mainForm.showChargeTimeSTAGE(); //PaymentForm.Hide(); } else { //post error } } }
public void PasswordEntered(object sender, ChargePhone.PasswordEventArgs e) { //Transact PaymentForm = sender as Transact; ChargePhone ChargePhoneForm = sender as ChargePhone; NextStageEventArgs nextStageEvent = new NextStageEventArgs(); EventHandler <NextStageEventArgs> GoToNextHandler = gotoNextStage; if (GoToNextHandler == null) { return; //error } CurrentUIstageState = e_CurrentUIstageState.USER_SELECTED; nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; GoToNextHandler(this, nextStageEvent); //log Status //Check that current STAGE is the slot selection STAGE if (CurrentUIstage == e_CurrentUIstage.PASSWORD_GENERATION_STAGE) { CurrentSlotPassword = e.Password; CurrentUIstageState = e_CurrentUIstageState.PROCESSING_INPUT; //log Status //Check that the current mode is charging if (ChargingOrRetrieving == e_ChargingOrRetrieving.CHARGING) { //m_Slot[CurrentSlot].setChargeTime(CurrentSlotChargeTime); CurrentUIstage = e_CurrentUIstage.PAYMENT_STAGE; CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT; //log Status nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; GoToNextHandler(this, nextStageEvent); //log Status // mainForm.showChargeTimeSTAGE(); //PaymentForm.Hide(); // System.Threading.Thread.Sleep(2000); MoneyReceived = m_MoneyMachine.getMoney(getMoneyCharged()); Console.WriteLine("Received " + MoneyReceived); if (MoneyReceived == 0) //User didn't insert { CurrentUIstageState = e_CurrentUIstageState.USER_ERROR; } else if (MoneyReceived == -1) // { CurrentUIstageState = e_CurrentUIstageState.HARDWARE_ERROR; } else { CurrentUIstageState = e_CurrentUIstageState.DONE; nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; //log Status GoToNextHandler(this, nextStageEvent); Console.WriteLine("Going to Insert Money"); //System.Threading.Thread.Sleep(3000); //dispense change bool result = m_ChangeDispenser.dispenseChange(MoneyReceived - MoneyCharged); CurrentUIstage = e_CurrentUIstage.DISPENSE_CHANGE_STAGE; CurrentUIstageState = e_CurrentUIstageState.GENERATING_FEEDBACK; nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; //log Status GoToNextHandler(this, nextStageEvent); Console.WriteLine("Going to Dispense change"); // System.Threading.Thread.Sleep(3000); if (!result) { CurrentUIstageState = e_CurrentUIstageState.HARDWARE_ERROR; //log error } else { CurrentUIstage = e_CurrentUIstage.PRINT_RECEIPT_STAGE; CurrentUIstageState = e_CurrentUIstageState.GENERATING_FEEDBACK; nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; //log Status GoToNextHandler(this, nextStageEvent); m_Printer.print("Slot Selected is " + CurrentSlot + "\r\n" + "Time is " + DateTime.Now + "\r\n" + "Charge time is " + CurrentSlotChargeTime + "\r\n" + "Password is " + CurrentSlotPassword + "\r\n" + "Money requested was " + MoneyCharged + "\r\n" + "Money received is " + MoneyReceived + "\r\n" + "Change dispensed is " + (MoneyReceived - MoneyCharged) + "\r\n"); CurrentUIstage = e_CurrentUIstage.PRINT_RECEIPT_STAGE; CurrentUIstageState = e_CurrentUIstageState.DONE; nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; GoToNextHandler(this, nextStageEvent); Console.WriteLine("Going to printing"); // System.Threading.Thread.Sleep(2000); //insert device CurrentUIstage = e_CurrentUIstage.INSERT_DEVICE_STAGE; CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT; nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; GoToNextHandler(this, nextStageEvent); Console.WriteLine("Going to Insert device"); // System.Threading.Thread.Sleep(2000); //go to start //insert device CurrentUIstage = e_CurrentUIstage.START_STAGE; CurrentUIstageState = e_CurrentUIstageState.WAITING_FOR_INPUT; nextStageEvent.UI_Stage_State = CurrentUIstageState; nextStageEvent.UI_Stage = CurrentUIstage; GoToNextHandler(this, nextStageEvent); Console.WriteLine("Going to Start"); } } } else { //post error } } }