예제 #1
0
        /// <summary>
        /// Update Items ObjectListView
        /// </summary>
        void UpdateBoardOLV()
        {
            databaseEntities db = new databaseEntities();

            List <Boardgames> itm;

            if (chbShowExcludedBoard.Checked)
            {
                itm = db.Boardgames.ToList();
            }
            else
            {
                itm = db.Boardgames.Where(p => !(p.Excluded ?? false)).ToList();
            }

            bgTags.Renderer     = new ImageRenderer();
            bgTags.AspectGetter = delegate(object x) {
                List <int> ret  = new List <int>();
                FastFlags  flag = (FastFlags)((Boardgames)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    ret.Add(0);
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    ret.Add(1);
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    ret.Add(2);
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    ret.Add(3);
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    ret.Add(4);
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    ret.Add(5);
                }

                return(ret);
            };
            bgTagsNum.AspectGetter = delegate(object x) {
                string    res  = "";
                FastFlags flag = (FastFlags)((Boardgames)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    res += "1";
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    res += "2";
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    res += "3";
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    res += "4";
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    res += "5";
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    res += "6";
                }
                return(res);
            };

            bgName.AspectGetter = delegate(object x) {
                return(((Boardgames)x).Name.Trim());
            };
            bgCategory.AspectGetter = delegate(object x) {
                return(((Boardgames)x).Category.Trim());
            };
            bgInvNum.AspectGetter = delegate(object x) {
                return(global.GetInvNumList(((Boardgames)x).ID));
            };
            bgLocation.AspectGetter = delegate(object x) {
                return(global.GetLocationList(((Boardgames)x).ID));
            };
            bgKeywords.AspectGetter = delegate(object x) {
                return(((Boardgames)x).Keywords.Trim());
            };
            bgCounts.AspectGetter = delegate(object x) {
                return(((Boardgames)x).Count.ToString());
            };
            bgAvailable.AspectGetter = delegate(object x) {
                /*var borr = db.Lending.Where(p => p.ItemID == ((Items)x).Id && p.ItemType.Contains("item") && !(p.Returned ?? false)).ToList();
                 * int count = ((Items)x).Count ?? 1 - borr.Count;*/
                return(((Boardgames)x).Available ?? (((Boardgames)x).Count ?? 1));
            };
            bgExcluded.Renderer     = new ImageRenderer();
            bgExcluded.AspectGetter = delegate(object x) {
                if (((Boardgames)x).Excluded ?? false)
                {
                    return(7);
                }
                else
                {
                    return(6);
                }
            };

            olvBoard.SetObjects(itm);
        }
예제 #2
0
        /// <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;
            }
        }
예제 #3
0
        /// <summary>
        /// Load Form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmEditBorrowing_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 Contacts autocomplete Context -----
            SetContactsContext();

            // ----- Set Default values -----
            dtFrom.Value = DateTime.Now;
            dtTo.Value   = DateTime.Now.AddDays(Properties.Settings.Default.DefaultBorrInterval);

            // ----- If Edit items -----
            if (ID.Count > 0)
            {
                Borrowing borr = new Borrowing();

                // ----- Find all edited items -----
                foreach (var itm in ID)
                {
                    borr = db.Borrowing.Find(itm);

                    // ----- Fill Item list -----
                    IInfo info = new IInfo();
                    info.Name = borr.Item.Trim();
                    if (borr.ItemInvNum != null)
                    {
                        info.InventoryNumber = borr.ItemInvNum.Trim();
                    }
                    if (borr.Note != null)
                    {
                        info.Note = borr.Note.Trim();
                    }

                    selItemList.Add(info);                      // Selected list
                    origItemList.Add(info);                     // Original list
                }


                // ----- Fill Person -----
                Contacts person = db.Contacts.Find(borr.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           = borr.From ?? DateTime.Now;
                dtTo.Value             = borr.To ?? DateTime.Now;
                cbStatus.SelectedIndex = borr.Status ?? 1;

                // ----- Fill Fast tags -----
                FastFlags flag = (FastFlags)(borr.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;
                }

                PersonGuid = borr.PersonID ?? Guid.Empty;

                // ----- 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;
            }
        }
예제 #4
0
        /// <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;
            }
        }
예제 #5
0
        private void frmEditRecipes_Load(object sender, EventArgs e)
        {
            // ----- Get Autofill lists -----
            var categoryList    = db.Recipes.Select(x => x.Category.Trim()).ToList();
            var subcategoryList = db.Recipes.Select(x => x.Subcategory.Trim()).ToList();

            // ----- Delete duplicates -----
            categoryList    = global.DeleteDuplicates(categoryList);
            subcategoryList = global.DeleteDuplicates(subcategoryList);

            // ----- Prepare autocomplete -----
            foreach (var item in categoryList)
            {
                txtCategory.AutoCompleteCustomSource.Add(item);
            }
            foreach (var item in subcategoryList)
            {
                txtSubCategory.AutoCompleteCustomSource.Add(item);
            }

            // ----- If Edit -> fill form -----
            if (ID != Guid.Empty)
            {
                Recipes itm = db.Recipes.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

                // ----- Recipes -----
                txtDescription.Text = itm.Description.Trim();
                txtResources.Text   = itm.Resources.Trim();
                txtProcedure.Text   = itm.Procedure.Trim();
                txtURL.Text         = itm.URL.Trim();

                // ----- Rating -----
                txtRating.Text   = itm.Rating.ToString();
                txtMyRating.Text = itm.MyRating.ToString();

                // ----- 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;
                }

                // ----- Excluded -----
                chbExcluded.Checked = itm.Excluded ?? false;

                // ----- Update -----
                lblUpdated.Text = Lng.Get("LastUpdate", "Last update") + ": " + (itm.Updated ?? DateTime.Now).ToShortDateString();
            }
            else
            {
            }
        }
