Example #1
0
 public JsonResult 修改會員資料(MemberViewModel oldMember)
 {
     if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
     {
         tCustomer         customer  = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
         MotaiDataEntities dbContext = new MotaiDataEntities();
         tCustomer         cust      = dbContext.tCustomers.Find(customer.CustomerId);
         List <tCustomer>  custList  = dbContext.tCustomers.ToList();
         foreach (var item in custList)
         {
             if (item.cCellPhone == oldMember.cCellPhone)
             {
                 if (cust.cCellPhone != oldMember.cCellPhone)
                 {
                     return(Json(new { result = false, msg = "此手機號碼已被註冊" }));
                 }
             }
             else if (item.cEmail == oldMember.cEmail)
             {
                 if (cust.cEmail != oldMember.cEmail)
                 {
                     return(Json(new { result = false, msg = "此信箱已被註冊" }));
                 }
             }
         }
         cust.cName      = oldMember.cName;
         cust.cTelePhone = oldMember.cTelePhone;
         cust.cGUI       = oldMember.cGUI;
         cust.cEmail     = oldMember.cEmail;
         cust.cAddress   = oldMember.cAddress;
         dbContext.SaveChanges();
         return(Json(new { result = true, msg = "修改成功", url = Url.Action("會員中心", "Customer") }));
     }
     return(Json(new { result = true, msg = "請先登入", url = Url.Action("首頁", "Customer") }));
 }
Example #2
0
        public ActionResult 修改會員資料(int CustomerId)
        {
            MotaiDataEntities db   = new MotaiDataEntities();
            tCustomer         cust = db.tCustomers.FirstOrDefault(c => c.CustomerId == CustomerId);

            if (cust == null)
            {
                return(RedirectToAction("會員中心"));
            }
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tCustomer         custer    = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
            int count = dbContext.tStatus.Where(c => c.sCustomerId == custer.CustomerId).ToList().Count;

            ViewBag.Count = count;
            MemberViewModel customer = new MemberViewModel();

            customer.cAccount   = cust.cAccount;
            customer.cPassword  = cust.cPassword;
            customer.cName      = cust.cName;
            customer.cTelePhone = cust.cTelePhone;
            customer.cCellPhone = cust.cCellPhone;
            customer.cAddress   = cust.cAddress;
            customer.cGUI       = cust.cGUI;
            customer.cEmail     = cust.cEmail;
            return(View(customer));
        }
Example #3
0
        public ActionResult 會員中心()
        {
            if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
            {
                tCustomer         cust   = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
                MotaiDataEntities db     = new MotaiDataEntities();
                tCustomer         custor = db.tCustomers.Find(cust.CustomerId);
                MemberViewModel   member = new MemberViewModel();


                MotaiDataEntities dbContext = new MotaiDataEntities();
                int count = dbContext.tStatus.Where(c => c.sCustomerId == cust.CustomerId).ToList().Count;
                ViewBag.Count = count + "項";


                member.cName      = custor.cName;
                member.cTelePhone = custor.cTelePhone;
                member.cCellPhone = custor.cCellPhone;
                member.cAddress   = custor.cAddress;
                member.cGUI       = custor.cGUI;
                member.cEmail     = custor.cEmail;
                member.cAccount   = custor.cAccount;
                member.cPassword  = custor.cPassword;

                return(View(member));
            }
            return(RedirectToAction("首頁"));
        }
        public JsonResult 會員註冊(RegisterViewModel newMember)
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();
            List <tCustomer>  custo     = dbContext.tCustomers.ToList();

            foreach (var item in custo)
            {
                if (item.cAccount == newMember.cAccount)
                {
                    return(Json(new { msg = "帳號已被註冊" }));
                }
                else if (item.cEmail == newMember.cEmail)
                {
                    return(Json(new { msg = "信箱已被使用" }));
                }
            }
            if (newMember.cPassword == newMember.cConfirmPassword)
            {
                tCustomer newmember = new tCustomer();
                newmember.cAccount   = newMember.cAccount;
                newmember.cPassword  = newMember.cPassword;
                newmember.cName      = newMember.cName;
                newmember.cTelePhone = newMember.cTelePhone;
                newmember.cCellPhone = newMember.cCellPhone;
                newmember.cAddress   = newMember.cAddress;
                newmember.cGUI       = newMember.cGUI;
                newmember.cEmail     = newMember.cEmail;
                dbContext.tCustomers.Add(newmember);
                dbContext.SaveChanges();
                return(Json(new { msg = "註冊成功" }));
            }
            return(Json(new { msg = "註冊失敗" }));
        }
