private void btnSave_Click(object sender, EventArgs e)
 {
     btnSave.Enabled        = false;
     btnCancel.Visible      = false;
     btnAddNewTeams.Enabled = true;
     if (lstTeams.SelectedIndex < 0)
     {
         MessageBox.Show("Lütfen değişiklikleri kaydetmek istediğiniz takımı seçiniz.");
         return;
     }
     else
     {
         int  seciliIndeks = lstTeams.SelectedIndex;
         Team team         = lstTeams.SelectedItem as Team;
         team.TeamName = txtTeamName.Text;
         if (txtTeamName.Text.Contains("closed"))
         {
             MessageBox.Show("closed kelimesi bir takım ismi belirlerken kullanılamaz");
             return;
         }
         if (txtTeamName.Text == "")
         {
             MessageBox.Show("Takım ismi boş girilemez");
             return;
         }
         lstTeams.DataSource    = db.Teams.ToList();
         lstTeams.SelectedIndex = seciliIndeks;
         db.SaveChanges();
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Player player = new Player();

            player.PlayerName = txtPlayerName.Text.Trim();

            if (txtPlayerName.Text == "")
            {
                MessageBox.Show("Oyuncu eklemek için bir oyuncu ismi girilmelidir");
                return;
            }

            if (cboTeams.SelectedIndex >= 0)
            {
                Team team = cboTeams.SelectedItem as Team;
                if (team.TeamName.Contains("closed"))
                {
                    MessageBox.Show("Bu takım kapanmış oyuncu eklenemez");
                    return;
                }
                team.Players.Add(player);
            }
            db.Players.Add(player);

            db.SaveChanges();
            lstPlayers.DataSource    = db.Players.ToList();
            lstPlayers.SelectedIndex = lstPlayers.Items.Count - 1;
        }
Esempio n. 3
0
        private void ResultControl()
        {
            var matches = db.Matches.ToList();

            foreach (var item in matches)
            {
                if (item.Score2 > item.Score1)
                {
                    item.Result = Result.Team2;
                }

                else if (item.Score1 > item.Score2)
                {
                    item.Result = Result.Team1;
                }

                else if (item.Score1 == item.Score2 && DateTime.Now > item.MatchTime)
                {
                    item.Result = Result.Draw;
                }

                else
                {
                    item.Result = null;
                }

                db.SaveChanges();
            }
        }
        private void btnAddMatch_Click(object sender, EventArgs e)
        {
            if (cboNewTeam1.SelectedIndex == 0 || cboNewTeam2.SelectedIndex == 0 || (Team)cboNewTeam1.SelectedItem == (Team)cboNewTeam2.SelectedItem)
            {
                MessageBox.Show("Please select team correctly!");
                return;
            }
            var      team1     = (Team)cboNewTeam1.SelectedItem;
            var      team2     = (Team)cboNewTeam2.SelectedItem;
            DateTime?matchDate = dtpNewDate.Value;

            if (team1.Team1Matches.ToList().Any(x => x.MatchTime.Value.ToShortDateString() == matchDate.Value.ToShortDateString()) || team1.Team2Matches.ToList().Any(x => x.MatchTime.Value.ToShortDateString() == matchDate.Value.ToShortDateString()))
            {
                MessageBox.Show($"{team1.TeamName} have a match on selected date");
                return;
            }
            if (team2.Team1Matches.ToList().Any(x => x.MatchTime.Value.ToShortDateString() == matchDate.Value.ToShortDateString()) || team2.Team2Matches.ToList().Any(x => x.MatchTime.Value.ToShortDateString() == matchDate.Value.ToShortDateString()))
            {
                MessageBox.Show($"{team2.TeamName} have  a match on selected date");
                return;
            }
            db.Matches.Add(new Match()
            {
                Team1     = team1,
                Team2     = team2,
                MatchTime = matchDate
            });
            db.SaveChanges();
            ListTeamsEditMatch();
            WhenMakeChange(EventArgs.Empty);
            ResetForm();
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string playerName = txtPlayerName.Text.Trim().UpperCaseFirst();

            if (cboPlayersTeam.SelectedIndex == 0 || playerName == "")
            {
                MessageBox.Show("You have to choose team.");
                return;
            }
            if (btnAdd.Text == "💾 Save")
            {
                var selectedPlayer = (Player)lstPlayers.SelectedItem;
                selectedPlayer.PlayerName = playerName;
                var teamEdit = (Team)cboPlayersTeam.SelectedItem;
                selectedPlayer.Team = cboPlayersTeam.SelectedIndex == 1 ? null : teamEdit;
                db.SaveChanges();
                ListPlayers();
                ResetForm();
                //WhenMakeChange(EventArgs.Empty);
                return;
            }


            var team = (Team)cboPlayersTeam.SelectedItem;

            db.Players.Add(new Player()
            {
                PlayerName = playerName,
                Team       = cboPlayersTeam.SelectedIndex == 1 ? null : team
            });
            db.SaveChanges();
            ListPlayers();
            ResetForm();
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (cboPlayersTeam.SelectedIndex == 0 || txtPlayerName.Text == "")
            {
                MessageBox.Show("Please fill all the blancks correctly");
                return;
            }
            if (btnAdd.Text == "💾 Save")
            {
                var selectedPlayer = (Player)lstPlayers.SelectedItem;
                selectedPlayer.PlayerName = txtPlayerName.Text.UppercaseFirst();

                var teamEdit = (Team)cboPlayersTeam.SelectedItem;
                selectedPlayer.Team = cboPlayersTeam.SelectedIndex == 1 ? null : teamEdit;
                db.SaveChanges();
                ListPlayers();
                ResetForm();
                //WhenMakeChange(EventArgs.Empty);
                return;
            }
            string playerName = txtPlayerName.Text.UppercaseFirst().Trim();

            var team = (Team)cboPlayersTeam.SelectedItem;

            db.Players.Add(new Player()
            {
                PlayerName = playerName,
                Team       = cboPlayersTeam.SelectedIndex == 1 ? null : team
            });
            db.SaveChanges();
            ListPlayers();
            ResetForm();
        }
        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            if (chkNoTeam.Checked)
            {
                string playerName = txtPlayerName.Text.UpperCaseFirst().Trim();
                if (playerName == null || playerName == "")
                {
                    MessageBox.Show("Please give the correct name");
                    return;
                }
                Player player = new Player()
                {
                    PlayerName = playerName,
                    TeamId     = null,
                };

                db.Players.Add(player);
                db.SaveChanges();
                if (txtTeamName.Text != "")
                {
                    FiltreTeams();
                    return;
                }
                LoadPlayers();
                txtTeamName.Clear();
                return;
            }
            else
            {
                string playerName = txtPlayerName.Text.UpperCaseFirst().Trim();
                if (playerName == null || playerName == "" || cboTeams.SelectedValue == null)
                {
                    MessageBox.Show("Please fill the areas");
                    return;
                }
                Player player = new Player()
                {
                    PlayerName = playerName,
                    TeamId     = (int)cboTeams.SelectedValue,
                };
                db.Players.Add(player);
                db.SaveChanges();
                if (txtTeamName.Text != "")
                {
                    dgvPlayers.DataSource = db.Players.Where(n => n.Team.TeamName.Contains(txtTeamName.Text)).ToList().Select(x => new
                    {
                        Id         = x.Id,
                        PlayerName = x.PlayerName,
                        Team       = x.Team.TeamName
                    }).ToList();
                    return;
                }
                LoadPlayers();
                txtTeamName.Clear();
                //aslkdj
                return;
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var teamName = txtTeamName.Text.UpperCaseFirst().Trim();

            if (teamName == "")
            {
                MessageBox.Show("Please fill team name fields correctly.");
                return;
            }
            var color1 = (Model.Color)cboFirstColor.SelectedItem;
            var color2 = (Model.Color)cboSecondColor.SelectedItem;

            if (color1 == null || color2 == null)
            {
                MessageBox.Show("Have to choose two colors.");
                return;
            }
            List <Model.Color> colors = new List <Model.Color>();

            colors.Add(color1);
            colors.Add(color2);

            if (btnAdd.Text == "💾 Save")
            {
                var selectedTeam = (Team)lstTeams.SelectedItem;
                selectedTeam.TeamName = txtTeamName.Text.Trim();
                if (db.Teams.ToList().Any(x => x.TeamName.ToLower() == teamName.ToLower().Replace(" ", "")))
                {
                    MessageBox.Show("Please enter different team name.");
                    return;
                }
                selectedTeam.TeamName   = teamName;
                selectedTeam.TeamColors = colors;
                db.SaveChanges();
                ListTeams();
                ResetForm();
                WhenMakeChange(EventArgs.Empty);
                return;
            }
            if (db.Teams.ToList().Any(x => x.TeamName.ToLower() == teamName.ToLower().Replace(" ", "")))
            {
                MessageBox.Show("There has already been a team in the list. Please try to enter different team name");
                return;
            }
            db.Teams.Add(new Team()
            {
                TeamName = teamName, TeamColors = colors
            });
            db.SaveChanges();
            ListTeams();
            ResetForm();
            WhenMakeChange(EventArgs.Empty);
        }
Esempio n. 9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtTeamName.Text == "")
            {
                MessageBox.Show("Please enter a team name!");
            }
            var color1 = (Model.Color)cboFirstColor.SelectedItem;
            var color2 = (Model.Color)cboSecondColor.SelectedItem;

            if (color1 == null || color2 == null)
            {
                MessageBox.Show("Please choose colors.");
                return;
            }
            List <Model.Color> colors = new List <Model.Color>();

            colors.Add(color1);
            colors.Add(color2);

            var teamName = txtTeamName.Text.UppercaseFirst();

            if (btnAdd.Text == "💾 Save")
            {
                var selectedTeam = (Team)lstTeams.SelectedItem;
                if (db.Teams.ToList().Any(x => x.TeamName.ToLower() == teamName.ToLower().Replace(" ", "") &&
                                          selectedTeam.TeamName.ToLower() != teamName.ToLower().Replace(" ", "")))
                {
                    MessageBox.Show("There is already a team with this team name!");
                    return;
                }
                selectedTeam.TeamName   = teamName;
                selectedTeam.TeamColors = colors;
                db.SaveChanges();
                ListTeams();
                ResetForm();
                WhenMakeChange(EventArgs.Empty);
                return;
            }
            if (db.Teams.ToList().Any(x => x.TeamName.ToLower() == teamName.ToLower().Replace(" ", "")))
            {
                MessageBox.Show("There is already a team with this team name!");
                return;
            }
            db.Teams.Add(new Team()
            {
                TeamName = teamName, TeamColors = colors
            });
            db.SaveChanges();
            ListTeams();
            ResetForm();
            WhenMakeChange(EventArgs.Empty);
        }
