Esempio n. 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, "RubricInfo");
            RowNum = DataGridTest.CurrentPageIndex * DataGridTest.PageSize + 1;
            LinNum = 0;

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

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

            DataGridTest.DataSource = SqlDS.Tables["RubricInfo"].DefaultView;
            DataGridTest.DataBind();
            for (int i = 0; i < DataGridTest.Items.Count; i++)
            {
                Label labTestContent = (Label)DataGridTest.Items[i].FindControl("labTestContent");
                DataGridTest.Items[i].Cells[6].ToolTip = labTestContent.Text;
                labTestContent.Text = Server.HtmlEncode(labTestContent.Text);
                if (labTestContent.Text.Trim().Length > 20)
                {
                    labTestContent.Text = labTestContent.Text.Trim().Substring(0, 20) + "...";
                }
                //labTestContent.Text=ObjFun.getStr(labTestContent.Text.Trim(),20)+"...";

                LinkButton LBEditTest = (LinkButton)DataGridTest.Items[i].FindControl("LinkButEditTest");
                LinkButton LBDel      = (LinkButton)DataGridTest.Items[i].FindControl("LinkButDel");

                if ((myLoginID.Trim().ToUpper() == "ADMIN") || (myLoginID.Trim().ToUpper() == DataGridTest.Items[i].Cells[7].Text.Trim().ToUpper()))
                {
                    LBEditTest.Attributes.Add("onclick", "javascript:jscomNewOpenBySize('EditTest.aspx?RubricID=" + DataGridTest.Items[i].Cells[0].Text + "','EditTest',688,496); return false;");
                    LBDel.Attributes.Add("onclick", "javascript:{if(confirm('确定要删除选择试题吗?')==false) return false;}");
                }
                else
                {
                    LBEditTest.Attributes.Add("onclick", "javascript:alert('对不起,您没有此操作权限!');return false;");
                    LBDel.Attributes.Add("onclick", "javascript:alert('对不起,您没有此操作权限!');return false;");
                }
            }
            LabelRecord.Text      = Convert.ToString(SqlDS.Tables["RubricInfo"].Rows.Count);
            LabelCountPage.Text   = Convert.ToString(DataGridTest.PageCount);
            LabelCurrentPage.Text = Convert.ToString(DataGridTest.CurrentPageIndex + 1);
            SqlConn.Dispose();
        }
