/// <summary>
 /// Deprecated Method for adding a new object to the DesignForms EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDesignForms(DesignForm designForm)
 {
     base.AddObject("DesignForms", designForm);
 }
Example #2
0
        protected void SaveAllTabs()
        {
            // if no session list , do nothing
            if (Session[SessionTabList] == null)
            {
                return;
            }

            // Remove all tab in tab table before save every thing
            List<DesignFormTab> oList = DesignFormTab.LoadListWhere<DesignFormTab>("Where T.FormID=" + eFormID);
            //if (oList.Count() > 0)
            //{
            //    foreach (DesignFormTab otab in oList)
            //    {
            //        DesignFormTab.FinalDelete<DesignFormTab>(otab);
            //    }

            //}
            //Save all session list

            List<DesignFormTab> oTabList = Session[SessionTabList] as List<DesignFormTab>;
            if (eFormID == 0)
            {
                DesignForm oForm = new DesignForm();
                if (this.txtFormName.Text != string.Empty)
                {
                    oForm.Name = this.txtFormName.Text;
                }
                oForm.ApplicaitonID = 4;
                oForm.Type = 1; // Resource type in design form table
                DesignForm.Save<DesignForm>(oForm);
                eFormID = oForm.FormID;
                foreach ( DesignFormTab oTab in oTabList   )
                {
                    oTab.FormID = oForm.FormID;

                }

            }

            foreach (DesignFormTab oRealTab in oTabList)
            {

                DesignFormTab.Save<DesignFormTab>(oRealTab);
            }
        }
 /// <summary>
 /// Create a new DesignForm object.
 /// </summary>
 /// <param name="formID">Initial value of the FormID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 /// <param name="createdBy">Initial value of the CreatedBy property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 public static DesignForm CreateDesignForm(global::System.Int32 formID, global::System.String name, global::System.Boolean isDeleted, global::System.Int32 createdBy, global::System.DateTime createdDate)
 {
     DesignForm designForm = new DesignForm();
     designForm.FormID = formID;
     designForm.Name = name;
     designForm.IsDeleted = isDeleted;
     designForm.CreatedBy = createdBy;
     designForm.CreatedDate = createdDate;
     return designForm;
 }
