コード例 #1
0
ファイル: MainForm.cs プロジェクト: Dzoks/Quizzy
        private void seasonTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            seasonTreeView.SelectedNode = e.Node;

            if (e.X <= 20)
            {
                return;
            }
            if (e.Node.IsExpanded)
            {
                e.Node.Collapse();
            }
            else
            {
                e.Node.Expand();
            }

            if (e.Node.Level == 1)
            {
                selectedRound = e.Node.Tag as round;
                lblPlaces.Hide();
                ShowRound();
            }
            else
            {
                selectedSeason = e.Node.Tag as season;
                lblPlaces.Show();
                ShowSeason();
            }
        }
コード例 #2
0
        //common lib
        public int Insert(season entity)
        {
            try
            {
                //Thêm mùa giải
                if (entity.start_date_at >= entity.end_date_at)
                {
                    return(-2);
                }
                db.seasons.Add(entity);
                db.SaveChanges();

                //Cập nhật số vòng đấu trong mua giải tương ứng với số đội tham gia
                int num_round   = (int)(entity.number_club * (entity.number_club - 1) / (entity.number_club / 2));
                var model_round = db.rounds.Where(x => x.tournament_id == entity.tournamnet_id).OrderBy(x => x.display_order).Take(num_round).ToList();
                foreach (var item in model_round)
                {
                    Insert_SeasonRound(entity.id, item.id);
                }

                return(1);
            }
            catch (Exception)
            {
                return(-1);
            }
        }
コード例 #3
0
        /*-------------------------------------------------------------------------
         * 更新
         * 季節が変わったときtrueを返す
         * ---------------------------------------------------------------------------*/
        public bool UpdateSeason()
        {
            bool     ret = false;
            DateTime now = DateTime.Now;

            long ticks = now.Ticks - m_base_season_start.Ticks;
            long t     = ticks / TimeSpan.FromHours(9).Ticks;

            if (t < 0)
            {
                t--;
            }
            // 偶数なら夏、奇数なら冬
            season now_s = ((t & 1) == 0)? season.summer: season.winter;

            if (now_s != m_now_season)
            {
                ret = true;                                     // 季節が変わった
            }
            m_now_season = now_s;                               // 今回得たの季節

            // 今回の変動開始日時
            m_now_season_start = m_base_season_start.AddHours((t + 0) * 9);
//			Debug.WriteLine(TojbbsDateTimeString(m_now_season_start));

            // 次回の変動開始日時
            m_next_season_start = m_base_season_start.AddHours((t + 1) * 9);
//			Debug.WriteLine(TojbbsDateTimeString(m_next_season_start));

            // 季節が変わったかどうかを返す
            return(ret);
        }
コード例 #4
0
        /*-------------------------------------------------------------------------
         *
         * ---------------------------------------------------------------------------*/
        public gvo_season()
        {
            // 夏の基準となる日時
            // 未来でも過去でもよい
            m_base_season_start = new DateTime(2010, 3, 2, 13, 30, 0);                  // 夏
            m_now_season        = season.MAX;

            // 更新
            UpdateSeason();
        }
コード例 #5
0
        /*-------------------------------------------------------------------------
         * 季節を文字列で返す
         * ---------------------------------------------------------------------------*/
        public static string ToSeasonString(season s)
        {
            switch (s)
            {
            case season.summer:             return("夏");

            case season.winter:             return("冬");
            }
            return("不明");
        }
コード例 #6
0
        public long GetCurrentSeasonId(long leagueId, DateTime date)
        {
            season _season = null;

            using (var context = new escorcenterdbEntities())
            {
                _season = (from s in context.seasons where s.league == leagueId && s.dateFrom <= date && s.dateTo >= date && s.enabled == true select s).FirstOrDefault <season>();
            }
            if (_season == null)
            {
                return(0);
            }
            return(_season.id);
        }
コード例 #7
0
        public IHttpActionResult CreateSeason([FromBody] SeasonDTO _season)
        {
            season s = new season()
            {
                description = _season.Description, league = (int)_season.League, dateFrom = DateTime.Now, dateTo = new DateTime(2016, 04, 29), title = _season.Title
            };

            using (var context = new escorcenterdbEntities())
            {
                context.seasons.Add(s);
                context.SaveChanges();
            }
            return(Ok(s));
        }
コード例 #8
0
        public ActionResult Details(string name, int?year)
        {
            //initialize the year to 2016.
            year = year ?? 2016;

            season season = db.seasons.FirstOrDefault(s => s.tournament.name == name && s.year == year);

            if (season == null)
            {
                return(HttpNotFound());
            }

            ViewBag.years = db.seasons.Select(s => s.year).Distinct().ToList();

            return(View(season));
        }
