Exemplo n.º 1
0
        public ActionResult 修改消息(int id)
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tPromotion        promotion = dbContext.tPromotions.FirstOrDefault(p => p.PromotionId == id);

            if (promotion == null)
            {
                return(RedirectToAction("員工看產品頁面"));
            }
            DetailPromotionViewModel Promo = new DetailPromotionViewModel();

            Promo.pADimage             = promotion.pADimage;
            Promo.pCondition           = promotion.pCondition;
            Promo.pDiscount            = promotion.pDiscount;
            Promo.pPromotionDeadline   = promotion.pPromotionDeadline;
            Promo.pPromotionPostDate   = promotion.pPromotionPostDate;
            Promo.pPromotionStartDate  = promotion.pPromotionStartDate;
            Promo.pPromotionWeb        = promotion.pPromotionWeb;
            Promo.PromotionDescription = promotion.PromotionDescription;
            Promo.sPromotinoCategory   = promotion.tPromotionCategory.PromtionCategory;
            Promo.PromotionName        = promotion.PromotionName;
            Promo.pDiscountCode        = promotion.pDiscountCode;
            Promo.PromotionId          = promotion.PromotionId;


            Promo.sPromotinoCategory = promotion.tPromotionCategory.PromtionCategory;
            Promo.pCategory          = promotion.PromotinoCategory;
            var categories = new PromotionRespoitory().GetPromoCategoryAll();
            List <SelectListItem> Cateitems = commodityRespoitory.GetSelectList(categories);//???? 黑人問號

            Promo.Categories = Cateitems;
            return(View(Promo));
        }
Exemplo n.º 2
0
        public ActionResult 修改消息(DetailPromotionViewModel promotion)
        {
            if (CSession關鍵字.SK_LOGINED_EMPLOYEE == null)
            {
                return(RedirectToAction("員工登入"));
            }
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tPromotion        Promo     = dbContext.tPromotions.FirstOrDefault(p => p.PromotionId == promotion.PromotionId);

            if (Promo != null)
            {
                Promo.pCondition           = promotion.pCondition;
                Promo.pDiscount            = promotion.pDiscount;
                Promo.pPromotionDeadline   = promotion.pPromotionDeadline;
                Promo.pPromotionPostDate   = promotion.pPromotionPostDate;
                Promo.pPromotionStartDate  = promotion.pPromotionStartDate;
                Promo.pPromotionWeb        = promotion.pPromotionWeb;
                Promo.PromotionDescription = promotion.PromotionDescription;
                Promo.PromotinoCategory    = promotion.pCategory;
                Promo.PromotionName        = promotion.PromotionName;
                Promo.pDiscountCode        = promotion.pDiscountCode;
                Promo.PromotionId          = promotion.PromotionId;
                Promo.pPromotionPostDate   = DateTime.Now;
                var uploagFile = promotion.upLoadimage;
                if (uploagFile != null)
                {
                    FileInfo file      = new FileInfo(uploagFile.FileName);
                    string   photoName = Guid.NewGuid().ToString() + file.Extension;
                    uploagFile.SaveAs(Server.MapPath("~/images/" + photoName));
                    Promo.pADimage = "../../images/" + Url.Content(photoName);
                }
                dbContext.SaveChanges();
            }
            return(RedirectToAction("員工看消息"));
        }
Exemplo n.º 3
0
        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("首頁"));
            }
        }
Exemplo n.º 4
0
        public ActionResult 修改消息(DetailPromotionViewModel promotion)
        {
            if (CSession關鍵字.SK_LOGINED_EMPLOYEE == null)
            {
                return(RedirectToAction("員工登入"));
            }
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tPromotion        Promo     = dbContext.tPromotions.FirstOrDefault(p => p.PromotionId == promotion.PromotionId);

            if (Promo != null)
            {
                Promo.pADimage             = promotion.pADimage;
                Promo.pCondition           = promotion.pCondition;
                Promo.pDiscount            = promotion.pDiscount;
                Promo.pPromotionDeadline   = promotion.pPromotionDeadline;
                Promo.pPromotionPostDate   = promotion.pPromotionPostDate;
                Promo.pPromotionStartDate  = promotion.pPromotionStartDate;
                Promo.pPromotionWeb        = promotion.pPromotionWeb;
                Promo.PromotionDescription = promotion.PromotionDescription;
                Promo.PromotinoCategory    = promotion.pCategory;
                Promo.PromotionName        = promotion.PromotionName;
                Promo.pDiscountCode        = promotion.pDiscountCode;
                Promo.PromotionId          = promotion.PromotionId;
                dbContext.SaveChanges();
            }
            return(RedirectToAction("員工看消息"));
        }
