Ejemplo n.º 1
0
        private void btlogin_Click(object sender, EventArgs e)
        {
            TaiKhoanPublic UserA = null;

            try
            {
                TaiKhoanPublic UserB = new TaiKhoanPublic();
                UserB.TENDANGNHAP = tbtendangnhap.Text;
                UserB.MATKHAU     = tbmatkhau.Text;
                TaiKhoanBUS User = new TaiKhoanBUS();

                UserA = User.DangNhap(UserB);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (UserA.TENTAIKHOAN != null)
                {
                    QLBanHang FQL = new QLBanHang(UserA, this.Show);
                    FQL.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Sai ten dang nhap hoac mat khau");
                }
            }
        }
Ejemplo n.º 2
0
        protected void btn_LoginKH_Click(object sender, ImageClickEventArgs e)
        {
            var         username    = tb_KHUsername.Text;
            var         password    = tb_KHPassword.Text;
            TaiKhoanBUS taiKhoanBUS = new TaiKhoanBUS();
            TaiKhoanDTO taiKhoanDTO = taiKhoanBUS.DangNhap(username, password);

            if (taiKhoanDTO != null)
            {
                if (taiKhoanDTO.PhanQuyen == "KH")
                {
                    Session["isLogin"]     = true;
                    Session["TenDangNhap"] = taiKhoanDTO.TenDangNhap;
                    Session["ChucNang"]    = taiKhoanDTO.PhanQuyen;
                    Response.Redirect("KhachHang.aspx");
                }
                else
                {
                    ErrorMessage1.Text    = "Mục này chỉ dành cho khách hàng. Xin hãy kéo xuống";
                    ErrorMessage1.Visible = true;
                }
            }
            else
            {
                Session["isLogin"]    = false;
                ErrorMessage1.Text    = "Sai tên đăng nhập/mật khẩu";
                ErrorMessage1.Visible = true;
            }
        }
Ejemplo n.º 3
0
        private void simpleButton_OK_Click(object sender, EventArgs e)
        {
            TaiKhoanBUS taikhoanBUS = new TaiKhoanBUS();

            MainForm.user = taikhoanBUS.DangNhap(textEdit_TenDangNhap.Text, textEdit_MatKhau.Text);
            if (MainForm.user.TenDangNhap == null)
            {
                XtraMessageBox.Show("Tên Đăng Nhập Hoặc Mật Khẩu Không Chính Xác!\n\nNếu có vấn đề về tài khoản xin liên hệ với người quản trị.", @"Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                XtraMessageBox.Show("Đăng Nhập Thành Công", @"Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 4
0
        protected void btndn_Click(object sender, EventArgs e)
        {
            string TENTK = txtTK.Text;
            string MK    = txtMK.Text;

            if (TaiKhoanBUS.DangNhap(TENTK, MK))
            {
                Response.Write("<script>alert('Đăng nhập thành công!')</script>");
                Response.Redirect("Index.aspx");
            }
            else
            {
                Response.Write("<script>alert('Đăng nhập thất bại!')</script>");
            }
        }
Ejemplo n.º 5
0
        protected void btn_LoginNV_Click(object sender, ImageClickEventArgs e)
        {
            var         username    = tb_NVUsername.Text;
            var         password    = tb_NVPassword.Text;
            TaiKhoanBUS taiKhoanBUS = new TaiKhoanBUS();
            TaiKhoanDTO taiKhoanDTO = taiKhoanBUS.DangNhap(username, password);

            if (taiKhoanDTO != null)
            {
                Session["isLogin"]     = true;
                Session["TenDangNhap"] = taiKhoanDTO.TenDangNhap;
                Session["ChucNang"]    = taiKhoanDTO.PhanQuyen;
                switch (taiKhoanDTO.PhanQuyen)
                {
                case "AD":
                    Response.Redirect("Admin.aspx");
                    break;

                case "NV":
                    Response.Redirect("NhanVienKT.aspx");
                    break;

                case "QL":
                    Response.Redirect("QuanLy.aspx");
                    break;

                case "KT":
                    Response.Redirect("KeToan.aspx");
                    break;

                default:
                    ErrorMessage2.Text    = "Mục này chỉ dành cho nhân viên. Xin hãy kéo lên";
                    ErrorMessage2.Visible = true;
                    break;
                }
            }
            else
            {
                Session["isLogin"]    = false;
                ErrorMessage2.Visible = true;
                ErrorMessage2.Text    = "Sai tên đăng nhập/mật khẩu";
            }
        }
Ejemplo n.º 6
0
        private void btndangnhap_Click(object sender, EventArgs e)
        {
            TaiKhoanBUS taikhoanBUS = new TaiKhoanBUS();
            TaiKhoan    taikhoan    = new TaiKhoan();

            taikhoan.Username = txtusename.Text;
            taikhoan.Password = txtPassword.Text;

            bool thanhcong = taikhoanBUS.DangNhap(taikhoan);

            if (thanhcong)
            {
                dadangnhap       = true;
                frmmain.username = txtusename.Text;
                frmmain.gid      = taikhoanBUS.GetGID(taikhoan);
                Dispose();
            }
            else
            {
                MessageBox.Show("Sai thông tin đăng nhập", "Lỗi đăng nhập", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Cập nhật tài khoản
        /// </summary>
        public void UpdateMatKhau()
        {
            TaiKhoanBUS taiKhoanBUS = new TaiKhoanBUS();
            TaiKhoan    taiKhoan    = taiKhoanBUS.DangNhap(this.textEdit_TenDangNhap.Text, this.textEdit_MatKhau.Text);

            if (taiKhoan == null)
            {
                XtraMessageBox.Show("Mật Khẩu Không Chính Xác!", @"Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (textEdit_MatKhauMoi.Text == textEdit_XacNhanMatKhau.Text)
                {
                    try
                    {
                        taiKhoan = new TaiKhoan(
                            MainForm.user.MaTaiKhoan,
                            this.textEdit_TenDangNhap.Text,
                            this.textEdit_MatKhauMoi.Text,
                            MainForm.user.quyenHan.ToString());


                        taiKhoanBUS.Update(taiKhoan);

                        this.DialogResult = DialogResult.OK;

                        XtraMessageBox.Show("Cập Nhật Thành Công", @"Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, @"Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    XtraMessageBox.Show("Mật Khẩu Không Khớp!", @"Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }