Пример #1
0
 private void LoadSalesData()
 {
     using (var db = new StoreManagerContext())
     {
         allSaleItems = db.SaleItems.Include("Product").Include("Sale").ToList();
     }
     bsSales.DataSource = allSaleItems;
 }
Пример #2
0
 private void GetUsersData()
 {
     using (var db = new StoreManagerContext())
     {
         allUsers           = db.Users.Include("Role").ToList();
         bsUsers.DataSource = allUsers;
     }
 }
 private void GetSuppliersData()
 {
     using (var db = new StoreManagerContext())
     {
         allSuppliers           = db.Suppliers.ToList();
         bsSuppliers.DataSource = allSuppliers;
     }
 }
Пример #4
0
 private void InitStoreContext()
 {
     if (StoreContext == null)
     {
         m_Context = new StoreManagerContext();
         m_Context.Init();
         lookUpEditStores.Properties.DataSource = ListOfStoresView;
     }
 }
Пример #5
0
 private void InitStoreContext()
 {
     if (StoreContext == null)
     {
         m_Context = new StoreManagerContext();
         m_Context.Init();
         lookUpEditStores.Properties.DataSource = ListOfStoresView;
     }
 }
 private void GetProductsData(Supplier supplier)
 {
     using (var db = new StoreManagerContext())
     {
         supplierProducts = (from p in db.Products
                             where p.SupplierID == supplier.SupplierID
                             select p).ToList();
     }
     bsProducts.DataSource = supplierProducts;
 }
Пример #7
0
 private void LoadSuppliersData()
 {
     using (var db = new StoreManagerContext())
     {
         allSuppliers = db.Suppliers.ToList();
     }
     bsSuppliers.DataSource = allSuppliers;
     if (IsEditItem())
     {
         MoveToEditedItemPosition();
     }
 }
        private void RemoveProduct()
        {
            Product product = GetSelectedProduct();

            using (var db = new StoreManagerContext())
            {
                Product productToRemove = (from s in db.Products
                                           where s.ProductID == product.ProductID
                                           select s).Single();
                db.Products.Remove(productToRemove);
                db.SaveChanges();
            }
        }
Пример #9
0
        private void RemoveUser()
        {
            User user = GetSelectedUser();

            using (var db = new StoreManagerContext())
            {
                User userToRemove = (from u in db.Users
                                     where u.UserID == user.UserID
                                     select u).Single();
                db.Users.Remove(userToRemove);
                db.SaveChanges();
            }
        }
        private void RemoveSupplier()
        {
            Supplier supplier = GetSelectedSupplier();

            using (var db = new StoreManagerContext())
            {
                Supplier supplierToRemove = (from s in db.Suppliers
                                             where s.SupplierID == supplier.SupplierID
                                             select s).Single();
                db.Suppliers.Remove(supplierToRemove);
                db.SaveChanges();
            }
        }
Пример #11
0
        public static void AuthenticateUser(string username, string password)
        {
            using (var db = new StoreManagerContext())
            {
                var user = (from u in db.Users
                            where u.UserName == username && u.Password == password
                            select u).SingleOrDefault();

                if (user != null)
                {
                    userInfo = new UserInfo(user.UserID, user.UserName, user.RoleID);
                }
            }
        }
Пример #12
0
        private void NewUser()
        {
            User        user       = new User();
            frmEditUser frmNewUser = new frmEditUser(user);

            if (frmNewUser.ShowDialog() == DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    db.Users.Add(user);
                    db.SaveChanges();
                }
            }
        }
        private void NewSupplier()
        {
            Supplier        supplier        = new Supplier();
            frmEditSupplier frmEditSupplier = new frmEditSupplier(supplier);

            if (frmEditSupplier.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    db.Suppliers.Add(supplier);
                    db.SaveChanges();
                }
            }
        }
Пример #14
0
 private Product GetSelectedProduct()
 {
     if (bsProducts.Current != null)
     {
         using (var db = new StoreManagerContext())
         {
             Product product = (from p in db.Products.Include("Supplier")
                                where p.ProductID == ((Product)bsProducts.Current).ProductID
                                select p).Single();
             return(product);
         }
     }
     return(null);
 }
Пример #15
0
 private Supplier GetSelectedSupplier()
 {
     if (bsSuppliers.Current != null)
     {
         using (var db = new StoreManagerContext())
         {
             Supplier supplier = (from s in db.Suppliers.Include("Products")
                                  where s.SupplierID == ((Supplier)bsSuppliers.Current).SupplierID
                                  select s).Single();
             return(supplier);
         }
     }
     return(null);
 }
