protected void BtnSua_Click(object sender, EventArgs e)
        {
            BUSNguoiDung NguoiDungBUS = new BUSNguoiDung();
            NGUOIDUNG a = ((NGUOIDUNG)Session["LOGIN"]);
            if (TxbHoTen.Text == "" || TxbEmail.Text == "")
            {
                lThongTin.Text = "Cập nhật không thành công do bạn chưa nhập Họ tên hoặc Email";
            }
            else
            {
                a.HoTen = TxbHoTen.Text.Trim();
                a.Email = TxbEmail.Text.Trim();

                NguoiDungBUS.CapNhat(a);

                lThongTin.Text = "Cập nhật thành công";
            }

            //             a.HoTen = TxbHoTen.Text;
            //             a.Email = TxbEmail.Text;

            /*    NguoiDungBUS.CapNhat(a);*/

              /*          lThongTin.Text = "Cập nhật thành công";             */
        }
        protected void btLayMatKhau_Click(object sender, EventArgs e)
        {
            if (txtMSSV.Text == "")
            {
                txtThongTin.Text = "Vui lòng nhập MSSV";
                txtThongTin.Visible = true;
                return;
            }

            if (txtEmail.Text == "")
            {
                txtThongTin.Text = "Vui lòng nhập địa chỉ Email";
                txtThongTin.Visible = true;
                return;
            }

            BUSNguoiDung busnguoidung = new BUSNguoiDung();

            NGUOIDUNG sv = busnguoidung.TimKiemTheoUsernameVaEmail(txtMSSV.Text, txtEmail.Text);

            if (sv == null)
            {
                txtThongTin.Text = "MSSV hoặc email không đúng, vui lòng nhập lại.";
            }
            else
            {
                sv.Password = txtMSSV.Text;

                busnguoidung.CapNhat(sv);

                txtThongTin.Text = "Mật khẩu mới của bạn là " + txtMSSV.Text;
            }

            txtThongTin.Visible = true;
        }
 private void LoadMaNguoiDung()
 {
     //string tempMa = Request.QueryString["id"];
     int MaND = ((NGUOIDUNG)Session["LOGIN"]).MaNguoiDung;
     BUSNguoiDung NguoiDungBUS = new BUSNguoiDung();
     NGUOIDUNG NguoiDung = NguoiDungBUS.TimKiem(MaND);
     if (NguoiDung != null)
     {
         TxbHoTen.Text = NguoiDung.HoTen;
         TxbEmail.Text = NguoiDung.Email;
     }
 }
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            try
            {
                //lay thong tin tu textbox
                NGUOIDUNG lpDTO = new NGUOIDUNG();
                lpDTO.MaNguoiDung  = MaNguoiDung;
                lpDTO.Username = txtmasinhvien.Text;
                lpDTO.Password  = txtpass.Text;
                lpDTO.HoTen  = txthoten.Text;
                lpDTO.Email  = txtemail.Text;
                lpDTO.MaVaiTro = int.Parse(txtvaitro.Text);

                //Goi ham cap nhat
                BUSNguoiDung BUSNguoiDung = new BUSNguoiDung();
                if (txtpass.ReadOnly)
                {
                    if (BUSNguoiDung.CapNhatWhitOutPass(lpDTO) == 0)
                    {
                        //Thong bao
                        lbThongBao.Text = "Cập Nhật Thành Công";
                        lbThongBao.Visible = true;
                        Response.Redirect("NguoiDung.aspx?id=" + MaNguoiDung.ToString());
                    }
                    else
                    {
                        lbThongBao.Text = "Cập Nhật Không Thành Công";
                        lbThongBao.Visible = true;
                    }
                }
                else
                {
                    if (BUSNguoiDung.CapNhat(lpDTO) == 0)
                    {
                        //Thong bao
                        lbThongBao.Text = "Cập Nhật Thành Công";
                        lbThongBao.Visible = true;
                        Response.Redirect("NguoiDung.aspx?id=" + MaNguoiDung.ToString());
                    }
                    else
                    {
                        lbThongBao.Text = "Cập Nhật Không Thành Công";
                        lbThongBao.Visible = true;
                    }
                }
            }

            catch
            {
                lbThongBao.Text = "Cập nhật Không Thành Công";
                lbThongBao.Visible = true;
            }
        }