Esempio n. 10
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtTeamName.Text == "")
            {
                MessageBox.Show("Please fill teamname field");
                return;
            }
            var teamName = (txtTeamName.Text).UpperCaseFirst();
            var color1   = (Models.Color)cboColor1.SelectedItem;
            var color2   = (Models.Color)cboColor2.SelectedItem;

            if (color1 == null || color2 == null)
            {
                MessageBox.Show("Have to choose two colors.");
                return;
            }
            List <Models.Color> colors = new List <Models.Color> {
                color1, color2
            };

            if (btnAdd.Text == "Save")
            {
                var selectedTeam = (Team)lstTeams.SelectedItem;
                if (db.Teams.ToList().Any(x => x.TeamName.ToLower() == teamName.ToLower().Replace(" ", "")))
                {
                    MessageBox.Show("There already a team in this team name");
                    return;
                }
                selectedTeam.TeamName   = teamName;
                selectedTeam.TeamColors = colors;
                db.SaveChanges();
                ListTeams();
                TeamsFormReset();
                WhenChanged(EventArgs.Empty);
                return;
            }
            if (db.Teams.ToList().Any(x => x.TeamName.ToLower() == teamName.ToLower().Replace(" ", "")))
            {//zxc!= zxc
                MessageBox.Show("There already a team in this team name");
                return;
            }

            db.Teams.Add(new Team()
            {
                TeamName = teamName, TeamColors = colors
            });
            db.SaveChanges();
            ListTeams();
            TeamsFormReset();
            WhenChanged(EventArgs.Empty);
        }