예제 #6
0
        private void frmEditObjects_Load(object sender, EventArgs e)
        {
            // ----- Get Autofill lists -----
            var categoryList    = db.Objects.Select(x => x.Category.Trim()).ToList();
            var subcategoryList = db.Objects.Select(x => x.Subcategory.Trim()).ToList();



            // ----- Delete duplicates -----
            categoryList    = global.DeleteDuplicates(categoryList);
            subcategoryList = global.DeleteDuplicates(subcategoryList);

            // ----- Prepare autocomplete -----
            foreach (var item in categoryList)
            {
                txtCategory.AutoCompleteCustomSource.Add(item);
            }
            foreach (var item in subcategoryList)
            {
                txtSubCategory.AutoCompleteCustomSource.Add(item);
            }


            var typeList = db.Objects.Where(x => x.Active == true).Select(s => s.Type).ToList();

            typeList.Sort();
            string lastType = "";

            for (int i = typeList.Count - 1; i >= 0; i--)
            {
                if (typeList[i] != "")
                {
                    if (typeList[i] == lastType)
                    {
                        typeList.RemoveAt(i);
                    }
                    lastType = typeList[i];
                }
                else
                {
                    typeList.RemoveAt(i);
                }
            }

            cbType.Items.Clear();
            foreach (var item in typeList)
            {
                cbType.Items.Add(item);
            }


            // ----- If Edit -> fill form -----
            if (ID != Guid.Empty)
            {
                Objects itm = db.Objects.Find(ID);

                // ----- Prepare Parent list -----
                parentList = global.GetParentlist(itm.ID);
                cbParent.Items.Clear();
                foreach (var item in parentList)
                {
                    cbParent.Items.Add(item.Name);
                }

                // ----- 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
                txtURL.Text         = itm.URL.Trim();               // URL

                // ----- Objects -----
                txtDescription.Text = itm.Description.Trim();
                txtVersion.Text     = itm.Version.Trim();
                txtFolder.Text      = itm.Folder.Trim();
                Files = itm.Files.Trim();
                if (Files != "")
                {
                    btnFiles.ForeColor = Color.Green;
                    btnFiles.Font      = new Font(btnFiles.Font, FontStyle.Bold);
                }
                ObjectList = itm.UsedObjects;
                if (ObjectList != "")
                {
                    btnObjects.ForeColor = Color.Green;
                    btnObjects.Font      = new Font(btnObjects.Font, FontStyle.Bold);
                }
                cbType.Text      = itm.Type.Trim();
                txtNumber.Text   = itm.ObjectNum.Trim();
                txtLanguage.Text = itm.Language.Trim();
                if (itm.Parent != null)
                {
                    var parentName = db.Objects.Where(x => x.ID == itm.Parent).Select(x => x.Name).ToList();
                    if (parentName.Count > 0)
                    {
                        cbParent.Text = parentName[0];
                    }
                }
                txtCustomer.Text    = itm.Customer.Trim();
                txtDevelopment.Text = itm.Development.Trim();
                chbIsParent.Checked = itm.IsParent ?? false;

                // ----- Rating -----
                txtRating.Text   = itm.Rating.ToString();
                txtMyRating.Text = itm.MyRating.ToString();

                // ----- 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;
                }

                // ----- Excluded -----
                chbActive.Checked = itm.Active ?? true;

                // ----- Update -----
                lblUpdated.Text = Lng.Get("LastUpdate", "Last update") + ": " + (itm.Updated ?? DateTime.Now).ToShortDateString();
            }
            else
            {
                // ----- Prepare Parent list -----
                parentList = global.GetParentlist(Guid.Empty);
                cbParent.Items.Clear();
                foreach (var item in parentList)
                {
                    cbParent.Items.Add(item.Name);
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Update Contacts ObjectListView
        /// </summary>
        void UpdateConOLV()
        {
            databaseEntities db = new databaseEntities();

            List <Contacts> con;

            if (chbShowUnactivCon.Checked)
            {
                con = db.Contacts.ToList();
            }
            else
            {
                con = db.Contacts.Where(p => (p.Active ?? true) == true).ToList();
            }

            conFastTags.Renderer     = new ImageRenderer();
            conFastTags.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                List <int> ret  = new List <int>();
                FastFlags  flag = (FastFlags)((Contacts)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    ret.Add(0);
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    ret.Add(1);
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    ret.Add(2);
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    ret.Add(3);
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    ret.Add(4);
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    ret.Add(5);
                }

                return(ret);
            };
            conFastTagsNum.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                string    res  = "";
                FastFlags flag = (FastFlags)((Contacts)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    res += "1";
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    res += "2";
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    res += "3";
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    res += "4";
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    res += "5";
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    res += "6";
                }
                return(res);
            };
            conName.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Contacts)x).Name);
            };
            conSurname.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Contacts)x).Surname);
            };
            conNick.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Contacts)x).Nick);
            };
            conPhone.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(GetOnlyValue(((Contacts)x).Phone));
            };
            conEmail.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(GetOnlyValue(((Contacts)x).Email));
            };
            conAddress.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                string address = ((Contacts)x).Street;
                string city    = ((Contacts)x).City;
                string country = ((Contacts)x).Country;

                if ((city != null && city != "") && (address != null && address != ""))
                {
                    address += ", ";
                }
                address += city;

                if ((country != null && country != "") && (address != null && address != ""))
                {
                    address += ", ";
                }
                address += country;
                return(address);
            };
            conCompany.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Contacts)x).Company);
            };
            olvContacts.SetObjects(con);
        }