Example #5
0
        public ActionResult 購物車清單()
        {
            if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
            {
                MotaiDataEntities dbContext = new MotaiDataEntities();
                tCustomer         cust      = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
                int count = dbContext.tStatus.Where(c => c.sCustomerId == cust.CustomerId).ToList().Count;
                ViewBag.Count = count + "項";

                List <tStatu> StateList             = dbContext.tStatus.Where(c => c.sCustomerId == cust.CustomerId).ToList();
                List <StatusCartViewModel> cartList = new List <StatusCartViewModel>();
                StatusCartGoToPayViewModel Cart     = new StatusCartGoToPayViewModel();
                foreach (var items in StateList)
                {
                    tProduct            cartProd = dbContext.tProducts.Where(p => p.ProductId == items.sProductId).FirstOrDefault();
                    StatusCartViewModel cartC    = new StatusCartViewModel();
                    cartC.StatusId    = items.StatusId;
                    cartC.ProductId   = items.sProductId;
                    cartC.pName       = cartProd.pName;
                    cartC.pPrice      = cartProd.pPrice;
                    cartC.sProductQty = items.sProductQty;
                    cartList.Add(cartC);
                }
                Cart.Carts = cartList;
                var warehouseNames = commodityRespoitory.GetWarehouseAll();
                List <SelectListItem> warehouselist = commodityRespoitory.GetSelectList(warehouseNames);
                Cart.warehouses = warehouselist;
                return(View(Cart));
            }
            else
            {
                return(RedirectToAction("首頁"));
            }
        }
        public JsonResult CustomerChangePassword(int CustomerId, string cPassword, string oldpass)
        {
            if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
            {
                tCustomer         customer  = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
                MotaiDataEntities dbContext = new MotaiDataEntities();

                if (customer.cPassword == oldpass)
                {
                    customer.cPassword = cPassword;
                    Session[CSession關鍵字.SK_LOGINED_CUSTOMER] = customer;
                    tCustomer changePwd = dbContext.tCustomers.Where(c => c.CustomerId.Equals(customer.CustomerId)).FirstOrDefault();
                    changePwd.cPassword = cPassword;
                    dbContext.SaveChanges();
                    return(Json(new { result = true, msg = "更新成功" }));
                }
                else
                {
                    return(Json(new { result = false, msg = "舊密碼錯誤" }));
                }
            }
            else
            {
                return(Json(new { result = false, msg = "請先登入" }));
            }
        }
        public ActionResult 購物車清單()
        {
            if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
            {
                MotaiDataEntities          dbContext = new MotaiDataEntities();
                tCustomer                  cust      = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
                List <tStatu>              StateList = dbContext.tStatus.Where(c => c.sCustomerId == cust.CustomerId).ToList();
                List <StatusCartViewModel> cartList  = new List <StatusCartViewModel>();

                foreach (var items in StateList)
                {
                    tPromotion          discount = dbContext.tPromotions.Where(p => p.PromotionId == items.sProductId).FirstOrDefault();
                    tProduct            cartProd = dbContext.tProducts.Where(p => p.ProductId == items.sProductId).FirstOrDefault();
                    StatusCartViewModel cartC    = new StatusCartViewModel();
                    cartC.StatusId      = items.StatusId;
                    cartC.pName         = cartProd.pName;
                    cartC.pPrice        = cartProd.pPrice;
                    cartC.sProductQty   = items.sProductQty;
                    cartC.pDiscountCode = discount.pDiscountCode;
                    cartList.Add(cartC);
                }
                return(View(cartList));
            }
            else
            {
                return(RedirectToAction("首頁"));
            }
        }
Example #8
0
        public ActionResult UserMain(int?p)
        {
            dbDemoDataContext db       = new dbDemoDataContext();
            tCustomer         customer = (new dbDemoDataContext()).tCustomer.FirstOrDefault(m => m.fId == p);

            customer = Session[CDictionary.LOGIN_USER] as tCustomer;
            Timer timer = new Timer(5000);

            timer.AutoReset = true;
            timer.Enabled   = true;
            if (customer != null)
            {
                ViewBag.Id      = customer.fId.ToString() + ".jpg";
                ViewBag.Name    = customer.fName;
                ViewBag.Phone   = customer.fPhone;
                ViewBag.Email   = customer.fEmail;
                ViewBag.Address = customer.fAddress;
                AllModel all = new AllModel();
                return(View(all));
            }
            else
            {
                return(RedirectToAction("../Home/Index"));
            }
        }
