Survey.xaml.cs
上传用户:jxqhsy
上传日期:2020-12-31
资源大小:1793k
文件大小:4k
源码类别:

SilverLight

开发平台:

HTML/CSS

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12. using System.Xml;
  13. using System.Text;
  14. using System.Diagnostics;
  15. using System.IO;
  16. namespace SFGS
  17. {   
  18.     public partial class Survey : UserControl
  19.     {
  20.         private bool HasError = false;
  21.   
  22.         public Survey()
  23.         {
  24.             InitializeComponent();            
  25.         }
  26.         public Survey(string SurveyID)
  27.         {
  28.             InitializeComponent();
  29.             UpdateSurveyContent();
  30.             UpdateQuestionOption(SurveyID);
  31.         }
  32.         private void UpdateSurveyContent()
  33.         {
  34.             WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
  35.             userManageSoapClient.ReadAllSurveyAsync();
  36.             userManageSoapClient.ReadAllSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.ReadAllSurveyCompletedEventArgs>(userMgrSoapClient_ReadAllSurveyCompleted);
  37.         
  38.         }
  39.         private void userMgrSoapClient_ReadAllSurveyCompleted(object sender, SFGS.WebServiceProxy.ReadAllSurveyCompletedEventArgs e)
  40.         {
  41.             List<Customer> theSurveyList = new List<Customer>();
  42.             if (!e.Result.Equals(""))
  43.             {
  44.                 theSurveyList = Global.getList(e.Result);
  45.                 foreach (Customer ctm in theSurveyList)
  46.                 {
  47.                     if (ctm.IsCurrentSurvey == "1")
  48.                     {
  49.                         this.title.Text = ctm.Name;
  50.                         this.desc.Text = ctm.Description;
  51.                         break;
  52.                     }
  53.                 }
  54.             }
  55.             else
  56.             {
  57.                 this.title.Text = "No Content";
  58.                 this.desc.Text = "No Content";
  59.             }
  60.         }  
  61.   
  62.         private void UpdateQuestionOption(string SurveyID)
  63.         {
  64.             WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
  65.             userManageSoapClient.ReadQuestionAsync(SurveyID);
  66.             userManageSoapClient.ReadQuestionCompleted += new EventHandler<SFGS.WebServiceProxy.ReadQuestionCompletedEventArgs>(userMgrSoapClient_ReadQuestionCompleted);
  67.         }
  68.         private void userMgrSoapClient_ReadQuestionCompleted(object sender,SFGS.WebServiceProxy.ReadQuestionCompletedEventArgs e)
  69.         {
  70.             List<QuestionOptioner> theQuestionList;
  71.             if (!e.Result.Equals(""))
  72.             {
  73.                 int count=1;
  74.                 theQuestionList = Global.getQuestionList(e.Result);
  75.                 foreach (QuestionOptioner qo in theQuestionList)
  76.                 {
  77.                     Option o = new Option(qo.ID);
  78.                     o.DefaultOption = "A";
  79.                     o.SerialNumber = count.ToString();
  80.                     o.QuestionName = qo.Text;
  81.                     o.OptionA = qo.OptionA;
  82.                     o.OptionB = qo.OptionB;
  83.                     o.OptionC = qo.OptionC;
  84.                     o.OptionD = qo.OptionD;
  85.                     this.OptionCanvas.Children.Add(o);
  86.                 }
  87.             }
  88.         }
  89.         private void sum_Click(object sender, RoutedEventArgs e)
  90.         {            
  91.             WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
  92.             this.HasError = false;
  93.             foreach (Option option in this.OptionCanvas.Children)
  94.             {              
  95.                 userManageSoapClient.AddResponseAsync(option.GroupName, option.Checked);
  96.                 userManageSoapClient.AddResponseCompleted += new EventHandler<SFGS.WebServiceProxy.AddResponseCompletedEventArgs>(userMgrSoapClient_AddResponseCompleted);        
  97.             }
  98.             
  99.             if (!HasError)
  100.             {
  101.                 this.theMessagge.Text = "Save Succeed!";
  102.             }
  103.             else
  104.             {
  105.                 this.theMessagge.Text = "Has Some Errors!";
  106.             }
  107.         }
  108.         private void userMgrSoapClient_AddResponseCompleted(object sender,SFGS.WebServiceProxy.AddResponseCompletedEventArgs e)
  109.         {
  110.             if (e.Result==false)
  111.             {
  112.                 HasError = true;
  113.             }
  114.         }
  115.     }
  116. }