示例#1
0
        public ActionResult Profile()
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }

            _9d_user u = AccountContent._9d_users.Where(c => c.user_name == Session["login"].ToString() && c.delete_flag == false).FirstOrDefault();

            return(View(u));
        }
示例#2
0
        public ActionResult Changepass(FormCollection collection)
        {
            string passwordo = collection["passwordo"].ToString();
            string password  = collection["password"].ToString();
            string passwordx = collection["passwordx"].ToString();

            if (passwordo == "" || password == "" || passwordx == "")
            {
                TempData["erorprofile"] = "Vui lòng nhập đủ thông tin.";
                return(View("Changepass"));
            }
            if (password != passwordx)
            {
                TempData["erorprofile"] = "Mật khẩu mới phải nhập trùng nhau.";
                return(View("Changepass"));
            }
            else if (passwordx.Length < 6)
            {
                TempData["erorprofile"] = "Mật khẩu mới phải lớn hơn 6 kí tự.";
                return(View("Changepass"));
            }
            passwordo = Common.GetMD5(collection["passwordo"].ToString());
            password  = Common.GetMD5(collection["password"].ToString());
            passwordx = Common.GetMD5(collection["passwordx"].ToString());

            _9d_user item = AccountContent._9d_users.Where(c => c.user_name == Session["login"].ToString()).FirstOrDefault();

            if (item.password != passwordo)
            {
                TempData["erorprofile"] = "Bạn đã nhập sai mật khẩu cũ, vui lòng nhập lại.";
                return(View("Changepass"));
            }

            item.password = passwordx;

            try
            {
                AccountContent.SubmitChanges();
                Tbl_Member_Password it = AccountContent.Tbl_Member_Passwords.Where(c => c.userid == Session["login"].ToString()).FirstOrDefault();
                it.userpassword            = passwordx;
                TempData["erorprofile"]    = null;
                TempData["successprofile"] = "Chúc mừng, mật khẩu của bạn đã được cập nhật.";
                AccountContent.SubmitChanges();
                return(View("Changepass"));
            }
            catch (Exception)
            {
                throw;
            }

            return(View("Changepass"));
        }
示例#3
0
        public ActionResult Index(FormCollection collection)
        {
            string username = collection["name"].ToString();
            string password = Common.GetMD5(collection["password"].ToString());

            if (username == "" || collection["password"].ToString() == "")
            {
                TempData["errorlogin"] = "******";
                return(RedirectToAction("Index"));
            }
            else
            {
                //_9d_user users1 = AccountContent._9d_users.Where(c => c.user_name.Trim().ToString() != "a").FirstOrDefault();
                _9d_user users = AccountContent._9d_users.Where(c => c.user_name.Trim().ToString() == username.Trim()).FirstOrDefault();
                if (users != null)
                {
                    if (users.password == password)
                    {
                        Session["login"] = users.user_name;
                        Session["xu"]    = users.balance;
                        if (users.status == true)
                        {
                            Session["status"]  = true;
                            Session["message"] = "<script type='text/javascript'> alert('Quản trị game cảnh báo. \\n \\n" + users.message + "'); </script>";
                        }
                        else
                        {
                            Session["status"]  = false;
                            Session["message"] = "";
                        }
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        TempData["errorlogin"] = "******";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    TempData["errorlogin"] = "******";
                    return(RedirectToAction("Index"));
                }
            }
        }
示例#4
0
        public ActionResult Addxu(FormCollection collection)
        {
            if (Session["Quantri-website-Quantrivien"] == null)
            {
                Response.Redirect("/");
            }
            string username = collection["username"].ToString();
            string xu       = collection["xu"].ToString();

            if (username == "" || xu == "")
            {
                TempData["erroraddxu"]   = "Vui lòng nhập đủ thông tin.";
                TempData["successaddxu"] = null;
                return(View());
            }
            if (Common.checkInt(xu))
            {
                TempData["erroraddxu"]   = "Vui lòng nhập đúng số xu.";
                TempData["successaddxu"] = null;
                return(View());
            }

            _9d_user us = accountContext._9d_users.Where(c => c.user_name == username && c.delete_flag == false).FirstOrDefault();

            if (us == null)
            {
                TempData["erroraddxu"]   = "Vui lòng kiểm tra lại, tài khoản không tồn tại trong hệ thống.";
                TempData["successaddxu"] = null;
                return(View());
            }

            us.balance = us.balance + Convert.ToInt32(xu);
            try
            {
                accountContext.SubmitChanges();
                TempData["successaddxu"] = "Tài khoản " + username + " đã thêm thành công " + xu + " xu.";
                return(View());
            }
            catch (Exception)
            {
                TempData["erroraddxu"] = "Có lỗi từ hệ thống, vui lòng liên hệ quản trị viên.";
                return(View());
            }
        }
示例#5
0
        public ActionResult Profile(FormCollection collection)
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            if (collection["email"].ToString() == "" || collection["sodienthoai"].ToString() == "" || collection["address"].ToString() == "")
            {
                TempData["errorchange"]   = "Vui lòng nhập thông tin chính xác.";
                TempData["successchange"] = null;
                _9d_user u = AccountContent._9d_users.Where(c => c.user_name == Session["login"].ToString() && c.delete_flag == false).FirstOrDefault();
                return(View(u));
            }
            _9d_user i = AccountContent._9d_users.Where(c => c.user_name == Session["login"].ToString() && c.delete_flag == false).FirstOrDefault();

            i.email     = collection["email"].ToString();
            i.telephone = collection["sodienthoai"].ToString();
            i.address   = collection["address"].ToString();
            i.status    = false;
            i.message   = "";
            try
            {
                AccountContent.SubmitChanges();
                TempData["errorchange"]   = null;
                TempData["successchange"] = "Dữ liệu mới đã được cập nhât.";
                Session["status"]         = false;
                Session["message"]        = null;
                _9d_user u = AccountContent._9d_users.Where(c => c.user_name == Session["login"].ToString() && c.delete_flag == false).FirstOrDefault();
                return(View(u));
            }
            catch (Exception)
            {
                TempData["errorchange"]   = "Có lỗi, liên hệ quản trị viên.";
                TempData["successchange"] = null;
                _9d_user u = AccountContent._9d_users.Where(c => c.user_name == Session["login"].ToString() && c.delete_flag == false).FirstOrDefault();
                return(View(u));
            }
        }