Пример #16
0
        public static void AuthenticateUser(string username, string password)
        {
            using (var db = new StoreManagerContext())
            {
                var user = (from u in db.Users
                            where u.UserName == username && u.Password == password
                            select u).SingleOrDefault();

                if (user != null)
                {
                    userInfo = new UserInfo(user.UserID, user.UserName, user.RoleID);
                }
            }
        }
Пример #17
0
 public void SetStoreContext(StoreManagerContext context)
 {
     _context = context;
     lookUpEditStoresFrom.Properties.DataSource = ListOfStoresView;
     lookUpEditStoresTo.Properties.DataSource   = ListOfStoresView;
     lookUpEditStoresFrom.EditValue             = null;
     lookUpEditStoresTo.EditValue = null;
     if (Context.CurrentView != null)
     {
         toStoreID = Context.CurrentView.ID;
         lookUpEditStoresTo.Enabled = false;
     }
     lookUpEditStoresFrom.Properties.View.ExpandAllGroups();
     lookUpEditStoresTo.Properties.View.ExpandAllGroups();
 }
Пример #18
0
        public void SetStoreContext(StoreManagerContext context)
        {
            _context = context;
            lookUpEditStores.Properties.DataSource = ListOfStoresView;

            if (Context.CurrentView != null)
            {
                lookUpEditStores.EditValue = Context.CurrentView.ID;
            }
            lookUpEditStores.Properties.View.ExpandAllGroups();
            if ((ListOfStoresView != null) && (ListOfStoresView.Count == 1))
            {
                lookUpEditStores.EditValue = ListOfStoresView[0].ID;
            }
        }
        private void NewProduct()
        {
            Product        product        = new Product();
            frmEditProduct frmEditProduct = new frmEditProduct(product);

            if (frmEditProduct.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Supplier supplier = GetSelectedSupplier();
                product.SupplierID = supplier.SupplierID;
                using (var db = new StoreManagerContext())
                {
                    db.Products.Add(product);
                    db.SaveChanges();
                }
            }
        }
Пример #20
0
 private void EditUser()
 {
     User user = GetSelectedUser();
     frmEditUser frmEditUser = new frmEditUser(user);
     if (frmEditUser.ShowDialog() == DialogResult.OK)
     {
         using (var db = new StoreManagerContext())
         {
             var originalUser = (from u in db.Users
                                 where u.UserID == user.UserID
                                 select u).Single();
             CloneUser(user, originalUser);
             db.SaveChanges();
         }
     }
 }
Пример #21
0
        private void EditUser()
        {
            User        user        = GetSelectedUser();
            frmEditUser frmEditUser = new frmEditUser(user);

            if (frmEditUser.ShowDialog() == DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    var originalUser = (from u in db.Users
                                        where u.UserID == user.UserID
                                        select u).Single();
                    CloneUser(user, originalUser);
                    db.SaveChanges();
                }
            }
        }
Пример #22
0
 private void AddSale()
 {
     sale.SaleItems = saleItems;
     sale.SaleTimeStamp = DateTime.Now;
     using (var db = new StoreManagerContext())
     {
         foreach (SaleItem saleItem in sale.SaleItems)
         {
             Product product = (from p in db.Products
                                where p.ProductID == saleItem.ProductID
                                select p).Single();
             product.Stock -= saleItem.Quantity;
             saleItem.Product = null;
         }
         db.Sales.Add(sale);
         db.SaveChanges();
     }
 }
