Example #1
0
        public ActionResult LoginAccount(FormCollection collection)
        {
            var tendn   = collection["TEN_DANGNHAP"];
            var matkhau = collection["MATKHAU"];

            if (string.IsNullOrEmpty(tendn))
            {
                ViewData["Loi1"] = "Username not empty";
            }
            else if (string.IsNullOrEmpty(matkhau))
            {
                ViewData["Loi2"] = "Password not empty";
            }
            else
            {
                TAIKHOANKHACHHANG kh = db.TAIKHOANKHACHHANGs.SingleOrDefault(n => n.TEN_DANGNHAP == tendn && n.MATKHAU == matkhau);
                if (kh != null)
                {
                    db.Configuration.ValidateOnSaveEnabled = false;
                    THONGTINKHACHHANG tt = db.THONGTINKHACHHANGs.SingleOrDefault(t => t.ID_TTKH == kh.ID_TTKH);
                    Session["TEN_DANGNHAP"]    = tt.TEN_KHACHHANG;
                    Session["ID_TTKH"]         = tt.ID_TTKH;
                    Session["EMAIL_KHACHHANG"] = tt.EMAIL_KHACHHANG;
                    Session["DIACHI"]          = tt.DIACHI;
                    Session["SO_DIENTHOAI"]    = tt.SO_DIENTHOAI;
                    return(RedirectToAction("Index", "uHome"));
                }
                else
                {
                    ViewBag.ThongBao = "Username or password is incorrect";
                }
            }
            return(View());
        }
        public THONGTINKHACHHANG InFO(string email)
        {
            var tt = new THONGTINKHACHHANG();

            tt.KhachHang = context.KHACH_HANG.Find(email);
            object[] sqlParams =
            {
                new SqlParameter("@Email", email),
            };
            tt.ThanhToan = context.Database.SqlQuery <THANH_TOAN>("SP_ThanhToan_List @Email", sqlParams).ToList();

            return(tt);
        }
Example #3
0
 public ActionResult Create(THONGTINKHACHHANG tt)
 {
     try
     {
         tt.TONG_TIEUDUNG = 0;
         db.THONGTINKHACHHANGs.Add(tt);
         db.SaveChanges();
         Session["TEN_KHACHHANG"]   = tt.TEN_KHACHHANG;
         Session["ID_TTKH"]         = tt.ID_TTKH;
         Session["EMAIL_KHACHHANG"] = tt.EMAIL_KHACHHANG;
         Session["DIACHI"]          = tt.DIACHI;
         Session["SO_DIENTHOAI"]    = tt.SO_DIENTHOAI;
         return(RedirectToAction("ShowCart", "ShoppingCart"));
     }
     catch
     {
         return(View());
     }
 }
Example #4
0
 public ActionResult RegisterUser(TAIKHOANKHACHHANG _user, THONGTINKHACHHANG tt)
 {
     if (ModelState.IsValid)
     {
         var check_ID = db.TAIKHOANKHACHHANGs.Where(s => s.ID_KHACHHANG == _user.ID_KHACHHANG)
                        .FirstOrDefault();
         if (check_ID == null)
         {
             db.Configuration.ValidateOnSaveEnabled = false;
             db.THONGTINKHACHHANGs.Add(tt);
             _user.ID_TTKH = tt.ID_TTKH;
             db.TAIKHOANKHACHHANGs.Add(_user);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.ErrorRegister = "This ID is exist";
             return(View());
         }
     }
     return(View());
 }
Example #5
0
        public ActionResult Edit(THONGTINKHACHHANG tt)
        {
            int id = (int)Session["ID_TTKH"];

            try
            {
                THONGTINKHACHHANG _tt = db.THONGTINKHACHHANGs.Where(t => t.ID_TTKH == id).FirstOrDefault();
                _tt.TEN_KHACHHANG          = tt.TEN_KHACHHANG;
                _tt.EMAIL_KHACHHANG        = tt.EMAIL_KHACHHANG;
                _tt.DIACHI                 = tt.DIACHI;
                _tt.SO_DIENTHOAI           = tt.SO_DIENTHOAI;
                Session["TEN_DANGNHAP"]    = _tt.TEN_KHACHHANG;
                Session["EMAIL_KHACHHANG"] = _tt.EMAIL_KHACHHANG;
                Session["DIACHI"]          = _tt.DIACHI;
                Session["SO_DIENTHOAI"]    = _tt.SO_DIENTHOAI;
                db.SaveChanges();
                return(RedirectToAction("Details", "UserLogin"));
            }
            catch
            {
                return(View());
            }
        }