示例#1
0
        public ActionResult Payment(FormCollection collection)
        {
            if (collection["action"] == "cancel")
            {
                return RedirectToAction("取消");
            }
            PayViewModel ViewModel = new PayViewModel();
            ViewModel.check = true;
            MyUser = new UserMessage();
            MyUser.id = 35;
            MyUser.name = "admin";
            string NewPassword = Request.Form["password"];
            string NewDetailAddr = Request.Form["detailaddr"];
            string NewCity = Request.Form["city"];
            string NewProvince = Request.Form["province"];
            int result;
            int NewZipCode, NewCardNum;
            if (int.TryParse(Request.Form["zipcode"], out result))
            {
                NewZipCode = result;
            }
            else
            {
                NewZipCode = 0;
            }
            int result2;
            if (int.TryParse(Request.Form["creditcode"], out result2))
            {
                NewCardNum = result2;
            }
            else
            {
                NewCardNum = 0;
            }
            string NewDistrict = Request.Form["district"];
            old_user = db2.TB_USER.Where(a => a.ID == MyUser.id).FirstOrDefault();
            if (NewPassword != "" && NewPassword != old_user.PASSWORD)
            {
                old_user.PASSWORD = NewPassword;
            }

            if (NewCardNum != 0 && NewCardNum != old_user.CREDIT_NO)
            {
                old_user.CREDIT_NO = NewCardNum;
            }

            if (NewDetailAddr != "" && NewDetailAddr != old_user.DETAILADDR)
            {
                old_user.DETAILADDR = NewDetailAddr;
            }

            if (NewCity != "" && NewCity != old_user.CITY)
            {
                old_user.CITY = NewCity;
            }

            if (NewProvince != "" && NewProvince != old_user.PROVINCE)
            {
                old_user.PROVINCE = NewProvince;
            }

            if (NewZipCode != 0 && NewZipCode != old_user.ZIPCODE)
            {
                old_user.ZIPCODE = NewZipCode;
            }

            if (NewDistrict != "" && NewDistrict != old_user.DISTRICT)
            {
                old_user.DISTRICT = NewDistrict;
            }
            if (NewPassword != old_user.PASSWORD)
            {

            }
            db.SaveChanges();
            if (NewPassword != old_user.PASSWORD)
            {
                ViewModel.check = false;
                return View(ViewModel);
            }
            return RedirectToAction("完成成功");
        }
示例#2
0
        public ActionResult Payment(FormCollection collection)
        {
            if (collection["action"] == "cancel")
            {
                return(RedirectToAction("取消"));
            }
            PayViewModel ViewModel = new PayViewModel();

            ViewModel.check = true;
            MyUser          = new UserMessage();
            MyUser.id       = 35;
            MyUser.name     = "admin";
            string NewPassword   = Request.Form["password"];
            string NewDetailAddr = Request.Form["detailaddr"];
            string NewCity       = Request.Form["city"];
            string NewProvince   = Request.Form["province"];
            int    result;
            int    NewZipCode, NewCardNum;

            if (int.TryParse(Request.Form["zipcode"], out result))
            {
                NewZipCode = result;
            }
            else
            {
                NewZipCode = 0;
            }
            int result2;

            if (int.TryParse(Request.Form["creditcode"], out result2))
            {
                NewCardNum = result2;
            }
            else
            {
                NewCardNum = 0;
            }
            string NewDistrict = Request.Form["district"];

            old_user = db2.TB_USER.Where(a => a.ID == MyUser.id).FirstOrDefault();
            if (NewPassword != "" && NewPassword != old_user.PASSWORD)
            {
                old_user.PASSWORD = NewPassword;
            }

            if (NewCardNum != 0 && NewCardNum != old_user.CREDIT_NO)
            {
                old_user.CREDIT_NO = NewCardNum;
            }

            if (NewDetailAddr != "" && NewDetailAddr != old_user.DETAILADDR)
            {
                old_user.DETAILADDR = NewDetailAddr;
            }

            if (NewCity != "" && NewCity != old_user.CITY)
            {
                old_user.CITY = NewCity;
            }

            if (NewProvince != "" && NewProvince != old_user.PROVINCE)
            {
                old_user.PROVINCE = NewProvince;
            }

            if (NewZipCode != 0 && NewZipCode != old_user.ZIPCODE)
            {
                old_user.ZIPCODE = NewZipCode;
            }

            if (NewDistrict != "" && NewDistrict != old_user.DISTRICT)
            {
                old_user.DISTRICT = NewDistrict;
            }
            if (NewPassword != old_user.PASSWORD)
            {
            }
            db.SaveChanges();
            if (NewPassword != old_user.PASSWORD)
            {
                ViewModel.check = false;
                return(View(ViewModel));
            }
            return(RedirectToAction("完成成功"));
        }