Esempio n. 11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var colorName = txtColorName.Text.Trim();

            if (colorName == "")
            {
                MessageBox.Show("Please fill all fields correctly.");
                return;
            }
            if (btnAdd.Text == "💾 Save")
            {
                if (colorName == "")
                {
                    MessageBox.Show("Please fill all fields correctly.");
                    return;
                }
                var selectedColor = (Models.Color)lstColors.SelectedItem;
                selectedColor.ColorName = txtColorName.Text;
                if (db.Colors.Any(x => x.ColorName == selectedColor.ColorName))
                {
                    MessageBox.Show("Please enter different color name.");
                    return;
                }
                selectedColor.Red   = Convert.ToByte(lblRed.Text);
                selectedColor.Green = Convert.ToByte(lblGreen.Text);
                selectedColor.Blue  = Convert.ToByte(lblBlue.Text);
                db.SaveChanges();
                ListColors();
                ResetForm();
                return;
            }
            var color = new Models.Color
            {
                ColorName = txtColorName.Text.UpperCaseFirst(),
                Red       = Convert.ToByte(lblRed.Text),
                Green     = Convert.ToByte(lblGreen.Text),
                Blue      = Convert.ToByte(lblBlue.Text)
            };

            if (db.Colors.Any(x => x.ColorName == color.ColorName))
            {
                MessageBox.Show("Please enter different color name.");
                return;
            }
            db.Colors.Add(color);
            db.SaveChanges();
            ListColors();
            ResetForm();
        }
        private void btnKarsilastirmaEkle_Click(object sender, EventArgs e)
        {
            int a     = 0;
            int b     = 0;
            int durum = 0;

            foreach (var item in db.Teams)
            {
                if (cboIcSaha.Text == item.TeamName)
                {
                    a = item.Id;
                }
                else if (cboDisSaha.Text == item.TeamName)
                {
                    b = item.Id;
                }
            }
            if (nudIcSahaScore.Value == nudDisSahaScore.Value)
            {
                durum = 0;
            }
            else if (nudIcSahaScore.Value > nudDisSahaScore.Value)
            {
                durum = 1;
            }
            else if (nudIcSahaScore.Value < nudDisSahaScore.Value)
            {
                durum = 2;
            }
            Match match = new Match();

            match.MatchTime  = dtpTarih.Value;
            match.IcSahaId   = a;
            match.IcSahalar  = IcSaha;
            match.DısSahaId  = b;
            match.DısSahalar = DisSaha;
            match.Score1     = (int)nudIcSahaScore.Value;
            match.Score2     = (int)nudDisSahaScore.Value;
            match.Durumlar   = durum;

            db.Matchs.Add(match);
            db.SaveChanges();
            VerileriYukle();
            this.Close();
        }