Esempio n. 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, "RubricInfo");

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

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

            DataGridTest.DataSource = SqlDS.Tables["RubricInfo"].DefaultView;
            DataGridTest.DataBind();
            for (int i = 0; i < DataGridTest.Items.Count; i++)
            {
                CheckBox chkCheckBoxSel = (CheckBox)DataGridTest.Items[i].FindControl("CheckBoxSel");
                string   strTmp         = ObjFun.GetValues("select RubricID from PaperTest where RubricID=" + DataGridTest.Items[i].Cells[1].Text + " and PaperID=" + intPaperID + "", "RubricID");
                if (strTmp != "")
                {
                    chkCheckBoxSel.Checked = true;
                }

                Label labTestContent = (Label)DataGridTest.Items[i].FindControl("labTestContent");
                DataGridTest.Items[i].Cells[7].ToolTip = labTestContent.Text;
                labTestContent.Text = Server.HtmlEncode(labTestContent.Text);
                if (labTestContent.Text.Trim().Length > 20)
                {
                    labTestContent.Text = labTestContent.Text.Trim().Substring(0, 20) + "...";
                }
                //labTestContent.Text=ObjFun.getStr(labTestContent.Text.Trim(),20)+"...";
            }
            LabelRecord.Text      = Convert.ToString(SqlDS.Tables["RubricInfo"].Rows.Count);
            LabelCountPage.Text   = Convert.ToString(DataGridTest.PageCount);
            LabelCurrentPage.Text = Convert.ToString(DataGridTest.CurrentPageIndex + 1);
            SqlConn.Dispose();
        }
        public static void Validation_Load(Page p)
        {
            string       testType = (string)WebTest.CurrentTest.UserData;
            DataGridTest dg       = new DataGridTest();

            dg.ID = "mygrid";
            EditCommandColumn e;

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.LinkButton;
            e.CancelText = "Cancel";
            e.EditText   = "Edit";
            e.UpdateText = "Update";

            switch (testType)
            {
            case "ValidatingValid":
            case "ValidatingInvalid":
            case "ValidationGroupIncluded":
            case "ValidationGroupNotIncluded":
                e.CausesValidation = true;
                break;

            case "NotValidatingInvalid":
                e.CausesValidation = false;
                break;
            }

            switch (testType)
            {
            case "ValidationGroupIncluded":
            case "ValidationGroupNotIncluded":
                e.ValidationGroup = "Group1";
                break;

            default:
                e.ValidationGroup = "";
                break;
            }

            dg.Columns.Add(e);

            TextBox tb = new TextBox();

            tb.ID = "Text1";
            switch (testType)
            {
            case "ValidatingValid":
                tb.Text = "111";
                break;

            case "ValidatingInvalid":
            case "NotValidatingInvalid":
            case "ValidationGroupIncluded":
            case "ValidationGroupNotIncluded":
                tb.Text = "";
                break;
            }

            RequiredFieldValidator v = new RequiredFieldValidator();

            v.ControlToValidate = "Text1";
            switch (testType)
            {
            case "ValidationGroupIncluded":
                v.ValidationGroup = "Group1";
                break;

            case "ValidationGroupNotIncluded":
                v.ValidationGroup = "NotGroup1";
                break;

            default:
                v.ValidationGroup = "";
                break;
            }
            TemplateColumn tc = new TemplateColumn();

            tc.EditItemTemplate = new ValidatingEditTemplate(tb, v);
            dg.Columns.Add(tc);

            ObjectDataSource ods = new ObjectDataSource("MyObjectDS", "Select");

            ods.UpdateMethod       = "Update";
            ods.DataObjectTypeName = "MyObjectDS";
            ods.ID = "MyDS";

            p.Form.Controls.Add(ods);

            dg.DataSource = ods;
            //dg.DataKeyField = "i";

            //DataTable table = new DataTable ();
            //table.Columns.Add (new DataColumn ("one", typeof (string)));
            //table.Columns.Add (new DataColumn ("two", typeof (string)));
            //table.Columns.Add (new DataColumn ("three", typeof (string)));
            //table.Rows.Add (new object [] { "1", "2", "3" });

            //dg.DataSource = new DataView (table);

            dg.EditItemIndex = 0;
            p.Form.Controls.Add(dg);

            dg.DataBind();
            if (!p.IsPostBack)
            {
                WebTest.CurrentTest.UserData = dg.Items [0].Cells [0].Controls [0].UniqueID;
            }
        }
