public JsonResult ListTaiKhoan()
        {
            NguoiDungDAO user = new NguoiDungDAO();
            var          list = user.ListOf();

            return(Json(list, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Edit(NguoiDung nguoiDung)
        {
            if (ModelState.IsValid)
            {
                var ndDAO = new NguoiDungDAO();


                var nd = db.NguoiDungs.Find(nguoiDung.MaNguoiDung);

                if (nguoiDung.UploadHinhAnh != null)
                {
                    string fileName = Path.GetFileName(nguoiDung.UploadHinhAnh.FileName);
                    string filePath = "~/Assets/Admin/img/" + fileName;
                    nguoiDung.UploadHinhAnh.SaveAs(Server.MapPath(filePath));

                    nd.HinhAnh = fileName;
                }

                ndDAO.Edit(nguoiDung);
                db.SaveChanges();

                return(RedirectToAction("Profile"));
            }
            return(View(nguoiDung));
        }
예제 #3
0
        //Rút trích dữ liệu: select
        public static List <NguoiDungDTO> LayDSNguoiDung()
        {
            List <NguoiDungDTO> _ds;

            _ds = NguoiDungDAO.LayDSNguoiDung();
            return(_ds);
        }
예제 #4
0
        public NguoiDungDTO layThongTinNguoiDung(String strTDN, String strMK)
        {
            NguoiDungDAO dao = new NguoiDungDAO();
            NguoiDungDTO dto = dao.layThongTinNguoiDung(strTDN, strMK);

            return(dto);
        }
        public ActionResult ProfileById(int id)
        {
            var ndDAO     = new NguoiDungDAO();
            var nguoidung = ndDAO.getById(id);

            return(View(nguoidung));
        }
        public ActionResult TaiKhoan()
        {
            var ndDAO     = new NguoiDungDAO();
            var nguoidung = ndDAO.getByTaiKhoan(Session["TAIKHOAN"].ToString());

            return(View(nguoidung));
        }
예제 #7
0
        public BindingList <NguoiDungDTO> LayDanhSach()
        {
            // Kiem tra Business Rule neu co
            BindingList <NguoiDungDTO> danhSach = new BindingList <NguoiDungDTO>();
            NguoiDungDAO itemDAO = new NguoiDungDAO();

            danhSach = itemDAO.LayDanhSach();
            return(danhSach);
        }
예제 #8
0
        public ActionResult DeleteItemGH(int idSP, int idDDH)
        {
            GioHangDAO   ghDAO = new GioHangDAO();
            NguoiDungDAO ndDAO = new NguoiDungDAO();
            NguoiDung    nd    = ndDAO.getByTaiKhoan(Session["TAIKHOAN"].ToString());

            ghDAO.deleteGH(idSP, idDDH, (List <GioHangModel>)Session["GIOHANG"]);

            return(RedirectToAction("Index"));
        }
예제 #9
0
        public ActionResult AddSP(int idSP)
        {
            List <GioHangModel> gh    = (List <GioHangModel>)Session["GIOHANG"];
            NguoiDungDAO        ndDAO = new NguoiDungDAO();
            var       ghDAO           = new GioHangDAO();
            NguoiDung nd = ndDAO.getByTaiKhoan(Session["TAIKHOAN"].ToString());

            Session["GIOHANG"] = ghDAO.addGH(nd.MaNguoiDung, idSP, gh);

            return(RedirectToAction("Index"));
        }
        public ActionResult Login(FormCollection f)
        {
            NguoiDungDAO tk   = new NguoiDungDAO();
            string       user = f["user"].ToString();
            string       pass = f["password"].ToString();

            if (tk.Login(user, pass))
            {
                var nguoidung = tk.GetNguoiDungById(user);
                Session["taikhoan"] = nguoidung;
                return(RedirectToAction("Index", "NguoiDung"));
            }
            return(RedirectToAction("Index", "Home"));
        }
예제 #11
0
        // GET: GioHang
        public ActionResult Index()
        {
            NguoiDungDAO ndDAO = new NguoiDungDAO();
            GioHangDAO   ghDAO = new GioHangDAO();

            NguoiDung nd = ndDAO.getByTaiKhoan(Session["TAIKHOAN"].ToString());

            Session["GIOHANG"] = ghDAO.getGioHangByND(nd.MaNguoiDung);

            int tongDDH   = ghDAO.getTongSPByND(nd.MaNguoiDung);
            int tongGTDDH = ghDAO.getTongGTDDHByND(nd.MaNguoiDung);

            Session.Add("DDH", tongDDH);
            Session.Add("GIATRIDDH", tongGTDDH);

            return(View((List <GioHangModel>)Session["GIOHANG"]));
        }
        public ActionResult DangKy(FormCollection f)
        {
            NguoiDungDAO nd   = new NguoiDungDAO();
            NguoiDung    user = new NguoiDung();

            user.TaiKhoan = f["user"];
            user.Email    = f["email"];
            user.MatKhau  = f["pass"];
            if (nd.Login(user.TaiKhoan, user.MatKhau))
            {
            }
            else
            {
                nd.AddNew(user);
                Session["taikhoan"] = user;
            }
            return(RedirectToAction("Index", "NguoiDung"));
        }
예제 #13
0
        public Trangchu(string account)
        {
            InitializeComponent();
            this.account = account;
            string name   = NguoiDungDAO.GetHoTenByUser(account);
            int    chucvu = NguoiDungDAO.GetPhanQuyenByUser(account);
            string loaind = NguoiDungDAO.GetLoaiNguoiDungByUser(account);

            LabelName.Content   = name;
            LabelChucVu.Content = loaind;
            if (chucvu == 3)
            {
                btnKhachHang.Visibility       = Visibility.Hidden;
                btnQuanLyPhong.Visibility     = Visibility.Hidden;
                btnQuanLyLoaiPhong.Visibility = Visibility.Hidden;
                btnDichVu.Visibility          = Visibility.Hidden;
            }
        }
예제 #14
0
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         var ndDAO  = new NguoiDungDAO();
         var result = ndDAO.Login(model.taikhoan, model.matkhau);
         if (result)
         {
             var taikhoan = model.taikhoan;
             Session.Add("TAIKHOAN", taikhoan);
             return(RedirectToAction("Index", "test"));
         }
         else
         {
             ModelState.AddModelError("", "Đăng nhập không thành công.");
         }
     }
     return(View("Index"));
 }
        public ActionResult DangKy(SignupModel model)
        {
            var ndDAO = new NguoiDungDAO();

            if (ModelState.IsValid)
            {
                if (ndDAO.checkData(model))
                {
                    ndDAO.InsertND(model);
                    return(RedirectToAction("Login"));
                }
                else
                {
                    ModelState.AddModelError("", "Đăng ký không thành công, tài khoản hoặc số điện thoại đã tồn tại");
                }
            }

            return(View(model));
        }
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var ndDAO = new NguoiDungDAO();
                var ghDAO = new GioHangDAO();

                var result = ndDAO.Login(model.taikhoan, model.matkhau);
                if (result)
                {
                    var    nguoidung = ndDAO.getByTaiKhoan(model.taikhoan);
                    var    taikhoan  = model.taikhoan;
                    string hinhanh   = nguoidung.HinhAnh;
                    int    tongDDH   = ghDAO.getTongSPByND(nguoidung.MaNguoiDung);
                    int    tongGTDDH = ghDAO.getTongGTDDHByND(nguoidung.MaNguoiDung);

                    Session.Add("TAIKHOAN", taikhoan);
                    Session.Add("HINHANH", hinhanh);
                    Session.Add("DDH", tongDDH);
                    Session.Add("GIATRIDDH", tongGTDDH);

                    NguoiDung nd = ndDAO.getByTaiKhoan(model.taikhoan);
                    Session["GIOHANG"] = ghDAO.getGioHangByND(nd.MaNguoiDung);

                    if (nguoidung.MaLND == 1)
                    {
                        return(RedirectToAction("Index", "Home", new { area = "Admin" }));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "TrangChu"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Đăng nhập không thành công.");
                }
            }
            return(View("Login"));
        }
        public ActionResult UpdateThongTinCaNhan(FormCollection f, HttpPostedFileBase file)
        {
            string fileName;

            if (file != null)
            {
                fileName  = Path.GetFileNameWithoutExtension(file.FileName);
                fileName += Path.GetExtension(file.FileName);
                string folderPath = Server.MapPath("~") + @"Assets/avatar";

                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }

                string path = Path.Combine(folderPath, fileName);

                file.SaveAs(path);
            }
            else
            {
                fileName = "";
            }


            NguoiDungDAO nd = new NguoiDungDAO();

            int id     = Convert.ToInt32(f["id"]);
            var detail = nd.Detail(id);

            detail.DiaChi       = f["diachi"];
            detail.TaiKhoan     = f["taikhoan"];
            detail.TenNguoiDung = f["ten"];
            detail.Email        = f["email"];
            detail.AnhDaiDien   = fileName;
            Session["taikhoan"] = detail;
            nd.UpdateThongTinCaNhan(detail);
            return(RedirectToAction("ThongTinCaNhan", "NguoiDung"));
        }
