public UserForm() { InitializeComponent(); newUser = true; User = new User(); }
public void AddUser(User newUser) { using (IDocumentSession session = DocumentStore.OpenSession()) { session.Store(newUser); session.SaveChanges(); } }
public List<Purchase> UserPurchaseHistory(User user) { using (IDocumentSession session = DocumentStore.OpenSession()) { User loadedUser = session.Include("ItemPurchases,ItemId").Load<User>(user.Id); foreach (Purchase purchase in loadedUser.ItemPurchases.OrderByDescending(p => p.Timestamp)) { purchase.Item = session.Load<Item>(purchase.ItemId); } return loadedUser.ItemPurchases; } }
public void EditUser(User changedUser) { using (IDocumentSession session = DocumentStore.OpenSession()) { User storedUser = session.Load<User>(changedUser.Id); storedUser.Active = changedUser.Active; storedUser.Name = changedUser.Name; storedUser.Team = changedUser.Team; storedUser.Study = changedUser.Study; storedUser.Barcode = changedUser.Barcode; storedUser.Bill = changedUser.Bill; storedUser.ItemPurchases = changedUser.ItemPurchases; session.SaveChanges(); } }
public UserForm(User user) { InitializeComponent(); User = user; NameField.Text = User.Name; BarcodeField.Text = User.Barcode; StudyField.Text = User.Study; TeamField.Text = User.Team; BillField.Text = User.Bill.ToString(); if (!User.Active) { SwitchActive(); } DeletBtn.Enabled = true; }
public void Buy(Purchase newPurchase, User buyer) { using (IDocumentSession session = DocumentStore.OpenSession()) { Item loadedItem = session.Load<Item>(newPurchase.Item.Id); loadedItem.Sold += newPurchase.Quantity; loadedItem.Stock -= newPurchase.Quantity; User loadedUser = session.Load<User>(buyer.Id); loadedUser.ItemPurchases.Add(new Purchase { ItemId = loadedItem.Id, Quantity = newPurchase.Quantity, Timestamp = newPurchase.Timestamp }); loadedUser.Bill += loadedItem.Price*newPurchase.Quantity; session.SaveChanges(); } }
public LoggedInForm(UnitOfWork unitOfWork, User loggedInUser, IdleForm idleForm) { if (unitOfWork == null) { throw new NullReferenceException(); } UnitOfWork = unitOfWork; IdleForm = idleForm; PurchaseHistory = new BindingList<string>(); CheckOutList = new BindingList<Purchase>(); Multipliers = new Dictionary<string, int>(); logLevel = 3; generateMultipliers(); LoggedInUser = loggedInUser; InitializeComponent(); SetElementSize(); AddLogMessage(1, String.Format("--- Welcome to InTracker! Current time is {0:HH:mm}", DateTime.Now)); UpdateElements(loggedInUser); UpdateHistoryList(); RefreshLogo(); }
private void UpdateElements(User user) { LoggedInNameLabel.Text = user.Name; LoggedInStudyLabel.Text = user.Study; LoggedInTeamLabel.Text = user.Team; LoggedInPerformanceLabel.Text = "??"; LoggedInTab.Text = user.Bill.ToString(); }
public void ImportExcel(Stream stream) { using (IDocumentSession session = DocumentStore.OpenSession()) { string line; Regex regex = new Regex(@"^(;*|navn.*)$", RegexOptions.Compiled | RegexOptions.ExplicitCapture); // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(stream); while ((line = file.ReadLine()) != null && !regex.IsMatch(line)) { string[] words = line.Split(';'); User user = new User { Active = true, Name = words[0], Barcode = words[1], Team = words[2], Study = words[3] }; session.Store(user); } file.Close(); session.SaveChanges(); } }
public void RemoveUser(User existingUser) { using (IDocumentSession session = DocumentStore.OpenSession()) { User storedUser = session.Load<User>(existingUser.Id); session.Delete(storedUser); session.SaveChanges(); } }
public void LoadNewUser(User newUser) { logIn.Dispose(); Login(newUser.Barcode); }