예제 #8
0
        /// <summary>
        /// Update Books ObjectListView
        /// </summary>
        void UpdateBooksOLV()
        {
            databaseEntities db = new databaseEntities();

            List <Books> book = db.Books.ToList();

            bkFastTags.Renderer     = new ImageRenderer();
            bkFastTags.AspectGetter = delegate(object x) {
                List <int> ret = new List <int>();
                if (((Books)x).FastTags == null)
                {
                    return(ret);
                }

                FastFlags flag = (FastFlags)((Books)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    ret.Add(0);
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    ret.Add(1);
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    ret.Add(2);
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    ret.Add(3);
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    ret.Add(4);
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    ret.Add(5);
                }

                return(ret);
            };
            bkFastTagsNum.AspectGetter = delegate(object x) {
                string    res  = "";
                FastFlags flag = (FastFlags)((Books)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    res += "1";
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    res += "2";
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    res += "3";
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    res += "4";
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    res += "5";
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    res += "6";
                }
                return(res);
            };
            bkName.AspectGetter = delegate(object x) {
                if (((Books)x).Title == null)
                {
                    return("");
                }
                return(((Books)x).Title.Trim());
            };
            bkAuthor.AspectGetter = delegate(object x) {
                if (((Books)x).AuthorSurname == null)
                {
                    return("");
                }
                return(((Books)x).AuthorSurname.Trim() + ", " + ((Books)x).AuthorName.Trim());
            };
            bkCount.AspectGetter = delegate(object x) {
                return(((Books)x).Count.ToString());
            };
            bkAvailable.AspectGetter = delegate(object x) {
                /*var borr = db.Lending.Where(p => p.ItemID == ((Items)x).Id && p.ItemType.Contains("item") && !(p.Returned ?? false)).ToList();
                 * int count = ((Items)x).Count ?? 1 - borr.Count;*/
                return(((Books)x).Available ?? (((Books)x).Count ?? 1));
            };
            bkType.AspectGetter = delegate(object x) {
                if (((Books)x).Type == null)
                {
                    return("");
                }
                return(((Books)x).Type.Trim());
            };
            bkYear.AspectGetter = delegate(object x) {
                return(((Books)x).Year.ToString());
            };
            bkGenre.AspectGetter = delegate(object x) {
                if (((Books)x).Genre == null)
                {
                    return("");
                }
                return(((Books)x).Genre.Trim());
            };
            bkSubgenre.AspectGetter = delegate(object x) {
                if (((Books)x).SubGenre == null)
                {
                    return("");
                }
                return(((Books)x).SubGenre.Trim());
            };
            bkInvNum.AspectGetter = delegate(object x) {
                return(global.GetInvNumList(((Books)x).ID));
            };
            bkLocation.AspectGetter = delegate(object x) {
                return(global.GetLocationList(((Books)x).ID));
            };
            bkKeywords.AspectGetter = delegate(object x) {
                if (((Books)x).Keywords == null)
                {
                    return("");
                }
                return(((Books)x).Keywords.Trim());
            };
            bkSeries.AspectGetter = delegate(object x) {
                if (((Books)x).Series == null)
                {
                    return("");
                }
                return(((Books)x).Series.Trim() + " " + ((Books)x).SeriesNum.ToString());
            };

            olvBooks.SetObjects(book);
        }
