private async void BtnAdd_Click(object sender, EventArgs e)
        {
            string nameText    = txtName.Text.Trim();
            string surnameText = txtSurname.Text.Trim();
            string ageText     = txtAge.Text.Trim();

            EPLposition SelectedEplposition = cmbPosition.SelectedItem as EPLposition;
            EPLclub     SelectedEplclub     = cmbClub.SelectedItem as EPLclub;

            EPLplayer eplplayer = new EPLplayer
            {
                name       = nameText,
                surname    = surnameText,
                age        = Convert.ToByte(ageText),
                positionId = SelectedEplposition.id,
                clubId     = SelectedEplclub.id
            };

            eplEntities.EPLplayers.Add(eplplayer);
            await eplEntities.SaveChangesAsync();

            MessageBox.Show("Successfully added");
            ResetInputs();
            LoadDataBase();
        }
Beispiel #2
0
        private async void BtnUpdate_Click(object sender, EventArgs e)
        {
            EPLplayer fullnameText = (EPLplayer)cmbFullname.SelectedItem;
            EPLclub   eplclub      = (EPLclub)cmbClub.SelectedItem;

            fullnameText.clubId = eplclub.id;
            MessageBox.Show("Updated");
            await eplEntities.SaveChangesAsync();
        }
        private async void BtnDelete_Click(object sender, EventArgs e)
        {
            EPLplayer eplplayer = (EPLplayer)cmbPlayers.SelectedItem;

            eplEntities.EPLplayers.Remove(eplplayer);
            MessageBox.Show("Deleted");
            await eplEntities.SaveChangesAsync();

            cmbPlayers.Items.Clear();
            cmbPlayers.Items.AddRange(eplEntities.EPLplayers.ToArray());
        }
Beispiel #4
0
        private void CmbFullname_SelectedIndexChanged(object sender, EventArgs e)
        {
            EPLplayer selectedEplplayer = cmbFullname.SelectedItem as EPLplayer;

            cmbPosition.SelectedIndex = Convert.ToInt32(selectedEplplayer.positionId - 1); // Convertion ???
            cmbClub.SelectedIndex     = Convert.ToInt32(selectedEplplayer.clubId - 1);

            lblPosition.Visible = true;
            cmbPosition.Visible = true;
            lblClub.Visible     = true;
            cmbClub.Visible     = true;
        }