// GET: UpdateInfo
 public ActionResult Update()
 {
     userMes = new UserMessage();
     userMes = Session["UserMessage"] as UserMessage;
     //userMes.id = 24;
     //userMes.name = "liuzhili";
     old_user = db.TB_USER.Where(a => a.ID == userMes.id).FirstOrDefault();
     ViewData["check_password"] = true;
     return View(old_user);
 }
        public ActionResult Index(string keyString)
        {
            userMes = Session["UserMessage"] as UserMessage;

            keyString = Request.Form["keyString"];

            TempData["KeyString"] = keyString;

            SearchByName(keyString);

            return View(Items);
        }
예제 #3
0
        // GET: Pay
        public ActionResult Payment()
        {
            //UserMessage MyUser = Session["UserMessage"] as UserMessage;
            MyUser = new UserMessage();
            MyUser.id = 35;
            MyUser.name = "admin";
            //string o_id = (Session["orderID"] as decimal?).ToString();
            //Session.Remove("orderID");
            string o_id = "24";
            string SqlString = "SELECT P.PRICE,P.DISCOUNT_RATE FROM TB_PRODUCT P,TB_CONTAINS C,TB_ORDER O WHERE P.ID = C.P_ID AND P.S_ID = C.S_ID AND C.O_ID = O.ID AND O.ID =" + o_id;
            List<PriceRate> prices = db.Database.SqlQuery<PriceRate>(SqlString).ToList();
            ViewModel.old_price = 0;
            ViewModel.new_price = 0;
            foreach (PriceRate item in prices)
            {
                ViewModel.old_price += item.price;
                ViewModel.new_price += item.price * item.rate;
            }
            Users user_db = new Users();
            TB_USER user = user_db.TB_USER.Where(a => a.ID == MyUser.id).First();
            if (user != null)
            {
                ViewModel.name = MyUser.name;
                ViewModel.phone = user.PHONE;
                ViewModel.province = user.PROVINCE;
                ViewModel.zipcode = user.ZIPCODE;
                ViewModel.city = user.CITY;
                ViewModel.creditcode = user.CREDIT_NO;
                ViewModel.district = user.DISTRICT;
                ViewModel.detailaddr = user.DETAILADDR;
                ViewModel.point_num = (decimal)ViewModel.old_price - decimal.Floor((decimal)ViewModel.old_price);
                ViewModel.check = true;
            }

            return View(ViewModel);
        }
        public ActionResult AddToCart()
        {
            UserMessage UserMes = new UserMessage();
            UserMes = Session["UserMessage"] as UserMessage;
            //UserMes.id = 35;
            SingleOrder myOrder = new SingleOrder();

            List<TB_ORDER> ShopCart = new List<TB_ORDER>();
            //dbOrd = new Orders();
            ShopCart = dbOrd.Database.SqlQuery<TB_ORDER>(
                "SELECT * FROM TB_ORDER WHERE U_ID = " + UserMes.id + " AND S_ID = " + productMes.s_id + " AND STATE = 1").ToList();
            if (ShopCart.Count == 0)
            {
                string sql = "SELECT ORDERZIZENG.nextval FROM dual";
                decimal nextOrderID = dbOrd.Database.SqlQuery<decimal>(sql).ToList().First();

                myOrder.contain.O_ID = nextOrderID;
                myOrder.contain.P_ID = productMes.id;
                myOrder.contain.S_ID = productMes.s_id;
                myOrder.contain.NUM = Convert.ToInt16(Request.Form["points"]);

                myOrder.order.ID = nextOrderID;
                myOrder.order.S_ID = productMes.s_id;
                myOrder.order.U_ID = UserMes.id;
                myOrder.order.STATE = 1;
                myOrder.order.TIME = DateTime.Now;
                myOrder.order.TOTAL_PRICE = productMes.new_price * myOrder.contain.NUM;
                if (ModelState.IsValid)
                {
                    dbOrd.TB_ORDER.Add(myOrder.order);
                    dbOrd.SaveChanges();
                    dbCon.TB_CONTAINS.Add(myOrder.contain);
                    dbCon.SaveChanges();
                    //  UpdateProductNum(dbCon.Database.SqlQuery<TB_CONTAINS>("select * from TB_CONTAINS WHERE O_ID = " + nextOrderID).ToList());
                }
            }
            else
            {
                short ProductNum = Convert.ToInt16(Request.Form["points"]);
                myOrder.order = ShopCart.First();
                List<TB_CONTAINS> Contain = new List<TB_CONTAINS>();
                Contain = dbCon.Database.SqlQuery<TB_CONTAINS>(
                    "SELECT * FROM TB_CONTAINS WHERE O_ID = " + myOrder.order.ID + " AND P_ID = " + productMes.id).ToList();
                if (Contain.Count == 0)
                {
                    myOrder.contain.O_ID = myOrder.order.ID;
                    myOrder.contain.P_ID = productMes.id;
                    myOrder.contain.S_ID = productMes.s_id;
                    myOrder.contain.NUM = ProductNum;
                    if (ModelState.IsValid)
                    {
                        dbCon.TB_CONTAINS.Add(myOrder.contain);
                        dbCon.SaveChanges();
                    }
                }
                else
                {
                    myOrder.contain = Contain.First();
                    myOrder.contain.NUM += ProductNum;
                    if (ModelState.IsValid)
                    {
                        dbCon.Entry(myOrder.contain).State = EntityState.Modified;
                        dbCon.SaveChanges();
                    }
                }
                myOrder.order.TIME = DateTime.Now;
                myOrder.order.TOTAL_PRICE += productMes.new_price * ProductNum;
                if (ModelState.IsValid)
                {
                    dbOrd.Entry(myOrder.order).State = EntityState.Modified;
                    dbOrd.SaveChanges();
                }
            }
            return RedirectToAction("Index", "ShoppingCart");
        }
        public ActionResult BuyNow()
        {
            UserMessage UserMes = new UserMessage();
            // UserMes = Session["UserMassage"] as UserMessage;
            UserMes.id = 35;
            SingleOrder myOrder = new SingleOrder();
            string sql = "SELECT ORDERZIZENG.nextval FROM dual";
            decimal nextOrderID = dbOrd.Database.SqlQuery<decimal>(sql).ToList().First();

            myOrder.contain.O_ID = nextOrderID;
            myOrder.contain.P_ID = productMes.id;
            myOrder.contain.S_ID = productMes.s_id;
            myOrder.contain.NUM = Convert.ToInt16(Request.Form["points"]);

            myOrder.order.ID = nextOrderID;
            myOrder.order.S_ID = productMes.s_id;
            myOrder.order.U_ID = UserMes.id;
            myOrder.order.STATE = 2;
            myOrder.order.TIME = DateTime.Now;
            myOrder.order.TOTAL_PRICE = productMes.new_price * myOrder.contain.NUM;
            if (ModelState.IsValid)
            {
                dbOrd.TB_ORDER.Add(myOrder.order);
                dbOrd.SaveChanges();
                dbCon.TB_CONTAINS.Add(myOrder.contain);
                dbCon.SaveChanges();
                UpdateProductNum(dbCon.Database.SqlQuery<TB_CONTAINS>("select * from TB_CONTAINS WHERE O_ID = " + nextOrderID).ToList());
            }
            TempData["BuyNow"] = myOrder;

            return RedirectToAction("Payment", "Pay");
        }
        public ActionResult Update(string NewPassword, int? NewCardNum, string NewDetailAddr, string NewCity, string NewProvince, int? NewZipCode, string NewDistrict,int? NewPhone)
        {
            //userMes = Session["UserMessage"] as UserMessage;
            userMes = new UserMessage();
            //userMes.id = 24;
            //userMes.name = "liuzhili";
            userMes = Session["UserMessage"] as UserMessage;

            NewPassword = Request.Form["first_password"];
            NewDetailAddr = Request.Form["detail_address"];
            NewCity = Request.Form["city"];
            NewProvince = Request.Form["province"];
            int result;
            if (int.TryParse(Request.Form["zipcode"], out result))
            {
                NewZipCode = result;
            }
            else
            {
                NewZipCode = 0;
            }
            int result2;
            if (int.TryParse(Request.Form["credit_no"], out result2))
            {
                NewCardNum = result2;
            }
            else
            {
                NewCardNum = 0;
            }
            int result3;
            if (int.TryParse(Request.Form["phone"], out result3))
            {
                NewPhone = result3;
            }
            else
            {
                NewPhone = 0;
            }
            NewDistrict = Request.Form["district"];
            //string SqlString = "select * from TB_USER where ID = " + userMes.id.ToString();
            //TB_USER old_user = db.Database.SqlQuery<TB_USER>(SqlString).First();
            old_user = db.TB_USER.Where(a => a.ID == userMes.id).FirstOrDefault();
            if (Request.Form["first_password"] != Request.Form["second_password"])
            {
                ViewData["check_password"] = false;
                return View(old_user);
            }
            ViewData["check_password"] = true;
            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 (NewPhone != 0 && NewPhone != old_user.PHONE)
            {
                old_user.PHONE = NewPhone;
            }

            db.SaveChanges();

            return View(old_user);
        }