コード例 #9
0
 public bool Update(season entity)
 {
     try
     {
         var info = db.seasons.Find(entity.id);
         info.name          = entity.name;
         info.start_date_at = entity.start_date_at;
         info.end_date_at   = entity.end_date_at;
         info.number_club   = entity.number_club;
         info.display_order = entity.display_order;
         info.is_active     = entity.is_active;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #10
0
        public IHttpActionResult GetPastMatchesByLeagueId(long leagueId)
        {
            DateTime now      = DateTime.Now;
            long     seasonId = GetCurrentSeasonId(leagueId, now);

            if (seasonId < 0)
            {
                return(Ok());
            }

            season         _season = null;
            List <WeekDTO> weeks   = new List <WeekDTO>();

            using (var context = new escorcenterdbEntities())
            {
                week[] _weeks = (from w in context.weeks where w.enabled == true && w.season == seasonId && w.dateFrom <= now select w).OrderByDescending(w => w.dateFrom).ToArray <week>();
                foreach (week _week in _weeks)
                {
                    WeekDTO week = GetPastMatchesByWeekId(_week.id, now);
                    if (week != null)
                    {
                        weeks.Add(week);
                    }
                }
                _season = (from s in context.seasons where s.id == seasonId select s).FirstOrDefault <season>();
            }
            if (_season == null)
            {
                return(Ok());
            }
            SeasonDTO season = new SeasonDTO
            {
                Title       = _season.title,
                DateFrom    = _season.dateFrom.ToString(),
                DateTo      = _season.dateTo.ToString(),
                Description = _season.description,
                Id          = _season.id,
                League      = _season.league
            };

            season.Weeks.AddRange(weeks);
            return(Ok(season));
        }
コード例 #11
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (database.seasons.FirstOrDefault(s => s.deleted == 0 && s.name == fldSeason.Text) != null)
     {
         new ErrorPopup("Naziv sezone mora biti jedinstven!").ShowDialog(this);
     }
     else
     {
         Season = new season()
         {
             name    = fldSeason.Text.Trim(),
             deleted = 0
         };
         database.seasons.Add(Season);
         database.SaveChanges();
         Success = true;
         Close();
     }
 }
コード例 #12
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            {
                using (DataClasses1DataContext db = new DataClasses1DataContext())
                {
                    try
                    {
                        var goal = new season();
                        goal.season_id  = Convert.ToInt32(TextBox1.Text);
                        goal.date_start = Convert.ToDateTime(TextBox3.Text);
                        goal.date_end   = Convert.ToDateTime(TextBox3.Text);

                        if (CheckBox1.Checked)
                        {
                            goal.category = 'P';
                        }
                        else if (CheckBox2.Checked)
                        {
                            goal.category = '1';
                        }
                        else if (CheckBox3.Checked)
                        {
                            goal.category = '2';
                        }

                        else if (CheckBox4.Checked)
                        {
                            goal.category = '3';
                        }
                        db.seasons.InsertOnSubmit(goal);
                        db.SubmitChanges();

                        BindGridView();
                    }

                    catch (System.Exception excep)
                    {
                        ch_();
                    }
                }
            }
        }
コード例 #13
0
ファイル: GameTime.cs プロジェクト: MaxSimon95/gothelapfel
 void UpdateSeason()
 {
     if (daysSinceYearStart < seasonLengthSpring)
     {
         currentSeason = season.SPRING;
     }
     if ((daysSinceYearStart >= seasonLengthSpring) && (daysSinceYearStart < seasonLengthSpring + seasonLengthSummer))
     {
         currentSeason = season.SUMMER;
     }
     if ((daysSinceYearStart >= seasonLengthSpring + seasonLengthSummer) && (daysSinceYearStart < seasonLengthSpring + seasonLengthSummer + seasonLengthAutumn))
     {
         currentSeason = season.AUTUMN;
     }
     if (daysSinceYearStart >= seasonLengthSpring + seasonLengthSummer + seasonLengthAutumn)
     {
         currentSeason = season.WINTER;
         Debug.Log(currentSeason);
     }
 }
コード例 #14
0
        public ActionResult Edit(season season)
        {
            if (ModelState.IsValid)
            {
                var dao = new season_dao();

                var result = dao.Update(season);
                if (result)
                {
                    SetAlert(StaticResources.Resources.Pub_UpdateSucess, "success");
                    return(RedirectToAction("Index", "Season"));
                }
                else
                {
                    ModelState.AddModelError("", StaticResources.Resources.UpdateSeasonFailed);
                }
            }
            SetListTournament(season.tournamnet_id);
            return(View());
        }
