public List <S> Select <S>(Expression <Func <T, S> > selector)
 {
     using (ShoppingMallEntities context = new ShoppingMallEntities())
     {
         return(context.Set <T>().Select(selector).ToList());
     }
 }
예제 #2
0
 public List <Customer> GetAll()
 {
     using (ShoppingMallEntities context = new ShoppingMallEntities())
     {
         return(context.Customers.Distinct().ToList());
     }
 }
 public List <string> GetEmployeePW()
 {
     using (ShoppingMallEntities context = new ShoppingMallEntities())
     {
         return(context.Employees.Select(x => x.LoginPW).ToList());
     }
 }
 public Employee GetByPK(int employeeId)
 {
     using (ShoppingMallEntities context = new ShoppingMallEntities())
     {
         return(context.Employees.FirstOrDefault(x => x.EmployeeID == employeeId));
     }
 }
 public Order GetByPK(int orderId)
 {
     using (ShoppingMallEntities context = new ShoppingMallEntities())
     {
         return(context.Orders.FirstOrDefault(x => x.OrderID == orderId));
     }
 }
 public List <T> GetAll()
 {
     using (ShoppingMallEntities context = new ShoppingMallEntities())
     {
         return(context.Set <T>().ToList());
     }
 }
 public List <String> GetParentsCategoryName()
 {
     using (ShoppingMallEntities context = new ShoppingMallEntities())
     {
         return(context.ParentsCategories.
                Select(x => x.ParentsCategoryName).Distinct().ToList());
     }
 }
        public void Delete(T entity)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                context.Entry(entity).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
        public void Insert(T entity)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                context.Set <T>().Add(entity);

                context.SaveChanges();
            }
        }
예제 #10
0
        public List <Product> GetProductInfo()
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                var query = from x in context.Products
                            select x;

                return(query.ToList());
            }
        }
        public List <Employee> SearchInfo(string Name)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                var query = from x in context.Employees
                            where x.Name == Name
                            select x;

                return(query.ToList());
            }
        }
예제 #12
0
        public int GetByPK(string productName, string size, string color)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                var query = from x in context.Products
                            where x.ProductName == productName && x.Size == size && x.Color == color
                            select x;
                var productId = (query.Select(x => x.ProductId).First());

                return(productId);
            }
        }
예제 #13
0
        public List <Product> SearchInfo(string Name, string Parents, string Sub,
                                         string Size, string Color)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                var query = from x in context.Products
                            select x;
                query.ToList();

                if (string.IsNullOrEmpty(Name) == false)
                {
                    query = from x in query
                            where x.ProductName == Name
                            select x;
                    query.ToList();
                }

                if (string.IsNullOrEmpty(Parents) == false)
                {
                    query = from x in query
                            where x.ParentsCategory.ParentsCategoryName == Parents
                            select x;
                    query.ToList();
                }

                if (string.IsNullOrEmpty(Sub) == false)
                {
                    query = from x in query
                            where x.SubCategory.SubCategoryName == Sub
                            select x;
                    query.ToList();
                }
                if (string.IsNullOrEmpty(Size) == false)
                {
                    query = from x in query
                            where x.Size == Size
                            select x;
                    query.ToList();
                }

                if (string.IsNullOrEmpty(Color) == false)
                {
                    query = from x in query
                            where x.Color == Color
                            select x;
                    query.ToList();
                }

                return(query.ToList());
            }
        }
예제 #14
0
        public void DeliveredProduct()
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                Product product     = new Product();
                string  shippedDate = DateTime.Now.ToString("yy.MM.dd");
                //배송 날짜가 오늘날짜와 같은 상품주문서 찾기
                var query = from x in context.ProductOrders
                            where x.ShippedDate == shippedDate
                            select x;

                //배송되는 상품 기본키 찾기
                var pk = query.Select(x => x.ProductId).ToList();

                var orderAmount = query.Select(x => x.Amount).ToList();

                for (int i = 0; i < query.Count(); i++)
                {
                    int productId   = pk[i];
                    var productInfo = from x in context.Products
                                      where x.ProductId == productId
                                      select x;

                    var stockAmount = productInfo.Select(x => x.StockAmount).First();

                    if (stockAmount <= 5)
                    {
                        var productName       = productInfo.Select(x => x.ProductName).First();
                        var parentsCategoryId = productInfo.Select(x => x.ParentsCategoryId).First();
                        var subCategoryId     = productInfo.Select(x => x.SubCategoryId).First();
                        var size  = productInfo.Select(x => x.Size).First();
                        var color = productInfo.Select(x => x.Color).First();
                        var price = productInfo.Select(x => x.Price).First();

                        product.ProductId         = pk[i];
                        product.ProductName       = productName;
                        product.ParentsCategoryId = parentsCategoryId;
                        product.SubCategoryId     = subCategoryId;
                        product.Size         = size;
                        product.Color        = color;
                        product.Price        = price;
                        product.StockAmount += orderAmount[i];

                        DB.Product.Update(product);

                        MessageBox.Show("입고되었습니다.", "알림", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
        }
        public void ProductOrdering(int productId)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                ProductOrder productOrder = new ProductOrder();

                productOrder.ProductId   = productId;
                productOrder.SupplierId  = 2;
                productOrder.OrderDate   = DateTime.Now.ToString("yy.MM.dd");
                productOrder.ShippedDate =
                    DateTime.Now.AddDays(1).ToString("yy.MM.dd");
                productOrder.Amount = 10;
                DB.ProdutOrders.Insert(productOrder);
            }
        }
