Exemple #1
0
 private void AddPenalty(object sender, RoutedEventArgs e)
 {
     try
     {
         Button b = e.Source as Button;
         if (b.Name == "btnAddHomePenalty")
         {
             int     index = homepenalties.Count;
             Penalty p     = new Penalty()
             {
                 Rangaistusnro = ++index,
                 Aika          = currentTime
             };
             homepenalties.Add(p);
             dgHomePenalties.ItemsSource = null;
             dgHomePenalties.ItemsSource = homepenalties;
         }
         else if (b.Name == "btnAddAwayPenalty")
         {
             int     index = awaypenalties.Count;
             Penalty p     = new Penalty()
             {
                 Rangaistusnro = ++index,
                 Aika          = currentTime
             };
             awaypenalties.Add(p);
             dgAwayPenalties.ItemsSource = null;
             dgAwayPenalties.ItemsSource = awaypenalties;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tapahtui virhe: " + ex.ToString());
     }
 }
Exemple #2
0
        public static List <Penalty> GetPenaltiesFromDB(int gameID, int teamID)
        {
            List <Penalty> penalties = new List <Penalty>();
            string         str       = $"Rangaistus WHERE Ottelu = {gameID} AND Joukkue = {teamID} ORDER BY RangaistusID";
            DataTable      dt        = DBSalibandytournament.GetViewDB(str);
            int            index     = 0;

            foreach (DataRow item in dt.Rows)
            {
                Penalty p = new Penalty()
                {
                    Rangaistusnro = ++index,
                    RangaistusID  = int.Parse(item[0].ToString()),
                    Aika          = item[1].ToString(),
                    Kesto         = int.Parse(item[2].ToString()),
                    Syy           = item[3].ToString(),
                    Henkilo       = int.Parse(item[4].ToString()),
                    Joukkue       = int.Parse(item[5].ToString()),
                    Ottelu        = int.Parse(item[6].ToString())
                };
                penalties.Add(p);
            }
            return(penalties);
        }