Esempio n. 13
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var colorName = txtColorName.Text.UpperCaseFirst().Trim();

            if (colorName == "")
            {
                MessageBox.Show("Please fill all fields correctly.");
                return;
            }
            if (btnAdd.Text == "Save")
            {
                var selectedColor = (Models.Color)lstColors.SelectedItem;
                selectedColor.ColorName = txtColorName.Text.UpperCaseFirst();
                selectedColor.Red       = Convert.ToByte(lblRed.Text);
                selectedColor.Green     = Convert.ToByte(lblGreen.Text);
                selectedColor.Blue      = Convert.ToByte(lblBlue.Text);
                btnAdd.Text             = "Add";
                btnAdd.IconChar         = FontAwesome.Sharp.IconChar.Plus;
                btnAdd.BackColor        = System.Drawing.Color.OrangeRed;
                db.SaveChanges();
                ListColors();
                ResetColorsForm();
                btnDelete.Show();
                btnEdit.Show();
                return;
            }
            var color = new Models.Color
            {
                ColorName = txtColorName.Text.UpperCaseFirst(),
                Red       = Convert.ToByte(lblRed.Text),
                Green     = Convert.ToByte(lblGreen.Text),
                Blue      = Convert.ToByte(lblBlue.Text)
            };

            if (db.Colors.Any(x => x.ColorName == color.ColorName))
            {
                MessageBox.Show("Please enter different color name.");
                return;
            }
            db.Colors.Add(color);
            db.SaveChanges();
            ListColors();
            ResetColorsForm();
        }
