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

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.IO;
  14. namespace SFGS
  15. {
  16.     public partial class Admin : UserControl
  17.     {
  18.         private List<Customer> theSurveyList = new List<Customer>();
  19.         public Admin()
  20.         {
  21.             InitializeComponent();
  22.             UpdateDataGrid();            
  23.         }
  24.         private void UpdateDataGrid()
  25.         {
  26.             WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
  27.             userManageSoapClient.ReadAllSurveyAsync();
  28.             userManageSoapClient.ReadAllSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.ReadAllSurveyCompletedEventArgs>(userMgrSoapClient_ReadAllSurveyCompleted);
  29.         }
  30.         private void userMgrSoapClient_ReadAllSurveyCompleted(object sender, SFGS.WebServiceProxy.ReadAllSurveyCompletedEventArgs e)
  31.         {            
  32.             if (!e.Result.Equals(""))
  33.             {
  34.                 this.theSurveyList = Global.getList(e.Result);                
  35.                 this.dataGrid4.ItemsSource = this.theSurveyList;
  36.                 foreach (Customer customer in this.theSurveyList)
  37.                 {
  38.                     this.theDisplayedSurvey.Items.Add(customer.Name);
  39.                 }
  40.                 UpdateComboBox();
  41.                 return;
  42.             }            
  43.         }       
  44.         private void UpdateComboBox()
  45.         {
  46.             WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
  47.             userManageSoapClient.ReadCurrentSurveyAsync();
  48.             userManageSoapClient.ReadCurrentSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.ReadCurrentSurveyCompletedEventArgs>(userMgrSoapClient_ReadCurrentSurveyCompleted);        
  49.         }
  50.         private void userMgrSoapClient_ReadCurrentSurveyCompleted(object sender, SFGS.WebServiceProxy.ReadCurrentSurveyCompletedEventArgs e)
  51.         {
  52.             if (!e.Result.Equals(""))
  53.             {                
  54.                 for (int i = 0; i < this.theDisplayedSurvey.Items.Count;i++ )
  55.                 {
  56.                     string surveyName=this.theDisplayedSurvey.Items[i].ToString();
  57.                     if (surveyName==e.Result)
  58.                     {
  59.                         this.theDisplayedSurvey.SelectedIndex = i;
  60.                     }
  61.                 }
  62.             }            
  63.         }
  64.         private void btnSaveDisSurvey_Click(object sender, RoutedEventArgs e)
  65.         {
  66.             WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
  67.             userManageSoapClient.WriteCurrentSurveyAsync(this.theDisplayedSurvey.SelectedItem.ToString());
  68.             userManageSoapClient.WriteCurrentSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.WriteCurrentSurveyCompletedEventArgs>(userMgrSoapClient_WriteCurrentSurveyCompleted);        
  69.         }
  70.         //保存当前调查
  71.         private void userMgrSoapClient_WriteCurrentSurveyCompleted(object sender,SFGS.WebServiceProxy.WriteCurrentSurveyCompletedEventArgs e)
  72.         {
  73.             if (e.Result==false)
  74.             {
  75.                 this.theMessage.Text = "Operation Failed!";
  76.             }
  77.             else
  78.             {
  79.                 this.theMessage.Text = "Operation succeed!";
  80.             }
  81.         }
  82.         //登出
  83.         private void logout_Click(object sender, RoutedEventArgs e)
  84.         {
  85.             Login login = new Login();                       
  86.             login.Width = 960;
  87.             login.Height = 700;
  88.             Global.IsLogin = false;
  89.             (Parent as Canvas).Children.Add(login);
  90.             (Parent as Canvas).Children.Remove(this); 
  91.         }
  92.         //新建调查
  93.         private void addNewSurvey_Click(object sender, RoutedEventArgs e)
  94.         {
  95.             //AddSurvery survey = new AddSurvery();
  96.             //survey.Width = 960;
  97.             //survey.Height = 700;
  98.             //(Parent as Canvas).Children.Add(survey);
  99.             //(Parent as Canvas).Children.Remove(this); 
  100.         }
  101.         private void Result_Click(object sender, RoutedEventArgs e)
  102.         {
  103.             //System.Windows.Browser.HtmlPage.Window.Alert((sender as HyperlinkButton).Tag.ToString());
  104.             // TODO: 在此添加调result的页面
  105.         }
  106.         private void Question_Click(object sender, RoutedEventArgs e)
  107.         {
  108.             // TODO: 在此添加调Question的页面
  109.         }
  110.         private void Edit_Click(object sender, RoutedEventArgs e)
  111.         {
  112.             // TODO: 在此添加调Edit的页面
  113.         }
  114.         private void Delete_Click(object sender, RoutedEventArgs e)
  115.         {
  116.             // TODO: 在此添加调Delete的页面
  117.         }
  118.         private void theNew_Click(object sender, RoutedEventArgs e)
  119.         {
  120.             // TODO: 在此添加调新建的页面
  121.         }
  122.     }    
  123. }