Beispiel #1
0
        public bool Insert_AnswerInfo(Class_AnswerInfo class_answerInfo)
        {
            if (class_answerInfo == null)
                return false;

            class_answerInfo.Question_Tail = CommonFunction.FilterString(class_answerInfo.Question_Tail);

            String Sql = "";
            Sql += "Insert Into AnswerInfo(AnswerInfo_ID,ClientInfo_ID,Question_ID,Question_Tail,AddTime) ";
            Sql += "Values(" + class_answerInfo.AnswerInfo_ID + "," + class_answerInfo.ClientInfo_ID.ToString() + "," + class_answerInfo.Question_ID + ",'" + class_answerInfo.Question_Tail + "','" + DateTime.Now.ToString() + "')";

            OleDbDataAdapter oleDb = new OleDbDataAdapter(Sql, DBConnection.AccessConnection);
            DataTable dt = new DataTable();
            oleDb.Fill(dt);

            return true;
        }
Beispiel #2
0
        private void Save_Test(int SaveTest)
        {
            if (QuestionList_TotalPage > 0)
            {
                Hashtable list_answerInfo_Score = new Hashtable();
                Hashtable list_answerInfo_Text = new Hashtable();
                Panel panel;
                Control[] panel_controls;

                //保存
                if (SaveTest == 0)
                {
                    bool Is_Save = false;
                    if (AnswerInfo_ID > 0)
                        Is_Save = true;

                    String Question_Tail = "";
                    Function_AnswerInfo function_answerInfo = new Function_AnswerInfo();

                    if (!Is_Save)
                        AnswerInfo_ID = function_answerInfo.Query_AnswerInfo_ID();

                    for (int i = 1; i <= QuestionList_TotalPage; i++)
                    {
                        panel_controls = Controls.Find("Panel_QuestionList" + i.ToString(), false);
                        if (panel_controls == null || panel_controls.Length == 0)
                            return;

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

                        foreach (Control control_questionList in panel.Controls)
                        {
                            if (control_questionList is Control_QuestionList)
                            {
                                int QuestionList_ListID = (control_questionList as Control_QuestionList).QuestionList_ListID;
                                int QuestionSelect_Score = (control_questionList as Control_QuestionList).QuestionSelect_Score;
                                String QuestionSelect_Text = (control_questionList as Control_QuestionList).QuestionSelect_Text;
                                TextBox TextBox_QuestionList = (control_questionList as Control_QuestionList).TextBox_QuestionList;

                                if (QuestionSelect_Score != -1)
                                {
                                    list_answerInfo_Score.Add(QuestionList_ListID, QuestionSelect_Score);
                                    list_answerInfo_Text.Add(QuestionList_ListID, QuestionSelect_Text);
                                }

                                if (TextBox_QuestionList != null)
                                {
                                    if (TextBox_QuestionList.Name == "ClientInfo_Weight")
                                    {
                                        if (!String.IsNullOrEmpty(TextBox_QuestionList.Text))
                                        {
                                            if (class_clientInfo != null && CommonFunction.IsNumber(TextBox_QuestionList.Text, 2))
                                                class_clientInfo.ClientInfo_Weight = Convert.ToSingle(TextBox_QuestionList.Text);

                                            Function_ClientInfo function_clientInfo = new Function_ClientInfo();
                                            function_clientInfo.Update_ClientInfo(class_clientInfo);
                                        }
                                    }

                                    if (TextBox_QuestionList.Name == "ClientInfo_Height")
                                    {
                                        if (!String.IsNullOrEmpty(TextBox_QuestionList.Text))
                                        {
                                            if (class_clientInfo != null && CommonFunction.IsNumber(TextBox_QuestionList.Text, 2))
                                                class_clientInfo.ClientInfo_Height = Convert.ToSingle(TextBox_QuestionList.Text);

                                            Function_ClientInfo function_clientInfo = new Function_ClientInfo();
                                            function_clientInfo.Update_ClientInfo(class_clientInfo);
                                        }
                                    }
                                }

                                Class_AnswerList class_answerList = new Class_AnswerList();
                                class_answerList.AnswerInfo_ID = AnswerInfo_ID;
                                class_answerList.QuestionList_ID = (control_questionList as Control_QuestionList).QuestionList_ID;
                                class_answerList.QuestionSelect_ID = (control_questionList as Control_QuestionList).QuestionSelect_ID;

                                Function_AnswerList function_answerList = new Function_AnswerList();
                                if (Is_Save)
                                {
                                    if (!function_answerList.Update_AnswerList(class_answerList))
                                        MessageBox.Show("Update_AnswerList更新数据失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else
                                {
                                    if (!function_answerList.Insert_AnswerList(class_answerList))
                                        MessageBox.Show("Insert_AnswerList插入数据失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            if (control_questionList is TextBox)
                            {
                                TextBox textBox_controls = (TextBox)control_questionList;
                                if (textBox_controls.Name == "Text_Question_Tail")
                                    Question_Tail = textBox_controls.Text;
                            }
                        }
                    }

                    Class_AnswerInfo class_answerInfo = new Class_AnswerInfo();
                    class_answerInfo.AnswerInfo_ID = AnswerInfo_ID;
                    class_answerInfo.ClientInfo_ID = ClientInfo_ID;
                    class_answerInfo.Question_ID = Question_ID;
                    class_answerInfo.Question_Tail = Question_Tail;

                    if (Is_Save)
                    {
                        if (!function_answerInfo.Update_AnswerInfo(class_answerInfo))
                            MessageBox.Show("Update_AnswerInfo更新数据失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (!function_answerInfo.Insert_AnswerInfo(class_answerInfo))
                            MessageBox.Show("Insert_AnswerInfo插入数据失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    MessageBox.Show("已将答卷记录保存到数据库。", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }

                //测试
                if (SaveTest == 1)
                {
                    int QuestionList_NoSelect = 0;
                    for (int i = 1; i <= QuestionList_TotalPage; i++)
                    {
                        panel_controls = Controls.Find("Panel_QuestionList" + i.ToString(), false);
                        if (panel_controls == null || panel_controls.Length == 0)
                            return;

                        if (panel_controls[0] is Panel)
                        {
                            panel = (Panel)panel_controls[0];
                            //panel.Visible = false;
                        }
                        else
                            return;

                        foreach (Control control_questionList in panel.Controls)
                        {
                            if (control_questionList is Control_QuestionList)
                            {
                                int QuestionList_ListID = (control_questionList as Control_QuestionList).QuestionList_ListID;
                                int QuestionSelect_Score = (control_questionList as Control_QuestionList).QuestionSelect_Score;
                                String QuestionSelect_Text = (control_questionList as Control_QuestionList).QuestionSelect_Text;
                                TextBox TextBox_QuestionList = (control_questionList as Control_QuestionList).TextBox_QuestionList;

                                if (TextBox_QuestionList == null)
                                {
                                    if (QuestionSelect_Score != -1 && !String.IsNullOrEmpty(QuestionSelect_Text))
                                    {
                                        list_answerInfo_Score.Add(QuestionList_ListID, QuestionSelect_Score);
                                        list_answerInfo_Text.Add(QuestionList_ListID, QuestionSelect_Text);
                                    }
                                    else
                                    {
                                        QuestionList_NoSelect = i;
                                        MessageBox.Show("第" + QuestionList_ListID.ToString() + "题没选择", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        break;
                                    }
                                }
                                else
                                {
                                    if (!String.IsNullOrEmpty(TextBox_QuestionList.Text) && CommonFunction.IsNumber(TextBox_QuestionList.Text, 2))
                                    {
                                        list_answerInfo_Score.Add(QuestionList_ListID, Convert.ToSingle(TextBox_QuestionList.Text));
                                        list_answerInfo_Text.Add(QuestionList_ListID, QuestionSelect_Text);
                                    }
                                    else
                                    {
                                        list_answerInfo_Score.Add(QuestionList_ListID, 0);
                                        list_answerInfo_Text.Add(QuestionList_ListID, QuestionSelect_Text);
                                    }
                                }
                            }
                        }

                        if (QuestionList_NoSelect > 0)
                            break;
                    }

                    if (QuestionList_NoSelect > 0)
                    {
                        QuestionList_CurrentPage = QuestionList_NoSelect;
                        for (int i = 1; i <= QuestionList_TotalPage; i++)
                        {
                            panel_controls = Controls.Find("Panel_QuestionList" + i.ToString(), false);
                            if (panel_controls == null || panel_controls.Length == 0)
                                return;

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

                            if (i == QuestionList_NoSelect)
                            {
                                Control_Visible();
                                panel.Visible = true;
                            }
                            else
                                panel.Visible = false;
                        }

                        return;
                    }

                    //Control[] flow_controls = Controls.Find("Panel_Top", false);
                    //if (flow_controls == null || flow_controls.Length == 0)
                    //    return;

                    //if (flow_controls[0] is FlowLayoutPanel)
                    //{
                    //    FlowLayoutPanel flow = (FlowLayoutPanel)flow_controls[0];
                    //    flow.Visible = false;
                    //}

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

                    //panel = new Panel();
                    //panel.AutoSize = true;
                    ////panel.BorderStyle = BorderStyle.Fixed3D;
                    //panel.Location = new System.Drawing.Point(50, label5.Location.Y + 15);
                    //panel.Name = "Panel_QuestionCase";
                    //panel.Visible = true;
                    //Controls.Add(panel);

                    //if (Question_ID == 1)
                    //{
                    //    Control_QuestionCase1 control_questionCase = new Control_QuestionCase1(Convert.ToInt32(Question_ID), list_answerInfo_Score);
                    //    control_questionCase.Show_Result();

                    //    panel.Controls.Add(control_questionCase);
                    //}

                    //if (Question_ID == 2)
                    //{
                    //    Control_QuestionCase2 control_questionCase = new Control_QuestionCase2(Convert.ToInt32(Question_ID), list_answerInfo_Score, list_answerInfo_Text);
                    //    control_questionCase.Show_Result();

                    //    panel.Controls.Add(control_questionCase);
                    //}

                    //choiButton1.Enabled = false;
                    //choiButton1.Visible = false;

                    //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);

                    //IsClose = true;
                    //choiButton2.Text = "打印";
                    //choiButton3.Text = "关闭";

                    //this.Refresh();

                    Form_Result form_Result = new Form_Result(Question_ID, ClientInfo_ID, list_answerInfo_Score, list_answerInfo_Text);
                    form_Result.Show_Result();
                    form_Result.FormBorderStyle = FormBorderStyle.None;
                    form_Result.StartPosition = FormStartPosition.Manual;
                    form_Result.WindowState = FormWindowState.Maximized;
                    form_Result.Show();
                }
            }
        }
Beispiel #3
0
        public bool Update_AnswerInfo(Class_AnswerInfo class_answerInfo)
        {
            if (class_answerInfo == null)
                return false;

            class_answerInfo.Question_Tail = CommonFunction.FilterString(class_answerInfo.Question_Tail);

            String Sql = "";
            Sql += "Update AnswerInfo Set Question_Tail = '" + class_answerInfo.Question_Tail + "' Where AnswerInfo_ID = " + class_answerInfo.AnswerInfo_ID.ToString();

            OleDbDataAdapter oleDb = new OleDbDataAdapter(Sql, DBConnection.AccessConnection);
            DataTable dt = new DataTable();
            oleDb.Fill(dt);

            return true;
        }