예제 #1
0
 private void btEnter_Click(object sender, EventArgs e)
 {
     if (nameForm == "SoTienKhoac")
     {
         var     Form       = Application.OpenForms[1];
         TextBox txt_SoTien = Form.Controls["txtNhapLieu"] as TextBox;
         if (!string.IsNullOrEmpty(txt_SoTien.Text))    //check null số tiền nhập vào
         {
             var sotien  = double.Parse(txt_SoTien.Text);
             var account = AccountBUS.getByAccountNo(SoThe);     //lấy thông tin account từ số thẻ chuyển tiền
             if ((account.Balance - 50000 - sotien) > 0)         //kiểm tra số tiền sau khi rút còn đủ 50.000 duy trì thẻ hay không
             {
                 //thực hiện giao dịch
                 if (AccountBUS.RutTien(SoThe, sotien)) //thực hiện rút tiền
                 {
                     InHoaDon_Load();                   //thành công
                 }
                 else
                 {
                     GiaoDienChinh_Load();
                 }
             }
             else
             {
                 GiaoDienChinh_Load();
             }
         }
         else
         {
             RutTien_Load();
         }
     }
     else if (nameForm == "DoiMaPIN")
     {
         var     Form         = Application.OpenForms[1];
         TextBox txt_MaPinMoi = Form.Controls["txtNhapLieu"] as TextBox;
         if (!string.IsNullOrEmpty(txt_MaPinMoi.Text))  //check null nhập mã pin
         {
             var mapinmoi = double.Parse(txt_MaPinMoi.Text);
             if (CardBUS.DoiPin(SoThe, mapinmoi)) //Đổi mã pin
             {
                 DoiMaPINThanhCong_Load();        //thông báo đổi pin thành công
             }
             else
             {
                 DoiMaPINThanhCong_Load();                                            //thông báo đổi pin thất bại
                 var   Form_alert = Application.OpenForms[1];                         //get form hiện tại
                 Label lbl_alert  = Form_alert.Controls["lbl_alert"] as Label;        //get label thông báo thành công
                 lbl_alert.Visible = false;                                           //ẩn label thông báo thành công
                 Label lbl_alert_err = Form_alert.Controls["lbl_alert_err"] as Label; //get label thông báo thất bại
                 lbl_alert.Visible = true;                                            //hiển thị label thông báo thất bại
             }
         }
         else
         {
             DoiMaPIN_Load();   //load lại nhập mà pin
         }
     }
 }
