private void btnLogin_Click(object sender, RoutedEventArgs e)
 {
     if (!LoginUser(txtEmail.Text, pwBoxAdmin.Password) && (from users in dbContext.GetTable <User>()
                                                            where users.Email == txtEmail.Text
                                                            select users).ToList().Count > 0)
     {
         MessageBox.Show("The email address or password you provided is incorrect.", "Inventory Manager Error System");
         pwBoxAdmin.Password = "";
     }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Grabs all of the bins containing items and sets the combobox's datasource to it
            binList = (from bins in dbContext.GetTable <InventoryEntry>() select bins.BinId).ToList();
            cbBinSearch.ItemsSource = binList;

            //Gets all possible shelves that the user could change to
            cbShelfSearch.ItemsSource = (from shelves in dbContext.GetTable <Shelf>() select shelves.ShelfId).ToList <String>();

            //Gets all possible foods that the user could change to
            cbFoodSearch.ItemsSource = (from foods in dbContext.GetTable <Food>() select foods.FoodName).ToList <String>();
        }
 private List <FoodInfo> GetFoods()
 {
     return((from foods in dbContext.GetTable <Food>()
             select new FoodInfo
     {
         FoodName = foods.FoodName,
         MinimumQty = foods.MinimumQty
     }).ToList());
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     /*Gets all of the inventory entries that are condensed in the InventoryInfo object that was passed
      * to the constructor of this page
      */
     individualEntries = (from entries in dbContext.GetTable <InventoryEntry>()
                          where entries.FoodName == selectedEntry.FoodName
                          select new InventoryInfo
     {
         FoodName = entries.FoodName,
         BinId = entries.BinId,
         ShelfId = entries.ShelfId,
         DateEntered = entries.DateEntered,
         Quantity = entries.ItemQty
     }).ToList();
     //Sets the data source of the datagrid to the previous linq query
     gridItems.ItemsSource = individualEntries;
 }
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            //If user enters a password that matches the database, user's password is changed to desired new password
            User myCurrentUser = new User();

            if (Validate(txtEmail.Text))
            {
                myCurrentUser = (from users in dbContext.GetTable <User>()
                                 where users.Email == txtEmail.Text
                                 select users).First();
            }
            if (BCrypt.CheckPassword(pwBoxCurrent.Password, myCurrentUser.Password))
            {
                string myHash = "";
                if (Validate(pwBoxNew.Password))
                {
                    string mySalt = BCrypt.GenerateSalt();
                    myHash = BCrypt.HashPassword(pwBoxNew.Password, mySalt);
                }
                else
                {
                    MessageBox.Show("Please enter a password.", "Inventory Manager Error System");
                }
                if (Validate(pwBoxConfirm.Password) && BCrypt.CheckPassword(pwBoxConfirm.Password, myHash))
                {
                    //For some reason you have to query for the user instead of being able to use
                    //the one passed to you (i.e. myCurrentUser), or at least that's only what works for me
                    User user = (from users in dbContext.GetTable <User>()
                                 where users.Email == myCurrentUser.Email
                                 select users).First <User>();
                    user.Password = myHash;
                    dbContext.SubmitChanges();
                    MessageBox.Show("Password successfully changed!");
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Incorrect password provided.", "Inventory Manager Error System");
            }
        }
        private void btnRmvFromInv_Click(object sender, RoutedEventArgs e)
        {
            //string[] foodQuery = (from food in dbContext.GetTable<InvBin>() where food.FoodCode == txtFood.Text orderby food.DateEntered select food).ToArray<string>();
            //Gathers info from Bins for oldest to newest
            //IQueryable < InvBin > dateQuery = from database in foodQuery orderby database.DateEntered select database;
            var oldestItem = (from food in dbContext.GetTable <InventoryEntry>() where food.FoodId == txtFood.Text orderby food.DateEntered select food).First();

            txtBinRemove.Text   = oldestItem.BinId;
            txtShelfRemove.Text = oldestItem.ShelfId;

            //delete from InvBin based on BinCode
            dbContext.InventoryEntries.DeleteOnSubmit(oldestItem);
            dbContext.SubmitChanges();
        }
Esempio n. 7
0
        /// <summary>
        /// Displays items that are entered into database in current session page is opened in
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnScan_Click(object sender, RoutedEventArgs e)
        {
            inputBox.Visibility = Visibility.Visible;
            ScannerEmulator se = new ScannerEmulator(myCurrentUser);

            se.ShowDialog();
            var inventoryInfo = from items in dbContext.GetTable <InventoryEntry>()
                                where items.DateEntered > dateOpened
                                select new DepositEntry
            {
                FoodName = items.FoodName,
                BinId    = items.BinId,
                ShelfId  = items.ShelfId,
                Quantity = items.ItemQty
            };

            grdItems.ItemsSource = inventoryInfo;
            inputBox.Visibility  = Visibility.Collapsed;
        }