Esempio n. 14
0
 private void btnTransfer_Click(object sender, EventArgs e)
 {
     if (lstTeamsPlayers.SelectedIndex >= 0)
     {
         Player player = lstTeamsPlayers.SelectedItem as Player;
         player.Team = null;
         db.SaveChanges();
         lstTeamsPlayers.DataSource = team.Players.ToList();
         lstIdlePlayers.DataSource  = db.Players.Where(x => x.Team == null).ToList();
     }
     else if (lstIdlePlayers.SelectedIndex >= 0)
     {
         Player player = lstIdlePlayers.SelectedItem as Player;
         player.Team = team;
         db.SaveChanges();
         lstTeamsPlayers.DataSource = team.Players.ToList();
         lstIdlePlayers.DataSource  = db.Players.Where(x => x.Team == null).ToList();
     }
 }
Esempio n. 15
0
        private void btnEkle_Click(object sender, EventArgs e)
        {
            if (cboPlayerTakım.SelectedIndex < 0 || txtPlayer.Text == "")
            {
                MessageBox.Show("Lütfen Tüm Alanları Doldurunuz");
                return;
            }
            string playerName = txtPlayer.Text.Trim();
            var    team       = cboPlayerTakım.SelectedIndex + 1;

            db.Players.Add(new Moldels.Player()
            {
                PlayerName = playerName,
                TeamId     = team,
            });
            db.SaveChanges();
            KisileriListele();
            FormuResetle();
        }
Esempio n. 16
0
        private void btnEkle_Click(object sender, EventArgs e)
        {
            string colorName = txtRenkAdı.Text.Trim();

            if (colorName == "")
            {
                MessageBox.Show("Lütfen Oluşturulacak Renk Adını Giriniz");
                return;
            }

            db.Colors.Add(new Moldels.Color()
            {
                ColorName = txtRenkAdı.Text.Trim(),
                Red       = (byte)sbRed.Value,
                Green     = (byte)sbGreen.Value,
                Blue      = (byte)sbBlue.Value,
            });;
            db.SaveChanges();
            RenkleriListele();
            FormuResetle();
        }
Esempio n. 17
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Color newColor = new Color();

            newColor.ColorName = txtColorName.Text.Trim();
            if (txtColorName.Text == "")
            {
                MessageBox.Show("Bu aşamada bir renk ismi belirtmek zorundasınız");
                return;
            }
            if (db.Colors.Any(x => x.ColorName == newColor.ColorName))
            {
                DialogResult dr = new DialogResult();
                dr = MessageBox.Show("Bu isimde Renk mevcut,yeni renk mi oluşturmak istiyorsunuz", "Yeni Renk Oluşturma", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dr == DialogResult.Yes)
                {
                    lstAvailableColors.SelectedIndex = -1;
                    txtColorName.Text = "";
                    tbBlue.Value      = 0;
                    tbGreen.Value     = 0;
                    tbRed.Value       = 0;
                    txtColorName.Focus();
                    panelColor.BackColor = System.Drawing.Color.Black;
                    return;
                }
                else
                {
                    return;
                }
            }
            newColor.Red   = tbRed.Value;
            newColor.Green = tbGreen.Value;
            newColor.Blue  = tbBlue.Value;
            db.Colors.Add(newColor);
            db.SaveChanges();
            lstAvailableColors.DataSource    = db.Colors.ToList();
            lstAvailableColors.SelectedIndex = lstAvailableColors.Items.Count - 1;
        }
