示例#1
0
        public void Show_QuestionList()
        {
            //显示客户姓名和编号
            Function_ClientInfo function_clientInfo = new Function_ClientInfo();
            DataTable dt = function_clientInfo.Query_ClientInfo(ClientInfo_ID);
            if (dt != null && dt.Rows.Count > 0)
            {
                class_clientInfo = new Class_ClientInfo();
                class_clientInfo.ClientInfo_ID = Convert.ToInt32(dt.Rows[0]["ClientInfo_ID"].ToString());
                class_clientInfo.ClientInfo_Name = dt.Rows[0]["ClientInfo_Name"].ToString();
                class_clientInfo.ClientInfo_Age = Convert.ToUInt32(dt.Rows[0]["ClientInfo_Age"].ToString());
                class_clientInfo.ClientInfo_Sex = dt.Rows[0]["ClientInfo_Sex"].ToString();

                if (dt.Rows[0]["ClientInfo_Weight"] != null && !String.IsNullOrEmpty(dt.Rows[0]["ClientInfo_Weight"].ToString()) && CommonFunction.IsNumber(dt.Rows[0]["ClientInfo_Weight"].ToString(), 2))
                    class_clientInfo.ClientInfo_Weight = Convert.ToSingle(dt.Rows[0]["ClientInfo_Weight"].ToString());

                if (dt.Rows[0]["ClientInfo_Height"] != null && !String.IsNullOrEmpty(dt.Rows[0]["ClientInfo_Height"].ToString()) && CommonFunction.IsNumber(dt.Rows[0]["ClientInfo_Height"].ToString(), 2))
                    class_clientInfo.ClientInfo_Height = Convert.ToSingle(dt.Rows[0]["ClientInfo_Height"].ToString());

                if (dt.Rows[0]["ClientInfo_Province"] != null && !String.IsNullOrEmpty(dt.Rows[0]["ClientInfo_Province"].ToString()))
                    class_clientInfo.ClientInfo_Province = dt.Rows[0]["ClientInfo_Province"].ToString();

                if (dt.Rows[0]["ClientInfo_City"] != null && !String.IsNullOrEmpty(dt.Rows[0]["ClientInfo_City"].ToString()))
                    class_clientInfo.ClientInfo_City = dt.Rows[0]["ClientInfo_City"].ToString();

                if (dt.Rows[0]["ClientInfo_Address"] != null && !String.IsNullOrEmpty(dt.Rows[0]["ClientInfo_Address"].ToString()))
                    class_clientInfo.ClientInfo_City = dt.Rows[0]["ClientInfo_Address"].ToString();

                if (dt.Rows[0]["ClientInfo_Tel"] != null && !String.IsNullOrEmpty(dt.Rows[0]["ClientInfo_Tel"].ToString()))
                    class_clientInfo.ClientInfo_City = dt.Rows[0]["ClientInfo_Tel"].ToString();

                if (dt.Rows[0]["ClientInfo_Email"] != null && !String.IsNullOrEmpty(dt.Rows[0]["ClientInfo_Email"].ToString()))
                    class_clientInfo.ClientInfo_Email = dt.Rows[0]["ClientInfo_Email"].ToString();

                if (dt.Rows[0]["ClientInfo_Zip"] != null && !String.IsNullOrEmpty(dt.Rows[0]["ClientInfo_Zip"].ToString()))
                    class_clientInfo.ClientInfo_Zip = dt.Rows[0]["ClientInfo_Zip"].ToString();

                if (dt.Rows[0]["AddTime"] != null && !String.IsNullOrEmpty(dt.Rows[0]["AddTime"].ToString()))
                    class_clientInfo.AddTime = Convert.ToDateTime(dt.Rows[0]["AddTime"].ToString());

                label5.Text += class_clientInfo.ClientInfo_ID.ToString();
                label6.Text += class_clientInfo.ClientInfo_Name.ToString();
            }

            if (Question_ID > 0)
            {
                //显示题目名称和题目头
                Function_Question function_question = new Function_Question();
                dt = function_question.Query_AnswerInfo(Question_ID);
                if (dt != null && dt.Rows.Count > 0)
                {
                    label2.Text = dt.Rows[0]["Question_Title"].ToString();
                    label4.Text = dt.Rows[0]["Question_Top"].ToString();

                    //flowLayoutPanel1.BorderStyle = BorderStyle.Fixed3D;
                    flowLayoutPanel1.Controls.Add(label3);
                    flowLayoutPanel1.Controls.Add(label4);
                    flowLayoutPanel1.Height = label3.Height + label4.Height + 5;

                    label5.Location = new Point(label5.Location.X, flowLayoutPanel1.Location.Y + flowLayoutPanel1.Height + 10);
                    label6.Location = new Point(label6.Location.X, flowLayoutPanel1.Location.Y + flowLayoutPanel1.Height + 10);

                    Panel_Height = label5.Location.Y + label5.Height + 10;
                }

                Function_AnswerInfo function_anwerInfo = new Function_AnswerInfo();
                dt = function_anwerInfo.Query_AnswerInfo(ClientInfo_ID, Question_ID);
                if (dt != null && dt.Rows.Count > 0)
                {
                    if (CommonFunction.IsNumber(dt.Rows[0]["AnswerInfo_ID"].ToString(), 0))
                    {
                        AnswerInfo_ID = Convert.ToInt32(dt.Rows[0]["AnswerInfo_ID"].ToString());
                        Text_Question_Tail.Text = dt.Rows[0]["Question_Tail"].ToString();
                    }
                }

                Hashtable hash_answerList = new Hashtable();
                if (AnswerInfo_ID > 0)
                {
                    //读出每条答过的题目
                    Function_AnswerList function_answerList = new Function_AnswerList();
                    dt = function_answerList.Query_AnswerList(AnswerInfo_ID);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        int QuestionList_ID = 0;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (QuestionList_ID != Convert.ToInt32(dt.Rows[i]["QuestionList_ID"].ToString()))
                            {
                                QuestionList_ID = Convert.ToInt32(dt.Rows[i]["QuestionList_ID"].ToString());

                                ArrayList list_questionSelect = new ArrayList();
                                list_questionSelect.Add(Convert.ToInt32(dt.Rows[i]["QuestionSelect_ID"].ToString()));

                                hash_answerList.Add(QuestionList_ID, list_questionSelect);
                            }
                            else
                            {
                                ArrayList list_questionSelect = (ArrayList)hash_answerList[QuestionList_ID];
                                list_questionSelect.Add(Convert.ToInt32(dt.Rows[i]["QuestionSelect_ID"].ToString()));

                                hash_answerList[QuestionList_ID] = list_questionSelect;
                            }
                        }
                    }
                }

                //读出每条题目
                Function_QuestionList function_questionList = new Function_QuestionList();
                dt = function_questionList.Query_QuestionList(Question_ID);
                if (dt != null && dt.Rows.Count > 0)
                {
                    ArrayList list_QuestionList = new ArrayList();
                    int j = -1;
                    int QuestionList_Sequence = 0;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int QuestionList_ID = Convert.ToInt32(dt.Rows[i]["QuestionList_ID"].ToString());
                        if (QuestionList_ID != QuestionList_Sequence)
                        {
                            Class_Question class_question = new Class_Question();
                            class_question.QuestionList_ListID = Convert.ToInt32(dt.Rows[i]["QuestionList_ListID"].ToString()); ;
                            class_question.QuestionList_ID = QuestionList_ID;
                            class_question.Question_Title = dt.Rows[i]["QuestionList_Title"].ToString();
                            class_question.Question_Option = Convert.ToInt32(dt.Rows[i]["QuestionList_Option"].ToString());
                            class_question.Question_TurnRow = Convert.ToInt32(dt.Rows[i]["QuestionList_TurnRow"].ToString());

                            Class_QuestionSelect class_questionSelect = new Class_QuestionSelect();
                            class_questionSelect.QuestionSelect_ID = Convert.ToInt32(dt.Rows[i]["QuestionSelect_ID"].ToString());
                            class_questionSelect.QuestionSelect_MainID = Convert.ToInt32(dt.Rows[i]["QuestionSelect_MainID"].ToString());
                            class_questionSelect.QuestionSelect_ListID = Convert.ToInt32(dt.Rows[i]["QuestionSelect_ListID"].ToString());
                            class_questionSelect.QuestionSelect_Text = dt.Rows[i]["QuestionSelect_Text"].ToString();
                            class_questionSelect.QuestionSelect_Score = Convert.ToInt32(dt.Rows[i]["QuestionSelect_Score"].ToString());

                            ArrayList list_questionSelect = new ArrayList();
                            list_questionSelect.Add(class_questionSelect);
                            list_QuestionList.Add(class_question);

                            class_question.Class_QuestionSelect = list_questionSelect;
                            QuestionList_Sequence = QuestionList_ID;
                            j++;
                        }
                        else
                        {
                            Class_Question class_question = (Class_Question)list_QuestionList[j];
                            ArrayList list_question = class_question.Class_QuestionSelect;

                            Class_QuestionSelect class_questionSelect = new Class_QuestionSelect();
                            class_questionSelect.QuestionSelect_ID = Convert.ToInt32(dt.Rows[i]["QuestionSelect_ID"].ToString());
                            class_questionSelect.QuestionSelect_MainID = Convert.ToInt32(dt.Rows[i]["QuestionSelect_MainID"].ToString());
                            class_questionSelect.QuestionSelect_ListID = Convert.ToInt32(dt.Rows[i]["QuestionSelect_ListID"].ToString());
                            class_questionSelect.QuestionSelect_Text = dt.Rows[i]["QuestionSelect_Text"].ToString();
                            class_questionSelect.QuestionSelect_Score = Convert.ToInt32(dt.Rows[i]["QuestionSelect_Score"].ToString());

                            list_question.Add(class_questionSelect);
                        }
                    }

                    //显示每条题目
                    if (list_QuestionList.Count > 0)
                    {
                        QuestionList_Total = list_QuestionList.Count;
                        QuestionList_TotalPage = (list_QuestionList.Count - 1) / 10 + 1;

                        Panel panel = null;
                        int p = QuestionList_CurrentPage;

                        int i = 0;
                        for (i = 0; i < list_QuestionList.Count; i++)
                        {
                            if (i % 10 == 0)
                            {
                                panel = new Panel();
                                panel.AutoSize = true;
                                //panel.BorderStyle = BorderStyle.Fixed3D;
                                panel.Location = new System.Drawing.Point(pictureBox1.Location.X, Panel_Height);
                                panel.Name = "Panel_QuestionList" + p.ToString();
                                panel.Visible = false;
                                panel.ControlAdded += new ControlEventHandler(Panel_Control_Added);
                                Controls.Add(panel);

                                if (p == QuestionList_CurrentPage)
                                    panel.Visible = true;

                                p++;
                                Controls_Height = 0;
                            }

                            Class_Question class_question = (Class_Question)list_QuestionList[i];
                            Control_QuestionList control_questionList = new Control_QuestionList(class_question, class_clientInfo);

                            if (hash_answerList != null && hash_answerList.Count > 0)
                            {
                                ArrayList list_questionSelect = (ArrayList)hash_answerList[class_question.QuestionList_ID];
                                control_questionList.QuestionSelect_List = list_questionSelect;
                            }

                            control_questionList.Show_QuestionList();
                            panel.Controls.Add(control_questionList);
                        }

                        String Question_Tail = function_question.Query_Question_Tail(Question_ID);
                        if (!String.IsNullOrEmpty(Question_Tail))
                            label7.Text = Question_Tail;
                        else
                        {
                            label7.Visible = false;
                            Text_Question_Tail.Visible = false;
                        }

                        if (panel != null)
                        {
                            panel.Controls.Add(label7);
                            panel.Controls.Add(Text_Question_Tail);
                        }

                        Control[] panel_controls = Controls.Find("Panel_QuestionList" + QuestionList_CurrentPage, false);
                        if (panel_controls == null || panel_controls.Length == 0)
                            return;

                        if (panel_controls[0] is Panel)
                        {
                            panel = (Panel)panel_controls[0];

                            choiButton1.Location = new Point(choiButton1.Location.X, panel.Location.Y + panel.Size.Height + 10);
                            choiButton2.Location = new Point(choiButton2.Location.X, panel.Location.Y + panel.Size.Height + 10);
                            choiButton3.Location = new Point(choiButton3.Location.X, panel.Location.Y + panel.Size.Height + 10);
                        }
                    }
                }
            }
        }
