Exemplo n.º 1
0
        //admin / director creating form
        protected void CreateFormBtn_Click(object sender, EventArgs e)
        {
            FormResult.Visible = false;

            if (FormName.Text.Length > 0)
            {
                string formJson = formBuilderData.Value.ToString();

                if (formJson.Length > 0 && formJson != "undefined")
                {
                    User user = (User)Session["User"];
                    //updating a form not, creating it
                    if (Request.QueryString["fid"] != null)
                    {
                        int formId = int.Parse(Request.QueryString["fid"]);
                        FormUtil.UpdateFormTemplate(formId, FormName.Text, formJson);
                        Log.Info(user.Identity + " updated a form template " + FormName.Text + " with " + formJson);
                        FormResult.CssClass = "success";
                        FormResult.Text     = "Updated form " + FormName.Text;
                        Response.Redirect("Forms.aspx?fid=" + formId);
                    }
                    else
                    {
                        Form f = FormUtil.CreateFormTemplate(FormName.Text, formJson);
                        Log.Info(user.Identity + " created a form template " + FormName.Text + " with " + formJson);
                        FormResult.CssClass = "success";
                        FormResult.Text     = "Created form " + FormName.Text;
                        Response.Redirect("Forms.aspx?fid=" + f.FormId);
                    }
                }
                else
                {
                    FormResult.CssClass = "error";
                    FormResult.Text     = "Please add elements to the form";
                }
            }
            else
            {
                FormResult.CssClass = "error";
                FormResult.Text     = "Please enter a form name";
            }
            FormResult.Visible = true;
        }