예제 #1
0
        private void btnDauHang_Click(object sender, EventArgs e)
        {
            tienThuong = layer02.ChuaHoaTienThuong(getButtonText(number));
            layer02.CapNhapKetQuaNguoiChoi(getTaiKhoanDN(), (number - 1).ToString(), tienThuong);
            GiaoDienNguoiChoi giaoDien = new GiaoDienNguoiChoi(getTaiKhoanDN());

            this.Hide();
            giaoDien.ShowDialog();
            this.Close();
        }
예제 #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            try
            {
                string MatkhauMD5      = MD5.getMd5Hash(txtMatkhau.Text.Trim()); // mã hóa mật khẩu
                bool   KiemTraDangNhap = layer02.Kiemtradangnhap(txtTaikhoan.Text.Trim(), MatkhauMD5);
                int    ChucNang        = layer02.ChucNangNguoiDung(txtTaikhoan.Text.Trim(), MatkhauMD5);

                if (txtTaikhoan.Text.Trim() == "")
                {
                    throw new Taikhoannull();
                }
                if (txtMatkhau.Text.Trim() == "")
                {
                    throw new Matkhaunull();
                }
                if (!KiemTraDangNhap || ChucNang == 0)
                {
                    throw new LoiDangnhap();
                }
                if (ChucNang == 1) // người chơi
                {
                    GiaoDienNguoiChoi GDNC = new GiaoDienNguoiChoi(txtTaikhoan.Text.Trim());
                    this.Hide();
                    GDNC.ShowDialog();
                    this.Close();
                }
                else if (ChucNang == 2) // kỹ thuật viên
                {
                    string MaKTV = layer02.LayMaKyThuatVien(txtTaikhoan.Text.Trim());
                    if (MaKTV != null)
                    {
                        FormKyThuatVien kyThuatVien = new FormKyThuatVien(MaKTV);
                        this.Hide();
                        kyThuatVien.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        throw new MaKTVNULL();
                    }
                }
                else if (ChucNang == 3) // quản lý viên
                {
                    string MaQLV = layer02.LayMaQuanLyVien(txtTaikhoan.Text.Trim());
                    if (MaQLV != null)
                    {
                        FormQuanLyVien formQuanLy = new FormQuanLyVien(MaQLV);
                        this.Hide();
                        formQuanLy.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        throw new MaQLVNULL();
                    }
                }
            }
            catch (LoiDangnhap)
            {
                MessageBox.Show("Đăng Nhập Thất Bại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Form1_Load(sender, e);
            }
            catch (Taikhoannull)
            {
                MessageBox.Show("Không được để trống tài khoản.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Form1_Load(sender, e);
            }
            catch (MaQLVNULL)
            {
                MessageBox.Show("Không phải tài khoản Quan lý viên.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Form1_Load(sender, e);
            }
            catch (MaKTVNULL)
            {
                MessageBox.Show("Không phải tài khoản kỹ thuật viên.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Form1_Load(sender, e);
            }
            catch (Matkhaunull)
            {
                MessageBox.Show("Không được để trống mất khẩu.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Form1_Load(sender, e);
            }
            catch (SqlException sql)
            {
                MessageBox.Show("Đăng Nhập Thất Bại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Console.WriteLine(sql.ToString());
                Form1_Load(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đăng Nhập Thất Bại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Console.WriteLine(ex.ToString());
                Form1_Load(sender, e);
            }
        }