Пример #5
0
        //protected void btDangNhap_Click(object sender, EventArgs e)
        //{
        //    int id;
        //    if (Request.QueryString["id"] != null)
        //    {
        //        id = int.Parse(Request.QueryString["id"]);
        //    }
        //    else
        //    {
        //        id = 0;
        //    }
        //    BUSNguoiDung BUSNguoiDung = new BUSNguoiDung();
        //    NGUOIDUNG NGUOIDUNG = new NGUOIDUNG();
        //    NGUOIDUNG = BUSNguoiDung.TimKiem(txtusername.Text, txtpassword.Text);
        //    if (NGUOIDUNG != null)
        //    {
        //        if (NGUOIDUNG.MaVaiTro == 3)
        //        {
        //            Session["QUANLY"] = NGUOIDUNG;
        //            Response.Redirect(redirect[id]);
        //        }
        //        else
        //        {
        //            LabelError.Text = "Moi ban dang nhap lai!";
        //        }
        //    }
        //    else
        //    {
        //        LabelError.Text = "Moi ban dang nhap lai!";
        //    }
        //}
        protected void LoginAdmin_Authenticate(object sender, AuthenticateEventArgs e)
        {
            int id;
            if (Request.QueryString["id"] != null)
            {
                id = int.Parse(Request.QueryString["id"]);
            }
            else
            {
                id = 0;
            }
            BUSNguoiDung BUSNguoiDung = new BUSNguoiDung();
            NGUOIDUNG NGUOIDUNG = new NGUOIDUNG();

            NGUOIDUNG = BUSNguoiDung.TimKiem(LoginAdmin.UserName, LoginAdmin.Password);

            if (NGUOIDUNG != null)
            {
                if (NGUOIDUNG.MaVaiTro == 3)
                {
                    Application.Lock();
                    HttpContext.Current.Session["QUANLY"] = NGUOIDUNG.Username;
                    Application.UnLock();
                    Response.Redirect(redirect[id]);
                }
                else
                {
                    if (NGUOIDUNG.MaVaiTro == 4)
                    {
                        Application.Lock();
                        HttpContext.Current.Session["ADMIN"] = NGUOIDUNG.Username;
                        Application.UnLock();
                        Response.Redirect(redirect[id]);
                    }
                    else
                    {
                        LoginAdmin.InstructionText = "Bạn phải đăng nhập bằng tài khoảng Quản Lý!";
                    }

                }
            }
            else
            {
                LoginAdmin.InstructionText = "Bạn phải đăng nhập bằng tài khoảng Quản Lý!";
            }
        }
        //Load
        public int LoadSinhVien()
        {
            List<NGUOIDUNG_getallResult> lt = new List<NGUOIDUNG_getallResult>();

            BUSNguoiDung BUSNguoiDung = new BUSNguoiDung();

            lt = BUSNguoiDung.SelectNGUOIDUNGsAll ();
            if (lt.Count > 0)
            {
                this.GridViewSinhVien.DataSource = lt;
                GridViewSinhVien.DataBind();
                PanelDanhSach.Visible = true;
                PanelMessage.Visible = false;
                return lt.Count;
            }
            else
            {
                PanelDanhSach.Visible = false;
                PanelMessage.Visible = true;
                return 0;
            }
        }
        protected void btXacNhan_Click(object sender, EventArgs e)
        {
            string szTenDangNhap = (Session["LOGIN"] as string);

            if (szTenDangNhap != null)
            {
                BUSNguoiDung NguoiDungBUS = new BUSNguoiDung();

                NGUOIDUNG sv = NguoiDungBUS.TimKiem(int.Parse(szTenDangNhap));

                if (txtHoTen.Text != null)
                    sv.HoTen = txtHoTen.Text;

                if (txtEmail.Text != null)
                    sv.Email = txtEmail.Text;

                NguoiDungBUS.CapNhat(sv);

                lThongTin.Text = "Cập nhật thành công";
            }
            else
                lThongTin.Text = "Cập nhật thất bại";
        }
        protected void WriteDataGridView(ExcelCOM.Worksheet worksheet)
        {
            int rowIndex = 4;
            int colIndex = 1;

            for (int i = 0; i < GridViewDangKyHoatDong.Rows.Count; i++)
            {
                for (int j = 0; j < GridViewDangKyHoatDong.Columns.Count; j++)
                {
                    WriteData(worksheet, i + rowIndex, j + colIndex, GridViewDangKyHoatDong.Rows[i].Cells[j].Text);
                }

                BUSNguoiDung busnguoidung = new BUSNguoiDung();
                NGUOIDUNG nguoidung = busnguoidung.TimKiem(GridViewDangKyHoatDong.Rows[i].Cells[1].Text);
                WriteData(worksheet, i + rowIndex, 3, nguoidung.HoTen);
            }
        }
