コード例 #1
0
        public void GetTickCount()
        {
            // 获取剩余票数
            string s = TickCute.GetRegeditInfo(MachineCode);

            TickCount = TickCute.GetUseTick(MachineCode, s, false);
            SetTickText();
            btnDuihuan.Enabled = true;
            btn_luntan.Enabled = true;
            if (TickCount > 0)
            {
                //登录ToolStripMenuItem.Enabled = true;
                int hour = DateTime.Now.Hour;
                if (hour > 7 && hour < 23)
                {
                    登录ToolStripMenuItem.Enabled = true;
                    labUserInfo.ForeColor       = Color.Green;
                    labUserInfo.Text            = "请登录!";
                }
                else
                {
                    登录ToolStripMenuItem.Enabled = true;
                    labUserInfo.ForeColor       = Color.Red;
                    labUserInfo.Text            = "晚上23点后到凌晨7点前\n是12306系统维护时间,将无法购票!";
                }
            }
            else
            {
                labUserInfo.ForeColor = Color.Red;
                labUserInfo.Text      = "剩余购票卷数量不足,请购买!";
            }
        }
コード例 #2
0
ファイル: FrmDuiHuan.cs プロジェクト: yinsinnet/yisintick
        private void button2_Click(object sender, EventArgs e)
        {
            string code = textBox1.Text;

            if (String.IsNullOrEmpty(code))
            {
                label1.Text = "请输入兑换码!";
            }
            else
            {
                // 先判断是否存在
                List <String> list = TickCute.readHistoryStr();
                String        key = "", codeKey = "";// MyEncrypt.EncryptA(code);
                int           count = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    key     = list[i];
                    codeKey = MyEncrypt.DecryptB(key);
                    if (code.Equals(codeKey))
                    {
                        count++;
                    }
                }
                if (count == 0)
                {
                    count = TickCute.GetUseTick(Form1.MachineCode, code, true);
                    if (count <= 0 && count > 50)
                    {
                        label1.Text = "您输入的兑换码无效!";
                    }
                    else
                    {
                        TickCute.ChangeTickCount(count);
                        TickCute.WriteHistoryToFile(code);
                        this.Dispose();
                    }
                }
                else
                {
                    label1.Text = "您输入的兑换码无效!";
                }
            }
        }