コード例 #15
0
        /*-------------------------------------------------------------------------
         * 更新
         * ---------------------------------------------------------------------------*/
        public void UpdateSeason()
        {
            DateTime now = DateTime.Now;

            long ticks = now.Ticks - m_base_season_start.Ticks;
            long t     = ticks / TimeSpan.FromHours(9).Ticks;

            if (t < 0)
            {
                t--;
            }
            // 偶数なら夏、基数なら冬
            m_now_season = ((t & 1) == 0)? season.summer: season.winter;

            // 今回の変動開始日時
            m_now_season_start = m_base_season_start.AddHours((t + 0) * 9);
//			Debug.WriteLine(TojbbsDateTimeString(m_now_season_start));

            // 次回の変動開始日時
            m_next_season_start = m_base_season_start.AddHours((t + 1) * 9);
//			Debug.WriteLine(TojbbsDateTimeString(m_next_season_start));
        }
コード例 #16
0
        public ActionResult Create(season season)
        {
            if (ModelState.IsValid)
            {
                var dao = new season_dao();

                int result = dao.Insert(season);
                if (result == 1)
                {
                    SetAlert(StaticResources.Resources.Pub_InsertSuccess, "success");
                    return(RedirectToAction("Index", "Season"));
                }
                else if (result == -2)
                {
                    ModelState.AddModelError("", "Ngày bắt đầu phải nhỏ hơn ngày kết thúcss");
                }
                else if (result == -1)
                {
                    ModelState.AddModelError("", StaticResources.Resources.InsertSeasonFailed);
                }
            }
            SetListTournament(season.tournamnet_id);
            return(View());
        }
コード例 #17
0
 public ActionResult <season> Postseason([FromBody] season c)
 {
     _context.seasons.Add(c);
     _context.SaveChanges();
     return(Ok(c));
 }
コード例 #18
0
        public IHttpActionResult GetResultTable(int leagueId)
        {
            long seasonId = GetCurrentSeasonId(leagueId, DateTime.Now);

            if (seasonId == 0)
            {
                return(Ok());
            }

            scoretableview[]           _scoreTable = null;
            season                     _season     = null;
            List <ScoreTableResultDTO> scoreTable  = new List <ScoreTableResultDTO>();

            using (var context = new escorcenterdbEntities())
            {
                _scoreTable = (from st in context.scoretableviews where st.season == seasonId select st).OrderBy(st => st.GamesWon.Value * 3 + st.GamesDrawn.Value * 1).ToArray <scoretableview>();
                _season     = (from s in context.seasons where s.id == seasonId && s.enabled == true select s).FirstOrDefault <season>();

                if (_scoreTable == null || _season == null)
                {
                    return(NotFound());
                }

                foreach (scoretableview st in _scoreTable)
                {
                    team _team = (from t in context.teams where t.Id == st.team select t).FirstOrDefault <team>();

                    String leagueName          = getLeagueNameById(_team.League);
                    ScoreTableResultDTO result = new ScoreTableResultDTO
                    {
                        Team        = AutoMapper.Mapper.Map <team, TeamDTO>(_team),
                        GamesDrawn  = st.GamesDrawn.Value,
                        GamesLost   = st.GamesLost.Value,
                        GamesPlayed = st.GamesPlayed.Value,
                        GamesWined  = st.GamesWon.Value,
                        //Cambiar esto a hacerlo dinamico, no solo para el fut
                        Points          = st.GamesWon.Value * 3 + st.GamesDrawn.Value * 1,
                        ScoreAgainst    = (long)st.ScoreAgainst.Value,
                        ScoreDifference = (long)st.ScoreDifference.Value,
                        ScoreFavor      = (long)st.ScoreFavor.Value,
                        League          = leagueName
                    };

                    scoreTable.Add(result);
                }
            }
            if (_season == null)
            {
                return(Ok());
            }

            scoreTable.OrderBy(r => r.Points);

            SeasonDTO season = new SeasonDTO
            {
                DateFrom    = _season.dateFrom.ToString(),
                DateTo      = _season.dateTo.ToString(),
                Description = _season.description,
                Id          = _season.id,
                League      = _season.league,
                Title       = _season.title
            };

            season.ScoreTableResult.AddRange(scoreTable);
            return(Ok(season));
        }