/// <summary> /// Button Add Copy /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddCopy_Click(object sender, EventArgs e) { string InvNum = txtInvNum.Text; // ----- Increment Inv Num ----- if (Properties.Settings.Default.IncSpecimenInv) { TempMaxInvNum++; InvNum = Properties.Settings.Default.BoardPrefix + (TempMaxInvNum).ToString("D" + Properties.Settings.Default.BoardMinCharLen.ToString()) + Properties.Settings.Default.BoardSuffix; } // ----- Save Form fill to selected Copy ----- SaveCopy(); // ----- Create new Copy ----- Copies copy = global.CopyCopies(CopiesList[SelCopy]); copy.InventoryNumber = InvNum; CopiesList.Add(copy); // ----- Add New copy to combobox ----- cbCopy.Items.Add((cbCopy.Items.Count + 1).ToString()); cbCopy.SelectedIndex = cbCopy.Items.Count - 1; btnDelCopy.Enabled = true; // ---- Refresh Counts label ----- lblCount.Text = "/ " + CopiesList.Count.ToString(); // Counts }
/// <summary> /// Save Form Items to selected Copy /// </summary> private void SaveCopy() { Copies copy = CopiesList[SelCopy]; FillCopies(ref copy); CopiesList.RemoveAt(SelCopy); CopiesList.Insert(SelCopy, copy); }
/// <summary> /// Fill Form from Copies /// </summary> /// <param name="itm">Copies Item</param> private void FillFromCopies(Copies itm) { // ----- Fill Copies ----- txtPrice.Text = itm.Price.ToString(); // Price dtAcqDate.Value = itm.AcquisitionDate ?? DateTime.Now; // Acqusition date chbExcluded.Checked = itm.Excluded ?? false; // Excluded txtCondition.Text = itm.Condition; // Condition txtInvNum.Text = itm.InventoryNumber; // Inventory Number txtLocation.Text = itm.Location; // Location }
/// <summary> /// Copy Combobox change /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbCopy_SelectedIndexChanged(object sender, EventArgs e) { if (CopiesList.Count > 0) { if (SelCopy < CopiesList.Count) { Copies copy = CopiesList[SelCopy]; FillCopies(ref copy); CopiesList.RemoveAt(SelCopy); CopiesList.Insert(SelCopy, copy); } FillFromCopies(CopiesList[cbCopy.SelectedIndex]); SelCopy = cbCopy.SelectedIndex; } }
/// <summary> /// OLV Forma Row /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void olvCopies_FormatRow(object sender, FormatRowEventArgs e) { if (e.Model == null) { return; } Copies itm = (Copies)e.Model; if ((itm.Excluded ?? false) == true) { e.Item.ForeColor = Color.Gray; } else { e.Item.ForeColor = Color.Black; } }
/// <summary> /// Fill Copies from Form /// </summary> /// <param name="itm">Copies item</param> private void FillCopies(ref Copies itm) { // ----- Fill Copies ----- itm.Price = Conv.ToDoubleNull(txtPrice.Text); // Price itm.AcquisitionDate = dtAcqDate.Value; // Acqusition date itm.Excluded = chbExcluded.Checked; // Excluded itm.Condition = txtCondition.Text; // Condition itm.InventoryNumber = txtInvNum.Text; // Inventory Number itm.Barcode = Conv.ToNumber(itm.InventoryNumber); // Barcode itm.Location = txtLocation.Text; // Location // ----- Recalculate maxnum ----- long maxNum = Conv.ToNumber(itm.InventoryNumber); if (maxNum > MaxInvNumbers.Boardgame) { MaxInvNumbers.Boardgame = maxNum; } }
/// <summary> /// Fill Lending Items /// </summary> /// <param name="lend"></param> /// <param name="item"></param> private void FillLend(ref Lending lend, Copies item) { // ----- Item ----- lend.CopyType = item.ItemType.ToString(); lend.CopyID = item.ID; // ----- Other ----- lend.PersonID = PersonGuid; lend.From = dtFrom.Value; lend.To = dtTo.Value; lend.Status = (short)cbStatus.SelectedIndex; lend.Note = txtNote.Text; // ----- Fast tags ----- short fastTag = 0; if (btnTag1.BackColor == SelectColor) { fastTag |= 0x01; } if (btnTag2.BackColor == SelectColor) { fastTag |= 0x02; } if (btnTag3.BackColor == SelectColor) { fastTag |= 0x04; } if (btnTag4.BackColor == SelectColor) { fastTag |= 0x08; } if (btnTag5.BackColor == SelectColor) { fastTag |= 0x10; } if (btnTag6.BackColor == SelectColor) { fastTag |= 0x20; } lend.FastTags = fastTag; }
/// <summary> /// Form Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmEditBoardGames_Load(object sender, EventArgs e) { // ----- Create barcode reader connection ----- com.ReceivedData += new ReceivedEventHandler(DataReceive); try { com.ConnectSP(Properties.Settings.Default.scanCOM); } catch { } // ----- Get Autofill lists ----- var categoryList = db.Boardgames.Select(x => x.Category.Trim()).ToList(); var locationList = db.Copies.Select(x => x.Location.Trim()).ToList(); // ----- Delete duplicates ----- categoryList = global.DeleteDuplicates(categoryList); locationList = global.DeleteDuplicates(locationList); // ----- Prepare autocomplete ----- txtCondition.AutoCompleteCustomSource.Add(Lng.Get("New")); txtCondition.AutoCompleteCustomSource.Add(Lng.Get("Preserved")); txtCondition.AutoCompleteCustomSource.Add(Lng.Get("Damaged")); txtCondition.AutoCompleteCustomSource.Add(Lng.Get("Destroyed")); txtCondition.AutoCompleteCustomSource.Add(Lng.Get("Unfunctional")); foreach (var item in categoryList) { txtCategory.AutoCompleteCustomSource.Add(item); } foreach (var item in locationList) { txtLocation.AutoCompleteCustomSource.Add(item); } // ----- Add Specimen ----- cbCopy.Items.Clear(); cbCopy.Items.Add("1"); cbCopy.SelectedIndex = 0; Copies copy = global.CreateCopy(ID, ItemTypes.boardgame); CopiesList.Add(copy); // ----- If Edit -> fill form ----- if (ID != Guid.Empty) { Boardgames itm = db.Boardgames.Find(ID); // ----- Fill Image ----- imgCover.Image = Conv.ByteArrayToImage(itm.Cover); img1.Image = Conv.ByteArrayToImage(itm.Img1); img2.Image = Conv.ByteArrayToImage(itm.Img2); img3.Image = Conv.ByteArrayToImage(itm.Img3); // ----- Fill main data ----- txtName.Text = itm.Name.Trim(); // Name txtURL.Text = itm.URL.Trim(); // URL txtCategory.Text = itm.Category.Trim(); // Category txtLanguage.Text = itm.Language.Trim(); // Language txtKeywords.Text = itm.Keywords.Trim(); // Keywords txtGameWorld.Text = itm.GameWorld.Trim(); // Game World txtPublisher.Text = itm.Publisher.Trim(); // Publisher txtAuthor.Text = itm.Author.Trim(); // Author txtYear.Text = itm.Year.ToString(); // Year txtNote.Text = itm.Note.Trim(); // Note numMinPlayers.Value = itm.MinPlayers ?? 0; // Min Players numMaxPlayers.Value = itm.MaxPlayers ?? 0; // Max Players numMinAge.Value = itm.MinAge ?? 0; // Min Age numGameTime.Value = itm.GameTime ?? 0; // Game Time txtFamily.Text = itm.Family.Trim(); // Family chbExtension.Checked = itm.Extension ?? false; // Extension numExtension.Value = itm.ExtensionNumber ?? 0; // Extension number txtRating.Text = itm.Rating.ToString(); // Rating txtMyRating.Text = itm.MyRating.ToString(); // My rating // ----- Fill Specimen ----- CopiesList = db.Copies.Where(x => x.ItemID == ID).ToList(); OriginalCopies = db.Copies.Where(x => x.ItemID == ID).ToList(); cbCopy.Items.Clear(); // ----- If found copies ----- if (CopiesList != null && CopiesList.Count > 0) { // ----- Fill textboxes ----- FillFromCopies(CopiesList[0]); // ----- Prepare buttons ----- if (CopiesList.Count > 1) { btnDelCopy.Enabled = true; } // ----- Prepare combobox ----- for (int i = 0; i < CopiesList.Count; i++) // Fill Copies combobox { cbCopy.Items.Add((i + 1).ToString()); } cbCopy.SelectedIndex = 0; lblCount.Text = "/ " + CopiesList.Count.ToString(); // Counts } // ----- Fast tags ----- FastFlags flag = (FastFlags)(itm.FastTags ?? 0); if (flag.HasFlag(FastFlags.FLAG1)) { btnTag1.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG2)) { btnTag2.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG3)) { btnTag3.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG4)) { btnTag4.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG5)) { btnTag5.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG6)) { btnTag6.BackColor = SelectColor; } // ----- Update ----- lblUpdated.Text = Lng.Get("LastUpdate", "Last update") + ": " + (itm.Updated ?? DateTime.Now).ToShortDateString(); } else { // ----- Set Acquisition date ----- dtAcqDate.Value = DateTime.Now; numMinPlayers.Value = 2; // Min Players numMaxPlayers.Value = 4; // Max Players // ----- New Inv Number ----- if (TempMaxInvNum < Properties.Settings.Default.BoardStart) { TempMaxInvNum = Properties.Settings.Default.BoardStart; } else { TempMaxInvNum++; } txtInvNum.Text = Properties.Settings.Default.BoardPrefix + (TempMaxInvNum).ToString("D" + Properties.Settings.Default.BoardMinCharLen.ToString()) + Properties.Settings.Default.BoardSuffix; } }
/// <summary> /// Load Form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmEditLending_Load(object sender, EventArgs e) { databaseEntities db = new databaseEntities(); // ----- Create connection to barcode reader ----- com.ReceivedData += new ReceivedEventHandler(DataReceive); try { com.ConnectSP(Properties.Settings.Default.scanCOM); } catch { } // ----- Prepare Status Combo box ----- cbStatus.Items.Clear(); cbStatus.Items.Add(Lng.Get("Reserved")); cbStatus.Items.Add(Lng.Get("Borrowed")); cbStatus.Items.Add(Lng.Get("Returned")); cbStatus.Items.Add(Lng.Get("Canceled")); cbStatus.SelectedIndex = 1; // ----- Prepare autocomplete Context ----- SetContactsContext(); // Contacts SetItemsContext(); // Items // ----- Set Default values ----- dtFrom.Value = DateTime.Now; dtTo.Value = DateTime.Now.AddDays(Properties.Settings.Default.DefaultBorrInterval); // ----- If Edit items ----- if (ID.Count > 0) { Lending lend = new Lending(); // ----- Find all edited items ----- foreach (var itm in ID) { lend = db.Lending.Find(itm); // ----- Fill Item list ----- Copies copy = db.Copies.Find(lend.CopyID); selItemList.Add(copy); // Selected list //origItemList.Add(copy); // Original list } // ----- Fill Person ----- Contacts person = db.Contacts.Find(lend.PersonID); if (person != null) { txtPerson.Text = person.Name.Trim() + " " + person.Surname.Trim(); lblPersonNum.Text = Lng.Get("PersonNum", "Person number") + ": " + person.PersonCode.Trim(); } // ----- Fill other values ----- dtFrom.Value = lend.From ?? DateTime.Now; dtTo.Value = lend.To ?? DateTime.Now; int stat = lend.Status ?? 1; if (stat < cbStatus.Items.Count) { cbStatus.SelectedIndex = stat; } txtNote.Text = lend.Note; ItemGuid = lend.CopyID ?? Guid.Empty; LastItemGuid = ItemGuid; PersonGuid = lend.PersonID ?? Guid.Empty; // ----- Fill Fast tags ----- FastFlags flag = (FastFlags)(lend.FastTags ?? 0); if (flag.HasFlag(FastFlags.FLAG1)) { btnTag1.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG2)) { btnTag2.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG3)) { btnTag3.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG4)) { btnTag4.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG5)) { btnTag5.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG6)) { btnTag6.BackColor = SelectColor; } // ----- Update Items OLV ----- UpdateOLV(); } // ----- Lending to person ----- else if (PersonGuid != Guid.Empty) { Guid temp = PersonGuid; // ----- Fill Person ----- Contacts person = db.Contacts.Find(PersonGuid); if (person != null) { txtPerson.Text = person.Name.Trim() + " " + person.Surname.Trim(); lblPersonNum.Text = Lng.Get("PersonNum", "Person number") + ": " + person.PersonCode.Trim(); } PersonGuid = temp; txtPerson.Enabled = false; btnAddPerson.Enabled = false; this.ActiveControl = txtItem; } }
/// <summary> /// Form Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmEditBooks_Load(object sender, EventArgs e) { // ----- Create barcode reader connection ----- com.ReceivedData += new ReceivedEventHandler(DataReceive); try { com.ConnectSP(Properties.Settings.Default.scanCOM); } catch { } // ----- Prepare type ----- cbType.Items.Clear(); cbType.Items.Add(""); cbType.Items.Add(Lng.Get("EBook", "E-Book")); cbType.Items.Add(Lng.Get("Book")); cbType.Items.Add(Lng.Get("Magazine")); cbType.Items.Add(Lng.Get("Newspaper")); cbType.Items.Add(Lng.Get("Document")); cbType.Items.Add(Lng.Get("Map")); cbType.SelectedIndex = 0; // ----- Prepare bookbinding ----- SetBookbinding(); // ----- Add Specimen ----- cbCopy.Items.Clear(); cbCopy.Items.Add("1"); cbCopy.SelectedIndex = 0; Copies copy = global.CreateCopy(ID, ItemTypes.book); CopiesList.Add(copy); if (ID != Guid.Empty) { Books book = db.Books.Find(ID); // ----- Cover ----- imgCover.Image = Conv.ByteArrayToImage(book.Cover); // ----- Book ----- txtName.Text = book.Title.Trim(); cbType.Text = book.Type.Trim(); txtAuthor.Text = book.AuthorName.Trim(); txtAuthorSurname.Text = book.AuthorSurname.Trim(); cbBookbinding.Text = book.Bookbinding.Trim(); txtIllustrator.Text = book.Illustrator.Trim(); txtTranslator.Text = book.Translator.Trim(); txtLanguage.Text = book.Language.Trim(); txtISBN.Text = book.ISBN.Trim(); txtPublisher.Text = book.Publisher.Trim(); txtEdition.Text = book.Edition.Trim(); txtYear.Text = book.Year.ToString(); txtPages.Text = book.Pages.ToString(); txtHero.Text = book.MainCharacter.Trim(); txtURL.Text = book.URL.Trim(); txtNote.Text = book.Note.Trim(); txtContent.Text = book.Content.Trim(); // ----- Original book ----- txtOrigName.Text = book.OrigName.Trim(); txtOrigLang.Text = book.OrigLanguage.Trim(); txtOrigYear.Text = book.OrigYear.ToString(); // ----- Inclusion ----- txtGenre.Text = book.Genre.Trim(); txtSubGenre.Text = book.SubGenre.Trim(); txtSeries.Text = book.Series.Trim(); txtSNumber.Text = book.SeriesNum.ToString(); txtKeywords.Text = book.Keywords.Trim(); // ----- Rating ----- txtRating.Text = book.Rating.ToString(); txtMyRating.Text = book.MyRating.ToString(); chbReaded.Checked = book.Readed ?? false; // ----- Fill Specimen ----- CopiesList = db.Copies.Where(x => x.ItemID == ID).ToList(); OriginalCopies = db.Copies.Where(x => x.ItemID == ID).ToList(); cbCopy.Items.Clear(); // ----- If found copies ----- if (CopiesList != null && CopiesList.Count > 0) { // ----- Fill textboxes ----- FillFromCopies(CopiesList[0]); // ----- Prepare buttons ----- if (CopiesList.Count > 1) { btnDelCopy.Enabled = true; } // ----- Prepare combobox ----- for (int i = 0; i < CopiesList.Count; i++) // Fill Copies combobox { cbCopy.Items.Add((i + 1).ToString()); } cbCopy.SelectedIndex = 0; lblCount.Text = "/ " + CopiesList.Count.ToString(); // Counts } // ----- Fast tags ----- FastFlags flag = (FastFlags)(book.FastTags ?? 0); if (flag.HasFlag(FastFlags.FLAG1)) { btnTag1.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG2)) { btnTag2.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG3)) { btnTag3.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG4)) { btnTag4.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG5)) { btnTag5.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG6)) { btnTag6.BackColor = SelectColor; } // ----- Update ----- lblUpdated.Text = Lng.Get("LastUpdate", "Last update") + ": " + (book.Updated ?? DateTime.Now).ToShortDateString(); } else { // ----- Set Acquisition date ----- dtAcqDate.Value = DateTime.Now; // ----- New Inv Number ----- if (TempMaxInvNum < Properties.Settings.Default.BoardStart) { TempMaxInvNum = Properties.Settings.Default.BoardStart; } else { TempMaxInvNum++; } txtInvNum.Text = Properties.Settings.Default.BookPrefix + (TempMaxInvNum).ToString("D" + Properties.Settings.Default.BookMinCharLen.ToString()) + Properties.Settings.Default.BookSuffix; } }
/// <summary> /// Form Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmEditItem_Load(object sender, EventArgs e) { // ----- Create barcode reader connection ----- com.ReceivedData += new ReceivedEventHandler(DataReceive); try { com.ConnectSP(Properties.Settings.Default.scanCOM); } catch { } // ----- Get Autofill lists ----- var categoryList = db.Items.Select(x => x.Category.Trim()).ToList(); var subcategoryList = db.Items.Select(x => x.Subcategory.Trim()).ToList(); var locationList = db.Copies.Select(x => x.Location.Trim()).ToList(); // ----- Delete duplicates ----- categoryList = global.DeleteDuplicates(categoryList); subcategoryList = global.DeleteDuplicates(subcategoryList); locationList = global.DeleteDuplicates(locationList); // ----- Prepare autocomplete ----- txtCondition.AutoCompleteCustomSource.Add(Lng.Get("New")); txtCondition.AutoCompleteCustomSource.Add(Lng.Get("Preserved")); txtCondition.AutoCompleteCustomSource.Add(Lng.Get("Damaged")); txtCondition.AutoCompleteCustomSource.Add(Lng.Get("Destroyed")); txtCondition.AutoCompleteCustomSource.Add(Lng.Get("Unfunctional")); foreach (var item in categoryList) { txtCategory.AutoCompleteCustomSource.Add(item); } foreach (var item in subcategoryList) { txtSubCategory.AutoCompleteCustomSource.Add(item); } foreach (var item in locationList) { txtLocation.AutoCompleteCustomSource.Add(item); } // ----- Add Specimen ----- cbCopy.Items.Clear(); cbCopy.Items.Add("1"); cbCopy.SelectedIndex = 0; Copies copy = global.CreateCopy(ID, ItemTypes.item); CopiesList.Add(copy); // ----- If Edit -> fill form ----- if (ID != Guid.Empty) { Items itm = db.Items.Find(ID); // ----- Fill Image ----- imgImg.Image = Conv.ByteArrayToImage(itm.Image); // ----- Fill main data ----- txtName.Text = itm.Name.Trim(); // Name txtCategory.Text = itm.Category.Trim(); // Category txtSubCategory.Text = itm.Subcategory.Trim(); // SubCategory txtKeywords.Text = itm.Keywords.Trim(); // Keywords txtNote.Text = itm.Note.Trim(); // Note txtManufacturer.Text = itm.Manufacturer.Trim(); // Manufacturer // ----- Fill Specimen ----- CopiesList = db.Copies.Where(x => x.ItemID == ID).ToList(); OriginalCopies = db.Copies.Where(x => x.ItemID == ID).ToList(); cbCopy.Items.Clear(); // ----- If found copies ----- if (CopiesList != null && CopiesList.Count > 0) { // ----- Fill textboxes ----- FillFromCopies(CopiesList[0]); // ----- Prepare buttons ----- if (CopiesList.Count > 1) { btnDelCopy.Enabled = true; } // ----- Prepare combobox ----- for (int i = 0; i < CopiesList.Count; i++) // Fill Copies combobox { cbCopy.Items.Add((i + 1).ToString()); } cbCopy.SelectedIndex = 0; lblCount.Text = "/ " + CopiesList.Count.ToString(); // Counts } // ----- Fast tags ----- FastFlags flag = (FastFlags)(itm.FastTags ?? 0); if (flag.HasFlag(FastFlags.FLAG1)) { btnTag1.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG2)) { btnTag2.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG3)) { btnTag3.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG4)) { btnTag4.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG5)) { btnTag5.BackColor = SelectColor; } if (flag.HasFlag(FastFlags.FLAG6)) { btnTag6.BackColor = SelectColor; } // ----- Update ----- lblUpdated.Text = Lng.Get("LastUpdate", "Last update") + ": " + (itm.Updated ?? DateTime.Now).ToShortDateString(); } else { // ----- Set Acquisition date ----- dtAcqDate.Value = DateTime.Now; // ----- New Inv Number ----- if (TempMaxInvNum < Properties.Settings.Default.ItemStart) { TempMaxInvNum = Properties.Settings.Default.ItemStart; } else { TempMaxInvNum++; } txtInvNum.Text = Properties.Settings.Default.ItemPrefix + (TempMaxInvNum).ToString("D" + Properties.Settings.Default.ItemMinCharLen.ToString()) + Properties.Settings.Default.ItemSuffix; } }