public Form_Result(int Q_ID, int C_ID, Hashtable A_List_Score, Hashtable A_List_Text) { InitializeComponent(); Question_ID = Q_ID; ClientInfo_ID = C_ID; list_answerInfo_Score = A_List_Score; list_answerInfo_Text = A_List_Text; DataTable dt = null; 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(); } Function_ClientInfo function_clientInfo = new Function_ClientInfo(); 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(); } }
private void contextMenuStrip_Del(object sender, EventArgs e) { if (MessageBox.Show("确定删除当前客户吗?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Function_ClientInfo function_clientInfo = new Function_ClientInfo(); if (function_clientInfo.Delete_ClientInfo(Convert.ToInt32(listView1.SelectedItems[0].SubItems[0].Text))) MessageBox.Show("删除成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); else MessageBox.Show("删除失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error); ClientInfoRefresh(); ClientListRefresh(); } }
private void choiButton1_Click(object sender, EventArgs e) { Class_ClientInfo class_clientInfo = new Class_ClientInfo(); if (!String.IsNullOrEmpty(choiTextBox1.Text) && CommonFunction.IsNumber(choiTextBox1.Text, 1)) class_clientInfo.ClientInfo_ID = Convert.ToInt32(choiTextBox1.Text); if (!String.IsNullOrEmpty(choiTextBox2.Text)) class_clientInfo.ClientInfo_Name = choiTextBox2.Text; if (!String.IsNullOrEmpty(choiTextBox3.Text) && CommonFunction.IsNumber(choiTextBox3.Text, 1)) class_clientInfo.ClientInfo_Age = Convert.ToUInt32(choiTextBox3.Text); if (choiRadioButton1.Checked) class_clientInfo.ClientInfo_Sex = "1"; if (choiRadioButton2.Checked) class_clientInfo.ClientInfo_Sex = "0"; if (!String.IsNullOrEmpty(choiTextBox4.Text) && CommonFunction.IsNumber(choiTextBox4.Text, 2)) class_clientInfo.ClientInfo_Weight = Convert.ToSingle(choiTextBox4.Text); if (!String.IsNullOrEmpty(choiTextBox5.Text) && CommonFunction.IsNumber(choiTextBox5.Text, 2)) class_clientInfo.ClientInfo_Height = Convert.ToSingle(choiTextBox5.Text); if (!String.IsNullOrEmpty(choiTextBox6.Text)) class_clientInfo.ClientInfo_Province = choiTextBox6.Text; if (!String.IsNullOrEmpty(choiTextBox7.Text)) class_clientInfo.ClientInfo_City = choiTextBox7.Text; if (!String.IsNullOrEmpty(choiTextBox8.Text)) class_clientInfo.ClientInfo_Address = choiTextBox8.Text; if (!String.IsNullOrEmpty(choiTextBox9.Text)) class_clientInfo.ClientInfo_Tel = choiTextBox9.Text; if (!String.IsNullOrEmpty(choiTextBox10.Text)) class_clientInfo.ClientInfo_Email = choiTextBox10.Text; if (!String.IsNullOrEmpty(choiTextBox11.Text)) class_clientInfo.ClientInfo_Zip = choiTextBox11.Text; Function_ClientInfo fc = new Function_ClientInfo(); ClientInfo_Table = fc.Query_ClientInfo(class_clientInfo); Close(); }
public void dataGridView_Refresh() { if (dataGridView1.Rows.Count > 0) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { dataGridView1.Rows.RemoveAt(i); } } Function_ClientInfo function_clientInfo = new Function_ClientInfo(); DataTable dt = function_clientInfo.Query_ClientInfo(); if (dt != null) { dataGridView1.DataSource = dt; dataGridView_SetColumns(); } }
public void listView_Refresh() { listView1.Items.Clear(); Function_ClientInfo function_clientInfo = new Function_ClientInfo(); DataTable dt = function_clientInfo.Query_ClientInfo(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { listView1.Items.Add(dt.Rows[i]["ClientInfo_ID"].ToString()); listView1.Items[i].SubItems.Add(dt.Rows[i]["ClientInfo_Name"].ToString()); } if (listView1.Items.Count > 0) { listView1.Items[0].Selected = true; } } }
public void Show_ClientDetail() { if (ClientInfo_ID > 0) { Function_ClientInfo function_clientInfo = new Function_ClientInfo(); DataTable dt = function_clientInfo.Query_ClientInfo(ClientInfo_ID); if (dt != null && dt.Rows.Count > 0) { label1.Visible = true; label2.Visible = true; label1.Text = dt.Rows[0]["ClientInfo_ID"].ToString(); choiTextBox1.Text = dt.Rows[0]["ClientInfo_Name"].ToString(); choiTextBox2.Text = dt.Rows[0]["ClientInfo_Age"].ToString(); if (dt.Rows[0]["ClientInfo_Sex"].ToString() == "1") { choiRadioButton1.Checked = true; choiRadioButton2.Checked = false; } else { choiRadioButton1.Checked = false; choiRadioButton2.Checked = true; } choiTextBox3.Text = dt.Rows[0]["ClientInfo_Weight"].ToString(); choiTextBox4.Text = dt.Rows[0]["ClientInfo_Height"].ToString(); choiTextBox5.Text = dt.Rows[0]["ClientInfo_Province"].ToString(); choiTextBox6.Text = dt.Rows[0]["ClientInfo_City"].ToString(); choiTextBox7.Text = dt.Rows[0]["ClientInfo_Address"].ToString(); choiTextBox8.Text = dt.Rows[0]["ClientInfo_Tel"].ToString(); choiTextBox9.Text = dt.Rows[0]["ClientInfo_Email"].ToString(); choiTextBox10.Text = dt.Rows[0]["ClientInfo_Zip"].ToString(); } } else { label1.Visible = false; label2.Visible = false; } }
private void choiButton3_Click(object sender, EventArgs e) { if (ClientInfo_ID <= 0) return; if (MessageBox.Show("确定删除当前客户吗?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Function_ClientInfo function_clientInfo = new Function_ClientInfo(); if (function_clientInfo.Delete_ClientInfo(Convert.ToInt32(ClientInfo_ID))) MessageBox.Show("删除成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); else MessageBox.Show("删除失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error); ClearInput(); form_main.ClientInfo_Refresh(); form_main.ClientList_Refresh(); } }
private void choiButton2_Click(object sender, EventArgs e) { if (ClientInfo_ID <= 0) return; Class_ClientInfo class_clientInfo = CheckInput(); if (class_clientInfo == null) return; class_clientInfo.ClientInfo_ID = Convert.ToInt32(ClientInfo_ID); Function_ClientInfo function_clientInfo = new Function_ClientInfo(); if (function_clientInfo.Update_ClientInfo(class_clientInfo)) MessageBox.Show("更新客户" + class_clientInfo.ClientInfo_Name + "成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); else MessageBox.Show("更新客户失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error); ClearInput(); form_main.ClientInfo_Refresh(); form_main.ClientList_Refresh(); }
private void choiButton1_Click(object sender, EventArgs e) { Class_ClientInfo class_clientInfo = CheckInput(); if (class_clientInfo == null) return; Function_ClientInfo function_clientInfo = new Function_ClientInfo(); if (function_clientInfo.Insert_ClientInfo(class_clientInfo)) MessageBox.Show("添加客户" + class_clientInfo.ClientInfo_Name + "成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); else MessageBox.Show("添加客户失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error); ClearInput(); form_main.ClientInfo_Refresh(); form_main.ClientList_Refresh(); }
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); } } } } }
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(); } } }
private void choiButton1_Click(object sender, EventArgs e) { FolderBrowserDialog folderBrowser = new FolderBrowserDialog(); folderBrowser.SelectedPath = Application.StartupPath; DialogResult Result = folderBrowser.ShowDialog(); if (Result == DialogResult.OK || Result == DialogResult.Yes) { if (QuestionTable == null || QuestionTable.Count <= 0) Set_QuestionTable(); if (listView1.SelectedItems.Count > 0 && QuestionTable != null && QuestionTable.Count > 0) { Class_Excel class_Excel = new Class_Excel(); Function_ClientInfo function_clientInfo = new Function_ClientInfo(); for (int i = 0; i < listView1.SelectedItems.Count;i++) { if (CommonFunction.IsNumber(listView1.SelectedItems[i].Text, 1)) { int ClientID = Convert.ToInt32(listView1.SelectedItems[i].Text); DataTable ClientInfo = function_clientInfo.Query_ClientInfo(ClientID); if (ClientInfo == null || ClientInfo.Rows.Count <= 0) continue; String ExcelFile = ClientInfo.Rows[0]["ClientInfo_Name"].ToString() + "-" + ClientInfo.Rows[0]["ClientInfo_ID"].ToString() + ".xls"; class_Excel.ExcelFile = folderBrowser.SelectedPath + "\\" + ExcelFile; Function_AnswerInfo function_answerInfo = new Function_AnswerInfo(); DataTable AnswerInfo = function_answerInfo.Query_AnswerInfo_List(ClientID); if (AnswerInfo != null && AnswerInfo.Rows.Count > 0) { int[] AnswerInfo_Array = new int[AnswerInfo.Rows.Count]; String Question_Tail = ""; for (int j = 0; j < AnswerInfo.Rows.Count; j++) { if (AnswerInfo.Rows[j]["Question_ID"] != null && CommonFunction.IsNumber(AnswerInfo.Rows[j]["Question_ID"].ToString(), 1)) { int QuestionID = Convert.ToInt32(AnswerInfo.Rows[j]["Question_ID"].ToString()); int AnswerInfo_ID = Convert.ToInt32(AnswerInfo.Rows[j]["AnswerInfo_ID"].ToString()); if (QuestionID == 1) Question_Tail = AnswerInfo.Rows[j]["Question_Tail"].ToString(); if (QuestionTable.ContainsKey(QuestionID)) { ArrayList QuestionArray = (ArrayList)QuestionTable[QuestionID]; Function_AnswerList function_answerList = new Function_AnswerList(); DataTable AnswerList = function_answerList.Query_AnswerList(AnswerInfo_ID); for (int k = 0; k < QuestionArray.Count; k++) { Class_AnswerTable class_answerTable = (Class_AnswerTable)QuestionArray[k]; if (AnswerList.Rows[k]["QuestionSelect_ID"] != null && CommonFunction.IsNumber(AnswerList.Rows[k]["QuestionSelect_ID"].ToString(), 1)) { int QuestionSelect_ID = Convert.ToInt32(AnswerList.Rows[k]["QuestionSelect_ID"].ToString()); class_answerTable.AnswerTable_SelectID = QuestionSelect_ID; } QuestionArray[k] = class_answerTable; } AnswerInfo_Array[j] = QuestionID; QuestionTable[QuestionID] = QuestionArray; } } } class_Excel.OutToFile(ClientInfo, QuestionTable, AnswerInfo_Array, AnswerInfo_Table, Question_Tail); } else { class_Excel.OutToFile(ClientInfo, null, null, null, ""); } } } class_Excel.ExcelClose(); class_Excel = null; MessageBox.Show("导出成功!"); } } }
private void listView_Refresh() { listView1.Items.Clear(); Function_ClientInfo function_clientInfo = new Function_ClientInfo(); Function_AnswerInfo function_answerInfo = new Function_AnswerInfo(); DataTable dt = function_clientInfo.Query_ClientInfo(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { int ClientID = Convert.ToInt32(dt.Rows[i]["ClientInfo_ID"].ToString()); int AnswerInfo = function_answerInfo.Query_AnswerInfo_Client(ClientID); listView1.Items.Add(dt.Rows[i]["ClientInfo_ID"].ToString()); listView1.Items[i].SubItems.Add(dt.Rows[i]["ClientInfo_Name"].ToString()); if (dt.Rows[i]["ClientInfo_Age"] != null && !String.IsNullOrEmpty(dt.Rows[i]["ClientInfo_Age"].ToString())) listView1.Items[i].SubItems.Add(dt.Rows[i]["ClientInfo_Age"].ToString()); else listView1.Items[i].SubItems.Add(""); if (dt.Rows[i]["ClientInfo_Sex"] != null && !String.IsNullOrEmpty(dt.Rows[i]["ClientInfo_Sex"].ToString())) { if (dt.Rows[i]["ClientInfo_Sex"].ToString() == "1") listView1.Items[i].SubItems.Add("男"); else listView1.Items[i].SubItems.Add("女"); } else listView1.Items[i].SubItems.Add(""); listView1.Items[i].SubItems.Add(AnswerInfo.ToString()); } if (listView1.Items.Count > 0) { listView1.Items[0].Selected = true; } } }