Esempio n. 4
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, "UserAnswer");
            RowNum = DataGridTest.CurrentPageIndex * DataGridTest.PageSize + 1;

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

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

            DataGridTest.DataSource = SqlDS.Tables["UserAnswer"].DefaultView;
            DataGridTest.DataBind();

            SqlDataAdapter SqlCmdTmp = null;
            DataSet        SqlDSTmp  = null;

            for (int i = 0; i < DataGridTest.Items.Count; i++)
            {
                System.Web.UI.WebControls.Image imgRate = (System.Web.UI.WebControls.Image)DataGridTest.Items[i].FindControl("imgRate");
                imgRate.Width   = Convert.ToInt32(200 * Convert.ToDouble(DataGridTest.Items[i].Cells[6].Text.Trim()) / Convert.ToDouble(DataGridTest.Items[i].Cells[5].Text.Trim()));
                imgRate.ToolTip = Convert.ToString(System.Math.Round(Convert.ToDouble(DataGridTest.Items[i].Cells[6].Text.Trim()) / Convert.ToDouble(DataGridTest.Items[i].Cells[5].Text.Trim()) * 100, 1)) + "%";

                if (DataGridTest.Items[i].Cells[3].Text.Trim() == "单选类")
                {
                    intSelA   = 0; intSelB = 0; intSelC = 0; intSelD = 0; intSelE = 0; intSelF = 0;
                    SqlCmdTmp = new SqlDataAdapter("select a.RubricID,a.UserAnswer from UserAnswer a,UserScore b where a.UserScoreID=b.UserScoreID and a.RubricID=" + DataGridTest.Items[i].Cells[0].Text.Trim() + " and b.PaperID=" + intPaperID + " and b.ExamState=1", SqlConn);
                    SqlDSTmp  = new DataSet();
                    SqlCmdTmp.Fill(SqlDSTmp, "TestAnswer");
                    for (j = 0; j < SqlDSTmp.Tables["TestAnswer"].Rows.Count; j++)
                    {
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper() == "A")
                        {
                            intSelA = intSelA + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper() == "B")
                        {
                            intSelB = intSelB + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper() == "C")
                        {
                            intSelC = intSelC + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper() == "D")
                        {
                            intSelD = intSelD + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper() == "E")
                        {
                            intSelE = intSelE + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper() == "F")
                        {
                            intSelF = intSelF + 1;
                        }
                    }
                    Label labSelA = (Label)DataGridTest.Items[i].FindControl("labSelA");
                    labSelA.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelA) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelB = (Label)DataGridTest.Items[i].FindControl("labSelB");
                    labSelB.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelB) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelC = (Label)DataGridTest.Items[i].FindControl("labSelC");
                    labSelC.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelC) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelD = (Label)DataGridTest.Items[i].FindControl("labSelD");
                    labSelD.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelD) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelE = (Label)DataGridTest.Items[i].FindControl("labSelE");
                    labSelE.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelE) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelF = (Label)DataGridTest.Items[i].FindControl("labSelF");
                    labSelF.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelF) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";
                }
                if (DataGridTest.Items[i].Cells[3].Text.Trim() == "多选类")
                {
                    intSelA   = 0; intSelB = 0; intSelC = 0; intSelD = 0; intSelE = 0; intSelF = 0;
                    SqlCmdTmp = new SqlDataAdapter("select a.RubricID,a.UserAnswer from UserAnswer a,UserScore b where a.UserScoreID=b.UserScoreID and a.RubricID=" + DataGridTest.Items[i].Cells[0].Text.Trim() + " and b.PaperID=" + intPaperID + " and b.ExamState=1", SqlConn);
                    SqlDSTmp  = new DataSet();
                    SqlCmdTmp.Fill(SqlDSTmp, "TestAnswer");
                    for (j = 0; j < SqlDSTmp.Tables["TestAnswer"].Rows.Count; j++)
                    {
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper().IndexOf("A") >= 0)
                        {
                            intSelA = intSelA + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper().IndexOf("B") >= 0)
                        {
                            intSelB = intSelB + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper().IndexOf("C") >= 0)
                        {
                            intSelC = intSelC + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper().IndexOf("D") >= 0)
                        {
                            intSelD = intSelD + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper().IndexOf("E") >= 0)
                        {
                            intSelE = intSelE + 1;
                        }
                        if (SqlDSTmp.Tables["TestAnswer"].Rows[j]["UserAnswer"].ToString().ToUpper().IndexOf("F") >= 0)
                        {
                            intSelF = intSelF + 1;
                        }
                    }
                    Label labSelA = (Label)DataGridTest.Items[i].FindControl("labSelA");
                    labSelA.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelA) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelB = (Label)DataGridTest.Items[i].FindControl("labSelB");
                    labSelB.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelB) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelC = (Label)DataGridTest.Items[i].FindControl("labSelC");
                    labSelC.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelC) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelD = (Label)DataGridTest.Items[i].FindControl("labSelD");
                    labSelD.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelD) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelE = (Label)DataGridTest.Items[i].FindControl("labSelE");
                    labSelE.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelE) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";

                    Label labSelF = (Label)DataGridTest.Items[i].FindControl("labSelF");
                    labSelF.Text = Convert.ToString(System.Math.Round((Convert.ToDouble(intSelF) / SqlDSTmp.Tables["TestAnswer"].Rows.Count) * 100, 1)) + "%";
                }
            }
            SqlConn.Dispose();
        }