Пример #9
0
        protected void btThayDoi_Click(object sender, EventArgs e)
        {
            /*BUSNguoiDung busnguoidung = new BUSNguoiDung();

            string szTenDangNhap = ((NGUOIDUNG)Session["LOGIN"]).Username;

            if (szTenDangNhap != null)
            {
                NGUOIDUNG sv = busnguoidung.TimKiem(szTenDangNhap);

                if (sv.Password.Trim() == txtMatKhauCu.Text)
                {
                    if (txtMatKhauMoi.Text == "")
                    {
                        txtThongTin.Text = "Mật khẩu mới không hợp lệ.";
                    }
                    else
                        if (txtMatKhauMoi.Text != txtXacNhan.Text)
                        {
                            txtThongTin.Text = "Vui lòng xác nhận lại mật khẩu mới.";
                        }
                        else
                        {
                            sv.Password = txtMatKhauMoi.Text;
                            busnguoidung.CapNhat(sv);
                            txtThongTin.Text = "Cập nhật mật khẩu thành công.";
                        }
                }
                else
                {
                    txtThongTin.Text = "Mật khẩu cũ không đúng";
                }

                txtThongTin.Visible = true;
            }
            else
            {
                txtThongTin.Text = "Vui lòng đăng nhập";
                txtThongTin.Visible = true;
            }*/
            #region Long Sửa 13/8
            BUSNguoiDung busnguoidung = new BUSNguoiDung();

            string szTenDangNhap = ((NGUOIDUNG)Session["LOGIN"]).Username;

            if (szTenDangNhap != null)
            {
                NGUOIDUNG sv = busnguoidung.TimKiem(szTenDangNhap);
                string encryptedPwd = busnguoidung.EncryptPassword(txtMatKhauCu.Text);

                if (sv.Password.Trim() == encryptedPwd)
                {
                    if (txtMatKhauMoi.Text == "")
                    {
                        txtThongTin.Text = "Mật khẩu mới không hợp lệ.";
                    }
                    else
                        if (txtMatKhauMoi.Text != txtXacNhan.Text)
                        {
                            txtThongTin.Text = "Vui lòng xác nhận lại mật khẩu mới.";
                        }
                        else
                        {
                            sv.Password = txtMatKhauMoi.Text;
                            busnguoidung.CapNhat(sv);
                            txtThongTin.Text = "Cập nhật mật khẩu thành công.";
                        }
                }
                else
                {
                    txtThongTin.Text = "Mật khẩu cũ không đúng";
                }

                txtThongTin.Visible = true;
            }
            else
            {
                txtThongTin.Text = "Vui lòng đăng nhập";
                txtThongTin.Visible = true;
            }
            #endregion
        }
