Ejemplo n.º 1
0
        private void FillInfo(BaseBike bike)
        {
            rentBikeInfoPnl.Visible = true;
            this.bike = bike;
            rentBikeInfoQrCodeTxt.Text = bike.QRCode;
            int deposit = bike.CalculateDeposit();

            rentBikeInfoDepositTxt.Text = String.Format("{0:n0}", deposit);
        }
 /// <summary>
 /// Handle click event PermitBut when process pay rental money transaction
 /// </summary>
 private async void PermitButWhenPay()
 {
     try
     {
         if (card == null)
         {
             card = rentBikeController.GetCardInformation("Group 13");
         }
         if (this.deposit == 0)
         {
             this.deposit = bike.CalculateDeposit();
         }
         InterbankResponse response = null;
         Transaction       transaction;
         if (this.deposit == this.rentalMoney)
         {
             transaction = returnBikeController.UpdatePaymentTransaction(bike.BikeId, this.rentalMoney);
             returnBikeController.UpdateStationAfterReturnbike(this.stationId, bike.BikeId);
             MessageBox.Show("giao dịch thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             homePageForm.Show(this);
             this.Hide();
             return;
         }
         if (this.deposit < this.rentalMoney)
         {
             response = await paymentController.Pay(card, this.rentalMoney - this.deposit, DateTime.Now, "Pay Rental Money");
         }
         else if (this.deposit > this.rentalMoney)
         {
             response = await paymentController.Refund(card, this.deposit - this.rentalMoney, DateTime.Now, "Refund deposit");
         }
         string error = response.errorCode;
         transaction = returnBikeController.UpdatePaymentTransaction(bike.BikeId, this.rentalMoney);
         returnBikeController.UpdateStationAfterReturnbike(this.stationId, bike.BikeId);
         MessageBox.Show("giao dịch thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         homePageForm.Show(this);
         this.Hide();
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }