Esempio n. 1
0
        void bindDataToGrid(String condition)
        {
            String userId = "";
            String status = "";
            String messageType = "";
            if (Session["userId"] != null)
            {
                userId = this.Session["userId"].ToString(); ;
            }
            else
            {
                logger.Info("userId=null" );
            }
            if (Session["status"] != null)
            {
                status = this.Session["status"].ToString(); ;
            }
            if (Session["messageType"] != null)
            {
                messageType = this.Session["messageType"].ToString(); ;
            }

            logger.Info("userId=" + userId);
            logger.Info("messageType=" + messageType);
            AgentExamDao examDao = new ChinaUnion_DataAccess.AgentExamDao();
            IList<Exam> examList = examDao.GetList(condition, userId, messageType);

           
            
           // this.lblAgentNo.Text = agentNo;
            this.lblUserId.Text = userId;
            // int index = 1;
            DataTable dt = new DataTable();
            dt.Columns.Add("seq");
            dt.Columns.Add("userId");
            dt.Columns.Add("subject");
            dt.Columns.Add("status");
            
            dt.Columns.Add("validateStartTime");
            dt.Columns.Add("validateEndTime");

            DataRow row = null;
            if (examList != null && examList.Count > 0)
            {
                foreach (Exam exam in examList)
                {
                    
                    row = dt.NewRow();
                    row["seq"] = exam.sequence;
                    row["userId"] = userId;
                    row["subject"] = exam.subject;
                    row["status"] = exam.status;
                    if (String.IsNullOrEmpty(exam.status))
                    {
                        row["status"] = "未开始";
                    }
                    row["validateStartTime"] = exam.validateStartTime;
                    row["validateEndTime"] = exam.validateEndTime;
                   // dt.Rows.Add(row);
                    
                    if (status.Equals("new") )
                    {
                        dt.Rows.Add(row);
                    }
                    if (status.Equals("finish") && !String.IsNullOrEmpty(exam.status))
                    {
                        dt.Rows.Add(row);
                    }
                }
            }
            else
            {
                this.lblMessag.Text = "未找到"  + "记录!";
            }
            GridView1.DataSource = dt.DefaultView;
            GridView1.DataBind();
        }
Esempio n. 2
0
        private void dgExam_SelectionChanged(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            if (this.dgExam.CurrentRow != null)
            {
                if (this.dgExam[0, this.dgExam.CurrentRow.Index].Value != null)
                {

                    String examSeq = this.dgExam[0, this.dgExam.CurrentRow.Index].Value.ToString();

                    AgentExamDao examDao = new ChinaUnion_DataAccess.AgentExamDao();
                    IList<AgentExam> examList = examDao.GetList(examSeq);
                    this.dgScore.Rows.Clear();
                    dgScore.Columns.Clear();
                    dgScore.Columns.Add("用户编号", "用户编号");
                    dgScore.Columns.Add("成绩", "成绩");
                    foreach (AgentExam exam in examList)
                    {
                        AgentExamScoreDao agentExamScoreDao = new AgentExamScoreDao();
                        IList<ExamQuestion> examQuestionList = agentExamScoreDao.GetUserExamQuestion(examSeq, exam.userId);
                        int wrongCount = 0;
                        foreach (ExamQuestion examQuestion in examQuestionList)
                        {

                            if (examQuestion.standardAnswer != null && !examQuestion.standardAnswer.Equals(examQuestion.answer))
                            {

                                wrongCount++;
                            }
                        }
                        int totalCount = examQuestionList.Count;
                        int rightCount = totalCount - wrongCount;
                        String strMessage = "总共:" + totalCount + "题,答对:" + rightCount + "题,答错:" + wrongCount;



                        dgScore.Rows.Add();
                        DataGridViewRow row = dgScore.Rows[dgScore.RowCount - 1];
                        row.Cells["用户编号"].Value = exam.userId;
                        row.Cells["成绩"].Value = strMessage;

                        dgScore.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
                        dgScore.AutoResizeColumns();
                        //this.dgScore.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                        //this.dgScore.AutoResizeColumns();
                    }
                }

            }
            this.Cursor = Cursors.Default;
        }