Example #9
0
        //搜尋客戶訂單
        public JsonResult SearchCustomerOrder(string CustomerCell)
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tCustomer         cust      = dbContext.tCustomers.Where(c => c.cCellPhone.Equals(CustomerCell)).FirstOrDefault();

            if (cust == null)
            {
                return(Json(new { result = false, msg = "查無此人" }));
            }
            else
            {
                int           custId    = cust.CustomerId;
                List <tOrder> orderlist = dbContext.tOrders.Where(o => o.oCustomerId == custId && o.oCheck == null).ToList();
                List <SearchCustomerOrderModel> searchlist = new List <SearchCustomerOrderModel>();
                foreach (var item in orderlist)
                {
                    SearchCustomerOrderModel search = new SearchCustomerOrderModel();
                    search.orderId       = item.OrderId;
                    search.purchaseDate  = item.oDate.ToString("yyyy/MM/dd");
                    search.WarehouseName = dbContext.tWarehouseNames.Where(wn => wn.WarehouseNameId == item.oWarehouseName).FirstOrDefault().WarehouseName;
                    OrderPayStatus payStatus = orderRespoitory.GetPayStatus(item.OrderId);
                    search.TotalAmount = payStatus.TotalAmount;
                    search.AlreadyPay  = payStatus.AlreadyPay;
                    search.Unpaid      = payStatus.Unpaid;
                    searchlist.Add(search);
                }
                return(Json(new { result = true, list = searchlist }));
            }
        }
Example #10
0
        public ActionResult Login(tCustomer p)
        {
            dbDemoDataContext db = new dbDemoDataContext();
            tCustomer         c  = db.tCustomer.FirstOrDefault(
                m => m.fEmail == p.fEmail);

            if (c == null)
            {
                ViewBag.kk = "郵件不可空白";
                return(View());
            }

            if ((c.fEmail != p.fEmail) || (c.fPassword != p.fPassword))
            {
                if (c.fPassword == "")
                {
                    ViewBag.kk = "請輸入密碼";
                    return(View());
                }
                else
                {
                    ViewBag.kk = "帳號或密碼輸入錯誤";
                    return(View());
                }
            }
            else
            {
                Session[CDictionary.LOGIN_USER] = c;
                return(RedirectToAction("../User/UserMain"));
            }
        }
 //加入購物車
 public JsonResult AddToCart(int ProductId, int buyQty)
 {
     if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
     {
         tCustomer         cust = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
         MotaiDataEntities db   = new MotaiDataEntities();
         var product            = (new MotaiDataEntities()).tProducts.FirstOrDefault(p => p.ProductId == ProductId);
         if (product != null && product.pQty > buyQty)
         {
             tStatu cart = new tStatu();
             cart.sCustomerId = cust.CustomerId;
             cart.sProductId  = ProductId;
             cart.sProductQty = buyQty;
             db.tStatus.Add(cart);
             db.SaveChanges();
             return(Json(new { result = true, msg = "加入成功" }));
         }
         else
         {
             return(Json(new { result = false, msg = "庫存不足" }));
         }
     }
     else
     {
         return(Json(new { result = false, msg = "請先登入" }));
     }
 }
Example #12
0
        public ActionResult EditCompany(tCustomer p)
        {
            tCustomer c = db.tCustomers.FirstOrDefault(u => u.fCustomerID == p.fCustomerID);

            if (c == null)
            {
                return(RedirectToAction("EditCompany"));
            }
            else
            {
                c.fContactName = p.fContactName;
                c.fCompanyName = p.fCompanyName;
                c.fCity        = p.fCity;
                c.fAddress     = p.fAddress;
                c.fFox         = p.fFox;
                c.fPhone       = p.fPhone;
                c.fTaxID       = p.fTaxID;
                c.fTelephone   = p.fTelephone;
                db.SaveChanges();
                return(RedirectToAction("Index", new { Message = ManageMessageId.ChangeCompanyInfoSuccess }));
            }

            //string username = Session[CDictionary.SK_Logon_UserName].ToString();
            //var q = (from p in db.tCustomers
            //         where p.fUserName == username
            //         select p).FirstOrDefault();
        }
 [HttpPost]  //代表用表單的submit做傳送,如果沒有寫表示是用get的呼叫方式走網址
 public ActionResult Create(tCustomer vCustomer)
 {
     db.tCustomer.Add(vCustomer);
     db.SaveChanges();
     TempData["ResultMsg"] = string.Format("顧客[{0}]成功新增", vCustomer.fName);
     return(RedirectToAction("Index"));
 }