Exemplo n.º 5
0
        public OrderPayStatus GetPayStatus(int orderId)
        {
            tOrder order = dbContext.tOrders.Where(o => o.OrderId == orderId).FirstOrDefault();
            List <tOrderDetail> detaillist = dbContext.tOrderDetails.Where(od => od.oOrderId == orderId).ToList();
            List <tOrderPay>    paylist    = dbContext.tOrderPays.Where(op => op.oOrderId == orderId).ToList();
            OrderPayStatus      payStatus  = new OrderPayStatus();

            foreach (var detail in detaillist)
            {
                int price = Convert.ToInt32(dbContext.tProducts.Where(p => p.ProductId == detail.oProductId).FirstOrDefault().pPrice);
                payStatus.TotalAmount += detail.oProductQty * price;
            }
            tPromotion promotion = dbContext.tPromotions.Where(pm => pm.PromotionId == order.oPromotionId).FirstOrDefault();

            if (promotion != null)
            {
                payStatus.TotalAmount -= Convert.ToInt32(promotion.pDiscount);
            }
            if (paylist.Count() == 0)
            {
                payStatus.AlreadyPay = 0;
            }
            else
            {
                foreach (var payitem in paylist)
                {
                    payStatus.AlreadyPay += Convert.ToInt32(payitem.oPayment);
                }
            }
            payStatus.Unpaid = payStatus.TotalAmount - payStatus.AlreadyPay;
            return(payStatus);
        }
Exemplo n.º 6
0
        public ActionResult 新增消息(DetailPromotionViewModel create消息)
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tPromotion        n消息       = new tPromotion();

            n消息.PromotionName        = create消息.PromotionName;
            n消息.PromotinoCategory    = create消息.pCategory;
            n消息.PromotionDescription = create消息.PromotionDescription;
            n消息.pPromotionStartDate  = create消息.pPromotionStartDate;
            n消息.pPromotionDeadline   = create消息.pPromotionDeadline;
            //n消息.pADimage = create消息.pADimage;
            n消息.pDiscountCode = create消息.pDiscountCode;
            n消息.pDiscount     = create消息.pDiscount;
            n消息.pCondition    = create消息.pCondition;
            var date = DateTime.Now;

            n消息.pPromotionPostDate = date;

            int PromotionId = dbContext.tPromotions.OrderByDescending(o => o.PromotionId).First().PromotionId;

            PromotionId = PromotionId + 1;

            //if (create消息.upLoadimage.Count() > 0)
            //{
            //    foreach (var uploagFile in create消息.upLoadimage)
            //    {
            //        if (uploagFile.ContentLength > 0)
            //        {
            //            FileInfo file = new FileInfo(uploagFile.FileName);
            //            string photoName = Guid.NewGuid().ToString() + file.Extension;
            //            uploagFile.SaveAs(Server.MapPath("~/images/" + photoName));
            //            n消息.pADimage = "~" + Url.Content("~/images/" + photoName);
            //            dbContext.tPromotions.Add(n消息);
            //            dbContext.SaveChanges();
            //        }
            //    }
            //}
            dbContext.SaveChanges();
            return(RedirectToAction("員工看消息"));


            //if (n新增產品.pImage.Count() > 0)
            //{
            //    foreach (var uploagFile in n新增產品.pImage)
            //    {
            //        if (uploagFile.ContentLength > 0)
            //        {
            //            tProductImage image = new tProductImage();
            //            FileInfo file = new FileInfo(uploagFile.FileName);
            //            string photoName = Guid.NewGuid().ToString() + file.Extension;
            //            uploagFile.SaveAs(Server.MapPath("~/images/" + photoName));
            //            image.ProductId = ProductId;
            //            image.pImage = "~" + Url.Content("~/images/" + photoName);
            //            db.tProductImages.Add(image);
            //        }
            //    }
            //}
        }
Exemplo n.º 7
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("首頁"));
 }
Exemplo n.º 8
0
        public JsonResult 修改消息讀圖(int PromotionId)
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tPromotion        Promo     = dbContext.tPromotions.FirstOrDefault(p => p.PromotionId == PromotionId);

            if (Promo.pADimage != null)
            {
                string image = Url.Content(Promo.pADimage);
                return(Json(new { images = image }));
            }
            else
            {
                return(Json(new { images = "" }));
            }
        }
