private void LoadSalesData() { using (var db = new StoreManagerContext()) { allSaleItems = db.SaleItems.Include("Product").Include("Sale").ToList(); } bsSales.DataSource = allSaleItems; }
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; } }
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; }
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(); } }
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(); } }
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); } } }
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(); } } }
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); }
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); }
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(); }
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(); } } }
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(); } } }
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(); } } }
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; } }
public void SetStoreContext(StoreManagerContext context) { m_context = context; }
private void GetSuppliersData() { using (var db = new StoreManagerContext()) { allSuppliers = db.Suppliers.ToList(); } bsSuppliers.DataSource = allSuppliers; }
private void InitContext() { _context = new StoreManagerContext(); _context.Init(); SetStoreContext(Context); }
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; }
public void InitContext() { _context = new StoreManagerContext(); _context.Init(); SetStoreContext(_context); }
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; }
public OrderRepository(StoreManagerContext storeManagerContext) { this.storeManagerContext = storeManagerContext; }
public LocationRepository(StoreManagerContext context) : base(context) { }