예제 #9
0
        /// <summary>
        /// Update Contacts ObjectListView
        /// </summary>
        void UpdateObjOLV()
        {
            databaseEntities db = new databaseEntities();

            List <Objects> obj;

            if (chbShowExcludedObjects.Checked)
            {
                if (cbObjectShow.SelectedIndex == 1)
                {
                    obj = db.Objects.Where(p => p.Parent == null).ToList();
                }
                else if (cbObjectShow.SelectedIndex == 2)
                {
                    obj = db.Objects.Where(p => !(p.IsParent ?? false)).ToList();
                }
                else
                {
                    obj = db.Objects.ToList();
                }
            }
            else
            {
                if (cbObjectShow.SelectedIndex == 1)
                {
                    obj = db.Objects.Where(p => (p.Active ?? true) && (p.Parent == null)).ToList();
                }
                else if (cbObjectShow.SelectedIndex == 2)
                {
                    obj = db.Objects.Where(p => (p.Active ?? true) && !(p.IsParent ?? false)).ToList();
                }
                else
                {
                    obj = db.Objects.Where(p => p.Active ?? true).ToList();
                }
            }

            objTags.Renderer     = new ImageRenderer();
            objTags.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                List <int> ret  = new List <int>();
                FastFlags  flag = (FastFlags)((Objects)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    ret.Add(0);
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    ret.Add(1);
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    ret.Add(2);
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    ret.Add(3);
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    ret.Add(4);
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    ret.Add(5);
                }

                return(ret);
            };
            objTagsNum.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                string    res  = "";
                FastFlags flag = (FastFlags)((Objects)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    res += "1";
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    res += "2";
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    res += "3";
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    res += "4";
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    res += "5";
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    res += "6";
                }
                return(res);
            };
            objName.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).Name);
            };
            objType.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).Type);
            };
            objCategory.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).Category);
            };
            objNumber.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).ObjectNum);
            };
            objParent.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                var parentName = db.Objects.Where(p => p.ID == ((Objects)x).Parent).Select(p => p.Name).ToList();
                if (parentName.Count > 0)
                {
                    return(parentName[0]);
                }
                return("");
            };
            objKeywords.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).Keywords);
            };
            objCustomer.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).Customer);
            };
            objDevelopment.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).Development);
            };
            objFolder.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).Folder);
            };
            objVersion.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Objects)x).Version);
            };

            objActive.Renderer     = new ImageRenderer();
            objActive.AspectGetter = delegate(object x) {
                if (((Objects)x).Active ?? true)
                {
                    return(6);
                }
                else
                {
                    return(7);
                }
            };
            olvObjects.SetObjects(obj);
        }
예제 #10
0
        private void frmEditGames_Load(object sender, EventArgs e)
        {
            // ----- Get Autofill lists -----
            var categoryList    = db.Games.Select(x => x.Category.Trim()).ToList();
            var subcategoryList = db.Games.Select(x => x.Subcategory.Trim()).ToList();
            var enviromentList  = db.Games.Select(x => x.Environment.Trim()).ToList();

            // ----- Delete duplicates -----
            categoryList    = global.DeleteDuplicates(categoryList);
            subcategoryList = global.DeleteDuplicates(subcategoryList);
            enviromentList  = global.DeleteDuplicates(enviromentList);

            // ----- Prepare autocomplete -----
            foreach (var item in categoryList)
            {
                txtCategory.AutoCompleteCustomSource.Add(item);
            }
            foreach (var item in subcategoryList)
            {
                txtSubCategory.AutoCompleteCustomSource.Add(item);
            }
            foreach (var item in enviromentList)
            {
                txtEnviroment.AutoCompleteCustomSource.Add(item);
            }

            // ----- If Edit -> fill form -----
            if (ID != Guid.Empty)
            {
                Games itm = db.Games.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

                // ----- Games -----
                txtDescription.Text = itm.Description.Trim();
                txtPlayerAge.Text   = itm.PlayerAge.Trim();
                txtMinPlayers.Text  = itm.MinPlayers != null?itm.MinPlayers.ToString() : "";

                txtMaxPlayers.Text = itm.MaxPlayers != null?itm.MaxPlayers.ToString() : "";

                txtPlayerAge.Text = itm.PlayerAge != null?itm.PlayerAge.ToString() : "";

                txtDuration.Text = itm.Duration != null?itm.Duration.ToString() : "";

                txtDurPreparation.Text = itm.DurationPreparation != null?itm.DurationPreparation.ToString() : "";

                txtThings.Text      = itm.Things.Trim();
                txtPreparation.Text = itm.Preparation.Trim();
                txtEnviroment.Text  = itm.Environment.Trim();
                txtRules.Text       = itm.Rules.Trim();
                txtURL.Text         = itm.URL.Trim();
                files = itm.Files.Trim();
                if (files != "")
                {
                    btnFiles.ForeColor = Color.Green;
                    btnFiles.Font      = new Font(btnFiles.Font, FontStyle.Bold);
                }

                // ----- Rating -----
                txtRating.Text   = itm.Rating.ToString();
                txtMyRating.Text = itm.MyRating.ToString();

                // ----- 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;
                }

                // ----- Excluded -----
                chbExcluded.Checked = itm.Excluded ?? false;

                // ----- Update -----
                lblUpdated.Text = Lng.Get("LastUpdate", "Last update") + ": " + (itm.Updated ?? DateTime.Now).ToShortDateString();
            }
            else
            {
            }
        }
예제 #11
0
        /// <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;
            }
        }
