コード例 #1
0
ファイル: Form1.cs プロジェクト: t0is/fantastic-spork
        public void refreshRows(Collection <Person> pl = null)
        {
            Collection <Person> players;

            TablePlayers.Rows.Clear();
            if (pl == null)
            {
                players = PersonTable.Select();
            }
            else
            {
                players = pl;
            }
            foreach (Person p in players)
            {
                int n = TablePlayers.Rows.Add();
                TablePlayers.Rows[n].Cells[0].Value = p.Id.ToString();
                TablePlayers.Rows[n].Cells[1].Value = p.First_Name;
                TablePlayers.Rows[n].Cells[2].Value = p.Last_Name;
                TablePlayers.Rows[n].Cells[3].Value = p.Birth_Date.ToString();
                TablePlayers.Rows[n].Cells[4].Value = p.Role;
                TablePlayers.Rows[n].Cells[5].Value = p.Game_Id.Name;
                TablePlayers.Rows[n].Cells[6].Value = p.Team_Id.Name;
            }
        }
コード例 #2
0
ファイル: Form2.cs プロジェクト: t0is/fantastic-spork
        private void button2_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes == MessageBox.Show("Do you really want to add this player?", "", MessageBoxButtons.YesNo))
            {
                Person p   = new Person();
                var    tmp = PersonTable.Select();
                try
                {
                    p.Id         = tmp.Count + 1;
                    p.First_Name = textBox1.Text;
                    p.Last_Name  = textBox5.Text;
                    p.Birth_Date = Int32.Parse(textBox4.Text);
                    if (comboBoxRole.SelectedIndex == -1)
                    {
                        MessageBox.Show("ROLE MUST BE CHOSEN!\nClick on the role to chose it\nThe role name must be in blue in order to be chosen sucessfully\n", "", MessageBoxButtons.OK);
                        return;
                    }
                    p.Role = comboBoxRole.Items[comboBoxRole.SelectedIndex].ToString();


                    if (p.First_Name.Length > 30 || p.Last_Name.Length > 30 || p.Birth_Date > 2300 || p.Birth_Date < 1800)
                    {
                        throw new Exception();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("WRONG FORMAT OF INPUT!\nBoth name and last name can be max 30 chars long\nBirth year must be realistic\n", "", MessageBoxButtons.OK);
                    return;
                }



                if (comboBoxTeam.SelectedIndex == -1)
                {
                    MessageBox.Show("TEAM NOT CHOSEN!\nClick on the team name to chose it\n", "", MessageBoxButtons.OK);
                    return;
                }
                Team t = new Team();
                t.Id      = comboBoxTeam.SelectedIndex + 1;
                p.Team_Id = t;



                if (comboBoxGame.SelectedIndex == -1)
                {
                    MessageBox.Show("GAME NOT CHOSEN!\nClick on the game name to chose it\n", "", MessageBoxButtons.OK);
                    return;
                }
                Game g = new Game();
                g.Id      = comboBoxGame.SelectedIndex + 1;
                p.Game_Id = g;

                PersonTable.Insert(p);
                this.Close();
            }
        }
コード例 #3
0
 // háttérben kerül végrehajtásra
 void bgWorker_studentsList_DoWork(object sender, DoWorkEventArgs e)
 {
     records_studentsList = manager_studentsTable.Select();
 }