Exemplo n.º 9
0
        public DetailPromotionViewModel GetPromotionById(int PromotionId)
        {
            tPromotion promotion           = dbContext.tPromotions.FirstOrDefault(p => p.PromotionId == PromotionId);
            DetailPromotionViewModel Promo = new DetailPromotionViewModel();

            Promo.pADimage             = promotion.pADimage;
            Promo.pCondition           = promotion.pCondition;
            Promo.pDiscount            = promotion.pDiscount;
            Promo.pPromotionDeadline   = promotion.pPromotionDeadline;
            Promo.pPromotionPostDate   = promotion.pPromotionPostDate;
            Promo.pPromotionStartDate  = promotion.pPromotionStartDate;
            Promo.pPromotionWeb        = promotion.pPromotionWeb;
            Promo.PromotionDescription = promotion.PromotionDescription;
            Promo.sPromotinoCategory   = promotion.tPromotionCategory.PromtionCategory;
            Promo.PromotionName        = promotion.PromotionName;
            Promo.pDiscountCode        = promotion.pDiscountCode;
            Promo.PromotionId          = promotion.PromotionId;
            return(Promo);
        }
Exemplo n.º 10
0
        public ActionResult 新增消息(DetailPromotionViewModel create消息)
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tPromotion        n消息       = new tPromotion();

            n消息.PromotionName        = create消息.PromotionName;
            n消息.PromotinoCategory    = create消息.pCategory;
            n消息.PromotionDescription = create消息.PromotionDescription;
            n消息.pPromotionStartDate  = create消息.pPromotionStartDate;
            n消息.pPromotionDeadline   = create消息.pPromotionDeadline;
            n消息.pPromotionWeb        = create消息.pPromotionWeb;
            n消息.pDiscountCode        = create消息.pDiscountCode;
            n消息.pDiscount            = create消息.pDiscount;
            n消息.pCondition           = create消息.pCondition;
            var date = DateTime.Now;

            n消息.pPromotionPostDate = date;

            int PromotionId = dbContext.tPromotions.OrderByDescending(o => o.PromotionId).First().PromotionId;

            PromotionId = PromotionId + 1;
            var uploagFile = create消息.upLoadimage;

            if (uploagFile == null)
            {
            }
            if (uploagFile.ContentLength > 0)
            {
                FileInfo file      = new FileInfo(uploagFile.FileName);
                string   photoName = Guid.NewGuid().ToString() + file.Extension;
                uploagFile.SaveAs(Server.MapPath("~/images/" + photoName));
                n消息.pADimage = "../../images/" + Url.Content(photoName);
                dbContext.tPromotions.Add(n消息);
            }
            dbContext.SaveChanges();
            return(RedirectToAction("員工看消息"));
        }
Exemplo n.º 11
0
        //實體結帳畫面
        public ActionResult realCheckView(int OrderId)
        {
            MotaiDataEntities         dbContext = new MotaiDataEntities();
            EmployeeCheckoutViewModel model     = new EmployeeCheckoutViewModel();
            EmployeeOrderViewModel    Order     = new EmployeeOrderViewModel();
            tOrder order = dbContext.tOrders.Where(o => o.OrderId.Equals(OrderId)).FirstOrDefault();

            Order.CustomerName = dbContext.tCustomers.Where(c => c.CustomerId == order.oCustomerId).FirstOrDefault().cName;
            Order.oAddress     = order.oAddress;
            Order.oDate        = order.oDate;
            if (order.cNote != null)
            {
                Order.cNote = order.cNote;
            }
            else
            {
                Order.cNote = "無";
            }

            List <tOrderDetail> orderDetails = dbContext.tOrderDetails.Where(od => od.oOrderId.Equals(OrderId)).ToList();
            List <EmployeeOrderDetailViewModel> Orderdetails = new List <EmployeeOrderDetailViewModel>();

            foreach (var itemdetails in orderDetails)
            {
                tProduct product = dbContext.tProducts.Where(p => p.ProductId.Equals(itemdetails.oProductId)).FirstOrDefault();
                EmployeeOrderDetailViewModel Orderdetail = new EmployeeOrderDetailViewModel();
                Orderdetail.oOrderId     = OrderId;
                Orderdetail.ProductName  = product.pName;
                Orderdetail.ProductNum   = product.pNumber;
                Orderdetail.ProductPrice = product.pPrice;
                Orderdetail.oProductQty  = itemdetails.oProductQty;
                model.originalPrice     += itemdetails.oProductQty * Convert.ToInt32(product.pPrice);
                Orderdetails.Add(Orderdetail);
            }
            if (order.oPromotionId != null)
            {
                tPromotion promotion = dbContext.tPromotions.Where(p => p.PromotionId == order.oPromotionId).FirstOrDefault();
                Order.PromotionName      = promotion.PromotionName;
                Order.PromotionDiscount  = promotion.pDiscount;
                Order.PromotionCondition = promotion.pCondition;
                model.TotalAmount        = model.originalPrice - Convert.ToInt32(promotion.pDiscount);
            }
            else
            {
                Order.PromotionName      = "不適用任何優惠活動";
                Order.PromotionDiscount  = "0";
                Order.PromotionCondition = "無";
                model.TotalAmount        = model.originalPrice;
            }
            model.AlreadyPay = 0;
            model.Unpaid     = model.TotalAmount;
            if (dbContext.tOrderPays.Where(op => op.oOrderId.Equals(OrderId)).ToList() != null)
            {
                List <tOrderPay> pays = dbContext.tOrderPays.Where(op => op.oOrderId.Equals(OrderId)).ToList();
                foreach (var item in pays)
                {
                    model.AlreadyPay += Convert.ToInt32(item.oPayment);
                }
                model.Unpaid = model.TotalAmount - model.AlreadyPay;
            }
            model.Order        = Order;
            model.orderDetails = Orderdetails;

            return(View(model));
        }