예제 #12
0
        /// <summary>
        /// Update Lending ObjectListView
        /// </summary>
        void UpdateLendingOLV()
        {
            databaseEntities db = new databaseEntities();

            List <Lending> lend;

            // ----- Show Expired -----
            if (cbLendingShow.SelectedIndex == 1)
            {
                DateTime now = DateTime.Now;
                lend = db.Lending.Where(p => ((p.To ?? now) < DateTime.Now) && ((p.Status ?? 1) == 0 || (p.Status ?? 1) == 1)).ToList();
            }
            // ----- Show Borrowed -----
            else if (cbLendingShow.SelectedIndex == 2)
            {
                if (chbShowReturned.Checked)
                {
                    lend = db.Lending.Where(p => ((p.Status ?? 1) == 1 || (p.Status ?? 1) == 2)).ToList();
                }
                else
                {
                    lend = db.Lending.Where(p => (p.Status ?? 1) == 1).ToList();
                }
            }
            // ----- Show Reserved -----
            else if (cbLendingShow.SelectedIndex == 3)
            {
                if (chbShowReturned.Checked)
                {
                    lend = db.Lending.Where(p => ((p.Status ?? 1) == 0 || (p.Status ?? 1) == 3)).ToList();
                }
                else
                {
                    lend = db.Lending.Where(p => (p.Status ?? 1) == 0).ToList();
                }
            }
            // ----- Show All -----
            else
            {
                if (chbShowReturned.Checked)
                {
                    lend = db.Lending.ToList();
                }
                else
                {
                    lend = db.Lending.Where(p => (p.Status ?? 1) == 0 || (p.Status ?? 1) == 1).ToList();
                }
            }

            ldFastTags.Renderer     = new ImageRenderer();
            ldFastTags.AspectGetter = delegate(object x) {
                List <int> ret = new List <int>();
                if (((Lending)x).FastTags != null)
                {
                    FastFlags flag = (FastFlags)((Lending)x).FastTags;
                    if (flag.HasFlag(FastFlags.FLAG1))
                    {
                        ret.Add(0);
                    }
                    if (flag.HasFlag(FastFlags.FLAG2))
                    {
                        ret.Add(1);
                    }
                    if (flag.HasFlag(FastFlags.FLAG3))
                    {
                        ret.Add(2);
                    }
                    if (flag.HasFlag(FastFlags.FLAG4))
                    {
                        ret.Add(3);
                    }
                    if (flag.HasFlag(FastFlags.FLAG5))
                    {
                        ret.Add(4);
                    }
                    if (flag.HasFlag(FastFlags.FLAG6))
                    {
                        ret.Add(5);
                    }
                }
                return(ret);
            };
            ldFastTagsNum.AspectGetter = delegate(object x) {
                string res = "";
                if (((Lending)x).FastTags != null)
                {
                    FastFlags flag = (FastFlags)((Lending)x).FastTags;
                    if (flag.HasFlag(FastFlags.FLAG1))
                    {
                        res += "1";
                    }
                    if (flag.HasFlag(FastFlags.FLAG2))
                    {
                        res += "2";
                    }
                    if (flag.HasFlag(FastFlags.FLAG3))
                    {
                        res += "3";
                    }
                    if (flag.HasFlag(FastFlags.FLAG4))
                    {
                        res += "4";
                    }
                    if (flag.HasFlag(FastFlags.FLAG5))
                    {
                        res += "5";
                    }
                    if (flag.HasFlag(FastFlags.FLAG6))
                    {
                        res += "6";
                    }
                }
                return(res);
            };
            ldPerson.AspectGetter = delegate(object x) {
                Contacts contact = db.Contacts.Find(((Lending)x).PersonID);
                if (contact != null)
                {
                    return(contact.Name.Trim() + " " + contact.Surname.Trim());
                }
                else
                {
                    return("");
                }
            };
            ldItemType.AspectGetter = delegate(object x) {
                switch (((Lending)x).CopyType.Trim())
                {
                case "item":
                    return(Lng.Get("Item"));

                case "book":
                    return(Lng.Get("Book"));

                case "boardgame":
                    return(Lng.Get("Boardgame", "Board game"));
                }
                return(Lng.Get("Unknown"));
            };
            ldItemName.AspectGetter = delegate(object x) {
                var copy = db.Copies.Find(((Lending)x).CopyID);
                if (copy == null)
                {
                    return("");
                }
                return(global.GetLendingItemName(copy.ItemType, copy.ItemID ?? Guid.Empty));
            };
            ldItemNum.AspectGetter = delegate(object x) {
                return(0);
            };
            ldItemInvNum.AspectGetter = delegate(object x) {
                if (((Lending)x).CopyID != null)
                {
                    var copy = db.Copies.Find(((Lending)x).CopyID);
                    if (copy == null)
                    {
                        return("");
                    }
                    return(copy.InventoryNumber);
                }


                return("");
            };
            ldFrom.AspectGetter = delegate(object x) {
                if (((Lending)x).From == null)
                {
                    return("");
                }
                DateTime t = ((Lending)x).From ?? DateTime.Now;
                return(t.ToShortDateString());
            };
            ldTo.AspectGetter = delegate(object x) {
                if (((Lending)x).To == null)
                {
                    return("");
                }
                DateTime t = ((Lending)x).To ?? DateTime.Now;
                return(t.ToShortDateString());
            };
            //brStatus.Renderer = new ImageRenderer();
            ldStatus.ImageGetter = delegate(object x) {
                int status = ((Lending)x).Status ?? 1;
                if (status == 2)        // Returned
                {
                    return(6);
                }
                else if (status == 0)   // Reserved
                {
                    return(9);
                }
                else if (status == 3)   // Canceled
                {
                    return(7);
                }
                else
                {
                    return(10);         // Borrowed
                }
            };
            ldStatus.AspectGetter = delegate(object x) {
                int status = ((Lending)x).Status ?? 1;
                if (status == 2)        // Returned
                {
                    return(Lng.Get("Returned"));
                }
                else if (status == 0)   // Reserved
                {
                    return(Lng.Get("Reserved"));
                }
                else if (status == 3)   // Canceled
                {
                    return(Lng.Get("Canceled"));
                }
                else
                {
                    return(Lng.Get("Borrowed")); // Borrowed
                }
            };
            ldNote.AspectGetter = delegate(object x) {
                return(((Lending)x).Note);
            };
            olvLending.SetObjects(lend);
        }