示例#6
0
        public _9d_user getUserInfo(string username)
        {
            _9d_user user = AccountContent._9d_users.Where(c => c.user_name == username.Trim() && c.delete_flag == false).FirstOrDefault();

            return(user);
        }
示例#7
0
        public ActionResult Usermanager(FormCollection collection)
        {
            if (Session["Quantri-website-Quantrivien"] == null)
            {
                Response.Redirect("/");
            }
            if (collection["warning"].ToString() == "")
            {
                TempData["erroruser"]   = "******";
                TempData["successuser"] = null;
                ViewBag.UserList        = accountContext._9d_users.Where(c => c.user_id == 0).ToList();
                return(View());
            }

            if (Convert.ToInt32(collection["usertype"].ToString()) == 2)
            {
                using (var db = new DataAccountContentDataContext())
                {
                    db._9d_users
                    .Where(x => x.telephone == collection["userid"].ToString())
                    .ToList()
                    .ForEach(a =>
                    {
                        a.status  = true;
                        a.message = collection["warning"].ToString();
                    });

                    try
                    {
                        db.SubmitChanges();
                        TempData["erroruser"]   = null;
                        TempData["successuser"] = "******";
                        if (Convert.ToInt32(collection["usertype"].ToString()) == 1)
                        {
                            ViewBag.UserList = accountContext._9d_users.Where(c => c.user_name == collection["usertype"].ToString()).ToList();
                            return(View());
                        }
                        else if (Convert.ToInt32(collection["usertype"].ToString()) == 2)
                        {
                            ViewBag.UserList = accountContext._9d_users.Where(c => c.telephone == collection["userid"].ToString()).ToList();
                        }
                        return(View());
                    }
                    catch (Exception)
                    {
                        TempData["erroruser"]   = "******";
                        TempData["successuser"] = null;
                        if (Convert.ToInt32(collection["usertype"].ToString()) == 1)
                        {
                            ViewBag.UserList = accountContext._9d_users.Where(c => c.user_name == collection["usertype"].ToString()).ToList();
                            return(View());
                        }
                        else if (Convert.ToInt32(collection["usertype"].ToString()) == 2)
                        {
                            ViewBag.UserList = accountContext._9d_users.Where(c => c.telephone == collection["userid"].ToString()).ToList();
                        }
                        return(View());
                    }
                }
            }
            else
            {
                _9d_user us = accountContext._9d_users.Where(c => c.user_name == collection["userid"].ToString()).FirstOrDefault();
                us.status  = true;
                us.message = collection["warning"].ToString();
                try
                {
                    accountContext.SubmitChanges();
                    TempData["erroruser"]   = null;
                    TempData["successuser"] = "******";
                    if (Convert.ToInt32(collection["usertype"].ToString()) == 1)
                    {
                        ViewBag.UserList = accountContext._9d_users.Where(c => c.user_name == collection["usertype"].ToString()).ToList();
                        return(View());
                    }
                    else if (Convert.ToInt32(collection["usertype"].ToString()) == 2)
                    {
                        ViewBag.UserList = accountContext._9d_users.Where(c => c.telephone == collection["userid"].ToString()).ToList();
                    }
                    return(View());
                }
                catch (Exception)
                {
                    TempData["erroruser"]   = "******";
                    TempData["successuser"] = null;
                    if (Convert.ToInt32(collection["usertype"].ToString()) == 1)
                    {
                        ViewBag.UserList = accountContext._9d_users.Where(c => c.user_name == collection["usertype"].ToString()).ToList();
                        return(View());
                    }
                    else if (Convert.ToInt32(collection["usertype"].ToString()) == 2)
                    {
                        ViewBag.UserList = accountContext._9d_users.Where(c => c.telephone == collection["userid"].ToString()).ToList();
                    }
                    return(View());
                }
            }
        }