예제 #7
0
        public ActionResult AddToCart()
        {
            UserMessage UserMes = new UserMessage();

            UserMes = Session["UserMessage"] as UserMessage;
            //UserMes.id = 35;
            SingleOrder myOrder = new SingleOrder();

            List <TB_ORDER> ShopCart = new List <TB_ORDER>();

            //dbOrd = new Orders();
            ShopCart = dbOrd.Database.SqlQuery <TB_ORDER>(
                "SELECT * FROM TB_ORDER WHERE U_ID = " + UserMes.id + " AND S_ID = " + productMes.s_id + " AND STATE = 1").ToList();
            if (ShopCart.Count == 0)
            {
                string  sql         = "SELECT ORDERZIZENG.nextval FROM dual";
                decimal nextOrderID = dbOrd.Database.SqlQuery <decimal>(sql).ToList().First();

                myOrder.contain.O_ID = nextOrderID;
                myOrder.contain.P_ID = productMes.id;
                myOrder.contain.S_ID = productMes.s_id;
                myOrder.contain.NUM  = Convert.ToInt16(Request.Form["points"]);

                myOrder.order.ID          = nextOrderID;
                myOrder.order.S_ID        = productMes.s_id;
                myOrder.order.U_ID        = UserMes.id;
                myOrder.order.STATE       = 1;
                myOrder.order.TIME        = DateTime.Now;
                myOrder.order.TOTAL_PRICE = productMes.new_price * myOrder.contain.NUM;
                if (ModelState.IsValid)
                {
                    dbOrd.TB_ORDER.Add(myOrder.order);
                    dbOrd.SaveChanges();
                    dbCon.TB_CONTAINS.Add(myOrder.contain);
                    dbCon.SaveChanges();
                    //  UpdateProductNum(dbCon.Database.SqlQuery<TB_CONTAINS>("select * from TB_CONTAINS WHERE O_ID = " + nextOrderID).ToList());
                }
            }
            else
            {
                short ProductNum = Convert.ToInt16(Request.Form["points"]);
                myOrder.order = ShopCart.First();
                List <TB_CONTAINS> Contain = new List <TB_CONTAINS>();
                Contain = dbCon.Database.SqlQuery <TB_CONTAINS>(
                    "SELECT * FROM TB_CONTAINS WHERE O_ID = " + myOrder.order.ID + " AND P_ID = " + productMes.id).ToList();
                if (Contain.Count == 0)
                {
                    myOrder.contain.O_ID = myOrder.order.ID;
                    myOrder.contain.P_ID = productMes.id;
                    myOrder.contain.S_ID = productMes.s_id;
                    myOrder.contain.NUM  = ProductNum;
                    if (ModelState.IsValid)
                    {
                        dbCon.TB_CONTAINS.Add(myOrder.contain);
                        dbCon.SaveChanges();
                    }
                }
                else
                {
                    myOrder.contain      = Contain.First();
                    myOrder.contain.NUM += ProductNum;
                    if (ModelState.IsValid)
                    {
                        dbCon.Entry(myOrder.contain).State = EntityState.Modified;
                        dbCon.SaveChanges();
                    }
                }
                myOrder.order.TIME         = DateTime.Now;
                myOrder.order.TOTAL_PRICE += productMes.new_price * ProductNum;
                if (ModelState.IsValid)
                {
                    dbOrd.Entry(myOrder.order).State = EntityState.Modified;
                    dbOrd.SaveChanges();
                }
            }
            return(RedirectToAction("Index", "ShoppingCart"));
        }