Пример #23
0
 private void AddSale()
 {
     sale.SaleItems     = saleItems;
     sale.SaleTimeStamp = DateTime.Now;
     using (var db = new StoreManagerContext())
     {
         foreach (SaleItem saleItem in sale.SaleItems)
         {
             Product product = (from p in db.Products
                                where p.ProductID == saleItem.ProductID
                                select p).Single();
             product.Stock   -= saleItem.Quantity;
             saleItem.Product = null;
         }
         db.Sales.Add(sale);
         db.SaveChanges();
     }
 }
        private void RegisterShipment()
        {
            Product          product          = GetSelectedProduct();
            frmEditShippment frmEditShippment = new frmEditShippment(product);

            if (frmEditShippment.ShowDialog() == DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    Product originalProduct = (from p in db.Products
                                               where p.ProductID == product.ProductID
                                               select p).Single();

                    originalProduct.Stock = product.Stock;
                    db.SaveChanges();
                }
            }
        }
        private void EditProduct()
        {
            Product        product        = GetSelectedProduct();
            frmEditProduct frmEditProduct = new frmEditProduct(product);

            if (frmEditProduct.ShowDialog() == DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    Product originalProduct = (from p in db.Products
                                               where p.ProductID == product.ProductID
                                               select p).Single();

                    CloneProduct(product, originalProduct);
                    db.SaveChanges();
                }
            }
        }
        private void EditSupplier()
        {
            Supplier        supplier        = GetSelectedSupplier();
            frmEditSupplier frmEditSupplier = new frmEditSupplier(supplier);

            if (frmEditSupplier.ShowDialog() == DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    var originalSupplier = (from s in db.Suppliers
                                            where s.SupplierID == supplier.SupplierID
                                            select s).Single();

                    CloneSupplier(supplier, originalSupplier);
                    db.SaveChanges();
                }
            }
        }
Пример #27
0
 private void LoadSuppliersData()
 {
     using (var db = new StoreManagerContext())
     {
         allSuppliers = db.Suppliers.ToList();
     }
     bsSuppliers.DataSource = allSuppliers;
     if (IsEditItem())
     {
         MoveToEditedItemPosition();
     }
 }
Пример #28
0
        public void SetStoreContext(StoreManagerContext context)
        {
            _context = context;
            gridLookUpEdit1.Properties.DataSource = ListOfStoresView;

            if (Context.CurrentView != null)
            {
                gridLookUpEdit1.EditValue = Context.CurrentView.ID;
            }
            gridLookUpEdit1.Properties.View.ExpandAllGroups();
            if ((ListOfStoresView != null) && (ListOfStoresView.Count == 1))
            {
                gridLookUpEdit1.EditValue = ListOfStoresView[0].ID;
            }
        }
        private void RegisterShipment()
        {
            Product product = GetSelectedProduct();
            frmEditShippment frmEditShippment = new frmEditShippment(product);
            if (frmEditShippment.ShowDialog() == DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    Product originalProduct = (from p in db.Products
                                               where p.ProductID == product.ProductID
                                               select p).Single();

                    originalProduct.Stock = product.Stock;
                    db.SaveChanges();
                }
            }
        }
Пример #30
0
 public void SetStoreContext(StoreManagerContext context)
 {
     m_context = context;
 }
Пример #31
0
 private void NewUser()
 {
     User user = new User();
     frmEditUser frmNewUser = new frmEditUser(user);
     if (frmNewUser.ShowDialog() == DialogResult.OK)
     {
         using (var db = new StoreManagerContext())
         {
             db.Users.Add(user);
             db.SaveChanges();
         }
     }
 }
Пример #32
0
 private void RemoveUser()
 {
     User user = GetSelectedUser();
     using (var db = new StoreManagerContext())
     {
         User userToRemove = (from u in db.Users
                              where u.UserID == user.UserID
                              select u).Single();
         db.Users.Remove(userToRemove);
         db.SaveChanges();
     }
 }
        private void EditProduct()
        {
            Product product = GetSelectedProduct();
            frmEditProduct frmEditProduct = new frmEditProduct(product);
            if (frmEditProduct.ShowDialog() == DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    Product originalProduct = (from p in db.Products
                                               where p.ProductID == product.ProductID
                                               select p).Single();

                    CloneProduct(product, originalProduct);
                    db.SaveChanges();
                }
            }
        }
 private void RemoveSupplier()
 {
     Supplier supplier = GetSelectedSupplier();
     using (var db = new StoreManagerContext())
     {
         Supplier supplierToRemove = (from s in db.Suppliers
                                      where s.SupplierID == supplier.SupplierID
                                      select s).Single();
         db.Suppliers.Remove(supplierToRemove);
         db.SaveChanges();
     }
 }
 private void RemoveProduct()
 {
     Product product = GetSelectedProduct();
     using (var db = new StoreManagerContext())
     {
         Product productToRemove = (from s in db.Products
                                    where s.ProductID == product.ProductID
                                    select s).Single();
         db.Products.Remove(productToRemove);
         db.SaveChanges();
     }
 }
 private void NewSupplier()
 {
     Supplier supplier = new Supplier();
     frmEditSupplier frmEditSupplier = new frmEditSupplier(supplier);
     if (frmEditSupplier.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         using (var db = new StoreManagerContext())
         {
             db.Suppliers.Add(supplier);
             db.SaveChanges();
         }
     }
 }
 private void NewProduct()
 {
     Product product = new Product();
     frmEditProduct frmEditProduct = new frmEditProduct(product);
     if (frmEditProduct.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         Supplier supplier = GetSelectedSupplier();
         product.SupplierID = supplier.SupplierID;
         using (var db = new StoreManagerContext())
         {
             db.Products.Add(product);
             db.SaveChanges();
         }
     }
 }
 private void GetSuppliersData()
 {
     using (var db = new StoreManagerContext())
     {
         allSuppliers = db.Suppliers.ToList();
     }
     bsSuppliers.DataSource = allSuppliers;
 }