Example #4
0
        protected void FieldAdd(object sender, EventArgs e)
        {
            // SaveAllFields();
            SetAllPositions();
            GetNewFieldName();

            foreach (AccordionPane Panes in accordionFormDesign.Panes)
            {

                Panes.Enabled = true;
            }

            // SetControlPosition(ddlCurrentTab.SelectedValue == string.Empty ? string.Empty  : ddlCurrentTab.SelectedValue);
            if (!IsAControlbeingSelected())
            {
                return;
            }

            if (!IsValidNewField())
            {
                return;
            };

            if (!IsValidControlName(true))
            {
                return;
            }

            DesignFormField.checkFieldMax(true, eFormID);
            if (DesignFormField.error != string.Empty)
            {
                Guid oMaxguid = new Guid();
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), oMaxguid.ToString(), "callBoxFancy('eFormWarnStatus','" + DesignFormField.error + "');", true);
                return;
            }

            if (lstTabList.SelectedValue == "-1")
            {
                Guid oNewTab = new Guid();
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), oNewTab.ToString(), "callBoxFancy('eFormWarnStatus','" + ValidationNewTabMessage_Message + "');", true);
                return;

            }

            // ini position
            string StartPos = "0";
            string ControlLeft = "0";
            //string ImageStartPos = "10";
            //string ImageLeftPos = "300";

            DesignFormField oDesign = new DesignFormField();

            // get control name and field name
            System.Web.UI.Control oControl = new System.Web.UI.Control();
            System.Web.UI.Control oLabel = CreateLabel(txtLabelName.Text, txtLabelName.Text);
            oLabel.SkinID = "Editorlabel";
            if (this.accordionFormDesign.SelectedIndex == 0)
            {
                oControl = CreateTextBox(txtTextBoxName.Text, out oDesign, true) as System.Web.UI.Control;

            }
            else if (this.accordionFormDesign.SelectedIndex == 1)
            {
                oControl = CreateDropDownList(txtTextBoxName.Text, out oDesign, true) as System.Web.UI.Control;

            }
            else if (this.accordionFormDesign.SelectedIndex == 2)
            {
                oControl = CreateCheckbox(txtTextBoxName.Text, out oDesign, true) as System.Web.UI.Control;

            }
            else if (this.accordionFormDesign.SelectedIndex == 3)
            {
                oControl = CreateDate(txtTextBoxName.Text, out oDesign, true) as System.Web.UI.Control;

            }

            else if (this.accordionFormDesign.SelectedIndex == 4)
            {
                oControl = CreateImage(txtTextBoxName.Text, out oDesign, true) as System.Web.UI.Control;

            }
            else if (this.accordionFormDesign.SelectedIndex == 5)
            {
                oControl = CreateHyperLink(txtTextBoxName.Text, out oDesign, true) as System.Web.UI.Control;

            }
            oDesign.Name = txtTextBoxName.Text.Replace(" ", string.Empty);

            Label oAtLabel = oLabel as Label;
            if (this.accordionFormDesign.SelectedIndex != 5)
            {
                oDesign.Label = oAtLabel.Text;
            }
            oDesign.ControlType = iControlType;
            oDesign.IsVisible = this.chkFieldVisible.Checked == true ? true : false;
            oDesign.IsEnabled = this.chkFieldEnabled.Checked == true ? true : false;
            DesignFormTab otab = new DesignFormTab();
            if (ddlCurrentTab.SelectedValue != string.Empty)
            {
                //add form first if form id is 0
                if (eFormID == 0)
                {
                    DesignForm oform = new DesignForm();
                    oform.Name = txtFormName.Text;
                    eFormName = txtFormName.Text;
                    oform.Type = 1;
                    DesignForm.Save(oform);
                    eFormID = oform.FormID;
                }

                if (Session[SessionTabList] != null)
                {
                    List<DesignFormTab> oList = Session[SessionTabList] as List<DesignFormTab>;

                    // save all table if form id is 0
                    foreach (DesignFormTab ot in oList)
                    {
                        if (!DesignFormTab.IsTabNameExist(eFormID, string.Empty, ot.Name))
                        {
                            //string Tabmsg = ValidationTabNameAlreadyExist_Message;
                            //Guid oTabguid = new Guid();
                            //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), oTabguid.ToString(), "callBoxFancy('eFormWarnStatus','" + Tabmsg + "');", true);
                            if (!ot.IsSysUse)
                            {

                                //return;

                                ot.FormID = eFormID;
                                DesignFormTab.Save<DesignFormTab>(ot);
                            }
                            // update tab list
                            //List<DesignFormTab> oNewList = DesignFormTab.GetDataBy(eFormID);
                            //Session[SessionTabList] = oNewList;

                        }

                    }

                    this.ActiveTabID = ddlCurrentTab.SelectedValue;
                    var otablist = from o in oList
                                   where o.SysIdentity == ddlCurrentTab.SelectedValue
                                   select o;
                    if (otablist != null && otablist.Count() > 0)
                    {
                        DesignFormTab
                        ofield = otablist.FirstOrDefault();
                        oDesign.TabID = ofield.FormTabID;
                        oDesign.FormID = eFormID;
                        otab = ofield;

                    }

                    else
                    {
                        oDesign.TabID = 1;
                    }
                }
            }
            else
            {
                oDesign.TabID = 1;

            }
            oDesign.SkinID = oControl.SkinID;
            oDesign.IsSearch = false;
            oDesign.FormID = eFormID;

            int fieldId = oDesign.FieldID;

            //Label css position style
            String cssStyle = string.Empty;
            cssStyle = FormDesign.ccsRelative + FormDesign.ccsTop + StartPos + FormDesign.ccsPX;
            cssStyle = cssStyle + FormDesign.ccsLeft + StartPos + FormDesign.ccsPX;

            int labelLength = txtLabelName.Text.Length + 80;

            // add control to panel
            if (CurrentTab != null)
            {
                if (this.ddlCurrentTab.SelectedValue != string.Empty)
                {
                    // DesignFormTab otab = DesignFormTab.GetDataBySysIdentity(eFormID,ddlCurrentTab.SelectedValue);
                    TabPanel oPanel = CurrentTab.FindControl(otab.SysIdentity) as TabPanel;
                    if (oPanel != null)
                    {
                        LiteralControl oLabelLiteral = new LiteralControl();
                        oLabelLiteral.Text = "<div id=\"DIV" + oControl.ID + "\" Style='" + cssStyle + "' class='" + this.dragcssClass + "'  >";

                        oPanel.Controls.Add(oLabelLiteral);
                        oPanel.Controls.Add(oLabel);
                        LiteralControl oLabelEndLiteral = new LiteralControl();
                        string endDiv = "</div>";
                        if ((this.accordionFormDesign.SelectedIndex == 0) && (this.chkMandatory.Checked))
                        {
                            endDiv = "<span style='Color: red'>*</span></div>";
                        }
                        oLabelEndLiteral.Text = endDiv;

                        //redefine css style
                        cssStyle = FormDesign.ccsRelative + FormDesign.ccsTop + StartPos + FormDesign.ccsPX;
                        cssStyle = cssStyle + FormDesign.ccsLeft + " " + labelLength.ToString() + FormDesign.ccsPX;

                        oPanel.Controls.Add(oLabelEndLiteral);
                        LiteralControl oLiteral = new LiteralControl();

                        oLiteral.Text = "<Div id=\"DIV" + oControl.ID + "\" Style='" + cssStyle + "' class='" + this.dragcssClass + "'  >";
                        // oLabel.Attributes.Add(AppConstManager.cStyle, cssStyle);
                        oPanel.Controls.Add(oLiteral);
                        oPanel.Controls.Add(oControl);
                        LiteralControl oEndLiteral = new LiteralControl();
                        oEndLiteral.Text = "</Div>";
                        oPanel.Controls.Add(oEndLiteral);

                    }
                }

            }
            else
            {
                CurrentPanel.Controls.Add(oLabel);
                CurrentPanel.Controls.Add(oControl);
            }
            oDesign.ControlLeft = labelLength;
            oDesign.ControlTop = Convert.ToInt16(StartPos);
            oDesign.LabelLeft = 0;
            oDesign.LabelTop = Convert.ToInt16(StartPos);

            DesignFormField.Save<DesignFormField>(oDesign);
            Guid gMessage = Guid.NewGuid();
            //string sJavascript = "eFormChangeClassForDrag('" + cssDragClass + "', true);editbox_init()";
            LoadFieldDetail();
            bntFieldAdd.Enabled = false;
            int count = 0;
            foreach (ListItem oItem in ddlFields.Items)
            {
                if (oItem.Value == oDesign.FieldID.ToString())
                {
                    ddlFields.SelectedIndex = count;
                    break;
                }
                count++;
            }

            hidFieldID.Value = oDesign.FieldID.ToString();
            hidControlList.Value = hidControlList.Value + "";
            hidLabelList.Value = hidLabelList.Value + "";
            string sJavascript = "editbox_init()";
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), gMessage.ToString(), sJavascript, true);
            string msg = Action_FieldAdd_Message;
            CreateFormDesignScript("Main", UpdatePanel1, TabContainer1);
            IsEnable = true;
            AccordingIndex = accordionFormDesign.SelectedIndex;
            string SelectedValue = string.Empty;
            if (lstTabList.SelectedValue == string.Empty)
            {
                SelectedValue = lstTabList.Items[0].Value;
            }
            else
            {
                SelectedValue = lstTabList.SelectedValue;
            }
            SetTab(SelectedValue);

            if (ddlFields.SelectedValue != "-1")
            {
                bntFieldDelete.Enabled = true;
            }

            SelectedValue =   this.ddlCurrentTab.SelectedValue;
            TabContainer1.Tabs[1].Enabled = true;
            bntSaveAllFields.Enabled = true;
            Guid oguid = new Guid();
            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), oguid.ToString(), "callBoxFancy('eFormSucessStatus','" + msg + "');", true);
        }