Exemplo n.º 1
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            double val = 0;

            if (txtNhapMatKhau.Text.Length != 6)
            {
                MessageBox.Show("Mật khẩu phải có 6 kí tự!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (double.TryParse(txtSoThe.Text, out val))
            {
                if (m_dangnhapController.checkDangNhap(txtSoThe, txtNhapMatKhau))
                {
                    GiaoDien.MayATM mainATM = new MayATM();
                    this.Hide();
                    mainATM.Show();
                    return;
                }
                MessageBox.Show("Login Fail!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Mã thẻ không bao gồm chữ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private async void btnDangNhap_Click(object sender, EventArgs e)
        {
            // Tắt tất cả controls khi ấn đăng nhập
            btnDangNhap.Enabled = false;
            btnDangKy.Enabled   = false;

            txtMaSo.Enabled     = false;
            txtPassword.Enabled = false;

            bool flag = false;

            // Mở process bar
            progressBar1.Visible = true;
            progressBar1.Style   = ProgressBarStyle.Marquee;
            progressBar1.MarqueeAnimationSpeed = 30;

            await Task.Run(() =>
            {
                try
                {
                    if (dangNhapController.checkDangNhap(txtMaSo, txtPassword))
                    {
                        this.Invoke(new Action(() => this.Hide()));
                        flag = true;
                    }
                    else
                    {
                        // tắt process bar khi có lỗi
                        progressBar1.Invoke(new Action(() =>
                        {
                            progressBar1.Style = ProgressBarStyle.Continuous;
                            progressBar1.MarqueeAnimationSpeed = 0;
                        }));

                        MessageBox.Show("Không thể đăng nhập!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch
                {
                    progressBar1.Invoke(new Action(() =>
                    {
                        progressBar1.Style = ProgressBarStyle.Continuous;
                        progressBar1.MarqueeAnimationSpeed = 0;
                    }));
                    MessageBox.Show("Không kết nối được với server!");
                }
            });

            // tắt process bar
            progressBar1.Style = ProgressBarStyle.Continuous;
            progressBar1.MarqueeAnimationSpeed = 0;

            if (flag)
            {
                ThongTinSinhVien ttsv = new ThongTinSinhVien();
                ttsv.Show();
            }

            // Xong hết rồi thì hiện lên nếu có lỗi
            btnDangNhap.Enabled = true;
            btnDangKy.Enabled   = true;

            txtMaSo.Enabled     = true;
            txtPassword.Enabled = true;
        }