Exemple #1
0
        void RefreshSellTimeInfo()
        {
            pictureBox2.Image = Properties.Resources.tick_16;
            BackColor         = SystemColors.Window;
            ForeColor         = SystemColors.WindowText;

            var code = _query.FromStationCode;
            var date = _query.DepartureDate;

            if (string.IsNullOrEmpty(code) || ParamData.SellTimeMap == null)
            {
                desc.Text = "欢迎使用<b>订票助手.NET</b>";
                return;
            }

            //是否是学生票区间?
            DateTime?beginSellDay = null;

            if (_query.QueryStudentTicket)
            {
                if (!ParamData.IsDateInStudentRange(date))
                {
                    BackColor         = Color.FromArgb(0xFF, 0xD6, 0xCF);
                    ForeColor         = Color.DarkRed;
                    desc.Text         = "<font color='DarkRed'>您所选的日期不在学生票的区间中,不可购买学生票</font>";
                    pictureBox2.Image = Properties.Resources.warning_16;

                    return;
                }
                beginSellDay = ParamData.GetBeginSellTime(date, _query.QueryStudentTicket);

                if (beginSellDay.Value <= DateTime.Now.Date)
                {
                    beginSellDay = null;
                }
            }
            else
            {
                var startDate = ParamData.GetBeginSellTime(date);

                if (startDate > DateTime.Now)
                {
                    beginSellDay = startDate;
                }
            }

            pictureBox2.Image = Properties.Resources.clock_16;
            desc.Text         = "<i>正在检索站点起售信息...</i>";
            var task = Task.Factory.StartNew(() => SameCityStationResolveWorker.Instance.Resolve(code));

            task.ContinueWith(_ => LoadSellTimes(beginSellDay, _.Result));
        }