Esempio n. 18
0
        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            if (cboNewTeam1.SelectedIndex == 0 || cboNewTeam2.SelectedIndex == 0)
            {
                MessageBox.Show("Please pick a team.");
                return;
            }
            if ((Team)cboNewTeam1.SelectedItem == (Team)cboNewTeam2.SelectedItem)
            {
                MessageBox.Show("You chose the same teams!");
                return;
            }
            var      team1     = (Team)cboNewTeam1.SelectedItem;
            var      team2     = (Team)cboNewTeam2.SelectedItem;
            DateTime?matchDate = dtpNewDate.Value;

            if (team1.Team1Matches.ToList().Any(x => x.MatchTime.Value.ToShortDateString() == matchDate.Value.ToShortDateString()) || team1.Team2Matches.ToList().Any(x => x.MatchTime.Value.ToShortDateString() == matchDate.Value.ToShortDateString()))
            {
                MessageBox.Show($"{team1} has already a match on this date!");
                return;
            }
            if (team2.Team1Matches.ToList().Any(x => x.MatchTime.Value.ToShortDateString() == matchDate.Value.ToShortDateString()) || team2.Team2Matches.ToList().Any(x => x.MatchTime.Value.ToShortDateString() == matchDate.Value.ToShortDateString()))
            {
                MessageBox.Show($"{team2} has already a match on this date!");
                return;
            }

            db.Matches.Add(new Match()
            {
                Team1     = team1,
                Team2     = team2,
                MatchTime = matchDate
            });
            db.SaveChanges();
            ListTeamsEditMatch();
            WhenMakeChange(EventArgs.Empty);
            ResetForm();
        }
        private void btnTakımOlustur_Click(object sender, EventArgs e)
        {
            if (RenkAdi1 == "")
            {
                RenkAdi1 = "bos";
            }

            if (RenkAdi2 == "")
            {
                RenkAdi2 = "bos";
            }

            if (RenkAdi3 == "")
            {
                RenkAdi3 = "bos";
            }

            if (RenkAdi4 == "")
            {
                RenkAdi4 = "bos";
            }
            db.Teams.Add(new Team()
            {
                TeamName = txtTakımAd.Text.Trim(),
                RenkAdi1 = RenkAdi1,
                RenkAdi2 = RenkAdi2,
                RenkAdi3 = RenkAdi3,
                RenkAdi4 = RenkAdi4
            });
            db.SaveChanges();
            TakimleriListele();
            lblRenk1.BackColor = System.Drawing.Color.Black;
            lblRenk2.BackColor = System.Drawing.Color.Black;
            lblRenk3.BackColor = System.Drawing.Color.Black;
            lblRenk4.BackColor = System.Drawing.Color.Black;
        }
