天天看點

關于簽到中簽到簽退的按鈕可用代碼

         int StuID = Convert.ToInt32(Session["StudentID"]);

        string s = "select top 1 * from AssignInfo    where StudentID='" + StuID + "'order by AssignID desc";

        SqlConnection ccc = new SqlConnection();

        ccc.ConnectionString = "server=.; Integrated Security=true; Initial Catalog=ManualAssign";

        SqlCommand cmm = new SqlCommand(s, ccc);

        ccc.Open();//調用資料庫

        SqlDataReader myr;

        myr = cmm.ExecuteReader();

        while (myr.Read())

        {

            if (myr["AssignTag"].ToString()=="True")

            {

                this.Button7.Enabled = false;

                this.Button8.Enabled = true;

            }

            else

            {

                this.Button8.Enabled = false;

                this.Button7.Enabled = true;

            }

        }