コード例 #1
0
        public Form1()
        {
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
            string json;

            using (var reader = new StreamReader(_filePath))
            {
                json = reader.ReadToEnd();
            }
            var d = new JavaScriptSerializer {
                MaxJsonLength = 86753090
            };

            _persons = d.Deserialize <IList <DataBaseRootObject> >(json);
            foreach (var person in _persons)
            {
                if (person.CommonName == "")
                {
                    cB_player.Items.Add(
                        person.FirstName + " " +
                        person.LastName + " (" +
                        person.Rating + ")");
                }
                else
                {
                    cB_player.Items.Add(person.CommonName + " (" +
                                        person.Rating + ")");
                }
            }

            cB_player.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cB_player.AutoCompleteSource = AutoCompleteSource.ListItems;
            cB_player.Focus();

            var allStyles = new ChemistryStyle().GetAll();

            foreach (var chemistryStyle in allStyles)
            {
                cB_cs.Items.Add(chemistryStyle.Name);
            }
        }
コード例 #2
0
        private void BT_Add_Click(object sender, EventArgs e)
        {
            if (cB_player.SelectedIndex != -1 &&
                cB_version.SelectedIndex != -1 &&
                cB_position.SelectedIndex != -1 &&
                cB_version.SelectedIndex != -1 &&
                tb_buy.Text != "" &&
                tb_sell.Text != "")
            {
                string rat;
                var    mystyle        = new ChemistryStyle().GetAll();
                var    chemistryStyle = mystyle[cB_cs.SelectedIndex].Id.ToString();

                var rating = Convert.ToInt32(_persons[cB_player.SelectedIndex].Rating);
                if (rating >= 75)
                {
                    rat = "gold";
                }
                else if (rating <= 64)
                {
                    rat = "bronze";
                }
                else
                {
                    rat = "silver";
                }
                int    baseId  = Convert.ToInt32(_persons[cB_player.SelectedIndex].bID);
                int    version = Convert.ToInt32(cB_version.Items[cB_version.SelectedIndex]);
                int    resId   = baseId + 1610612736 + version * 50331648;
                string name;

                //Name bestimmen ;)
                if (_persons[cB_player.SelectedIndex].CommonName == "")
                {
                    name = _persons[cB_player.SelectedIndex].FirstName + " " + _persons[cB_player.SelectedIndex].LastName + " (" + _persons[cB_player.SelectedIndex].Rating + ")";
                }
                else
                {
                    name = _persons[cB_player.SelectedIndex].CommonName + " (" + _persons[cB_player.SelectedIndex].Rating + ")";
                }

                string nationId = _persons[cB_player.SelectedIndex].NationId;
                string clubId   = _persons[cB_player.SelectedIndex].ClubId;
                string position = "";
                if (cB_position.SelectedIndex != -1)
                {
                    position = cB_position.Items[cB_position.SelectedIndex].ToString();
                }
                string buy  = "";
                string sell = "";
                if (tb_buy.Text != "" && tb_sell.Text != "")
                {
                    buy  = tb_buy.Text;
                    sell = tb_sell.Text;
                }
                object[] row = { rat, name, nationId, clubId, position, chemistryStyle, buy, sell, baseId.ToString(), resId.ToString() };
                dG_list.Rows.Add(row);
            }
            else
            {
                MessageBox.Show(@"Bitte alle Informationen angeben!");
            }
        }