예제 #8
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("完成成功");
        }
예제 #9
0
        // GET: MyOrder
        public ActionResult Index(decimal cur_page = 1)
        {
            userMes = Session["UserMessage"] as UserMessage;
            //userMes.id = 35;
            if (UserOrder == null)
            {
                UserOrder = new UserAndOrder();
                foreach (TB_ORDER myorder in dbOrd.TB_ORDER)
                {
                    if (myorder.U_ID == userMes.id)
                    {
                        OrderAndContains new_order = new OrderAndContains();
                        new_order.Order = myorder;
                        new_order.Products = (from a in dbCon.TB_CONTAINS where a.O_ID == myorder.ID select a).ToList();
                        new_order.Date = myorder.TIME.ToString();
                        if (new_order.Order.STATE >= 2)
                        {
                            UserOrder.Order.Add(new_order);
                        }
                    }
                }
            }

            List<OrderMessage> this_page = new List<OrderMessage>();
            int allPtr = (int)(cur_page - 1) * 5 + 1;
            int thisPtr = 0;
            foreach (OrderAndContains myorder in UserOrder.Order)
            {
                if (allPtr <= UserOrder.Order.Count && thisPtr < 5)
                {
                    this_page.Add(new OrderMessage());
                    //序号
                    this_page[thisPtr].index = thisPtr + 1;
                    //订单号
                    this_page[thisPtr].order_id = "9000" + myorder.Date.Substring(2, 2) +
                        ("000" + myorder.Order.ID.ToString()).Remove(0, myorder.Order.ID.ToString().Length - 1);
                    //商铺号
                    this_page[thisPtr].store_name = dbSto.Database.SqlQuery<string>(
                        "SELECT NAME FROM TB_STORE WHERE ID = " + myorder.Order.S_ID).ToList().FirstOrDefault();
                    //商品名
                    this_page[thisPtr].product_name = dbPro.Database.SqlQuery<string>(
                        "SELECT NAME FROM TB_PRODUCT WHERE ID = " + myorder.Products[0].P_ID).ToList().FirstOrDefault();
                    int number = myorder.Products.Count;
                    if (number > 1)
                    {
                        this_page[thisPtr].product_name += "等";
                    }
                    //商品图

                    //总价
                    this_page[thisPtr].total_price = (decimal)myorder.Order.TOTAL_PRICE;
                    //状态
                    if (myorder.Order.STATE == 2)
                    {
                        this_page[thisPtr].state = "未支付";
                        this_page[thisPtr].state_color = "";
                    }
                    else if (myorder.Order.STATE == 3)
                    {
                        this_page[thisPtr].state = "已付款";
                        this_page[thisPtr].state_color = "";
                    }
                    else if (myorder.Order.STATE == 4)
                    {
                        this_page[thisPtr].state = "已发货";
                        this_page[thisPtr].state_color = "";
                    }
                    else if (myorder.Order.STATE == 5)
                    {
                        this_page[thisPtr].state = "待评论";
                        this_page[thisPtr].state_color = "danger";
                    }
                    else if (myorder.Order.STATE == 6)
                    {
                        this_page[thisPtr].state = "已完成";
                        this_page[thisPtr].state_color = "success";
                    }
                    //创建时间
                    this_page[thisPtr].time = myorder.Date;
                    //循环变量
                    allPtr++;
                    thisPtr++;
                }
            }
            if (this_page.Count != 0)
            {
                this_page.FirstOrDefault().page_btn = new List<string>();
                for (int i = 0; i < 5; i++)
                {
                    if (i == cur_page - 1)
                    {
                        this_page.FirstOrDefault().page_btn.Add("active");
                    }
                    else
                    {
                        this_page.FirstOrDefault().page_btn.Add("");
                    }
                }
                return View(this_page);
            }
            else
            {
                return RedirectToAction("Index", new { cur_page = 1 });
            }
        }
예제 #10
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("完成成功"));
        }