示例#8
0
        public ActionResult Signup(FormCollection collection)
        {
            string username  = collection["name"].ToString();
            string password  = collection["password"].ToString();
            string passwordx = collection["passwordx"].ToString();
            string email     = collection["email"].ToString();
            string telephone = collection["sodienthoai"].ToString();
            string sex       = collection["option"].ToString();
            string address   = collection["address"].ToString();

            if (username.Trim() == string.Empty || password.Trim() == string.Empty || telephone.Trim() == string.Empty || passwordx.Trim() == string.Empty || email.Trim() == string.Empty || address.Trim() == string.Empty)
            {
                TempData["errorsignup"] = "Vui lòng nhập đầy đủ thông tin đăng ký, password phải lớn hơn 6 ký tự.";
                return(RedirectToAction("Signup", "Account"));
            }

            if (username.Trim().Length < 5)
            {
                TempData["errorsignup"] = "Vui lòng nhập tài khoản đăng nhập phải lớn hơn 6 kí tự.";
                return(RedirectToAction("Signup", "Account"));
            }


            if (password.Trim().Length < 5)
            {
                TempData["errorsignup"] = "Vui lòng nhập password phải lớn hơn 6 kí tự.";
                return(RedirectToAction("Signup", "Account"));
            }
            if (password != passwordx)
            {
                TempData["errorsignup"] = "Vui lòng nhập mật khẩu và xác nhận mật khẩu phải trùng nhau.";
                return(RedirectToAction("Signup", "Account"));
            }

            if (!isMemberExist(username))
            {
                Tbl_Member_Password adduser = new Tbl_Member_Password();
                adduser.userid       = username;
                adduser.userpassword = Common.GetMD5(password);

                AccountContent.Tbl_Member_Passwords.InsertOnSubmit(adduser);
                try
                {
                    AccountContent.SubmitChanges();
                }
                catch (Exception)
                {
                    TempData["errorsignup"] = "Có lỗi sảy ra vui lòng đăng ký lại.";
                    return(RedirectToAction("Signup", "Account"));
                }

                _9d_user user = new _9d_user();
                user.user_name    = username.Trim();
                user.password     = Common.GetMD5(password);
                user.email        = email.Trim();
                user.created_at   = DateTime.Now;
                user.telephone    = telephone;
                user.balance      = 0;
                user.address      = address.Trim();
                user.created_by   = "Admin";
                user.delete_flag  = false;
                user.isActivate   = true;
                user.ActivateCode = "FSGJTB45BDERT";
                user.level        = 1;
                user.totalpost    = 0;
                AccountContent._9d_users.InsertOnSubmit(user);
                try
                {
                    AccountContent.SubmitChanges();
                    string a = "";
                }
                catch (Exception)
                {
                    return(RedirectToAction("Signup", "Account"));
                }

                TempData["errorlogin"]      = null;
                TempData["registerSuccess"] = "Đăng ký thành công, bạn hãy đăng nhập để vào trang chủ tham gia các sự kiện đặc biệt.";
                return(RedirectToAction("Index", "Account"));
            }
            else
            {
                TempData["errorsignup"] = "Tài khoản đã tồn tại, vui lòng đăng ký tài khoản mới.";
                return(RedirectToAction("Signup", "Account"));
            }
        }
