我在不使用SQL但使用arraylists和datastructs的情况下创建了一个C#数据库。我正在建立一个足球数据库,并希望使用TabControl来存储比赛细节,例如分钟比赛,进球和罚球。这些都是使用NumericUpDown。我在TabControl顶部有一个面板,所有这些都在,我可以添加新标签,但数据继续,我希望能够为每个匹配添加不同的数据。无论如何这样做。
private void MinutesPlayed_Num_ValueChanged(object sender, EventArgs e)
{
// 1. create a new structure that can hold results for 5 matches
FootballClub TabStruct = new FootballClub(5);
// 2. copy the content of the current ArrayList data structure // into the new structure
TabStruct = (FootballClub)ClubData[CurrentPlayerShown];
// 3. update the data structure to what the GUI shows
TabStruct.MinutesPlayed[tabControl1.SelectedIndex] = (int)MinutesPlayed_Num.Value;
// 4. overwrite the old data with the changed one.
ClubData[CurrentPlayerShown] = TabStruct;
}
private void GoalsScored_Num_ValueChanged(object sender, EventArgs e)
{
// 1. create a new structure that can hold results for 5 matches
FootballClub TabStruct = new FootballClub(5);
// 2. copy the content of the current ArrayList data structure // into the new structure
TabStruct = (FootballClub)ClubData[CurrentPlayerShown];
// 3. update the data structure to what the GUI shows
TabStruct.Goals[tabControl1.SelectedIndex] = (int)GoalsScored_Num.Value;
// 4. overwrite the old data with the changed one.
ClubData[CurrentPlayerShown] = TabStruct;
}
private void PenaltiesScored_Num_ValueChanged(object sender, EventArgs e)
{
// 1. create a new structure that can hold results for 5 matches
FootballClub TabStruct = new FootballClub(5);
// 2. copy the content of the current ArrayList data structure // into the new structure
TabStruct = (FootballClub)ClubData[CurrentPlayerShown];
// 3. update the data structure to what the GUI shows
TabStruct.Penalties[tabControl1.SelectedIndex] = (int)PenaltiesScored_Num.Value;
// 4. overwrite the old data with the changed one.
ClubData[CurrentPlayerShown] = TabStruct;
}
这是我改变该字段中数据时到目前为止的代码。
然后这是我想要显示我们正在播放哪个播放器的代码。
private void ShowCurrentMember()
{
FootballClub PlayerMemberData;
PlayerMemberData = (FootballClub)ClubData[CurrentPlayerShown];
FirstNameTextBox.Text = PlayerMemberData.Firstname;
SurnameTextBox.Text = PlayerMemberData.Surname;
PlayerAge.Value = PlayerMemberData.age;
Address1_Text.Text = PlayerMemberData.Address1;
Address2_Text.Text = PlayerMemberData.Address2;
City_Text.Text = PlayerMemberData.City;
Country_Text.Text = PlayerMemberData.Country;
Postcode_Text.Text = PlayerMemberData.Postcode;
HomeNumber_Text.Text = " " + PlayerMemberData.HomeNum;
MobileNum_Text.Text = " " + PlayerMemberData.MobNum;
Email_Text.Text = PlayerMemberData.Email;
EmergName_Text.Text = PlayerMemberData.EmergencyName;
EmergNum_Text.Text = " " + PlayerMemberData.EmergencyNum;
//if (PlayerMemberData.CardGiven == 'Y') YellowCard_RadioButt.Checked = true;
//else RedCard_RadioButt.Checked = true;
TotalTime_Text.Text = " " + PlayerMemberData.MinutesPlayed;
TotalGoals_Text.Text = " " + PlayerMemberData.Goals;
TotalPenalties_Text.Text = " " + PlayerMemberData.Penalties;
pictureBox1.ImageLocation = ((FootballClub)ClubData[CurrentPlayerShown]).ImgFilePathName;
FootballClub TabStruct;
TabStruct = (FootballClub)ClubData[CurrentPlayerShown];
MinutesPlayed_Num.Value = ((FootballClub)ClubData[CurrentPlayerShown]).MinutesPlayed[tabControl1.SelectedIndex];
GoalsScored_Num.Value = ((FootballClub)ClubData[CurrentPlayerShown]).Goals[tabControl1.SelectedIndex];
PenaltiesScored_Num.Value = ((FootballClub)ClubData[CurrentPlayerShown]).Penalties[tabControl1.SelectedIndex];
Player1.Text = "Player " + (CurrentPlayerShown + 1);
UpdatePrevNextBtnStatus();