예제 #18
0
        public bool KiemTraDangNhap(string tenDangNhap, string matKhau)
        {
            NguoiDungDAO itemDAO      = new NguoiDungDAO();
            NguoiDungDTO nguoiDungDTO = itemDAO.KiemTraDangNhap(tenDangNhap, matKhau);

            if (nguoiDungDTO.Id > 0)
            {
                if (nguoiDungDTO.VoHieu == true)
                {
                    return(true);
                }
                else
                {
                    KiemTraThoiGian iThoiGian = new KiemTraThoiGian();
                    return(iThoiGian.KiemTraKhoangThoiGianDMY(nguoiDungDTO.NgayBatDau, nguoiDungDTO.NgayKetThuc));
                }
            }
            else
            {
                return(false);
            }
        }
 public static int EditEmployee(NguoiDungDTO employee)
 {
     if (employee.NhanVienBanHang == "True")
     {
         employee.NhanVienBanHang = "1";
         employee.NhanVienNhapKho = "0";
         employee.QuanLi          = "0";
     }
     if (employee.NhanVienNhapKho == "True")
     {
         employee.NhanVienBanHang = "0";
         employee.NhanVienNhapKho = "1";
         employee.QuanLi          = "0";
     }
     if (employee.QuanLi == "True")
     {
         employee.NhanVienBanHang = "0";
         employee.NhanVienNhapKho = "0";
         employee.QuanLi          = "1";
     }
     return(NguoiDungDAO.editEmployee(employee));
 }
