Exemplo n.º 1
0
        public ActionResult ValidLoginProcess(Models.LoginInfo li)
        {
            if (li.Phone == null)
            {
                return(RedirectToAction("Index", new { msg = "請輸入手機號碼" }));
            }
            if (li.PW == null)
            {
                return(RedirectToAction("Index", new { msg = "請輸入密碼" }));
            }

            DB.DB        mydb = new DB.DB();
            DB.ICustomer ic   = new DB.Impl_Customer(mydb.Connection);

            if (ic.CheckLogin(li.Phone, li.PW))
            {
                Session.Add("Login", li.Phone);
                Session.Add("LoginType", "c");

                // 取出User原先瀏覽的網頁
                HttpCookie hc = Request.Cookies["ReUrl"];
                if (hc == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    return(Redirect(hc.Value));
                }
            }
            else
            {
                return(RedirectToAction("Index", new { msg = "登入失敗!手機號碼或密碼有誤!" }));
            }
        }
Exemplo n.º 2
0
        public string CheckPhone(string phone)
        {
            if (phone.Length != 10 || phone.Substring(0, 2) != "09")
            {
                return("l");
            }
            for (int i = 2; i < 10; i++)
            {
                if (phone[i] > '9' || phone[i] < '0')
                {
                    return("l");
                }
            }

            DB.DB        mydb = new DB.DB();
            DB.ICustomer ic   = new DB.Impl_Customer(mydb.Connection);

            bool ans = ic.CheckPhoneDuplicate(phone);

            if (ans)
            {
                return("t");
            }
            else
            {
                return("f");
            }
        }
Exemplo n.º 3
0
        public ActionResult AddNewMember(Models.MemberInfo mi)
        {
            DB.DB        mydb = new DB.DB("SQLAdmin", "admin1234");
            DB.ICustomer ic   = new DB.Impl_Customer(mydb.Connection);

            ic.AddNewMember(mi.Phone, mi.PW, mi.Name, mi.Email);

            return(RedirectToAction("Index", "Login", new { msg = "成功加入會員,請登入!" }));
        }
        public ActionResult UpdatePW(Models.MemberInfo Mi)
        {
            if (!CheckLI(Session["Login"].ToString(), Mi.oldPW))
            {
                return(RedirectToAction("ChangePW", new { msg = "無效的舊密碼!" }));
            }
            else if (Mi.oldPW == Mi.PW)
            {
                return(RedirectToAction("ChangePW", new { msg = "新舊密碼不能相同!" }));
            }

            DB.DB        mydb = new DB.DB("SQLAdmin", "admin1234");
            DB.ICustomer ic   = new DB.Impl_Customer(mydb.Connection);
            ic.ChangePassword(Session["Login"].ToString(), Mi.PW);
            return(RedirectToAction("ChangePW", new { msg = "密碼變更成功!" }));
        }
        public ActionResult PlaceOrder(Models.Order order)
        {
            if (Session["Cart"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            DB.DB        mydb = new DB.DB();
            DB.ICustomer ic   = new DB.Impl_Customer(mydb.Connection);
            order.custID = ic.GetCustIDByPhone(Session["Login"].ToString());

            DB.DB     mydb2 = new DB.DB("SQLAdmin", "admin1234");
            DB.IOrder io    = new DB.Impl_Order(mydb2.Connection);
            order.orderID = io.AddNewOrder(order.custID, order.rcptName, order.rcptPhone, order.rcptAddr, order.DTID, order.Shipping, order.orderNote);

            HashSet <Models.CartItem> myCart =
                Session["Cart"] as HashSet <Models.CartItem>;

            List <Dictionary <string, object> > items = new List <Dictionary <string, object> >();

            foreach (Models.CartItem ii in myCart)
            {
                Dictionary <string, object> temp = new Dictionary <string, object>();
                temp["proID"]    = ii.ID;
                temp["Quantity"] = ii.Quantity;
                items.Add(temp);
            }

            DB.DB     mydb3  = new DB.DB("SQLAdmin", "admin1234");
            DB.IOrder io2    = new DB.Impl_Order(mydb3.Connection);
            bool      finish = io2.AddCartItems(order.orderID, items);

            if (finish)
            {
                return(RedirectToAction("FinishOrder", new { msg = "已完成訂單!請至個人中心查看!" }));
            }
            else
            {
                return(RedirectToAction("FinishOrder", new { msg = "訂單失敗!請重新下訂貨聯絡客服!" }));
            }
        }
 public bool CheckLI(string phone, string pw)
 {
     DB.DB        mydb = new DB.DB();
     DB.ICustomer ic   = new DB.Impl_Customer(mydb.Connection);
     return(ic.CheckLogin(phone, pw));
 }