日期:2014-05-17  浏览次数:20904 次

刚上班就提问的,大家就帮帮吧
是关于timer控件的,错误的地方就是不显示变化,只显示一个lable,对就显示lable
看代码
首先是timer的

C# code
 protected void Timer1_Tick(object sender, EventArgs e)
    {
        Paper ptime=new Paper();
        int paperid = Convert.ToInt32(Session["PaperID"].ToString());
        DataSet index = ptime.checktime(paperid);
        int index01 = int.Parse(index.ToString());
        index01--;

        //考试时间到了
        if (index01 == 0)
        {
            //设置Timer控件不可见
            this.Timer1.Enabled = false;
           
            Response.Redirect("login.aspx");
        }
        else
        {
            //显示考试剩余时间
            this.lbtime.Text = index01 / 60 + "分" + index01 % 60 + "秒将停止考试,请及时“提交”试卷,否则试卷作费成绩无效!";
        }

    }


然后是paper的checktime方法

C# code

    public DataSet checktime( int paperid)
        {
            DataBase DB = new DataBase();
            SqlParameter[] Params = new SqlParameter[1];
            Params[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid);
            return DB.GetDataSet("Proc_papertime", Params);
        }



然后是数据处理

C# code

public DataSet GetDataSet(string ProcName, SqlParameter[] Params)
        {
            Open();
            SqlCommand Cmd = CreateCommand(ProcName, Params);
            SqlDataAdapter adapter = new SqlDataAdapter(Cmd);
            DataSet dataset = new DataSet();
            adapter.Fill(dataset);
            Close();
            return dataset;
        }




最后是哪个存储过程

CREATE PROCEDURE [dbo].[Proc_papertime]
(@PaperID [int])
AS SELECT [dbo].[Paper].[PaperTime]
FROM [OnLineExam].[dbo].[Paper] 
where [PaperID]=@PaperID
GO


本来要实现一个倒计时的效果,可是什么都没有啊。。。。

------解决方案--------------------
DataSet index = ptime.checktime(paperid);
int index01 = int.Parse(index.ToString());

我咋看不懂呢,DataSet是数据集啊,
int index01 = int.Parse(index.ToString());

这个代码得到的是个什么值啊。