请牛人帮忙
我做个C/S模式的考试系统,用timer控件进行时间上的限制,可是每次都不执行这个代码,找了半天,百度也百了半天,还是不知道错在哪里,麻烦知道的说下这个timer控件的用法 或者一些实例代码
我做个C/S模式的考试系统,用timer控件进行时间上的限制,可是每次都不执行这个代码,找了半天,百度也百了半天,还是不知道错在哪里,麻烦知道的说下这个timer控件的用法 或者一些实例代码
解决方案 »
- 请问一下通过两点怎么画直线(非线段)呢.?
- 问一下简单的窗体显示隐藏的问题
- 求C#写个WinForm来查询网站搜索引擎收录数量的思路
- 统计销售额
- 请问高手一个关于数据库更新的问题
- 如何定时启动、停止IIS中某站点
- 本人的毕业设计中的两个问题,1.如何获取和设置richtext box 中光标的位置2.如何制作安装包.
- 请教方法——OA中的电子邮件功能模块
- 如何获取局域网中其他计算机的日志和进程信息,向思归、孟子等高手求救!在线求救中...
- 谁有真正的.net风格的菜单源码,带阴影的,薄边框的?
- 窗体间控件操作的问题,求实现方法!
- “MyFirstForm_Closing”的重载均与委托“System.EventHandler”不匹配
int minutes = 0;在 timer_tick() 编写
{
minutes++;
if (minutes >= 120) MessageBox.Show( "120分钟,考试时间到了" );
}
timer控件的Enabled属性缺省是设置为false的,lz看看是不是这个开关没有打开,呵呵。
{
this.timer1.Start();
timer1.Interval = 1000;
timer1.Enabled = true;
int sumsecond = 60;
int minute, second;
sumsecond--;
if (sumsecond > 0)
{
sumsecond--;
minute = sumsecond / 60;
second = sumsecond % 60;
// lblTime.Text = string.Format("{0:00}:{1:00}", minute, second);
} else
{ checkForm checkform = new checkForm();
int i = checkform.chkAnswer(); DialogResult result = MessageBox.Show("您的得分为" + i + "分" + "||" + "按确定退出考试系统"); string connStr = "server=yuanmh;Integrated Security=true;Data Source=(local);database=MySchool;";
string strinsert = "update Student set result=" + i + " where loginid='" + denglu.textBox_1.Text + "'and loginpwd='" + denglu.textBox_2.Text + "'";
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand(strinsert, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close(); if (result == DialogResult.OK)
{
Environment.Exit(0);
} }
}这是我的代码 麻烦各位看下 是不是哪里错掉了
private System.Timers.Timer testTimer;// 2. 在构造函数中给timer注册处理函数
testTimer.Elapsed += new System.Timers.ElapsedEventHandler(testTimer_Elapsed);// 3. 在开始考试的地方启动计时器
testTimer.start();// 4. 写计时器到时间后的处理代码
void testTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
// 这里写计时器到时间后的代码
}