Example #1
0
        /// <summary>
        /// Handles the ServerClick event of the imbtnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void imbtnSave_ServerClick(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            if (mc == null)             // Create
            {
                try
                {
                    mc = MetaDataWrapper.CreateCard(ddlClass.SelectedValue,
                                                    txtClassName.Text.Trim(), txtClassFriendlyName.Text.Trim(), txtClassPluralName.Text.Trim());

                    FormDocument fDocBase = FormController.CreateFormDocument(mc.Name, FormController.BaseFormName);
                    fDocBase.Save();

                    FormDocument fDocCreate = FormController.CreateFormDocument(mc.Name, FormController.CreateFormName);
                    fDocCreate.Save();

                    Response.Redirect(String.Format("~/Apps/MetaDataBase/Pages/Admin/MetaClassView.aspx?class={0}", mc.Name), true);
                }
                catch (MetaClassAlreadyExistsException)
                {
                    lbError.Text    = string.Format(GetGlobalResourceObject("GlobalMetaInfo", "CardExistsErrorMessage").ToString(), "'" + txtClassName.Text.Trim() + "'");
                    lbError.Visible = true;
                }
            }
            else              // Update
            {
                MetaDataWrapper.UpdateCard(mc, txtClassFriendlyName.Text.Trim(), txtClassPluralName.Text.Trim());

                if (Back == "list")
                {
                    Response.Redirect("~/Apps/MetaDataBase/Pages/Admin/MetaClassList.aspx", true);
                }
                else
                {
                    Response.Redirect(String.Format("~/Apps/MetaDataBase/Pages/Admin/MetaClassView.aspx?class={0}", mc.Name), true);
                }
            }
        }
Example #2
0
        protected void lbReCreate_Click(object sender, EventArgs e)
        {
            FormDocumentData = FormController.CreateFormDocument(MetaClassName, FormName);

            BindRendererInner();
        }
Example #3
0
        /// <summary>
        /// Handles the ServerClick event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnSave_ServerClick(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            if (!String.IsNullOrEmpty(uid))
            {
                #region Edit
                string columns   = FormDocumentData.FormTable.Columns;
                int    colsCount = columns.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Length;
                bool   needToAdd = false;
                if (!rb11.Disabled && rb11.Checked)
                {
                    columns = "50%;*";
                }

                if (!rb12.Disabled && rb12.Checked)
                {
                    columns = "35%;*";
                }

                if (!rb21.Disabled && rb21.Checked)
                {
                    columns = "*;35%";
                }

                if (!rb111.Disabled && rb111.Checked)
                {
                    columns = "33%;33%;*";
                    if (colsCount < 3)
                    {
                        needToAdd = true;
                    }
                }

                FormDocumentData.FormTable.Columns = columns;
                if (needToAdd)
                {
                    foreach (FormRow row in FormDocumentData.FormTable.Rows)
                    {
                        bool needCell = false;
                        foreach (FormCell cell in row.Cells)
                        {
                            if (cell.ColSpan > 1 && cell.ColSpan < 3)
                            {
                                cell.ColSpan = 3;
                            }
                            if (cell.ColSpan == 1)
                            {
                                needCell = true;
                            }
                        }
                        if (needCell)
                        {
                            FormCell cell = new FormCell("cell_23", 1);
                            row.Cells.Add(cell);
                        }
                    }
                }

                if (!String.IsNullOrEmpty(txtCellPadding.Text))
                {
                    FormDocumentData.FormTable.CellPadding = int.Parse(txtCellPadding.Text);
                }
                #endregion
            }
            else
            {
                #region Create
                string className = ddClasses.SelectedValue;
                try
                {
                    string formName = "";
                    if (!MetaUIManager.MetaUITypeIsSystem(ddClasses.SelectedValue, ddFormType.SelectedValue))
                    {
                        formName = txtTitle.Text;
                    }
                    else
                    {
                        formName = ddFormType.SelectedValue;
                    }

                    string columns = "50%;*";

                    if (rb11.Checked)
                    {
                        columns = "50%;*";
                    }
                    else if (rb12.Checked)
                    {
                        columns = "35%;*";
                    }
                    else if (rb21.Checked)
                    {
                        columns = "*;35%";
                    }
                    else if (rb111.Checked)
                    {
                        columns = "33%;33%;*";
                    }

                    //set columns

                    int cellPadding = 5;
                    if (!String.IsNullOrEmpty(txtCellPadding.Text))
                    {
                        cellPadding = int.Parse(txtCellPadding.Text);
                    }

                    FormDocumentData = FormController.CreateFormDocument(className, formName, ddFormType.SelectedValue, columns, Unit.Percentage(100), cellPadding);
                }
                catch
                {
                    lblError.Visible = true;
                    return;
                }
                #endregion
            }

            string newUid = Guid.NewGuid().ToString("N");
            Session[newUid] = FormDocumentData;
            CloseAndRefresh(newUid);
        }