Пример #1
0
        private void ShowData(string strSql)
        {
            string         strConn = ConfigurationSettings.AppSettings["strConn"];
            SqlConnection  SqlConn = new SqlConnection(strConn);
            SqlDataAdapter SqlCmd  = new SqlDataAdapter(strSql, SqlConn);
            DataSet        SqlDS   = new DataSet();

            SqlCmd.Fill(SqlDS, "UserScore");
            RowNum = DataGridGrade.CurrentPageIndex * DataGridGrade.PageSize + 1;

            string SortExpression = DataGridGrade.Attributes["SortExpression"];
            string SortDirection  = DataGridGrade.Attributes["SortDirection"];

            SqlDS.Tables["UserScore"].DefaultView.Sort = SortExpression + " " + SortDirection;

            DataGridGrade.DataSource = SqlDS.Tables["UserScore"].DefaultView;
            DataGridGrade.DataBind();
            for (int i = 0; i < DataGridGrade.Items.Count; i++)
            {
            }
            LabelRecord.Text      = Convert.ToString(SqlDS.Tables["UserScore"].Rows.Count);
            LabelCountPage.Text   = Convert.ToString(DataGridGrade.PageCount);
            LabelCurrentPage.Text = Convert.ToString(DataGridGrade.CurrentPageIndex + 1);
            SqlConn.Dispose();
        }
Пример #2
0
        private void ShowData(string strSql)
        {
            string         strConn = ConfigurationSettings.AppSettings["strConn"];
            SqlConnection  SqlConn = new SqlConnection(strConn);
            SqlDataAdapter SqlCmd  = new SqlDataAdapter(strSql, SqlConn);
            DataSet        SqlDS   = new DataSet();

            SqlCmd.Fill(SqlDS, "UserScore");
            RowNum = DataGridGrade.CurrentPageIndex * DataGridGrade.PageSize + 1;

            string SortExpression = DataGridGrade.Attributes["SortExpression"];
            string SortDirection  = DataGridGrade.Attributes["SortDirection"];

            SqlDS.Tables["UserScore"].DefaultView.Sort = SortExpression + " " + SortDirection;

            DataGridGrade.DataSource = SqlDS.Tables["UserScore"].DefaultView;
            DataGridGrade.DataBind();

            SqlDataAdapter SqlCmdTmp = null;
            DataSet        SqlDSTmp  = null;

            for (int i = 0; i < DataGridGrade.Items.Count; i++)
            {
                string m           = DataGridGrade.Items[i].Cells[3].Text.Trim();
                Label  labExamTime = (Label)DataGridGrade.Items[i].FindControl("labExamTime");
                labExamTime.Text = DataGridGrade.Items[i].Cells[10].Text.Trim() + "/<br>" + DataGridGrade.Items[i].Cells[11].Text.Trim();

                Label labTotalMark = (Label)DataGridGrade.Items[i].FindControl("labTotalMark");
                Label labPassState = (Label)DataGridGrade.Items[i].FindControl("labPassState");

                LinkButton LBOrder  = (LinkButton)DataGridGrade.Items[i].FindControl("LinkButOrder");
                LinkButton LBAnswer = (LinkButton)DataGridGrade.Items[i].FindControl("LinkButAnswer");
                LinkButton LBStatis = (LinkButton)DataGridGrade.Items[i].FindControl("LinkButStatis");

                if (DataGridGrade.Items[i].Cells[12].Text.Trim() == "0")
                {
                    labTotalMark.Text = "****";
                    labPassState.Text = "****";

                    LBOrder.Attributes.Add("onclick", "javascript:alert('该试卷不允许查看结果!');return false;");
                    LBAnswer.Attributes.Add("onclick", "javascript:alert('该试卷不允许查看结果!');return false;");
                    LBStatis.Attributes.Add("onclick", "javascript:alert('该试卷不允许查看结果!');return false;");
                }
                else
                {
                    //labTotalMark.Text=Convert.ToString(System.Math.Round(Convert.ToDouble(labTotalMark.Text),1));
                    //labPassState.Text=labPassState.Text;

                    //SqlCmdTmp=new SqlDataAdapter("select TotalMark from UserScore where PaperID="+DataGridGrade.Items[i].Cells[1].Text.Trim()+" and ExamState=1 order by TotalMark desc",SqlConn);
                    //SqlDSTmp=new DataSet();
                    //SqlCmdTmp.Fill(SqlDSTmp,"UserScore");
                    //for(int j=0;j<SqlDSTmp.Tables["UserScore"].Rows.Count;j++)
                    //{
                    //	if (System.Math.Round(Convert.ToDouble(SqlDSTmp.Tables["UserScore"].Rows[j]["TotalMark"]),1)==System.Math.Round(Convert.ToDouble(labTotalMark.Text),1))
                    //	{
                    //		intOrder=j+1;
                    //		break;
                    //	}
                    //}
                    intOrder = Convert.ToInt32(ObjFun.GetValues("select count(*) as count from UserScore where PaperID=" + DataGridGrade.Items[i].Cells[1].Text.Trim() + " and ExamState=1 and TotalMark>" + labTotalMark.Text + "", "count")) + 1;
                    LBOrder.Attributes.Add("onclick", "javascript:alert('您在本次" + labPaperType.Text + "中排名第" + intOrder.ToString() + "名!');return false;");
                    LBAnswer.Attributes.Add("onclick", "javascript:NewWin=window.open('ShowAnswer.aspx?UserScoreID=" + DataGridGrade.Items[i].Cells[0].Text.Trim() + "','ShowAnswer','titlebar=yes,menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=no,copyhistory=yes,top=0,left=0,width=screen.availWidth,height=screen.availHeight');NewWin.moveTo(0,0);NewWin.resizeTo(screen.availWidth,screen.availHeight);return false;");
                    LBStatis.Attributes.Add("onclick", "javascript:NewWin=window.open('ShowStatis.aspx?UserScoreID=" + DataGridGrade.Items[i].Cells[0].Text.Trim() + "','ShowStatis','titlebar=yes,menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=no,copyhistory=yes,top=0,left=0,width=screen.availWidth,height=screen.availHeight');NewWin.moveTo(0,0);NewWin.resizeTo(screen.availWidth,screen.availHeight);return false;");
                }
            }
            LabelRecord.Text      = Convert.ToString(SqlDS.Tables["UserScore"].Rows.Count);
            LabelCountPage.Text   = Convert.ToString(DataGridGrade.PageCount);
            LabelCurrentPage.Text = Convert.ToString(DataGridGrade.CurrentPageIndex + 1);
            SqlConn.Dispose();
        }