Esempio n. 20
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Match match     = db.Matches.FirstOrDefault(x => x.Id == id);
            Team  homeTeam  = cboHomeTeam.SelectedItem as Team;
            Team  guestTeam = cboGuestTeam.SelectedItem as Team;

            if (homeTeam.TeamName.Contains("closed") || guestTeam.TeamName.Contains("closed"))
            {
                MessageBox.Show("Kapanmış takımlara maç ayarlanamaz");
                return;
            }
            if (homeTeam == guestTeam)
            {
                MessageBox.Show("Takımlar aynı girilemez");
                return;
            }
            match.HomeTeam  = homeTeam;
            match.GuestTeam = guestTeam;
            DateTime nowDateTime = DateTime.Now;

            if (match.MatchTime != null)
            {
                DateTime matchDateTime = dtMatchTime.Value;

                if (DateTime.Compare(matchDateTime, nowDateTime) < 0)
                {
                    match.HomePoints  = (int)nudScoreHomeTeam.Value;
                    match.GuestPoints = (int)nudScoreGuestTeam.Value;
                    if (cbDraw.Checked == true)
                    {
                        match.Result = MatchResult.Draw;
                    }
                    else if (cbTeam1Won.Checked == true)
                    {
                        match.Result = MatchResult.HomeTeamWon;
                    }
                    else if (cbTeam2Won.Checked == true)
                    {
                        match.Result = MatchResult.GuestTeamWon;
                    }
                }
            }
            db.SaveChanges();

            WhenTheCurrentMatchChanges(EventArgs.Empty);
            Close();
        }
        private void btnCreateMatch_Click(object sender, EventArgs e)
        {
            DateTime nowDateTime = new DateTime();

            nowDateTime = DateTime.Now;
            Team homeTeam  = cboHomeTeam.SelectedItem as Team;
            Team guestTeam = cboGuestTeam.SelectedItem as Team;

            if (homeTeam.TeamName.Contains("closed") || guestTeam.TeamName.Contains("closed"))
            {
                MessageBox.Show("Kapanmış takımlara maç ayarlanamaz");
                return;
            }
            Match newMatch = new Match();

            if (homeTeam == guestTeam)
            {
                MessageBox.Show("Takımlar aynı girilemez");
                return;
            }
            DateTime matchTime = dtMatchTime.Value;

            newMatch.HomeTeam  = homeTeam;
            newMatch.GuestTeam = guestTeam;
            newMatch.MatchTime = matchTime;
            if (DateTime.Compare(matchTime, nowDateTime) < 0)
            {
                newMatch.HomePoints  = (int)nudScoreHomeTeam.Value;
                newMatch.GuestPoints = (int)nudScoreGuestTeam.Value;
                if (cbDraw.Checked == true)
                {
                    newMatch.Result = MatchResult.Draw;
                }
                else if (cbTeam1Won.Checked == true)
                {
                    newMatch.Result = MatchResult.HomeTeamWon;
                }
                else if (cbTeam2Won.Checked == true)
                {
                    newMatch.Result = MatchResult.GuestTeamWon;
                }
            }
            db.Matches.Add(newMatch);
            db.SaveChanges();
            WhenTheMatchIsAdded(EventArgs.Empty);
        }
Esempio n. 22
0
        private void btnSeciliyiSil_Click(object sender, EventArgs e)
        {
            int id  = (int)dgvMaclar.CurrentRow.Cells[0].Value;
            var sil = db.Veriler.Where(x => x.Id == id).FirstOrDefault();

            if (dgvMaclar.Rows.Count > -1)
            {
                DialogResult dialog = new DialogResult();
                dialog = MessageBox.Show("Seçilen Veri Silinsin Mi?", "Emin Misiniz.", MessageBoxButtons.YesNo);
                if (dialog == DialogResult.Yes)
                {
                    db.Veriler.Remove(sil);
                    db.SaveChanges();
                }
            }

            TakimlariListele();
        }
