AddSurvery.xaml.cs
上传用户:jxqhsy
上传日期:2020-12-31
资源大小:1793k
文件大小:9k
- 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 AddSurvery : UserControl
- {
- string title ="";
- string desc = "";
- string question ="";
- string stra ="";
- string strb = "";
- string strc = "";
- string strd = "";
- int Suvery = 0;
- public AddSurvery()
- {
- InitializeComponent();
- }
- private void preview_Click(object sender, RoutedEventArgs e)
- {
- if (cn1.Visibility == Visibility.Visible)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Visible;
- }
- else if (cn2.Visibility == Visibility.Visible)
- {
- cn1.Visibility = Visibility.Visible;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Collapsed;
- }
- else if (cn3.Visibility == Visibility.Visible)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Visible;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Collapsed;
- }
- else if (cn4.Visibility == Visibility.Visible)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Visible;
- cn4.Visibility = Visibility.Collapsed;
- }
- }
- private void next_Click(object sender, RoutedEventArgs e)
- {
- if (cn1.Visibility == Visibility.Visible)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Visible;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Collapsed;
- }
- else if (cn2.Visibility == Visibility.Visible)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Visible;
- cn4.Visibility = Visibility.Collapsed;
- }
- else if (cn3.Visibility == Visibility.Visible)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Visible;
- }
- else if (cn4.Visibility == Visibility.Visible)
- {
- cn1.Visibility = Visibility.Visible;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Collapsed;
- }
- }
- private void start_Click(object sender, RoutedEventArgs e)
- {
- cn1.Visibility = Visibility.Visible;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Collapsed;
- }
- private void entertitle_Click(object sender, RoutedEventArgs e)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Visible;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Collapsed;
- }
- private void enterdes_Click(object sender, RoutedEventArgs e)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Visible;
- cn4.Visibility = Visibility.Collapsed;
- }
- private void addquestion_Click(object sender, RoutedEventArgs e)
- {
- cn1.Visibility = Visibility.Collapsed;
- cn2.Visibility = Visibility.Collapsed;
- cn3.Visibility = Visibility.Collapsed;
- cn4.Visibility = Visibility.Visible;
- }
- private void done_Click(object sender, RoutedEventArgs e)
- {
- if (Title.Text == "")
- {
- System.Windows.Browser.HtmlPage.Window.Alert("Title must be in put");
- return;
- }
- if (Description.Text == "")
- {
- System.Windows.Browser.HtmlPage.Window.Alert("Description must be in put");
- return;
- }
- WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
- userManageSoapClient.AddSurveyAsync(Title.Text, Description.Text,System.DateTime.Now.ToShortDateString(),"0");
- userManageSoapClient.AddSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.AddSurveyCompletedEventArgs>(userMgrSoapClient_AddSurveyCompleted);
- userManageSoapClient.ReadMaxSurveyAsync();
- userManageSoapClient.ReadMaxSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.ReadMaxSurveyCompletedEventArgs>(userMgrSoapClient_SurveyCompleted);
-
- }
- private void userMgrSoapClient_AddSurveyCompleted(object sender, SFGS.WebServiceProxy.AddSurveyCompletedEventArgs e)
- {
- if (e.Result)
- {
- System.Windows.Browser.HtmlPage.Window.Alert("success");
- }
- else {
- System.Windows.Browser.HtmlPage.Window.Alert("failer");
- }
-
- }
- private void Save_Click(object sender, RoutedEventArgs e)
- {
- if (id.Text == "")
- {
- System.Windows.Browser.HtmlPage.Window.Alert("please click done to make a new Survey");
- return;
- }
- if (string.IsNullOrEmpty(questionA.Text))
- {
- System.Windows.Browser.HtmlPage.Window.Alert("chioce A must in put");
- return;
- }
- if (string.IsNullOrEmpty(questionB.Text))
- {
- System.Windows.Browser.HtmlPage.Window.Alert("chioce B must in put");
- return;
- }
- if (string.IsNullOrEmpty(questionC.Text))
- {
- System.Windows.Browser.HtmlPage.Window.Alert("chioce C must in put");
- return;
- }
- if (string.IsNullOrEmpty(questionD.Text))
- {
- System.Windows.Browser.HtmlPage.Window.Alert("chioce D must in put");
- return;
- }
-
- WebServiceProxy.UserManageSoapClient userManageSoapClient = new SFGS.WebServiceProxy.UserManageSoapClient();
- //userManageSoapClient.ReadMaxSurveyAsync();
- //userManageSoapClient.ReadMaxSurveyCompleted += new EventHandler<SFGS.WebServiceProxy.ReadMaxSurveyCompletedEventArgs>(userMgrSoapClient_SurveyCompleted);
- userManageSoapClient.AddQuestionAsync(id.Text, Question.Text, questionA.Text, questionB.Text, questionC.Text, questionD.Text);
- userManageSoapClient.AddQuestionCompleted += new EventHandler<SFGS.WebServiceProxy.AddQuestionCompletedEventArgs>(userMgrSoapClient_AddQuestionCompleted);
- }
- private void userMgrSoapClient_SurveyCompleted(object sender, SFGS.WebServiceProxy.ReadMaxSurveyCompletedEventArgs e)
- {
-
- String xmlString = e.Result;
- if ("false".Equals(xmlString))
- {
- //exception
- }
- else if ("".Equals(xmlString))
- {
- if (id.Text == "")
- {
- id.Text = "1";
- }
- }
- else
- {
- if (id.Text == "")
- {
- id.Text = xmlString;
- }
- }
- }
- private void userMgrSoapClient_AddQuestionCompleted(object sender, SFGS.WebServiceProxy.AddQuestionCompletedEventArgs e)
- {
-
-
- if (e.Result == true)
- {
- System.Windows.Browser.HtmlPage.Window.Alert("insert success");
- }
- else
- {
- System.Windows.Browser.HtmlPage.Window.Alert("Error");
- }
- }
- //public class Item
- //{
- // public string ID { get; set; }
- // public string Name { get; set; }
- // public string Description { get; set; }
- // public string Text { get; set; }
- // public string OptionA { get; set; }
- // public string OptionB { get; set; }
- // public string OptionC { get; set; }
- // public string OptionD { get; set; }
- //}
- }
-
- }
-