- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using System.Xml;
- using System.Text;
- using System.Diagnostics;
- using System.IO;
- namespace SFGS
- {
- public partial class Survey : UserControl
- {
- private bool HasError = false;
- public Survey()
- {
- InitializeComponent();
- }
- public Survey(string SurveyID)
- {
- InitializeComponent();
- UpdateSurveyContent();
- UpdateQuestionOption(SurveyID);
- }
- private void UpdateSurveyContent()
- {
- WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
- userManageSoapClient.ReadAllSurveyAsync();
- userManageSoapClient.ReadAllSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.ReadAllSurveyCompletedEventArgs>(userMgrSoapClient_ReadAllSurveyCompleted);
- }
- private void userMgrSoapClient_ReadAllSurveyCompleted(object sender, SFGS.WebServiceProxy.ReadAllSurveyCompletedEventArgs e)
- {
- List<Customer> theSurveyList = new List<Customer>();
- if (!e.Result.Equals(""))
- {
- theSurveyList = Global.getList(e.Result);
- foreach (Customer ctm in theSurveyList)
- {
- if (ctm.IsCurrentSurvey == "1")
- {
- this.title.Text = ctm.Name;
- this.desc.Text = ctm.Description;
- break;
- }
- }
- }
- else
- {
- this.title.Text = "No Content";
- this.desc.Text = "No Content";
- }
- }
- private void UpdateQuestionOption(string SurveyID)
- {
- WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
- userManageSoapClient.ReadQuestionAsync(SurveyID);
- userManageSoapClient.ReadQuestionCompleted += new EventHandler<SFGS.WebServiceProxy.ReadQuestionCompletedEventArgs>(userMgrSoapClient_ReadQuestionCompleted);
- }
- private void userMgrSoapClient_ReadQuestionCompleted(object sender,SFGS.WebServiceProxy.ReadQuestionCompletedEventArgs e)
- {
- List<QuestionOptioner> theQuestionList;
- if (!e.Result.Equals(""))
- {
- int count=1;
- theQuestionList = Global.getQuestionList(e.Result);
- foreach (QuestionOptioner qo in theQuestionList)
- {
- Option o = new Option(qo.ID);
- o.DefaultOption = "A";
- o.SerialNumber = count.ToString();
- o.QuestionName = qo.Text;
- o.OptionA = qo.OptionA;
- o.OptionB = qo.OptionB;
- o.OptionC = qo.OptionC;
- o.OptionD = qo.OptionD;
- this.OptionCanvas.Children.Add(o);
- }
- }
- }
- private void sum_Click(object sender, RoutedEventArgs e)
- {
- WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
- this.HasError = false;
- foreach (Option option in this.OptionCanvas.Children)
- {
- userManageSoapClient.AddResponseAsync(option.GroupName, option.Checked);
- userManageSoapClient.AddResponseCompleted += new EventHandler<SFGS.WebServiceProxy.AddResponseCompletedEventArgs>(userMgrSoapClient_AddResponseCompleted);
- }
- if (!HasError)
- {
- this.theMessagge.Text = "Save Succeed!";
- }
- else
- {
- this.theMessagge.Text = "Has Some Errors!";
- }
- }
- private void userMgrSoapClient_AddResponseCompleted(object sender,SFGS.WebServiceProxy.AddResponseCompletedEventArgs e)
- {
- if (e.Result==false)
- {
- HasError = true;
- }
- }
- }
- }