Пример #39
0
 private void InitContext()
 {
     _context = new StoreManagerContext();
     _context.Init();
     SetStoreContext(Context);
 }
Пример #40
0
 private Supplier GetSelectedSupplier()
 {
     if(bsSuppliers.Current != null)
     {
         using (var db = new StoreManagerContext())
         {
             Supplier supplier = (from s in db.Suppliers.Include("Products")
                                  where s.SupplierID == ((Supplier)bsSuppliers.Current).SupplierID
                                  select s).Single();
             return supplier;
         }
     }
     return null;
 }
Пример #41
0
 public void InitContext()
 {
     _context = new StoreManagerContext();
     _context.Init();
     SetStoreContext(_context);
 }
Пример #42
0
 private Product GetSelectedProduct()
 {
     if (bsProducts.Current != null)
     {
         using (var db = new StoreManagerContext())
         {
             Product product = (from p in db.Products.Include("Supplier")
                                where p.ProductID == ((Product)bsProducts.Current).ProductID
                                select p).Single();
             return product;
         }
     }
     return null;
 }
Пример #43
0
 public OrderRepository(StoreManagerContext storeManagerContext)
 {
     this.storeManagerContext = storeManagerContext;
 }
Пример #44
0
 private void InitContext()
 {
     _context = new StoreManagerContext();
     _context.Init();
     SetStoreContext(Context);
 }
Пример #45
0
 public void SetStoreContext(StoreManagerContext context)
 {
     _context = context;
     lookUpEditStoresFrom.Properties.DataSource = ListOfStoresView;
     lookUpEditStoresTo.Properties.DataSource = ListOfStoresView;
     lookUpEditStoresFrom.EditValue = null;
     lookUpEditStoresTo.EditValue = null;
     if (Context.CurrentView != null)
     {
         toStoreID = Context.CurrentView.ID;
         lookUpEditStoresTo.Enabled = false;
     }
     lookUpEditStoresFrom.Properties.View.ExpandAllGroups();
     lookUpEditStoresTo.Properties.View.ExpandAllGroups();
 }
Пример #46
0
 private void GetUsersData()
 {
     using (var db = new StoreManagerContext())
     {
         allUsers = db.Users.Include("Role").ToList();
         bsUsers.DataSource = allUsers;
     }
 }
Пример #47
0
 public void InitContext()
 {
     _context = new StoreManagerContext();
     _context.Init();
     SetStoreContext(_context);
 }
        private void EditSupplier()
        {
            Supplier supplier = GetSelectedSupplier();
            frmEditSupplier frmEditSupplier = new frmEditSupplier(supplier);
            if (frmEditSupplier.ShowDialog() == DialogResult.OK)
            {
                using (var db = new StoreManagerContext())
                {
                    var originalSupplier = (from s in db.Suppliers
                                            where s.SupplierID == supplier.SupplierID
                                            select s).Single();

                    CloneSupplier(supplier, originalSupplier);
                    db.SaveChanges();
                }
            }
        }
Пример #49
0
 public LocationRepository(StoreManagerContext context)
     : base(context)
 {
 }
Пример #50
0
 private void LoadSalesData()
 {
     using (var db = new StoreManagerContext())
     {
         allSaleItems = db.SaleItems.Include("Product").Include("Sale").ToList();
     }
     bsSales.DataSource = allSaleItems;
 }
 private void GetProductsData(Supplier supplier)
 {
     using (var db = new StoreManagerContext())
     {
         supplierProducts = (from p in db.Products
                             where p.SupplierID == supplier.SupplierID
                             select p).ToList();
     }
     bsProducts.DataSource = supplierProducts;
 }