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

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 AddSurvery : UserControl
  19.     {
  20.         string title ="";
  21.         string desc = "";
  22.         string question ="";
  23.         string stra ="";
  24.         string strb = "";
  25.         string strc = "";
  26.         string strd = "";
  27.         int  Suvery = 0;
  28.         public AddSurvery()
  29.         {
  30.             InitializeComponent();
  31.         }
  32.         private void preview_Click(object sender, RoutedEventArgs e)
  33.         {
  34.             if (cn1.Visibility == Visibility.Visible) 
  35.             {
  36.                 cn1.Visibility = Visibility.Collapsed;
  37.                 cn2.Visibility = Visibility.Collapsed;
  38.                 cn3.Visibility = Visibility.Collapsed;
  39.                 cn4.Visibility = Visibility.Visible;
  40.             }
  41.             else if (cn2.Visibility == Visibility.Visible) 
  42.             {
  43.                 cn1.Visibility = Visibility.Visible;
  44.                 cn2.Visibility = Visibility.Collapsed;
  45.                 cn3.Visibility = Visibility.Collapsed;
  46.                 cn4.Visibility = Visibility.Collapsed;
  47.             }
  48.             else if (cn3.Visibility == Visibility.Visible)
  49.             {
  50.                 cn1.Visibility = Visibility.Collapsed;
  51.                 cn2.Visibility = Visibility.Visible;
  52.                 cn3.Visibility = Visibility.Collapsed;
  53.                 cn4.Visibility = Visibility.Collapsed;
  54.             }
  55.             else if (cn4.Visibility == Visibility.Visible)
  56.             {
  57.                 cn1.Visibility = Visibility.Collapsed;
  58.                 cn2.Visibility = Visibility.Collapsed;
  59.                 cn3.Visibility = Visibility.Visible;
  60.                 cn4.Visibility = Visibility.Collapsed;
  61.             }
  62.         }
  63.         private void next_Click(object sender, RoutedEventArgs e)
  64.         {
  65.             if (cn1.Visibility == Visibility.Visible)
  66.             {
  67.                 cn1.Visibility = Visibility.Collapsed;
  68.                 cn2.Visibility = Visibility.Visible;
  69.                 cn3.Visibility = Visibility.Collapsed;
  70.                 cn4.Visibility = Visibility.Collapsed;
  71.             }
  72.             else if (cn2.Visibility == Visibility.Visible)
  73.             {
  74.                 cn1.Visibility = Visibility.Collapsed;
  75.                 cn2.Visibility = Visibility.Collapsed;
  76.                 cn3.Visibility = Visibility.Visible;
  77.                 cn4.Visibility = Visibility.Collapsed;
  78.             }
  79.             else if (cn3.Visibility == Visibility.Visible)
  80.             {
  81.                 cn1.Visibility = Visibility.Collapsed;
  82.                 cn2.Visibility = Visibility.Collapsed;
  83.                 cn3.Visibility = Visibility.Collapsed;
  84.                 cn4.Visibility = Visibility.Visible;
  85.             }
  86.             else if (cn4.Visibility == Visibility.Visible)
  87.             {
  88.                 cn1.Visibility = Visibility.Visible;
  89.                 cn2.Visibility = Visibility.Collapsed;
  90.                 cn3.Visibility = Visibility.Collapsed;
  91.                 cn4.Visibility = Visibility.Collapsed;
  92.             }
  93.         }
  94.         private void start_Click(object sender, RoutedEventArgs e)
  95.         {
  96.             cn1.Visibility = Visibility.Visible;
  97.             cn2.Visibility = Visibility.Collapsed;
  98.             cn3.Visibility = Visibility.Collapsed;
  99.             cn4.Visibility = Visibility.Collapsed;
  100.         }
  101.         private void entertitle_Click(object sender, RoutedEventArgs e)
  102.         {
  103.             cn1.Visibility = Visibility.Collapsed;
  104.             cn2.Visibility = Visibility.Visible;
  105.             cn3.Visibility = Visibility.Collapsed;
  106.             cn4.Visibility = Visibility.Collapsed;
  107.         }
  108.         private void enterdes_Click(object sender, RoutedEventArgs e)
  109.         {
  110.             cn1.Visibility = Visibility.Collapsed;
  111.             cn2.Visibility = Visibility.Collapsed;
  112.             cn3.Visibility = Visibility.Visible;
  113.             cn4.Visibility = Visibility.Collapsed;
  114.         }
  115.         private void addquestion_Click(object sender, RoutedEventArgs e)
  116.         {
  117.             cn1.Visibility = Visibility.Collapsed;
  118.             cn2.Visibility = Visibility.Collapsed;
  119.             cn3.Visibility = Visibility.Collapsed;
  120.             cn4.Visibility = Visibility.Visible;
  121.         }
  122.         private void done_Click(object sender, RoutedEventArgs e)
  123.         {
  124.             if (Title.Text == "") 
  125.             {
  126.                 System.Windows.Browser.HtmlPage.Window.Alert("Title  must be in put");
  127.                 return;
  128.             }
  129.             if (Description.Text == "")
  130.             {
  131.                 System.Windows.Browser.HtmlPage.Window.Alert("Description  must be in put");
  132.                 return;
  133.             }
  134.             WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
  135.             userManageSoapClient.AddSurveyAsync(Title.Text, Description.Text,System.DateTime.Now.ToShortDateString(),"0");
  136.             userManageSoapClient.AddSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.AddSurveyCompletedEventArgs>(userMgrSoapClient_AddSurveyCompleted);
  137.             userManageSoapClient.ReadMaxSurveyAsync();
  138.             userManageSoapClient.ReadMaxSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.ReadMaxSurveyCompletedEventArgs>(userMgrSoapClient_SurveyCompleted);
  139.           
  140.         }
  141.         private void userMgrSoapClient_AddSurveyCompleted(object sender, SFGS.WebServiceProxy.AddSurveyCompletedEventArgs e) 
  142.         {
  143.             if (e.Result)
  144.             {
  145.                 System.Windows.Browser.HtmlPage.Window.Alert("success");
  146.             }
  147.             else {
  148.                 System.Windows.Browser.HtmlPage.Window.Alert("failer");
  149.             }
  150.         
  151.         }
  152.         private void Save_Click(object sender, RoutedEventArgs e)
  153.         {
  154.             if (id.Text == "")
  155.             {
  156.                 System.Windows.Browser.HtmlPage.Window.Alert("please click done to  make a new Survey");
  157.                 return;
  158.             }
  159.             if (string.IsNullOrEmpty(questionA.Text)) 
  160.             {
  161.                 System.Windows.Browser.HtmlPage.Window.Alert("chioce A must in put");
  162.                 return;
  163.             }
  164.             if (string.IsNullOrEmpty(questionB.Text))
  165.             {
  166.                 System.Windows.Browser.HtmlPage.Window.Alert("chioce B must in put");
  167.                 return;
  168.             }
  169.             if (string.IsNullOrEmpty(questionC.Text))
  170.             {
  171.                 System.Windows.Browser.HtmlPage.Window.Alert("chioce C must in put");
  172.                 return;
  173.             }
  174.             if (string.IsNullOrEmpty(questionD.Text))
  175.             {
  176.                 System.Windows.Browser.HtmlPage.Window.Alert("chioce D must in put");
  177.                 return;
  178.             }
  179.             
  180.             WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
  181.             //userManageSoapClient.ReadMaxSurveyAsync();
  182.             //userManageSoapClient.ReadMaxSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.ReadMaxSurveyCompletedEventArgs>(userMgrSoapClient_SurveyCompleted);
  183.             userManageSoapClient.AddQuestionAsync(id.Text, Question.Text, questionA.Text, questionB.Text, questionC.Text, questionD.Text);
  184.             userManageSoapClient.AddQuestionCompleted += new EventHandler<SFGS.WebServiceProxy.AddQuestionCompletedEventArgs>(userMgrSoapClient_AddQuestionCompleted);
  185.         }
  186.         private void userMgrSoapClient_SurveyCompleted(object sender, SFGS.WebServiceProxy.ReadMaxSurveyCompletedEventArgs e)
  187.         {
  188.            
  189.            String xmlString = e.Result;
  190.            if ("false".Equals(xmlString))
  191.            {
  192.                //exception
  193.            }
  194.            else if ("".Equals(xmlString))
  195.            {
  196.                if (id.Text == "")
  197.                {
  198.                    id.Text = "1";
  199.                }  
  200.            }
  201.            else 
  202.            {
  203.                if (id.Text == "")
  204.                {
  205.                    id.Text = xmlString;
  206.                } 
  207.            } 
  208.         }
  209.         private void userMgrSoapClient_AddQuestionCompleted(object sender, SFGS.WebServiceProxy.AddQuestionCompletedEventArgs e)
  210.         {
  211.             
  212.             
  213.             if (e.Result == true)
  214.             {
  215.                 System.Windows.Browser.HtmlPage.Window.Alert("insert success");
  216.             }
  217.             else
  218.             {
  219.                 System.Windows.Browser.HtmlPage.Window.Alert("Error");
  220.             }
  221.         }
  222.         //public class Item
  223.         //{
  224.         //    public string ID { get; set; }
  225.         //    public string Name { get; set; }
  226.         //    public string Description { get; set; }
  227.         //    public string Text { get; set; }
  228.         //    public string OptionA { get; set; }
  229.         //    public string OptionB { get; set; }
  230.         //    public string OptionC { get; set; }
  231.         //    public string OptionD { get; set; }
  232.         //}
  233.     }
  234.    
  235. }
  236.