// press ENTER in state cash transfer money private void pressEnterCashTransferMoney() { if (CashTransfer.Instance.getTextBoxMoneyTransfer().Equals("")) { return; } bool checkMoney = accountBUL.compareBalance(Convert.ToInt32(CashTransfer.Instance.getTextBoxMoneyTransfer()), lbCardNo.Text); if (!checkMoney) { if (!panelMain.Controls.Contains(Fail.Instance)) { panelMain.Controls.Add(Fail.Instance); Fail.Instance.Dock = DockStyle.Fill; Fail.Instance.BringToFront(); } else { Fail.Instance.BringToFront(); } Fail.Instance.showErrorMoney(); state = "fail"; } else { bool checkSuccess = accountBUL.updateBalance(Convert.ToInt32(CashTransfer.Instance.getTextBoxMoneyTransfer()) , lbCardNo.Text, CashTransfer.Instance.getTextBoxCardNoTo()); if (!checkSuccess) { if (!panelMain.Controls.Contains(Fail.Instance)) { panelMain.Controls.Add(Fail.Instance); Fail.Instance.Dock = DockStyle.Fill; Fail.Instance.BringToFront(); } else { Fail.Instance.BringToFront(); } state = "fail"; } else { if (!panelMain.Controls.Contains(Success.Instance)) { panelMain.Controls.Add(Success.Instance); Success.Instance.Dock = DockStyle.Fill; Success.Instance.BringToFront(); } else { Success.Instance.BringToFront(); } state = "success"; createLog("logtype02", Convert.ToInt32(CashTransfer.Instance.getTextBoxMoneyTransfer()) , CashTransfer.Instance.getTextBoxCardNoTo(), lbCardNo.Text, "atm01", "Thành công"); } } }
private async void btnEnter_Click(object sender, EventArgs e) { if (state.Equals("ValidateCard")) { cardNo = txtCardNo.Text; checkCardNo(); } else if (state.Equals("ValidatePin")) { checkPIN(); } else if (state.Equals("CheckChangePIN")) { checkChangePIN(); } else if (state.Equals("ChangePIN")) { confirmChangePIN(); } else if (state.Equals("ConfirmChangePIN")) { changePIN(); } else if (state.Equals("ChangePINSuccess")) { createLog("LT004", "ATM001", getTextBoxCardNo(), 0, "Success", ""); state = "OtherTransaction"; addUserControl(OtherTransaction.Instance); } else if (state.Equals("CustomWithdraw")) { int money = CustomWithDraw.Instance.getTextBoxCustomWithDraw(); withdraw(money); } else if (state.Equals("CashTransferCard")) { transfer(); } else if (state.Equals("CashTransferEnterMoney")) { checkMoneyTransfer(); } else if (state.Equals("CashTransferMoneySuccess")) { Success.Instance.setLabelBalance(accountBUL.updateBalance( Convert.ToInt32(CashTransfer.Instance.getTextBoxMoney()), CashTransfer.Instance.getTextBoxCardNo(), CashTransfer.Instance.getTextBoxCardNoTo(), 3300) + ""); createLog("LT002", "ATM001", CashTransfer.Instance.getTextBoxCardNo(), Convert.ToInt32(CashTransfer.Instance.getTextBoxMoney()), "Chuyển khoản thành công", CashTransfer.Instance.getTextBoxCardNoTo()); addUserControl(Success.Instance); state = "AgreeBill"; } else if (state.Equals("AgreeBill")) { addUserControl(Bill.Instance); exportReceipt.exportReceiptCashTransfer( CashTransfer.Instance.getTextBoxCardNo(), CashTransfer.Instance.getTextBoxCardNoName(), CashTransfer.Instance.getTextBoxCardNoTo(), CashTransfer.Instance.getTextBoxCardNoToName(), Convert.ToInt32(CashTransfer.Instance.getTextBoxMoney()) ); await Task.Delay(3000); addUserControl(OtherTransaction.Instance); state = "AgreeTransaction"; } else if (state.Equals("AgreeTransaction")) { CashTransfer.Instance.clearTextBoxCardNo(); CashTransfer.Instance.clearTextBoxCardNoName(); CashTransfer.Instance.clearTextBoxCardNoTo(); CashTransfer.Instance.clearTextBoxCardNoToName(); CashTransfer.Instance.clearTextBoxMoney(); addUserControl(ListService.Instance); state = "ListService"; } else if (state.Equals("CashTransMoneyferFail1")) { Fail.Instance.clearLabel1(); Fail.Instance.clearLabel2(); Fail.Instance.clearLabel3(); Fail.Instance.setLabel1("Xin lỗi, giao dịch không thành công"); Fail.Instance.setLabel2("Xin vui lòng kiểm tra lại"); Fail.Instance.setLabel3("(Không được phép chuyển tiền vào tài khoản USD)"); Fail.Instance.ShowErrorChangLog(); addUserControl(Fail.Instance); state = "DisagreeBill1"; } else if (state.Equals("CashTransMoneyferFail2")) { Fail.Instance.clearLabel1(); Fail.Instance.clearLabel2(); Fail.Instance.clearLabel3(); Fail.Instance.setLabel1("Số tiền trong TK không đủ cho giao dịch rút tiền\n"); Fail.Instance.setLabel2("\t\tSố dư hiện có trong tài khoản :\n" + accountBUL.getBalanceInt(CashTransfer.Instance.getTextBoxCardNo())); Fail.Instance.ShowErrorChangLog(); addUserControl(Fail.Instance); state = "DisagreeBill2"; } }