예제 #13
0
        /// <summary>
        /// Update Contacts ObjectListView
        /// </summary>
        void UpdateRecOLV()
        {
            databaseEntities db = new databaseEntities();

            List <Recipes> rec;

            if (chbShowExcludedRecipes.Checked)
            {
                rec = db.Recipes.ToList();
            }
            else
            {
                rec = db.Recipes.Where(p => (p.Excluded ?? false) == false).ToList();
            }

            recTags.Renderer     = new ImageRenderer();
            recTags.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                List <int> ret  = new List <int>();
                FastFlags  flag = (FastFlags)((Recipes)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    ret.Add(0);
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    ret.Add(1);
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    ret.Add(2);
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    ret.Add(3);
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    ret.Add(4);
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    ret.Add(5);
                }

                return(ret);
            };
            recTagsNum.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                string    res  = "";
                FastFlags flag = (FastFlags)((Recipes)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    res += "1";
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    res += "2";
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    res += "3";
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    res += "4";
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    res += "5";
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    res += "6";
                }
                return(res);
            };
            recName.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Recipes)x).Name);
            };
            recCategory.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Recipes)x).Category);
            };
            recKeywords.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Recipes)x).Keywords);
            };
            recExcluded.Renderer     = new ImageRenderer();
            recExcluded.AspectGetter = delegate(object x) {
                if (((Recipes)x).Excluded ?? false)
                {
                    return(7);
                }
                else
                {
                    return(6);
                }
            };
            olvRecipes.SetObjects(rec);
        }
예제 #14
0
        /// <summary>
        /// Update Contacts ObjectListView
        /// </summary>
        void UpdateGameOLV()
        {
            databaseEntities db = new databaseEntities();

            List <Games> gam;

            if (chbShowExcludedGames.Checked)
            {
                gam = db.Games.ToList();
            }
            else
            {
                gam = db.Games.Where(p => (p.Excluded ?? false) == false).ToList();
            }

            gmTags.Renderer     = new ImageRenderer();
            gmTags.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                List <int> ret  = new List <int>();
                FastFlags  flag = (FastFlags)((Games)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    ret.Add(0);
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    ret.Add(1);
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    ret.Add(2);
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    ret.Add(3);
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    ret.Add(4);
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    ret.Add(5);
                }

                return(ret);
            };
            gmTagsNum.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                string    res  = "";
                FastFlags flag = (FastFlags)((Games)x).FastTags;
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    res += "1";
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    res += "2";
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    res += "3";
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    res += "4";
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    res += "5";
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    res += "6";
                }
                return(res);
            };
            gmName.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Games)x).Name);
            };
            gmCategory.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Games)x).Category);
            };
            gmKeywords.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Games)x).Keywords);
            };
            gmEnviroment.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Games)x).Environment);
            };
            gmMinPlayers.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Games)x).MinPlayers);
            };
            gmMaxPlayers.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Games)x).MaxPlayers);
            };
            gmDuration.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Games)x).Duration);
            };
            gmPlayerAge.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }
                return(((Games)x).PlayerAge);
            };

            gmExcluded.Renderer     = new ImageRenderer();
            gmExcluded.AspectGetter = delegate(object x) {
                if (((Games)x).Excluded ?? false)
                {
                    return(7);
                }
                else
                {
                    return(6);
                }
            };
            olvGames.SetObjects(gam);
        }