Example #14
0
 public ActionResult Registeration(tCustomer p)
 {
     try
     {
         if (p != null)
         {
             dbMSIT126TeamEntities db = new dbMSIT126TeamEntities();
             p.fUserName = Session[CDictionary.SK_Logon_UserName].ToString();
             db.tCustomers.Add(p);
             db.SaveChanges();
             var q = (from c in db.tCustomers
                      where c.fUserName == p.fUserName
                      select c.fCustomerID).FirstOrDefault();
             Session[CDictionary.SK_Logon_ID] = q.ToString();
             return(RedirectToAction("Index", "Home"));
         }
         return(View());
     }
     catch
     {
         p.fUserName = User.Identity.Name;
         db.tCustomers.Add(p);
         db.SaveChanges();
         var q = (from c in db.tCustomers
                  where c.fUserName == p.fUserName
                  select c.fCustomerID).FirstOrDefault();
         Session[CDictionary.SK_Logon_ID] = q.ToString();
         return(RedirectToAction("Index", "Manage"));
     }
 }
Example #15
0
 //客戶訂單
 public ActionResult 客戶看訂單()
 {
     if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
     {
         tCustomer                     cust      = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
         MotaiDataEntities             db        = new MotaiDataEntities();
         List <tOrder>                 orders    = db.tOrders.Where(o => o.oCustomerId.Equals(cust.CustomerId)).ToList();
         List <CustomerOrderViewModel> OrderList = new List <CustomerOrderViewModel>();
         foreach (var items in orders)
         {
             CustomerOrderViewModel order = new CustomerOrderViewModel();
             order.oDate         = items.oDate;
             order.WarehouseName = db.tWarehouseNames.Where(w => w.WarehouseNameId.Equals(items.oWarehouseName)).FirstOrDefault().WarehouseName;
             order.EmployeeName  = db.tEmployees.Where(e => e.EmployeeId.Equals(items.oEmployeeId)).FirstOrDefault().eName;
             order.cNote         = items.cNote;
             List <tOrderDetail> orderdetails = db.tOrderDetails.Where(od => od.oOrderId.Equals(items.OrderId)).ToList();
             List <CustomerOrderDetailViewModel> OrderDetailList = new List <CustomerOrderDetailViewModel>();
             foreach (var itemDetail in orderdetails)
             {
                 CustomerOrderDetailViewModel orderdetail = new CustomerOrderDetailViewModel();
                 orderdetail.ProductNum  = db.tProducts.Where(p => p.ProductId.Equals(itemDetail.oProductId)).FirstOrDefault().pNumber;
                 orderdetail.ProductName = db.tProducts.Where(p => p.ProductId.Equals(itemDetail.oProductId)).FirstOrDefault().pName;
                 orderdetail.oProductQty = itemDetail.oProductQty;
                 orderdetail.oNote       = itemDetail.oNote;
                 OrderDetailList.Add(orderdetail);
             }
             order.CustomerOrderDetails = OrderDetailList;
             OrderList.Add(order);
         }
         return(View(OrderList));
     }
     return(RedirectToAction("首頁"));
 }