Esempio n. 23
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dgvMatch.Rows.Count < 1)
            {
                MessageBox.Show("There is no match for edit");
                return;
            }
            chkScores.Text = "CancelledMatch";
            btnAdd.Enabled = false;
            gboItems.Text  = "EditYourMatch";
            int   id    = (int)dgvMatch.SelectedRows[0].Cells[0].Value;
            Match match = db.Matches.Find(id);

            if (btnEdit.Text == "Save ▼")
            {
                int index = dgvMatch.SelectedRows[0].Index;
                match.HomeTeamId  = (int)cboTeam1.SelectedValue;
                match.GuestTeamId = (int)cboTeam2.SelectedValue;
                if (chkScores.Checked)
                {
                    match.Score1 = null;
                    match.Score2 = null;
                    match.Result = (Result)0;
                }
                else
                {
                    match.Score1 = (int)nudScore1.Value;
                    match.Score2 = (int)nudScore2.Value;
                    match.Result = match.Score1 > match.Score2 ? (Result)2 : (Result)3;
                    if (match.Score1 == match.Score2)
                    {
                        match.Result = (Result)1;
                    }
                }
                match.MatchTime = dtpMatchTime.Value;
                if (match.HomeTeamId == match.GuestTeamId)
                {
                    MessageBox.Show("That compare not allowed. Check the teams!");
                    return;
                }
                btnAdd.Enabled = true;
                gboItems.Text  = "EditYourMatch";
                ButtonLocationVisiblePositive();
                db.SaveChanges();
                LoadMatches();
                dgvMatch.ClearSelection();
                btnEdit.Text = "Edit ✎";
                dgvMatch.Rows[index].Selected = true;
                return;
            }
            ButtonLocationVisibleNegative();
            LoadTeams();
            if (match.Score1 == null || match.Score2 == null)
            {
                nudScore1.Value = 0;
                nudScore2.Value = 0;
            }
            else
            {
                nudScore1.Value = (int)match.Score1;
                nudScore2.Value = (int)match.Score2;
            }
            cboTeam1.Text      = dgvMatch.SelectedRows[0].Cells[1].Value.ToString();
            cboTeam2.Text      = dgvMatch.SelectedRows[0].Cells[2].Value.ToString();
            dtpMatchTime.Value = (DateTime)dgvMatch.SelectedRows[0].Cells[4].Value;
            btnEdit.Text       = "Save ▼";
        }
Esempio n. 24
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            List <Models.Color> colors = new List <Models.Color>();
            var    color1   = (Models.Color)cboColor1.SelectedItem;
            var    color2   = (Models.Color)cboColor2.SelectedItem;
            string teamName = txtTeamName.Text.UpperCaseFirst().Trim();

            if (btnAdd.Text == "Save")
            {
                if (color1 == null || color2 == null)
                {
                    MessageBox.Show("Have to choose two colors.");
                    return;
                }
                colors.Add(color1);
                colors.Add(color2);
                var selectedTeam = (Team)dgvTeams.SelectedRows[0].DataBoundItem;
                selectedTeam.Colors = colors;
                if (dgvTeams.Rows.Count < 1)
                {
                    MessageBox.Show("There is no team for edit");
                    return;
                }
                int  id   = (int)dgvTeams.SelectedRows[0].Cells[0].Value;
                Team team = db.Teams.Find(id);
                if (teamName == "")
                {
                    MessageBox.Show("Wrong Name");
                    return;
                }

                int index = dgvTeams.SelectedRows[0].Index;
                if (teamName != team.TeamName)
                {
                    if (db.Teams.Any(x => x.TeamName.Replace(" ", "") == txtTeamName.Text.Replace(" ", "")))
                    {
                        MessageBox.Show("This team already in a list.");
                        return;
                    }
                }
                team.TeamName = teamName;
                db.SaveChanges();
                LoadTeams();
                dgvTeams.ClearSelection();
                dgvTeams.Rows[index].Selected = true;
                txtTeamName.Clear();
                WhenMakeChange(EventArgs.Empty);
                btnAdd.Text = "Add";
                return;
            }
            if (color1 == null || color2 == null)
            {
                MessageBox.Show("Have to choose two colors.");
                return;
            }
            if (teamName == "")
            {
                MessageBox.Show("Please write a correct team name");
                return;
            }
            if (db.Teams.Any(x => x.TeamName.Replace(" ", "") == teamName.Replace(" ", "")))
            {
                MessageBox.Show("This team already in a list.");
                return;
            }
            colors.Add(color1);
            colors.Add(color2);
            db.Teams.Add(new Team()
            {
                TeamName = teamName, Colors = colors
            });
            db.SaveChanges();
            LoadTeams();
            txtTeamName.Clear();
            WhenMakeChange(EventArgs.Empty);
        }