예제 #2
0
 public void btphai3_Click(object sender, EventArgs e)
 {
     if (nameForm.Equals("ChonNgonNgu"))
     {
         DangNhapMaPIN_Load();
     }
     else if (nameForm == "InHoaDon")
     {
         GiaoDichThanhCong_Load();
     }
     else if (nameForm == "RutTien")
     {
         //rút 2.000.000 VNĐ
         var account = AccountBUS.getByAccountNo(SoThe);     //lấy thông tin account từ số thẻ chuyển tiền
         if ((account.Balance - 2050000) > 0)                //kiểm tra số tiền sau khi rút còn đủ 50.000 duy trì thẻ hay không
         {
             //thực hiện giao dịch
             if (AccountBUS.RutTien(SoThe, 2000000)) //thực hiện rút tiền
             {
                 InHoaDon_Load();                    //thành công
             }
             else
             {
                 GiaoDienChinh_Load();
             }
         }
         else
         {
             GiaoDienChinh_Load();
         }
     }
     else if (nameForm.Equals("DangNhapMaPIN"))
     {
         var     Form      = Application.OpenForms[1];                //khởi tạo form đang mở hiện tại
         TextBox txt_MaPin = Form.Controls["txtNhapLieu"] as TextBox; //lấy textbox nhập mã pin
         if (!string.IsNullOrEmpty(txt_MaPin.Text))                   //check null nhập mã pin
         {
             var mapin = double.Parse(txt_MaPin.Text);
             if (CardBUS.ktDangNhap(SoThe, mapin)) //kiểm tra mã pin có đúng không
             {
                 GiaoDienChinh_Load();             //trở về giao diện chính
             }
             else
             {
                 DangNhapMaPIN_Load();   //load lại nhập mà pin
                 var   Form_nhap_ma_pin = Application.OpenForms[1];
                 Label lbl_alert        = Form_nhap_ma_pin.Controls["lbl_alert"] as Label;
                 lbl_alert.Visible = true;
             }
         }
         else
         {
             DangNhapMaPIN_Load();   //load lại nhập mà pin
         }
     }
     else if (nameForm.Equals("XemSoDuTaiKhoan"))
     {
         btHoaDon.BackColor = Color.Gray;
     }
     else if (nameForm.Equals("SoDuTaiKhoan"))
     {
         GiaoDienChinh_Load();
     }
     else if (nameForm.Equals("SaoKeTaiKhoan"))
     {
         GiaoDienChinh_Load();
     }
     else if (nameForm.Equals("ChuyenKhoanThanhCong"))
     {
         GiaoDienChinh_Load();
     }
     else if (nameForm.Equals("GiaoDichThanhCong"))
     {
         GiaoDienChinh_Load();
     }
     else if (nameForm.Equals("DoiMaPINThanhCong"))
     {
         GiaoDienChinh_Load();
     }
     else if (nameForm == "NhapTaiKhoanChuyenDen")
     {
         var     Form           = Application.OpenForms[1];                //khởi tạo form đang mở
         TextBox txt_SoTaiKhoan = Form.Controls["txtNhapLieu"] as TextBox; //lấy textbox nhập số tài khoản chuyển đến
         if (!string.IsNullOrEmpty(txt_SoTaiKhoan.Text))                   //check null số tài khoản
         {
             sothechuyenden = double.Parse(txt_SoTaiKhoan.Text);           //lưu lại số tài khoản chuyển tiền đến
             var account = AccountBUS.getByAccountNo(sothechuyenden);      //lấy thông tin tài khoản chuyển tiền đến
             if (account.AccountNo != null)                                //check null tài khoản chuyển tiền đến
             {
                 NhapSoTienChuyen_Load();                                  //load form nhập số tiền cần chuyển
             }
             else
             {
                 //tài khoản chuyển tiền đến không tồn tại => load lại form nhập tài khoàn chuyển tiền
                 NhapTaiKhoanChuyenDen_Load();
                 var   Form_NhapTaiKhoan = Application.OpenForms[1];
                 Label txt_alert         = Form_NhapTaiKhoan.Controls["lbl_alert"] as Label;
                 txt_alert.Visible = true;
             }
         }
         else
         {
             NhapTaiKhoanChuyenDen_Load();   //load lại form nhập số tài khoản chuyển tiền đến
         }
     }
     else if (nameForm == "NhapSoTienChuyen")
     {
         var     Form             = Application.OpenForms[1];                //khởi tạo form đang mở
         TextBox txt_Sotienchuyen = Form.Controls["txtNhapLieu"] as TextBox; //lấy textbox nhập số tiền chuyển đến
         if (!string.IsNullOrEmpty(txt_Sotienchuyen.Text))                   //check null số tiền chuyển
         {
             if (double.Parse(txt_Sotienchuyen.Text) < 2000)
             {
                 //thông báo số tiền chuyển khoản phải lớn hơn 20,000VNĐ
                 NhapSoTienChuyen_Load();
                 var   Form_Nhapsotien = Application.OpenForms[1];
                 Label txt_alert       = Form_Nhapsotien.Controls["lbl_alert2"] as Label;
                 txt_alert.Visible = true;
             }
             sotienchuyenden = double.Parse(txt_Sotienchuyen.Text); //lưu lại số tiền cần chuyển
             var account = AccountBUS.getByAccountNo(SoThe);        //lấy thông tin account từ số thẻ chuyển tiền
             if (sotienchuyenden <= account.Balance - 50000)        //check điều kiện số tiền chuyển đi <= số tiền trong thẻ - 50.000 duy trì thẻ
             {
                 ThongTinChuyenKhoan_Load();                        //mở form thông tin chuyển khoản
             }
             else
             {
                 //thông báo phải để lại 50.000 duy trì thẻ
                 NhapSoTienChuyen_Load();
                 var   Form_Nhapsotien = Application.OpenForms[1];
                 Label txt_alert       = Form_Nhapsotien.Controls["lbl_alert"] as Label;
                 txt_alert.Visible = true;
             }
         }
         else
         {
             NhapSoTienChuyen_Load();    //load lại form nhập số tiền chuyển khoản
         }
     }
     else if (nameForm == "ThongTinChuyenKhoan")
     {
         NhapSoTienChuyen_Load();
     }
     else if (nameForm == "DangNhapSoTheATM")
     {
         var     Form      = Application.OpenForms[1];                //khởi tạo form đang mở
         TextBox txt_sothe = Form.Controls["txtNhapLieu"] as TextBox; //lấy textbox nhập số thẻ atm
         if (!string.IsNullOrEmpty(txt_sothe.Text))                   //check null số thẻ
         {
             SoThe = double.Parse(txt_sothe.Text);                    //lưu lại số thẻ
             var account = AccountBUS.getByAccountNo(SoThe);          // lấy thông tin account theo số thẻ
             if (account.AccountNo == null)                           //check account có tồn tại hay không
             {
                 DangNhapSoTheATM_Load();                             // load lại form nhập số thẻ
                 var   Form_nhap_so_the = Application.OpenForms[1];
                 Label lbl_alert        = Form_nhap_so_the.Controls["lbl_alert"] as Label;
                 lbl_alert.Visible = true;
             }
             else
             {
                 ChonNgonNgu_Load(); // load form chọn ngôn ngữ
             }
         }
         else
         {
             DangNhapSoTheATM_Load();    // load lại form nhập số thẻ
         }
     }
     return;
 }