Ejemplo n.º 1
0
    protected void vSave_Click(object sender, EventArgs e)
    {
        try
        {
            List <string> Errors = new List <string>();

            //Title
            string Title = this.vTitle.Text.Trim();
            if (string.IsNullOrWhiteSpace(Title) == true)
            {
                Errors.Add("問題不能為空");
            }

            //ShortTitle
            string ShortTitle = this.vShortTitle.Text.Trim();
            if (string.IsNullOrWhiteSpace(ShortTitle) == true)
            {
                Errors.Add("問題簡述不能為空");
            }

            //vOptionType
            OptionType OptionType = (OptionType)Enum.Parse(typeof(OptionType), this.vOptionType.SelectedValue);

            //vOptions
            string Options = this.vOptions.Text.Trim().Replace(" ", "");
            if (string.IsNullOrWhiteSpace(Options) == true)
            {
                Errors.Add("選項不能為空");
            }

            //Sort
            int Sort;
            if (int.TryParse(this.vSort.Text.Trim(), out Sort) == false)
            {
                Errors.Add("排序格式不正確");
            }

            if (Errors.Count > 0)
            {
                throw new Exception(string.Join("\\r\\n", Errors.ToArray()));
            }

            _QuestionnaireItem.Title      = Title;
            _QuestionnaireItem.ShortTitle = ShortTitle;
            _QuestionnaireItem.OptionType = OptionType;
            _QuestionnaireItem.Options    = Options.Split(',').ToList();
            _QuestionnaireItem.Sort       = Sort;

            QuestionnaireItemManager.Save(_QuestionnaireItem);

            LeftHand.Gadget.Dialog.AlertWithCloseFancybox("儲存成功");
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Exception", "alert('" + ex.Message + "');", true);
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _CurrentOrderItem = OrderItemManager.GetTemp();
        if (_CurrentOrderItem == null)
        {
            Response.Redirect("Order_Form.aspx");
        }

        _QuestionnaireItems = QuestionnaireItemManager.GetAll();

        _Results = _CurrentOrderItem.QuestionResult.Split(new string[] { "<br />" }, StringSplitOptions.RemoveEmptyEntries).ToList();
    }
Ejemplo n.º 3
0
    protected void vDelete_Click(object sender, EventArgs e)
    {
        try
        {
            QuestionnaireItemManager.Remove(_QuestionnaireItem);

            LeftHand.Gadget.Dialog.AlertWithCloseFancybox("刪除成功");
        }
        catch (Exception ex)
        {
            LeftHand.Gadget.Dialog.Alert(ex.Message);
        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            _Argument = LeftHand.Gadget.Encoder.DictionaryDecoder(Server.UrlDecode(Request.QueryString.ToString()));
        }

        switch (_Argument["Mode"])
        {
        case "Add":
            _QuestionnaireItem = new QuestionnaireItem("", "", OptionType.單選);
            break;

        case "Edit":
            _QuestionnaireItem = QuestionnaireItemManager.GetById(_Argument["Id"]);
            break;
        }
    }
Ejemplo n.º 5
0
 private void Render_vQuestionnaireItemList()
 {
     this.vQuestionnaireItem.DataSource = QuestionnaireItemManager.GetAll();
     this.vQuestionnaireItem.DataBind();
 }