Example #16
0
 public JsonResult 實體店新增訂單(EmployeeOrderViewModel empOrder)
 {
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] != null)
     {
         tEmployee emp = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
         if (Session[CSession關鍵字.SK_ORDERDETAIL] == null)
         {
             return(Json(new { result = false, msg = "訂單尚未完成!", url = Url.Action("實體店新增訂單", "Order") }));
         }
         else
         {
             List <EmployeeOrderDetailViewModel> orders = Session[CSession關鍵字.SK_ORDERDETAIL] as List <EmployeeOrderDetailViewModel>;
             MotaiDataEntities dbContext = new MotaiDataEntities();
             tCustomer         customer  = dbContext.tCustomers.Where(c => c.cCellPhone == empOrder.cCellphone).FirstOrDefault();
             tOrder            list      = new tOrder();
             list.oEmployeeId = emp.EmployeeId;
             list.oCustomerId = customer.CustomerId;
             if (empOrder.oAddress == null)
             {
                 list.oAddress = customer.cAddress;
             }
             else
             {
                 list.oAddress = empOrder.oAddress;
             }
             list.oDate          = empOrder.oDate;
             list.cNote          = empOrder.cNote;
             list.oWarehouseName = empOrder.oWarehouseName;
             dbContext.tOrders.Add(list);
             dbContext.SaveChanges();
             int orderId       = dbContext.tOrders.OrderByDescending(i => i.OrderId).First().OrderId;
             int originalPrice = 0;
             foreach (var items in orders)
             {
                 tOrderDetail detail = new tOrderDetail();
                 detail.oOrderId    = orderId;
                 detail.oProductId  = items.oProductId;
                 detail.oProductQty = items.oProductQty;
                 detail.oNote       = items.oNote;
                 dbContext.tOrderDetails.Add(detail);
                 tProduct product = dbContext.tProducts.Where(p => p.ProductId.Equals(items.oProductId)).FirstOrDefault();
                 originalPrice += items.oProductQty * Convert.ToInt32(product.pPrice);
             }
             tOrder order       = dbContext.tOrders.Where(o => o.OrderId == orderId).FirstOrDefault();
             int    promotionId = orderRespoitory.SelectPromotionId(originalPrice, empOrder.oDate);
             if (promotionId != 0)
             {
                 order.oPromotionId = promotionId;
             }
             dbContext.SaveChanges();
             Session[CSession關鍵字.SK_ORDERDETAIL] = null;
             return(Json(new { result = true, msg = "新增成功", url = Url.Action("realCheckView", "Order"), OrderId = orderId }));
         }
     }
     else
     {
         return(Json(new { result = false, msg = "尚未登入!", url = Url.Action("員工登入", "Employee") }));
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            tCustomer tCustomer = db.tCustomers.Find(id);

            db.tCustomers.Remove(tCustomer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #18
0
 public bool SaveCustomer(tCustomer entity)
 {
     if (entity.Id > 0)
     {
         return(customerRepo.Update(entity));
     }
     return(customerRepo.Insert(entity));
 }
Example #19
0
        public ActionResult Logout(tCustomer p)
        {
            Session.Clear();
            dbDemoDataContext db = new dbDemoDataContext();
            tCustomer         c  = db.tCustomer.FirstOrDefault(
                m => m.fId == p.fId);

            return(RedirectToAction("../Home/Index"));
        }
Example #20
0
        public ActionResult New(tCustomer p)
        {
            dbDemoDataContext db = new dbDemoDataContext();

            db.tCustomer.InsertOnSubmit(p);
            db.SubmitChanges();

            return(RedirectToAction("List"));
        }
Example #21
0
 //客戶看訂單
 public ActionResult 過往訂單()
 {
     if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
     {
         tCustomer                     cust      = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
         MotaiDataEntities             db        = new MotaiDataEntities();
         List <tOrder>                 orders    = db.tOrders.Where(o => o.oCustomerId == cust.CustomerId).ToList();
         List <CustomerOrderViewModel> OrderList = new List <CustomerOrderViewModel>();
         foreach (var items in orders)
         {
             CustomerOrderViewModel order = new CustomerOrderViewModel();
             order.oDate         = items.oDate;
             order.WarehouseName = db.tWarehouseNames.Where(w => w.WarehouseNameId.Equals(items.oWarehouseName)).FirstOrDefault().WarehouseName;
             tEmployee employee = db.tEmployees.Where(e => e.EmployeeId == items.oEmployeeId).FirstOrDefault();
             if (employee != null)
             {
                 order.EmployeeName = employee.eName;
             }
             order.cNote = items.cNote;
             List <tOrderDetail> orderdetails = db.tOrderDetails.Where(od => od.oOrderId == items.OrderId).ToList();
             List <CustomerOrderDetailViewModel> OrderDetailList = new List <CustomerOrderDetailViewModel>();
             int originPrice = 0;
             foreach (var itemDetail in orderdetails)
             {
                 CustomerOrderDetailViewModel orderdetail = new CustomerOrderDetailViewModel();
                 tProduct product = db.tProducts.Where(p => p.ProductId == itemDetail.oProductId).FirstOrDefault();
                 orderdetail.ProductNum   = product.pNumber;
                 orderdetail.ProductName  = product.pName;
                 orderdetail.ProductPrice = product.pPrice;
                 orderdetail.oProductQty  = itemDetail.oProductQty;
                 orderdetail.oNote        = itemDetail.oNote;
                 OrderDetailList.Add(orderdetail);
                 originPrice += Convert.ToInt32(product.pPrice) * itemDetail.oProductQty;
             }
             if (items.oPromotionId != null)
             {
                 tPromotion promotion = db.tPromotions.Where(p => p.PromotionId == items.oPromotionId).FirstOrDefault();
                 order.TotalAmount = originPrice - Convert.ToInt32(promotion.pDiscount);
             }
             else
             {
                 order.TotalAmount = originPrice;
             }
             List <tOrderPay> paylists = db.tOrderPays.Where(op => op.oOrderId == items.OrderId).ToList();
             foreach (var itemPay in paylists)
             {
                 order.AlreadyPay += Convert.ToInt32(itemPay.oPayment);
             }
             order.Unpaid = order.TotalAmount - order.AlreadyPay;
             order.CustomerOrderDetails = OrderDetailList;
             OrderList.Add(order);
         }
         return(View(OrderList));
     }
     return(RedirectToAction("首頁"));
 }
Example #22
0
        public string getCustomerById(int?fId)
        {
            tCustomer x = (new dbDemoEntities()).tCustomer.FirstOrDefault(m => m.fId == fId);

            if (x == null)
            {
                return("查無客戶資料");
            }
            return(x.fName + "<br>" + x.fPhone);
        }
Example #23
0
 public bool Update(tCustomer entity)
 {
     if (entity == null)
     {
         return(false);
     }
     context.Customers.Update(entity);
     context.SaveChanges();
     return(true);
 }
Example #24
0
        public ActionResult customer(int id)//廠商資料
        {
            tCustomer customer = db.tCustomers.First(p => p.fCustomerID == id);

            if (customer == null)
            {
                return(RedirectToAction("sales"));
            }
            return(View(customer));
        }
 public ActionResult Edit([Bind(Include = "fCustomerId,fCustomerName,fCustomerBirth,fCustomerGender,fCustomerEmail,fCustomerAddress,fCustomerPhone")] tCustomer tCustomer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tCustomer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tCustomer));
 }