示例#9
0
        public ActionResult Napthe(FormCollection collection)
        {
            if (Session["login"] == null)
            {
                HttpContext.Application["_controler"] = "Service";
                HttpContext.Application["_action"]    = "Napthe";
                return(RedirectToAction("Index", "Account"));
                //return RedirectToAction("Index", HttpContext.Application["_controler"] as string);
            }

            if (collection["seri"].ToString() == "" || collection["pin"].ToString() == "")
            {
                TempData["errorcard"]   = "Vui lòng nhập đầy đủ thông tin thẻ cào.";
                TempData["successcard"] = null;
                _9d_percen p = accountContext._9d_percens.FirstOrDefault();
                TempData["status"] = p.status;
                return(View());
            }

            try
            {
                _9d_percen p = accountContext._9d_percens.FirstOrDefault();
                TempData["status"] = p.status;

                RequestInfo info = new RequestInfo();
                info.Merchant_id       = "36680";
                info.Merchant_acount   = "*****@*****.**";
                info.Merchant_password = "******";

                //Nhà mạng
                info.CardType = collection["MovieType"].ToString();
                info.Pincard  = collection["pin"].ToString();

                //Mã đơn hàng
                info.Refcode    = (new Random().Next(0, 10000)).ToString();
                info.SerialCard = collection["seri"].ToString();

                ResponseInfo resutl = NLCardLib.CardChage(info);

                if (resutl.Errorcode.Equals("00"))
                {
                    _9d_user user     = accountContext._9d_users.Where(c => c.user_name == Session["login"].ToString() && c.delete_flag == false).FirstOrDefault();
                    int      coutncar = (Convert.ToInt32(resutl.Card_amount) * p.percen) / 100;
                    user.balance = user.balance + coutncar;
                    accountContext.SubmitChanges();

                    User_History addhistory = new User_History();
                    addhistory.user_name = Session["login"].ToString();
                    addhistory.time_into = DateTime.Now;
                    addhistory.car_info  = coutncar.ToString();
                    addhistory.car_type  = collection["MovieType"].ToString();
                    accountContext.User_Histories.InsertOnSubmit(addhistory);
                    accountContext.SubmitChanges();
                    _9d_user u = common.getUserInfo(Session["login"].ToString());
                    ViewBag.balance = u != null?u.balance.ToString() : "0";

                    TempData["errorcard"]   = null;
                    TempData["successcard"] = "Chúc mừng, bạn đã nạp thành công thẻ mệnh giá " + coutncar.ToString() + ".";
                }
                else
                {
                    TempData["errorcard"]   = resutl.Message.ToString();
                    TempData["successcard"] = null;
                }

                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#10
0
        public ActionResult Buy(int id)
        {
            if (Session["login"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }

            _9d_user    u    = common.getUserInfo(Session["login"].ToString());
            _9d_KTCItem item = accountContext._9d_KTCItems.Where(c => c.id == id).FirstOrDefault();

            if (item == null)
            {
                TempData["ktcFailed"] = "Item này không tồn tại";
                return(RedirectToAction("Index", "Service"));
            }

            if (u.balance < item.itemprice)
            {
                TempData["ktcFailed"] = "Bạn không đủ tiền để mua vật phẩm này";
                return(RedirectToAction("Index", "Service"));
            }

            try
            {
                //chuyen item vao tk nguoi choi
                string userId  = u.user_name;
                int?   itemId  = Convert.ToInt32(item.itemid);
                byte?  server  = Convert.ToByte(0);
                int?   orderId = 0;
                byte?  err     = 0;

                cisContext.Sp_Purchase_Using(userId, Convert.ToInt32(item.itemid), server, 0, ref orderId, ref err);
                //add vao transaction
                try
                {
                    cisContext.SubmitChanges();
                }
                catch (Exception)
                {
                    throw;
                }


                int curr = u.balance;
                //tru tien
                //accountContext._9d_transactions.InsertOnSubmit(trans);
                //accountContext.SubmitChanges();
                _9d_user user = accountContext._9d_users.Where(c => c.user_name == userId).FirstOrDefault();
                user.balance  = curr - item.itemprice;
                Session["xu"] = null;
                Session["xu"] = user.balance;

                //accountContext._9d_transactions.InsertOnSubmit(trans);
                try
                {
                    accountContext.SubmitChanges();
                    TempData["ktcOK"] = "Mua hàng thành công !!!";
                    return(RedirectToAction("Index", "Service"));
                }
                catch (Exception)
                {
                    throw;
                }
            }
            catch (Exception)
            {
            }

            return(RedirectToAction("Index", "Service"));
        }