Example #1
0
        int Find(Cassete cas, string str)
        {
            string[] names = str.Split(',');
            int      s     = 0;
            int      voids = 0;

            foreach (string name in names)
            {
                string nm = name;
                while (nm.Length > 0 && name[0] == ' ')
                {
                    nm = nm.Substring(1, nm.Length - 1);
                }
                while (nm.Length > 0 && name[nm.Length - 1] == ' ')
                {
                    nm = nm.Substring(0, nm.Length - 1);
                }
                if (nm.Length < 1)
                {
                    voids++; break;
                }
                bool find = false;
                foreach (string game in cas.sideA)
                {
                    if (game.ToLower().Contains(nm.ToLower()))
                    {
                        find = true; break;
                    }
                }
                foreach (string game in cas.sideB)
                {
                    if (game.ToLower().Contains(nm.ToLower()))
                    {
                        find = true; break;
                    }
                }
                if (find)
                {
                    s++;
                }
            }
            float res = 0;

            if (voids < names.Count())
            {
                res = ((float)s / (names.Count() - voids)) * 100;
            }
            if (res > 100)
            {
                res = 100;
            }
            return((int)res);
        }
Example #2
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            itsNew = true;
            edit   = new Cassete();

            listViewCassetes.Enabled = false;
            textBoxLabel.Text        = "";
            textBoxLabel.Enabled     = true;
            textBoxPublisher.Text    = "";
            textBoxPublisher.Enabled = true;
            textBoxCity.Text         = "";
            textBoxCity.Enabled      = true;
            textBoxYear.Text         = "";
            textBoxYear.Enabled      = true;
            dataGridViewA.Rows.Clear();
            dataGridViewA.Enabled = true;
            dataGridViewB.Rows.Clear();
            dataGridViewB.Enabled = true;
            buttonAdd.Enabled     = false;
            buttonDel.Enabled     = false;
            buttonSave.Enabled    = true;
            buttonCancel.Enabled  = true;
        }
Example #3
0
        private void ListViewCassetes_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewCassetes.SelectedItems.Count == 0)
            {
                Clear();
                return;
            }
            itsNew = false;
            edit   = (Cassete)listViewCassetes.SelectedItems[0].Tag;

            listViewCassetes.Enabled = true;
            textBoxLabel.Text        = edit.name;
            textBoxLabel.Enabled     = true;
            textBoxPublisher.Text    = edit.publisher;
            textBoxPublisher.Enabled = true;
            textBoxCity.Text         = edit.city;
            textBoxCity.Enabled      = true;
            textBoxYear.Text         = edit.year;
            textBoxYear.Enabled      = true;
            dataGridViewA.Rows.Clear();
            foreach (string pr in edit.sideA)
            {
                dataGridViewA.Rows.Add(pr);
            }
            dataGridViewA.Enabled = true;
            dataGridViewB.Rows.Clear();
            foreach (string pr in edit.sideB)
            {
                dataGridViewB.Rows.Add(pr);
            }
            dataGridViewB.Enabled = true;

            buttonDel.Enabled    = true;
            buttonSave.Enabled   = true;
            buttonCancel.Enabled = true;
        }