예제 #16
0
        public List <String> GetSubName(string ParentsName)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                var query = from x in context.Products
                            from y in context.SubCategories
                            where (x.ParentsCategoryId == y.ParentsCategoryId && x.SubCategoryId == y.SubCategoryId) &&
                            x.ParentsCategory.ParentsCategoryName == ParentsName
                            select x;

                var query1 = query.Select(x => x.SubCategory.SubCategoryName).Distinct().ToList();


                return(query1);
            }
        }
        public void ProductOrder(int Amount, string ProductName, string Color, string Size, object ProductInfo)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                Random        random             = new Random();
                Order         productOrder       = new Order();
                Order_Detail  productOrderDetail = new Order_Detail();
                LoginControl  frm           = new LoginControl();
                CustomerOrder customerOrder = new CustomerOrder();
                Product       productInfo   = ProductInfo as Product;

                if (productInfo == null)
                {
                    return;
                }

                productInfo.StockAmount = productInfo.StockAmount - Amount;
                int EId = context.Employees.Select(x => x.EmployeeID).Max();
                int SId = context.Shippers.Select(x => x.ShipperID).Max();

                int EmployeeId = random.Next(1, EId);
                int ShiperId   = random.Next(1, SId);

                int OId = context.Orders.Select(x => x.OrderID).ToList().Count;

                productOrder.OrderDate    = DateTime.Now.ToString("yy.MM.dd");
                productOrder.ShippedDate  = DateTime.Now.AddDays(5).ToString("yy.MM.dd");
                productOrder.OrderID      = OId + 1;
                productOrder.ShiperID     = ShiperId;
                productOrder.EmployeeID   = EId;
                productOrder.CustomerName = "Choi Haesong";

                productOrderDetail.OrderID   = productOrder.OrderID;
                productOrderDetail.Amount    = Amount;
                productOrderDetail.ProductId =
                    context.Products.Where(x => x.ProductName == ProductName && x.Size == Size &&
                                           x.Color == Color).Select(x => x.ProductId).First();

                DB.Order.Insert(productOrder);
                DB.Orderdetail.Insert(productOrderDetail);
                DB.Product.Update(productInfo);
            }
        }
 public void LoginOK(string Id, string PW)
 {
     using (ShoppingMallEntities context = new ShoppingMallEntities())
     {
         if (GetEmployeeId().Contains(Id) == true)
         {
             if (GetEmployeePW().Contains(PW) == true)
             {
                 MainmenuForm form1 = new MainmenuForm();
                 form1.ShowDialog();
             }
             else
             {
                 MessageBox.Show("비밀번호가 잘못입력되었습니다", "알림", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
         else
         {
             MessageBox.Show("아이디가 잘못되었습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
예제 #19
0
        public List <Customer> SearchInfo(string Id, string Grade)
        {
            using (ShoppingMallEntities context = new ShoppingMallEntities())
            {
                if (string.IsNullOrEmpty(Id) == true &&
                    string.IsNullOrEmpty(Grade) == true)
                {
                    var query = from x in context.Customers
                                select x;
                    return(query.ToList());
                }

                else if (string.IsNullOrEmpty(Id) == true)
                {
                    var query = from x in context.Customers
                                where x.Grade == Grade
                                select x;

                    return(query.ToList());
                }
                else if (string.IsNullOrEmpty(Grade) == true)
                {
                    var query = from x in context.Customers
                                where x.UserId == Id
                                select x;

                    return(query.ToList());
                }
                else
                {
                    var query = from x in context.Customers
                                where x.UserId == Id && x.Grade == Grade
                                select x;
                    return(query.ToList());
                }
            }
        }