示例#2
0
        private void Set_QuestionTable()
        {
            QuestionTable = new Hashtable();

            Function_Question function_Question = new Function_Question();
            DataTable dt = function_Question.Query_AnswerInfo();
            if (dt != null && dt.Rows.Count > 0)
            {
                AnswerInfo_Table = new Hashtable();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    String Title = "";
                    if (dt.Rows[i]["Question_ID"] != null && CommonFunction.IsNumber(dt.Rows[i]["Question_ID"].ToString(), 1))
                    {
                        int QuestionID = Convert.ToInt32(dt.Rows[i]["Question_ID"].ToString());
                        AnswerInfo_Table.Add(QuestionID, dt.Rows[i]["Question_Title"].ToString());

                        Function_QuestionList function_QuestionList = new Function_QuestionList();
                        DataTable QuestionList = function_QuestionList.Query_QuestionList(QuestionID);

                        if (QuestionList != null && QuestionList.Rows.Count > 0)
                        {
                            ArrayList QuestionArray = new ArrayList();
                            for (int j = 0; j < QuestionList.Rows.Count; j++)
                            {
                                if (Title == QuestionList.Rows[j]["QuestionList_Title"].ToString() && j > 0)
                                {
                                    Class_AnswerTable class_answerTable = (Class_AnswerTable)QuestionArray[QuestionArray.Count - 1];
                                    SortedList QuestionSelect = class_answerTable.AnswerTable_Select;
                                    if (QuestionSelect != null && QuestionList.Rows[j]["QuestionSelect_ID"] != null && CommonFunction.IsNumber(QuestionList.Rows[j]["QuestionSelect_ID"].ToString(), 1))
                                    {
                                        int QuestionSelect_ID = Convert.ToInt32(QuestionList.Rows[j]["QuestionSelect_ID"].ToString());
                                        QuestionSelect.Add(QuestionSelect_ID, QuestionList.Rows[j]["QuestionSelect_Text"].ToString());
                                        class_answerTable.AnswerTable_Select = QuestionSelect;
                                    }

                                    QuestionArray[QuestionArray.Count - 1] = class_answerTable;
                                }
                                else
                                {
                                    Class_AnswerTable class_answerTable = new Class_AnswerTable();
                                    if (QuestionList.Rows[j]["QuestionList_ListID"] != null && CommonFunction.IsNumber(QuestionList.Rows[j]["QuestionList_ListID"].ToString(), 1))
                                    {
                                        class_answerTable.AnswerTable_ID = Convert.ToInt32(QuestionList.Rows[j]["QuestionList_ListID"].ToString());
                                        class_answerTable.AnswerTable_Title = QuestionList.Rows[j]["QuestionList_Title"].ToString();

                                        if (QuestionList.Rows[j]["QuestionSelect_ID"] != null && CommonFunction.IsNumber(QuestionList.Rows[j]["QuestionSelect_ID"].ToString(), 1))
                                        {
                                            SortedList QuestionSelect = new SortedList();
                                            int QuestionSelect_ID = Convert.ToInt32(QuestionList.Rows[j]["QuestionSelect_ID"].ToString());
                                            QuestionSelect.Add(QuestionSelect_ID, QuestionList.Rows[j]["QuestionSelect_Text"].ToString());
                                            class_answerTable.AnswerTable_Select = QuestionSelect;
                                        }
                                        else
                                        {
                                            class_answerTable.AnswerTable_Select = null;
                                        }

                                        class_answerTable.AnswerTable_SelectID = 0;

                                        if (QuestionList.Rows[j]["QuestionList_TurnRow"] != null && CommonFunction.IsNumber(QuestionList.Rows[j]["QuestionList_TurnRow"].ToString(), 1))
                                            class_answerTable.AnswerTable_TurnRow = Convert.ToInt32(QuestionList.Rows[j]["QuestionList_TurnRow"].ToString());
                                        else
                                            class_answerTable.AnswerTable_TurnRow = 0;
                                    }

                                    Title = QuestionList.Rows[j]["QuestionList_Title"].ToString();
                                    QuestionArray.Add(class_answerTable);
                                }
                            }

                            QuestionTable.Add(QuestionID, QuestionArray);
                        }
                    }
                }
            }
        }