Esempio n. 8
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     /*
      * Loads every audit record from database and loads it into a object displaying specific
      * properties of audit record (AuditInfo)
      */
     auditEntries = (from entries in dbContext.GetTable <AuditEntry>()
                     select new AuditInfo
     {
         EntryId = entries.AuditEntryId,
         FoodName = entries.FoodName,
         BinId = entries.BinId,
         ShelfId = entries.ShelfId,
         Qty = entries.ItemQty,
         Date_Action_Occured = entries.Date_Action_Occured,
         UserName = entries.UserName,
         ApplicationName = entries.ApplicationName,
         Action = entries.Action
     }).ToList();
     //Set's the datagrid's data source to the previous linq query
     gridAudit.ItemsSource = auditEntries;
 }
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (Validate(txtFoodName.Text))
            {
                if (myFoodName != txtFoodName.Text)
                {
                    MessageBoxResult result = MessageBox.Show("Are you sure you want to change " + myFoodName + " to " + txtFoodName.Text + "?",
                                                              "Confirm Change",
                                                              MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        string newFoodName = txtFoodName.Text;
                        Food   changedFood = (from foods in dbContext.GetTable <Food>() //Queries for old food name, and
                                              where foods.FoodName == myFoodName        //then sets it to new food name
                                              select foods).First();
                        changedFood.FoodName = newFoodName;

                        dbContext.SubmitChanges();
                        MessageBox.Show(myFoodName + " successfully changed to " + newFoodName + ".");
                        myFoodName = newFoodName;
                    }
                    else
                    {
                        return;
                    }
                }
                if (Validate(txtMinQty.Text))
                {
                    //if food with matching foodname exists and the desired min quantity is different from current, change the current min quantity to desired
                    if ((from foods in dbContext.GetTable <Food>()
                         where foods.FoodName == myFoodName
                         select foods).ToList().Count != 0)
                    {
                        if ((from foods in dbContext.GetTable <Food>()
                             where foods.FoodName == myFoodName
                             select foods.MinimumQty).First() != Convert.ToInt32(txtMinQty.Text))
                        {
                            int oldQty = (from foods in dbContext.GetTable <Food>()
                                          where foods.FoodName == myFoodName
                                          select foods.MinimumQty).First();
                            MessageBoxResult result = MessageBox.Show("Are you sure you want to change the minimum quantity of " + myFoodName + "?",
                                                                      "Confirm Change",
                                                                      MessageBoxButton.YesNo);
                            if (result == MessageBoxResult.Yes)
                            {
                                string newFoodName = txtFoodName.Text;
                                int    newQty      = Convert.ToInt32(txtMinQty.Text);
                                Food   changedFood = (from foods in dbContext.GetTable <Food>()
                                                      where foods.FoodName == newFoodName
                                                      select foods).First();
                                changedFood.MinimumQty = newQty;

                                dbContext.SubmitChanges();
                                MessageBox.Show("Minimum threshold of " + newFoodName + " changed from " + oldQty + " to " + newQty + " successfully!");
                            }
                        }
                    }
                }
            }
            Close();
        }
Esempio n. 10
0
 /// <summary>
 /// Retrieves current inventory
 /// </summary>
 /// <returns></returns>
 private List <InventoryInfo> getCurrentInventory()
 {
     return((from items in dbContext.GetTable <InventoryEntry>()
             select new InventoryInfo
     {
         FoodName = items.FoodName,
         DateEntered = items.DateEntered,
         BinId = string.Join(", ", (from bins in dbContext.GetTable <InventoryEntry>()        //grabs all bins food is in and puts them in a comma seperated string
                                    where bins.FoodName == items.FoodName
                                    select bins.BinId).Distinct().ToList()),
         ShelfId = string.Join(", ", (from shelves in dbContext.GetTable <InventoryEntry>()        //grabs all shelves that food is on and puts them in a comma seperated string
                                      where shelves.FoodName == items.FoodName
                                      select shelves.ShelfId).ToList().Distinct()),
         Quantity = (from foods in dbContext.GetTable <Food>()
                     where foods.FoodName == items.FoodName
                     select foods.Quantity).First()
     }).GroupBy(i => i.FoodName).Select(g => g.First()).ToList());        //Groups inventory entries by food name
 }