Пример #10
0
        protected void LoginAdmin_Authenticate(object sender, AuthenticateEventArgs e)
        {
            BUSNguoiDung BUSNguoiDung = new BUSNguoiDung();
            NGUOIDUNG NGUOIDUNG = new NGUOIDUNG();

            NGUOIDUNG = BUSNguoiDung.TimKiem(LoginAdmin.UserName, LoginAdmin.Password);

            if (NGUOIDUNG != null)
            {
                if (NGUOIDUNG.LOAIVAITRO.TenLoaiVaiTro == "Quản Lý")
                {
                    HttpCookie myCookie = new HttpCookie("myCookie");
                    Response.Cookies.Remove("myCookie");
                    Response.Cookies.Add(myCookie);
                    myCookie.Values.Add("username", NGUOIDUNG.Username);
                    myCookie.Values.Add("role", "quanly");

                    if (LoginAdmin.RememberMeSet == true)
                    {
                        DateTime dtExpiry = DateTime.Now.AddDays(3);
                        Response.Cookies["myCookie"].Expires = dtExpiry;
                    }
                    else
                    {
                        DateTime dtExpiry = DateTime.Now.AddMinutes(20);
                        Response.Cookies["myCookie"].Expires = dtExpiry;
                    }
                    Response.Redirect(redirect);
                }
                else
                {
                    if (NGUOIDUNG.LOAIVAITRO.TenLoaiVaiTro == "Admin" || NGUOIDUNG.LOAIVAITRO.TenLoaiVaiTro == "Quản lý")
                    {
                        HttpCookie myCookie = new HttpCookie("myCookie");
                        Response.Cookies.Remove("myCookie");
                        Response.Cookies.Add(myCookie);
                        myCookie.Values.Add("username", NGUOIDUNG.Username);
                        myCookie.Values.Add("role", "admin");
                        if (LoginAdmin.RememberMeSet == true)
                        {
                            DateTime dtExpiry = DateTime.Now.AddDays(3);
                            Response.Cookies["myCookie"].Expires = dtExpiry;
                        }
                        else
                        {
                            DateTime dtExpiry = DateTime.Now.AddMinutes(20);
                            Response.Cookies["myCookie"].Expires = dtExpiry;
                        }
                        Response.Redirect(redirect);
                    }
                    else
                    {
                        LoginAdmin.InstructionText = "Bạn phải đăng nhập bằng tài khoảng Quản Lý!";
                    }
                }
            }
            else
            {
                LoginAdmin.InstructionText = "Bạn phải đăng nhập bằng tài khoảng Quản Lý!";
            }
        }
        protected void btnThem_Click(object sender, EventArgs e)
        {
            try
            {
                //lay thong tin tu textbox
                NGUOIDUNG lpDTO = new NGUOIDUNG();
             //   lpDTO.MaNguoiDung = 0;
                lpDTO.Username = txtmasinhvien.Text;
                lpDTO.Password = txtpass.Text;
                lpDTO.HoTen = txthoten.Text;
                lpDTO.Email = txtemail.Text;
                lpDTO.MaVaiTro = int.Parse(txtvaitro.Text);

                //Goi ham cap nhat
                BUSNguoiDung BUSNguoiDung = new BUSNguoiDung();
                if (BUSNguoiDung.Them(lpDTO) == 1)
                {
                    //Thong bao
                    lbThongBao.Text = "Thêm Thành Công";
                    lbThongBao.Visible = true;
                    Response.Redirect("NguoiDung.aspx");
                }
                else
                {
                    lbThongBao.Text = "Thêm Không Thành Công";
                    lbThongBao.Visible = true;
                }
            }

            catch
            {
                lbThongBao.Text = "Thêm Không Thành Công";
                lbThongBao.Visible = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Thong tin nguoi dung
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    //lay ma
                    MaNguoiDung = int.Parse(Request.QueryString["id"]);

                    //lay thong tin va load len cac textbox
                    BUSNguoiDung BUSNguoiDung = new BUSNguoiDung();
                    NGUOIDUNG lpDTO = BUSNguoiDung.TimKiem(MaNguoiDung);
                    txtmasinhvien.Text = lpDTO.Username;
                    txtpass.Text = lpDTO.Password;
                    txthoten.Text = lpDTO.HoTen;
                    txtemail.Text = lpDTO.Email;
                    txtvaitro.Text = lpDTO.MaVaiTro.ToString();
                }
            }
        }
        protected void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                BUSNguoiDung BUSNguoiDung = new BUSNguoiDung();
                NGUOIDUNG lpDTO = BUSNguoiDung.TimKiem(MaNguoiDung);

                    //Goi ham xoa
                    if (BUSNguoiDung.Xoa(MaNguoiDung) == 0)
                    {
                        //Thong bao
                        lbThongBao.Text = "Xóa Thành Công";
                        lbThongBao.Visible = true;
                        Response.Redirect("NguoiDung.aspx");
                    }
                    else
                    {
                        lbThongBao.Text = "Xóa Không Thành Công";
                        lbThongBao.Visible = true;
                    }

            }

            catch
            {
                lbThongBao.Text = "Xóa Không Thành Công";
                lbThongBao.Visible = true;
            }
        }