Example #26
0
 // GET: Customer
 public ActionResult 首頁()
 {
     if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
     {
         MotaiDataEntities dbContext = new MotaiDataEntities();
         tCustomer         cust      = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
         int count = dbContext.tStatus.Where(c => c.sCustomerId == cust.CustomerId).ToList().Count;
         ViewBag.Count = count + "項";
     }
     return(View());
 }
        public ActionResult Create([Bind(Include = "fCustomerId,fCustomerName,fCustomerBirth,fCustomerGender,fCustomerEmail,fCustomerAddress,fCustomerPhone")] tCustomer tCustomer)
        {
            if (ModelState.IsValid)
            {
                db.tCustomers.Add(tCustomer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tCustomer));
        }
Example #28
0
        public ActionResult Update(int qq)
        {
            dbDemoDataContext db   = new dbDemoDataContext();
            tCustomer         cust = db.tCustomer.FirstOrDefault(m => m.fId == qq);

            if (cust != null)
            {
                return(View(cust));
            }
            return(RedirectToAction("List"));
        }
        public JsonResult beforeSendEmail(ForgotPasswordViewModel c電子郵件)
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tCustomer         d信箱確認     = dbContext.tCustomers.Where(c => c.cEmail == c電子郵件.Email).FirstOrDefault();

            if (d信箱確認 != null)
            {
                return(Json(new { result = true, msg = "已寄出修改密碼的信件!", url = Url.Action("首頁", "Customer") }));
            }
            return(Json(new { result = false, msg = "此電子郵件尚未被註冊", url = Url.Action("會員註冊", "Customer") }));
        }
Example #30
0
        public bool Insert(tCustomer entity)
        {
            if (entity == null)
            {
                return(false);
            }

            context.Customers.Add(entity);
            context.SaveChanges();
            return(true);
        }