예제 #20
0
파일: frmlogin.cs 프로젝트: viethuy20/git
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            NguoiDungDTO nd = new NguoiDungDTO();

            nd.TenNguoiDung = txtTaiKhoan.Text;
            nd.MatKhau      = txtMatKhau.Text;
            nd.PhanQuyen    = cmbphanquyen.Text;
            bool isLogin = NguoiDungDAO.KiemTraNguoiDung(nd);

            if (isLogin == true)
            {
                this.Hide();
                frmmain f1 = new frmmain();
                f1.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Bạn đã nhập sai tên người dùng, mật khẩu hoặc quyền đăng nhập!", "Cảnh báo");
                txtTaiKhoan.Text = "";
                txtMatKhau.Text  = "";
            }
        }
예제 #21
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string UserName = inputUsername.Text;
            string Password = inputPassword.Password.ToString();

            Password = HashPassword.hash(Password);
            //bool check = NguoiDungDAO.CheckTaiKhoan(UserName, Password);
            string GetPassword = NguoiDungDAO.GetMatKhauByUser(UserName);

            if (!Password.Equals(GetPassword))
            {
                MessageBox.Show("Sai tài khoản hoặc mật khẩu!\nVui lòng nhập lại...");
            }
            else
            //MessageBox.Show("Đăng nhập thành công!");
            {
                //string HoTen = NguoiDungDAO.GetHoTenByUser(UserName);

                Trangchu tc = new Trangchu(UserName);
                //Trangchu tc = new Trangchu();
                tc.Show();
                this.Close();
            }
        }
예제 #22
0
 public static void XoaNguoiDung(NguoiDungDTO ndDTO)
 {
     NguoiDungDAO.XoaNguoiDung(ndDTO);
 }
예제 #23
0
 public static bool AdminThemNguoiDung(NguoiDungDTO ndDTO)
 {
     return(NguoiDungDAO.AdminThemNguoiDung(ndDTO));
 }
예제 #24
0
 public static DataTable LayThongTinNguoiDungVuaDangKi(NguoiDungDTO ndDTO)
 {
     return(NguoiDungDAO.LayThongTinNguoiDungVuaDangKi(ndDTO));
 }
예제 #25
0
 public static void SuaThongTin(NguoiDungDTO ndDTO)
 {
     NguoiDungDAO.SuaThongTin(ndDTO);
 }
예제 #26
0
 public static DataTable LayDanhSachNguoiDung()
 {
     return(NguoiDungDAO.LayDanhSachNguoiDung());
 }
예제 #27
0
 public static bool ktraAdmin(NguoiDungDTO ndDTO)
 {
     return(NguoiDungDAO.ktraAdmin(ndDTO));
 }
예제 #28
0
 public static void DoiMatKhau(NguoiDungDTO ndDTO)
 {
     NguoiDungDAO.DoiMatKhau(ndDTO);
 }
예제 #29
0
 public static string LayMatKhau(NguoiDungDTO ndDTO)
 {
     return(NguoiDungDAO.LayMatKhau(ndDTO));
 }
예제 #30
0
 public static bool ktraQuenMatKhau(NguoiDungDTO ndDTO)
 {
     return(NguoiDungDAO.ktraQuenMatKhau(ndDTO));
 }