Exemplo n.º 12
0
        public List <OrderViewModel> GetOrderAllByEmp(int EmployeeId)
        {
            List <tOrder>         order     = dbContext.tOrders.OrderByDescending(o => o.oDate).Where(o => o.oEmployeeId == EmployeeId).ToList();
            List <OrderViewModel> orderlist = new List <OrderViewModel>();

            foreach (tOrder item in order)
            {
                OrderViewModel Order = new OrderViewModel();
                Order.oAddress = item.oAddress;
                Order.oCheck   = item.oCheck;
                if (item.oCheckDate != null)
                {
                    Order.oCheckDate = item.oCheckDate.Value.Date;
                }


                Order.oDate = item.oDate.Date;
                //if(item.oDeliverDate)
                //Order.oDeliverDate = item.oDeliverDate.Value.Date;
                Order.OrderId = item.OrderId;

                Order.sWarehouseName = item.tWarehouseName.WarehouseName;
                Order.seName         = item.tEmployee.eName;
                Order.scName         = item.tCustomer.cName;
                var note = item.cNote;
                if (note != null)
                {
                    if (note.Length > 10)
                    {
                        Order.cNote = note.Substring(0, 10) + "...";
                    }
                    else
                    {
                        Order.cNote = note;
                    }
                }
                //變數 - 觀察付了多少錢
                var receivedMoney = from tP in dbContext.tOrderPays
                                    where tP.oOrderId == item.OrderId
                                    select tP.oPayment;
                //已收到
                int receivedTotal = 0;
                foreach (var receivedM in receivedMoney)
                {
                    receivedTotal = (int)receivedM + receivedTotal;
                }

                Order.received = receivedTotal;
                //應收款
                var receivableMoney = from tp in dbContext.tOrderDetails
                                      where tp.oOrderId == item.OrderId
                                      select tp.oProductQty * tp.tProduct.pPrice;
                //全額
                int receivableTotal = 0;

                foreach (var receivableM in receivableMoney)
                {
                    receivableTotal += (int)receivableM;
                }
                //折扣
                if (item.oPromotionId != null)
                {
                    tPromotion promotion = dbContext.tPromotions.Where(p => p.PromotionId == item.oPromotionId).FirstOrDefault();

                    if (promotion.PromotionName.Length > 7)
                    {
                        Order.PromotionName = promotion.PromotionName.Substring(0, 6) + ".";
                    }
                    else
                    {
                        Order.PromotionName = promotion.PromotionName;
                    }

                    //Order.PromotionName = promotion.PromotionName;
                    Order.pDiscount  = Convert.ToInt32(item.tPromotion.pDiscount);
                    receivableTotal -= Convert.ToInt32(item.tPromotion.pDiscount);
                }

                Order.receivable = receivableTotal;
                //應付款額-收款
                var surplus = receivableTotal - receivedTotal;
                Order.surplus = surplus;
                if (item.oCheck != null)
                {
                    Order.htmlName = "tr_hidden1";
                }
                else if (surplus <= 0)
                {
                    Order.htmlName = "tr_hidden2";
                }
                else
                {
                    Order.htmlName = "tr_hidden3";
                }
                List <AccountOrderDetailViewModel> detailViewModels = new List <AccountOrderDetailViewModel>();
                List <tOrderDetail> detailLists = dbContext.tOrderDetails.Where(od => od.oOrderId == item.OrderId).ToList();
                foreach (tOrderDetail itemdetail in detailLists)
                {
                    AccountOrderDetailViewModel detail = new AccountOrderDetailViewModel();
                    tProduct product = dbContext.tProducts.Where(p => p.ProductId == itemdetail.oProductId).FirstOrDefault();
                    detail.ProductNum   = product.pNumber;
                    detail.ProductName  = product.pName;
                    detail.ProductPrice = product.pPrice;
                    detail.oProductQty  = itemdetail.oProductQty;
                    detail.oNote        = itemdetail.oNote;
                    detailViewModels.Add(detail);
                }
                Order.orderDetailViews = detailViewModels;
                orderlist.Add(Order);
            }
            return(orderlist);
        }