예제 #15
0
        /// <summary>
        /// Update Lending ObjectListView
        /// </summary>
        void UpdateBorrowingOLV()
        {
            databaseEntities db = new databaseEntities();


            List <Borrowing> borr;

            // ----- Show Expired -----
            if (cbBorrowingShow.SelectedIndex == 1)
            {
                DateTime now = DateTime.Now;
                borr = db.Borrowing.Where(p => ((p.To ?? now) < DateTime.Now) && ((p.Status ?? 1) == 0 || (p.Status ?? 1) == 1)).ToList();
            }
            // ----- Show Borrowed -----
            else if (cbBorrowingShow.SelectedIndex == 2)
            {
                if (chbBorrowingReturned.Checked)
                {
                    borr = db.Borrowing.Where(p => ((p.Status ?? 1) == 1 || (p.Status ?? 1) == 2)).ToList();
                }
                else
                {
                    borr = db.Borrowing.Where(p => (p.Status ?? 1) == 1).ToList();
                }
            }
            // ----- Show Reserved -----
            else if (cbBorrowingShow.SelectedIndex == 3)
            {
                if (chbBorrowingReturned.Checked)
                {
                    borr = db.Borrowing.Where(p => ((p.Status ?? 1) == 0 || (p.Status ?? 1) == 3)).ToList();
                }
                else
                {
                    borr = db.Borrowing.Where(p => (p.Status ?? 1) == 0).ToList();
                }
            }
            // ----- Show All -----
            else
            {
                if (chbBorrowingReturned.Checked)
                {
                    borr = db.Borrowing.ToList();
                }
                else
                {
                    borr = db.Borrowing.Where(p => (p.Status ?? 1) == 0 || (p.Status ?? 1) == 1).ToList();
                }
            }

            brFastTags.Renderer     = new ImageRenderer();
            brFastTags.AspectGetter = delegate(object x) {
                List <int> ret = new List <int>();
                if (((Borrowing)x).FastTags != null)
                {
                    FastFlags flag = (FastFlags)((Borrowing)x).FastTags;
                    if (flag.HasFlag(FastFlags.FLAG1))
                    {
                        ret.Add(0);
                    }
                    if (flag.HasFlag(FastFlags.FLAG2))
                    {
                        ret.Add(1);
                    }
                    if (flag.HasFlag(FastFlags.FLAG3))
                    {
                        ret.Add(2);
                    }
                    if (flag.HasFlag(FastFlags.FLAG4))
                    {
                        ret.Add(3);
                    }
                    if (flag.HasFlag(FastFlags.FLAG5))
                    {
                        ret.Add(4);
                    }
                    if (flag.HasFlag(FastFlags.FLAG6))
                    {
                        ret.Add(5);
                    }
                }
                return(ret);
            };
            brFastTagsNum.AspectGetter = delegate(object x) {
                string res = "";
                if (((Borrowing)x).FastTags != null)
                {
                    FastFlags flag = (FastFlags)((Borrowing)x).FastTags;
                    if (flag.HasFlag(FastFlags.FLAG1))
                    {
                        res += "1";
                    }
                    if (flag.HasFlag(FastFlags.FLAG2))
                    {
                        res += "2";
                    }
                    if (flag.HasFlag(FastFlags.FLAG3))
                    {
                        res += "3";
                    }
                    if (flag.HasFlag(FastFlags.FLAG4))
                    {
                        res += "4";
                    }
                    if (flag.HasFlag(FastFlags.FLAG5))
                    {
                        res += "5";
                    }
                    if (flag.HasFlag(FastFlags.FLAG6))
                    {
                        res += "6";
                    }
                }
                return(res);
            };
            brPerson.AspectGetter = delegate(object x) {
                Contacts contact = db.Contacts.Find(((Borrowing)x).PersonID);
                if (contact != null)
                {
                    return(contact.Name.Trim() + " " + contact.Surname.Trim());
                }
                else
                {
                    return("");
                }
            };
            brItemName.AspectGetter = delegate(object x) {
                return(((Borrowing)x).Item.Trim());
            };
            brItemInvNum.AspectGetter = delegate(object x) {
                if (((Borrowing)x).ItemInvNum != null)
                {
                    return(((Borrowing)x).ItemInvNum.Trim());
                }
                return("");
            };
            brFrom.AspectGetter = delegate(object x) {
                if (((Borrowing)x).From == null)
                {
                    return("");
                }
                DateTime t = ((Borrowing)x).From ?? DateTime.Now;
                return(t.ToShortDateString());
            };
            brTo.AspectGetter = delegate(object x) {
                if (((Borrowing)x).To == null)
                {
                    return("");
                }
                DateTime t = ((Borrowing)x).To ?? DateTime.Now;
                return(t.ToShortDateString());
            };
            //brStatus.Renderer = new ImageRenderer();
            brStatus.ImageGetter = delegate(object x) {
                int status = ((Borrowing)x).Status ?? 1;
                if (status == 2)        // Returned
                {
                    return(6);
                }
                else if (status == 0)   // Reserved
                {
                    return(9);
                }
                else if (status == 3)   // Canceled
                {
                    return(7);
                }
                else
                {
                    return(10);         // Borrowed
                }
            };
            brStatus.AspectGetter = delegate(object x) {
                int status = ((Borrowing)x).Status ?? 1;
                if (status == 2)        // Returned
                {
                    return(Lng.Get("Returned"));
                }
                else if (status == 0)   // Reserved
                {
                    return(Lng.Get("Reserved"));
                }
                else if (status == 3)   // Canceled
                {
                    return(Lng.Get("Canceled"));
                }
                else
                {
                    return(Lng.Get("Borrowed")); // Borrowed
                }
            };
            brNote.AspectGetter = delegate(object x) {
                if (((Borrowing)x).Note != null)
                {
                    return(((Borrowing)x).Note.Trim());
                }
                else
                {
                    return("");
                }
            };

            olvBorrowing.SetObjects(borr);
        }
