Exemple #1
0
        /// <summary>
        /// Delete Item
        /// </summary>
        private void DeleteItemBorrowing()
        {
            databaseEntities db = new databaseEntities();
            int count           = olvBorrowing.SelectedObjects.Count;

            if (count == 1)                // If selected Item
            {                              // Find Object
                Borrowing borr = db.Borrowing.Find(((Borrowing)olvBorrowing.SelectedObject).ID);

                if (Dialogs.ShowQuest(Lng.Get("DeleteItem", "Really delete item") + " \"" + borr.Item + "\"?", Lng.Get("Delete")) == DialogResult.Yes)
                {
                    db.Borrowing.Remove(borr);                  // Delete Item
                    db.SaveChanges();                           // Save to DB
                    UpdateBorrowingOLV();                       // Update Borrowing OLV
                }
            }
            else if (count > 1)                 // If selected Item
            {
                if (Dialogs.ShowQuest(Lng.Get("DeleteItems", "Really delete selected items") + " (" + count.ToString() + ")?", Lng.Get("Delete")) == DialogResult.Yes)
                {
                    foreach (var item in olvBorrowing.SelectedObjects) // Find Object
                    {
                        Borrowing itm = db.Borrowing.Find(((Borrowing)item).ID);
                        db.Borrowing.Remove(itm);               // Delete Item
                    }
                    db.SaveChanges();                           // Save to DB
                    UpdateBorrowingOLV();                       // Update Borrowing OLV
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Delete Item
        /// </summary>
        private void DeleteItemLending()
        {
            databaseEntities db = new databaseEntities();
            int count           = olvLending.SelectedObjects.Count;

            if (count == 1)                  // If selected Item
            {                                // Find Object
                Lending borr = db.Lending.Find(((Lending)olvLending.SelectedObject).ID);

                if (Dialogs.ShowQuest(Lng.Get("DeleteItem", "Really delete item") + " \"" + global.GetLendingItemName(borr.CopyType.Trim(), borr.CopyID ?? Guid.Empty) + "\"?", Lng.Get("Delete")) == DialogResult.Yes)
                {
                    db.Lending.Remove(borr);                    // Delete Item
                    db.SaveChanges();                           // Save to DB
                    UpdateLendingOLV();                         // Update Lending OLV
                    UpdateAllItemsOLV();
                }
            }
            else if (count > 1)                 // If selected Item
            {
                if (Dialogs.ShowQuest(Lng.Get("DeleteItems", "Really delete selected items") + " (" + count.ToString() + ")?", Lng.Get("Delete")) == DialogResult.Yes)
                {
                    foreach (var item in olvLending.SelectedObjects) // Find Object
                    {
                        Lending itm = db.Lending.Find(((Lending)item).ID);
                        db.Lending.Remove(itm);                 // Delete Item
                    }
                    db.SaveChanges();                           // Save to DB
                    UpdateLendingOLV();                         // Update Lending OLV
                    UpdateAllItemsOLV();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Delete Item
        /// </summary>
        private void DeleteItemContacts()
        {
            databaseEntities db = new databaseEntities();
            int count           = olvContacts.SelectedObjects.Count;

            if (count == 1)                 // If selected Item
            {                               // Find Object
                Contacts contact = db.Contacts.Find(((Contacts)olvContacts.SelectedObject).ID);

                if (Dialogs.ShowQuest(Lng.Get("DeleteItem", "Really delete item") + " \"" + contact.Name.Trim() + " " + contact.Surname.Trim() + "\"?", Lng.Get("Delete")) == DialogResult.Yes)
                {
                    db.Contacts.Remove(contact);                // Delete Item
                    db.SaveChanges();                           // Save to DB
                    UpdateConOLV();                             // Update Contacts OLV
                }
            }
            else if (count > 1)                 // If selected Item
            {
                if (Dialogs.ShowQuest(Lng.Get("DeleteItems", "Really delete selected items") + " (" + count.ToString() + ")?", Lng.Get("Delete")) == DialogResult.Yes)
                {
                    foreach (var item in olvContacts.SelectedObjects) // Find Object
                    {
                        Contacts contact = db.Contacts.Find(((Contacts)item).ID);
                        db.Contacts.Remove(contact);            // Delete Item
                    }
                    db.SaveChanges();                           // Save to DB
                    UpdateConOLV();                             // Update Contacts OLV
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Save edited items to DB
        /// </summary>
        private void SaveItem()
        {
            Items itm;

            // ----- Save last Specimen values -----
            SaveCopy();

            // ----- Check Duplicate InvNum -----
            foreach (var item in CopiesList)
            {
                string DulpicateInvNUm = "";
                if (global.IsDuplicate(item.InventoryNumber, item.ID))
                {
                    if (Dialogs.ShowQuest(String.Format(Lng.Get("DuplicateInvNum", "The inventory number {0} is already in use. Do you really write to database?"), DulpicateInvNUm), Lng.Get("Warning")) != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }


            // ----- Item ID -----
            if (ID != Guid.Empty)
            {
                itm = db.Items.Find(ID);
            }
            else
            {
                itm    = new Items();
                itm.ID = Guid.NewGuid();
            }

            // ----- Delete original Copies -----
            foreach (var item in OriginalCopies)
            {
                db.Copies.Remove(item);
            }
            db.SaveChanges();

            // ----- Add Copies to DB -----
            foreach (var item in CopiesList)
            {
                item.ItemID = itm.ID;
                db.Copies.Add(item);
            }
            db.SaveChanges();


            // ----- Fill Item values -----
            FillItem(ref itm);

            // ----- Update database -----
            if (ID == Guid.Empty)
            {
                db.Items.Add(itm);
            }
            db.SaveChanges();
        }
Exemple #5
0
        /// <summary>
        /// Button Ok
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            // ----- Find selected person in DB -----
            FindPerson();

            // ----- Check if record valid -----
            if (PersonGuid == Guid.Empty)
            {
                Dialogs.ShowWar(Lng.Get("NoSelPerson", "Not selected person!"), Lng.Get("Warning"));
                return;
            }

            if (selItemList.Count == 0)
            {
                Dialogs.ShowWar(Lng.Get("NoSelItem", "Not selected item!"), Lng.Get("Warning"));
                return;
            }

            databaseEntities db = new databaseEntities();

            Lending borr;

            // ----- Delete old data -----
            if (ID.Count > 0)
            {
                foreach (var itm in ID)
                {
                    borr = db.Lending.Find(itm);
                    db.Lending.Remove(borr);
                }
                db.SaveChanges();
            }

            // ----- Create new -----
            foreach (var itm in selItemList)
            {
                borr    = new Lending();
                borr.ID = Guid.NewGuid();
                FillLend(ref borr, itm);
                db.Lending.Add(borr);
            }

            // ----- Save to DB -----
            db.SaveChanges();

            // ----- Refresh Copy Status -----
            global.RefreshCopiesStatus(selItemList, (short)cbStatus.SelectedIndex);

            // ----- Refresh Available Items in Items Tables -----
            RefreshAvailableItems(selItemList);

            // ----- Close Barcode reader connection -----
            com.Close();

            this.DialogResult = DialogResult.OK;
        }
Exemple #6
0
        private void SaveItem()
        {
            Contacts contact;

            // ----- ID -----
            if (ID != Guid.Empty)
            {
                contact = db.Contacts.Find(ID);
            }
            else
            {
                contact    = new Contacts();
                contact.ID = Guid.NewGuid();
            }

            FillContact(ref contact);

            if (ID == Guid.Empty)
            {
                db.Contacts.Add(contact);
            }
            db.SaveChanges();

            ID = contact.ID;
        }
Exemple #7
0
        /// <summary>
        /// Save edited items to DB
        /// </summary>
        private void SaveItem()
        {
            Recipes itm;

            // ----- Item ID -----
            if (ID != Guid.Empty)
            {
                itm = db.Recipes.Find(ID);
            }
            else
            {
                itm    = new Recipes();
                itm.ID = Guid.NewGuid();
            }

            // ----- Fill Item values -----
            FillItem(ref itm);

            // ----- Update database -----
            if (ID == Guid.Empty)
            {
                db.Recipes.Add(itm);
            }
            db.SaveChanges();
        }
Exemple #8
0
        /// <summary>
        /// Delete Item
        /// </summary>
        private void DeleteItemBoard()
        {
            databaseEntities db = new databaseEntities();
            int count           = olvBoard.SelectedObjects.Count;

            if (count == 1)                     // If selected Item
            {                                   // Find Object
                Boardgames itm = db.Boardgames.Find(((Boardgames)olvBoard.SelectedObject).ID);

                if (Dialogs.ShowQuest(Lng.Get("DeleteItem", "Really delete item") + " \"" + itm.Name.Trim() + "\"?", Lng.Get("Delete")) == DialogResult.Yes)
                {
                    db.Boardgames.Remove(itm);                       // Delete Item

                    // ----- Remove copies -----
                    var copies = db.Copies.Where(x => (x.ItemType.Trim() == ItemTypes.boardgame.ToString()) && (x.ItemID == ((Boardgames)olvBoard.SelectedObject).ID)).ToList();
                    foreach (var copy in copies)
                    {
                        db.Copies.Remove(copy);                 // Remove copy
                    }

                    db.SaveChanges();                           // Save to DB
                    UpdateBoardOLV();                           // Update Items OLV
                    UpdateCopOLV();                             // Update Copies OLV
                }
            }
            else if (count > 1)                 // If selected Item
            {
                if (Dialogs.ShowQuest(Lng.Get("DeleteItems", "Really delete selected items") + " (" + count.ToString() + ")?", Lng.Get("Delete")) == DialogResult.Yes)
                {
                    foreach (var item in olvBoard.SelectedObjects) // Find Object
                    {
                        Boardgames itm = db.Boardgames.Find(((Boardgames)item).ID);
                        db.Boardgames.Remove(itm);                   // Delete Item

                        // ----- Remove copies -----
                        var copies = db.Copies.Where(x => (x.ItemType.Trim() == ItemTypes.boardgame.ToString()) && (x.ItemID == ((Boardgames)item).ID)).ToList();
                        foreach (var copy in copies)
                        {
                            db.Copies.Remove(copy);                 // Remove copy
                        }
                    }
                    db.SaveChanges();                           // Save to DB
                    UpdateBoardOLV();                           // Update Items OLV
                    UpdateCopOLV();                             // Update Copies OLV
                }
            }
        }
        /// <summary>
        /// Save changes to DB
        /// </summary>
        private void SaveChanges()
        {
            // ----- Save changes -----
            db.SaveChanges();

            // ----- No changes indicator -----
            changed = false;
        }
Exemple #10
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            FindPerson();
            FindItem();

            if (PersonGuid == Guid.Empty)
            {
                Dialogs.ShowWar(Lng.Get("NoSelPerson", "Not selected person!"), Lng.Get("Warning"));
                return;
            }

            if (ItemGuid == Guid.Empty)
            {
                Dialogs.ShowWar(Lng.Get("NoSelItem", "Not selected item!"), Lng.Get("Warning"));
                return;
            }

            if (Conv.ToIntDef(cbItemNum.Text, 0) == 0)
            {
                Dialogs.ShowWar(Lng.Get("NoSelItemNum", "Not selected item number!"), Lng.Get("Warning"));
                return;
            }

            databaseEntities db = new databaseEntities();

            Borrowing borr;

            // ----- ID -----
            if (ID != Guid.Empty)
            {
                borr = db.Borrowing.Find(ID);
            }
            else
            {
                borr    = new Borrowing();
                borr.ID = Guid.NewGuid();
            }

            FillBorr(ref borr);

            if (ID == Guid.Empty)
            {
                db.Borrowing.Add(borr);
            }
            db.SaveChanges();

            RefreshAvailableItems();


            this.DialogResult = DialogResult.OK;
        }
Exemple #11
0
 /// <summary>
 /// Set Fast Tags
 /// </summary>
 /// <param name="tag">Tags Mask</param>
 private void SetTagItemBoard(short tag)
 {
     if (olvBoard.SelectedObjects != null)                 // If selected Item
     {
         databaseEntities db = new databaseEntities();
         foreach (var item in olvBoard.SelectedObjects) // Find Object
         {
             Boardgames itm = db.Boardgames.Find(((Boardgames)item).ID);
             itm.FastTags |= tag;
         }
         db.SaveChanges();                           // Save to DB
         UpdateBoardOLV();                           // Update Contacts OLV
     }
 }
Exemple #12
0
 /// <summary>
 /// Set Fast Tags
 /// </summary>
 /// <param name="tag">Tags Mask</param>
 private void SetTagItemContacts(short tag)
 {
     if (olvContacts.SelectedObjects != null)                 // If selected Item
     {
         databaseEntities db = new databaseEntities();
         foreach (var item in olvContacts.SelectedObjects) // Find Object
         {
             Contacts contact = db.Contacts.Find(((Contacts)item).ID);
             contact.FastTags |= tag;
         }
         db.SaveChanges();                           // Save to DB
         UpdateConOLV();                             // Update Contacts OLV
     }
 }
        /// <summary>
        /// Save changes to DB
        /// </summary>
        private void SaveChanges()
        {
            // ----- Save changes -----
            db.SaveChanges();

            // ----- Refresh Copy Status -----
            global.RefreshCopiesStatus(lendList);

            // ----- Refresh Available Items -----
            RefreshAvailableItems();

            // ----- No changes indicator -----
            changed = false;
        }
Exemple #14
0
        /// <summary>
        /// Set active (excluded)
        /// </summary>
        /// <param name="active"></param>
        private void SetActiveBoard(bool active)
        {
            if (olvBoard.SelectedObjects != null)                 // If selected Item
            {
                databaseEntities db = new databaseEntities();

                foreach (var item in olvBoard.SelectedObjects) // Find Object
                {
                    Boardgames itm = db.Boardgames.Find(((Boardgames)item).ID);
                    itm.Excluded = !active;
                }
                db.SaveChanges();                           // Save to DB
                UpdateBoardOLV();                           // Update Contacts OLV
            }
        }
Exemple #15
0
        /// <summary>
        /// Set Fast Tags
        /// </summary>
        /// <param name="tag">Tags Mask</param>
        private void SetTagItemLending(short tag)
        {
            if (olvLending.SelectedObjects != null)                 // If selected Item
            {
                databaseEntities db = new databaseEntities();

                foreach (var item in olvLending.SelectedObjects) // Find Object
                {
                    Lending itm = db.Lending.Find(((Lending)item).ID);
                    itm.FastTags |= tag;
                }
                db.SaveChanges();                           // Save to DB
                UpdateLendingOLV();                         // Update Contacts OLV
            }
        }
Exemple #16
0
        /// <summary>
        /// Set active (excluded)
        /// </summary>
        /// <param name="active"></param>
        private void SetActiveContacts(bool active)
        {
            if (olvContacts.SelectedObjects != null)                 // If selected Item
            {
                databaseEntities db = new databaseEntities();

                foreach (var item in olvContacts.SelectedObjects) // Find Object
                {
                    Contacts itm = db.Contacts.Find(((Contacts)item).ID);
                    itm.Active = active;
                }
                db.SaveChanges();                           // Save to DB
                UpdateConOLV();                             // Update Contacts OLV
            }
        }
Exemple #17
0
        /// <summary>
        /// Set Fast Tags
        /// </summary>
        /// <param name="tag">Tags Mask</param>
        private void SetTagItemCopies(short tag)
        {
            if (olvRecipes.SelectedObjects != null)                 // If selected Item
            {
                databaseEntities db = new databaseEntities();

                foreach (var item in olvRecipes.SelectedObjects) // Find Object
                {
                    Recipes itm = db.Recipes.Find(((Recipes)item).ID);
                    itm.FastTags |= tag;
                }
                db.SaveChanges();                           // Save to DB
                UpdateRecOLV();                             // Update Contacts OLV
            }
        }
Exemple #18
0
        private void ImportObjects(string fileName)
        {
            List <Objects> con;

            if (Path.GetExtension(fileName) == "csv")
            {
                con = global.ImportObjectsCSV(fileName);
            }
            else
            {
                con = global.ImportObjectsXML(fileName);
            }

            if (con == null)
            {
                Dialogs.ShowErr(Lng.Get("ParseFileError", "Parse file error") + ".", Lng.Get("Error"));
                return;
            }

            databaseEntities db = new databaseEntities();

            foreach (var item in con)
            {
                Objects itm;
                // ----- ID -----
                if (item.ID != Guid.Empty)
                {
                    itm = db.Objects.Find(item.ID);
                    if (itm != null)
                    {
                        Conv.CopyClassPropetries(itm, item);
                    }
                    else
                    {
                        db.Objects.Add(item);
                    }
                }
                else
                {
                    item.ID = Guid.NewGuid();
                    db.Objects.Add(item);
                }
            }
            db.SaveChanges();
            UpdateObjOLV();
            Dialogs.ShowInfo(Lng.Get("SuccesfullyImport", "Import was succesfully done") + ".", Lng.Get("Import"));
        }
Exemple #19
0
        private void RefreshAvailableItems()
        {
            List <short?> borr = new List <short?>();

            if (cbItemType.SelectedIndex == 0)
            {
                borr = db.Borrowing.Where(p => (p.ItemID == ItemGuid) && p.ItemType.Contains("item") && !(p.Returned ?? false)).Select(c => c.ItemNum).ToList();
                Items itm = db.Items.Find(ItemGuid);
                itm.Available = (short)(itm.Count - borr.Count);
                db.SaveChanges();
            }
            else if (cbItemType.SelectedIndex == 1)
            {
                borr = db.Borrowing.Where(p => (p.ItemID == ItemGuid) && p.ItemType.Contains("book") && !(p.Returned ?? false)).Select(c => c.ItemNum).ToList();
                Books itm = db.Books.Find(ItemGuid);
                //itm.Available = (short)(itm.Count - borr.Count);
                //db.SaveChanges();
            }
        }
        /// <summary>
        /// Refresh Available Items
        /// </summary>
        /// <param name="list"></param>
        private void RefreshAvailableItems()
        {
            databaseEntities db = new databaseEntities();

            foreach (var itm in lendList)
            {
                var copy = db.Copies.Find(itm.CopyID);

                if (copy != null)
                {
                    var borr = db.Copies.Where(p => (p.ItemID == copy.ItemID) && p.ItemType.Contains(copy.ItemType.ToString()) && ((p.Status ?? 1) == (short)LendStatus.Reserved || (p.Status ?? 1) == (short)LendStatus.Lended)).Select(c => c.ID).ToList();

                    if (global.GetItemType(copy.ItemType) == ItemTypes.item)
                    {
                        Items item = db.Items.Find(copy.ItemID);
                        if (item != null)
                        {
                            item.Available = (short)((item.Count ?? 1) - borr.Count);
                        }
                    }
                    else if (global.GetItemType(copy.ItemType) == ItemTypes.book)
                    {
                        Books book = db.Books.Find(copy.ItemID);
                        if (book != null)
                        {
                            book.Available = (short)((book.Count ?? 1) - borr.Count);
                        }
                    }
                    else if (global.GetItemType(copy.ItemType) == ItemTypes.boardgame)
                    {
                        Boardgames board = db.Boardgames.Find(copy.ItemID);
                        if (board != null)
                        {
                            board.Available = (short)((board.Count ?? 1) - borr.Count);
                        }
                    }
                }
            }
            db.SaveChanges();
        }
Exemple #21
0
        private void ImportContacts(string fileName)
        {
            List <Contacts> con = global.ImportContactsCSV(fileName);

            if (con == null)
            {
                Dialogs.ShowErr(Lng.Get("ParseFileError", "Parse file error") + ".", Lng.Get("Error"));
                return;
            }

            databaseEntities db = new databaseEntities();

            foreach (var item in con)
            {
                Contacts contact;
                // ----- ID -----
                if (item.ID != Guid.Empty)
                {
                    contact = db.Contacts.Find(item.ID);
                    if (contact != null)
                    {
                        Conv.CopyClassPropetries(contact, item);
                    }
                    else
                    {
                        db.Contacts.Add(item);
                    }
                }
                else
                {
                    item.ID = Guid.NewGuid();
                    db.Contacts.Add(item);
                }
            }
            db.SaveChanges();
            UpdateConOLV();
            Dialogs.ShowInfo(Lng.Get("SuccesfullyImport", "Import was succesfully done") + ".", Lng.Get("Import"));
        }