예제 #16
0
        /// <summary>
        /// Form Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmEditContacts_Load(object sender, EventArgs e)
        {
            com.ReceivedData += new ReceivedEventHandler(DataReceive);
            try
            {
                com.ConnectSP(Properties.Settings.Default.scanCOM);
            }
            catch { }

            PrepareCbSex();

            PreparePhone();
            PrepareEmail();
            PrepareURL();
            PrepareIM();

            // ----- New Inv Number -----
            if (TempMaxInvNum < Properties.Settings.Default.ContactStart)
            {
                TempMaxInvNum = Properties.Settings.Default.ContactStart;
            }
            else
            {
                TempMaxInvNum++;
            }
            txtCode.Text = Properties.Settings.Default.ContactPrefix + (TempMaxInvNum).ToString("D" + Properties.Settings.Default.ContactMinCharLen.ToString()) + Properties.Settings.Default.ContactSuffix;

            // ----- If Edit -> fill form -----
            if (ID != Guid.Empty)
            {
                Contacts contact = db.Contacts.Find(ID);

                // ----- Avatar -----
                imgAvatar.Image = Conv.ByteArrayToImage(contact.Avatar);

                // ----- Name -----
                txtName.Text    = contact.Name;
                txtSurname.Text = contact.Surname;
                txtNick.Text    = contact.Nick;
                if (contact.Sex.Trim() == "M")
                {
                    cbSex.SelectedIndex = 1;
                }
                else if (contact.Sex.Trim() == "F")
                {
                    cbSex.SelectedIndex = 2;
                }
                else
                {
                    cbSex.SelectedIndex = 0;
                }

                // ----- Phone -----
                PhoneNums = GetDataItem(contact.Phone);
                if (PhoneNums.Count > 0)
                {
                    cbPhone.Items.Clear();
                    for (int i = 0; i < PhoneNums.Count; i++)
                    {
                        cbPhone.Items.Add(PhoneNums[i].name);
                    }
                    if (PhoneNums.Count > 1)
                    {
                        btnDelPhone.Enabled = true;
                    }
                    SelectPhone(0);
                }
                else
                {
                    CreatePhone();
                }


                // ----- Email -----
                Emails = GetDataItem(contact.Email);
                if (Emails.Count > 0)
                {
                    cbEmail.Items.Clear();
                    for (int i = 0; i < Emails.Count; i++)
                    {
                        cbEmail.Items.Add(Emails[i].name);
                    }
                    if (Emails.Count > 1)
                    {
                        btnDelEmail.Enabled = true;
                    }
                    SelectEmail(0);
                }
                else
                {
                    CreateEmail();
                }

                // ----- URL -----
                URLs = GetDataItem(contact.WWW);
                if (URLs.Count > 0)
                {
                    cbURL.Items.Clear();
                    for (int i = 0; i < URLs.Count; i++)
                    {
                        cbURL.Items.Add(URLs[i].name);
                    }
                    if (URLs.Count > 1)
                    {
                        btnDelURL.Enabled = true;
                    }
                    SelectURL(0);
                }
                else
                {
                    CreateURL();
                }

                // ----- IM -----
                IMs = GetDataItem(contact.IM);
                if (IMs.Count > 0)
                {
                    cbIM.Items.Clear();
                    for (int i = 0; i < IMs.Count; i++)
                    {
                        cbIM.Items.Add(IMs[i].name);
                    }
                    if (IMs.Count > 1)
                    {
                        btnDelIM.Enabled = true;
                    }
                    SelectIM(0);
                }
                else
                {
                    CreateIM();
                }

                // ----- Address -----
                txtStreet.Text   = contact.Street;
                txtCity.Text     = contact.City;
                txtRegion.Text   = contact.Region;
                txtState.Text    = contact.Country;
                txtPostCode.Text = contact.PostCode;

                txtNote.Text = contact.Note;
                if (contact.Birth != null)
                {
                    chbBirth.Checked = true;
                }
                dateBirth.Value = contact.Birth ?? dateBirth.MinDate;
                txtTag.Text     = contact.Tags;
                //contact.FastTags = 0;


                txtCode.Text = contact.PersonCode;

                txtCompany.Text  = contact.Company;
                txtPosition.Text = contact.Position;

                chbActive.Checked = contact.Active ?? true;

                // ----- Fast tags -----
                FastFlags flag = (FastFlags)(contact.FastTags ?? 0);
                if (flag.HasFlag(FastFlags.FLAG1))
                {
                    btnTag1.BackColor = Color.SkyBlue;
                }
                if (flag.HasFlag(FastFlags.FLAG2))
                {
                    btnTag2.BackColor = Color.SkyBlue;
                }
                if (flag.HasFlag(FastFlags.FLAG3))
                {
                    btnTag3.BackColor = Color.SkyBlue;
                }
                if (flag.HasFlag(FastFlags.FLAG4))
                {
                    btnTag4.BackColor = Color.SkyBlue;
                }
                if (flag.HasFlag(FastFlags.FLAG5))
                {
                    btnTag5.BackColor = Color.SkyBlue;
                }
                if (flag.HasFlag(FastFlags.FLAG6))
                {
                    btnTag6.BackColor = Color.SkyBlue;
                }

                // ----- Updated -----
                lblLastUpdate.Text = Lng.Get("LastUpdate", "Last update") + ": " + (contact.Updated ?? DateTime.Now).ToString();
                lblGoogleID.Text   = "Google ID: " + contact.GoogleID;

                // ----- Unused now -----

                /*contact.Partner = "";
                 * contact.Childs = "";
                 * contact.Parrents = "";
                 * contact.GoogleID = "";*/
            }
        }