/// <summary> /// Binds the forms. /// </summary> private void BindForms() { string className = MetaClassName; if (CanAddNewForm) { ddFormName.Items.Clear(); FormDocument[] mas = FormDocument.GetFormDocuments(className); foreach (FormDocument fd in mas) { ddFormName.Items.Add(new ListItem(CHelper.GetFormName(fd.Name), fd.Name)); } if (!String.IsNullOrEmpty(FormName)) { CHelper.SafeSelect(ddFormName, FormName); } FormName = (ddFormName.SelectedItem != null) ? ddFormName.SelectedValue : ""; } else { lblTempFormName.Text = FormName; } ddFormName.Visible = CanAddNewForm; lblTempFormName.Visible = !CanAddNewForm; BindRenderer(); }
private void BindRenderer() { FormDocumentData = null; try { FormDocumentData = FormDocument.Load(MetaClassName, FormName); if (FormDocumentData == null) { FormDocumentData = FormController.ReCreateFormDocument(MetaClassName, FormName); } if (MetaUIManager.MetaUITypeIsSystem(FormDocumentData.MetaClassName, FormDocumentData.MetaUITypeId) || FormName == FormDocumentData.MetaUITypeId) { lblFormName.Text = CHelper.GetFormName(FormName); } else { lblFormName.Text = String.Format("{0} ({1})", CHelper.GetFormName(FormName), CHelper.GetFormName(FormDocumentData.MetaUITypeId)); } } catch { } BindRendererInner(); }
private void AddRow(DataTable dt, string metaClassName, string name, string friendlyName, bool isForm, bool isHistory) { DataRow dr = dt.NewRow(); dr["Name"] = name; dr["ClassName"] = metaClassName; dr["IsForm"] = isForm.ToString().ToLower(); string sName = String.Empty; if (isForm) { sName = String.Format(" {0}{1}", CHelper.GetFormName(name), ((name != FormController.BaseFormType && name != FormController.CreateFormType && name != FormController.GeneralViewFormType && name != FormController.ShortViewFormType && name != FormController.GeneralViewHistoryFormType) ? " (" + GetGlobalResourceObject("IbnFramework.MetaForm", "FormName").ToString() + ")" : "")); } else { sName = String.Format(" {0}{1}", GetGlobalResourceObject("IbnFramework.ListInfo", "ListView").ToString(), " (" + CHelper.GetResFileString(friendlyName) + ")"); } dr["DisplayName"] = sName; dt.Rows.Add(dr); }
private void AddRow(DataTable dt, string metaClassName, string name, bool isForm, bool isHistory) { DataRow dr = dt.NewRow(); dr["Name"] = name; dr["ClassName"] = metaClassName; dr["IsForm"] = isForm.ToString().ToLower(); string sName = String.Format(" {0}{1}", (isForm ? CHelper.GetFormName(name) : ((name.IndexOf("_History") >= 0) ? GetGlobalResourceObject("Common", "HistoryView").ToString() : GetGlobalResourceObject("Common", "ListView").ToString())), ((isForm && name != FormController.BaseFormType && name != FormController.CreateFormType && name != FormController.GeneralViewFormType && name != FormController.ShortViewFormType && name != FormController.GeneralViewHistoryFormType) ? " (" + GetGlobalResourceObject("MetaForm", "FormName").ToString() + ")" : "")); dr["DisplayName"] = sName; dt.Rows.Add(dr); }
private void BindGrid() { DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("EditLink", typeof(string)); dt.Columns.Add("CanDelete", typeof(bool)); dt.Columns.Add("CanReset", typeof(bool)); dt.Columns.Add("PublicFormName", typeof(string)); bool isBaseFormAdded = false; bool isGeneralViewFormAdded = false; bool isShortViewFormAdded = false; //ListApp Fix: we don't use ShortViewForm for lists bool isList = ListManager.MetaClassIsList(mc.Name); if (isList) { isShortViewFormAdded = true; } FormDocument[] mas; #region Forms mas = FormDocument.GetFormDocuments(mc.Name); foreach (FormDocument fd in mas) { DataRow row = dt.NewRow(); row["Id"] = fd.Name; string name = ""; if (MetaUIManager.MetaUITypeIsSystem(fd.MetaClassName, fd.MetaUITypeId) || fd.MetaUITypeId == FormController.BaseFormType || fd.MetaUITypeId == FormController.CreateFormType || fd.MetaUITypeId == FormController.GeneralViewFormType || fd.MetaUITypeId == FormController.GeneralViewHistoryFormType || fd.MetaUITypeId == FormController.ShortViewFormType) { name = CHelper.GetFormName(fd.MetaUITypeId); } else { name = String.Format("{0} ({1})", CHelper.GetFormName(fd.Name), CHelper.GetFormName(fd.MetaUITypeId)); } row["PublicFormName"] = "-1"; //ListApp Fix if (ListManager.MetaClassIsList(mc.Name) && fd.MetaUITypeId == FormController.PublicEditFormType) { row["PublicFormName"] = fd.Name; } row["Name"] = name; row["EditLink"] = String.Format("javascript:OpenSizableWindow(\"{5}?ClassName={0}&btn={1}&FormName={2}\", {3}, {4});", mc.Name, btnRefresh.UniqueID, fd.Name, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/MetaUI/Pages/Admin/CustomizeObjectView2.aspx")); if (MetaUIManager.MetaUITypeIsSystem(fd.MetaClassName, fd.MetaUITypeId)) { row["CanDelete"] = false; row["CanReset"] = !isList; } else { row["CanDelete"] = true; row["CanReset"] = false; } if (fd.MetaUITypeId == FormController.BaseFormType) { isBaseFormAdded = true; } if (fd.MetaUITypeId == FormController.GeneralViewFormType) { isGeneralViewFormAdded = true; } if (fd.MetaUITypeId == FormController.ShortViewFormType) { isShortViewFormAdded = true; } dt.Rows.Add(row); } // Edit Form if (!isBaseFormAdded) { DataRow row = dt.NewRow(); string formType = FormController.BaseFormType; row["Id"] = formType; row["Name"] = CHelper.GetFormName(formType); row["PublicFormName"] = "-1"; row["EditLink"] = String.Format("javascript:OpenSizableWindow(\"{5}?ClassName={0}&btn={1}&FormName={2}\", {3}, {4});", mc.Name, btnRefresh.UniqueID, formType, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/MetaUI/Pages/Admin/CustomizeObjectView2.aspx")); row["CanDelete"] = false; row["CanReset"] = false; dt.Rows.Add(row); } // View Form if (!isGeneralViewFormAdded) { DataRow row = dt.NewRow(); string formType = FormController.GeneralViewFormType; row["Id"] = formType; row["Name"] = CHelper.GetFormName(formType); row["PublicFormName"] = "-1"; row["EditLink"] = String.Format("javascript:OpenSizableWindow(\"{5}?ClassName={0}&btn={1}&FormName={2}\", {3}, {4});", mc.Name, btnRefresh.UniqueID, formType, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/MetaUI/Pages/Admin/CustomizeObjectView2.aspx")); row["CanDelete"] = false; row["CanReset"] = false; dt.Rows.Add(row); } // Short View Form if (!isShortViewFormAdded) { DataRow row = dt.NewRow(); string formType = FormController.ShortViewFormType; row["Id"] = formType; row["Name"] = CHelper.GetFormName(formType); row["PublicFormName"] = "-1"; row["EditLink"] = String.Format("javascript:OpenSizableWindow(\"{5}?ClassName={0}&btn={1}&FormName={2}\", {3}, {4});", mc.Name, btnRefresh.UniqueID, formType, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/MetaUI/Pages/Admin/CustomizeObjectView2.aspx")); row["CanDelete"] = false; row["CanReset"] = false; dt.Rows.Add(row); } #endregion #region History Forms string historyClassName = HistoryManager.GetHistoryMetaClassName(mc.Name); mas = FormDocument.GetFormDocuments(historyClassName); foreach (FormDocument fd in mas) { DataRow row = dt.NewRow(); row["Id"] = String.Format(CultureInfo.InvariantCulture, "{0}{1}", fd.Name, historyPostfix); string name = ""; if (MetaUIManager.MetaUITypeIsSystem(fd.MetaClassName, fd.MetaUITypeId) || fd.MetaUITypeId == FormController.BaseFormType || fd.MetaUITypeId == FormController.CreateFormType || fd.MetaUITypeId == FormController.GeneralViewFormType || fd.MetaUITypeId == FormController.GeneralViewHistoryFormType || fd.MetaUITypeId == FormController.ShortViewFormType) { name = CHelper.GetFormName(fd.MetaUITypeId); } else { name = String.Format("{0} ({1})", CHelper.GetFormName(fd.Name), CHelper.GetFormName(fd.MetaUITypeId)); } row["PublicFormName"] = "-1"; row["Name"] = name; row["EditLink"] = String.Format("javascript:OpenSizableWindow(\"{5}?ClassName={0}&btn={1}&FormName={2}\", {3}, {4});", historyClassName, btnRefresh.UniqueID, fd.Name, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/MetaUI/Pages/Admin/CustomizeObjectView2.aspx")); if (MetaUIManager.MetaUITypeIsSystem(fd.MetaClassName, fd.MetaUITypeId)) { row["CanDelete"] = false; } else { row["CanDelete"] = true; } row["CanReset"] = false; dt.Rows.Add(row); } #endregion DataView dv = dt.DefaultView; dv.Sort = "Name"; grdMain.DataSource = dv; grdMain.DataBind(); foreach (DataGridItem row in grdMain.Items) { ImageButton ib; ib = (ImageButton)row.FindControl("ibDelete"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')"); } ib = (ImageButton)row.FindControl("ibReset"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "ResetToDefault").ToString() + "?')"); } ib = (ImageButton)row.FindControl("ibRecreate"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.MetaForm", "RecreateFormWarning").ToString() + "')"); } } }
/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("EditLink", typeof(string)); dt.Columns.Add("CanDelete", typeof(bool)); dt.Columns.Add("PublicFormName", typeof(string)); FormDocument[] mas = FormDocument.GetFormDocuments(mc.Name); foreach (FormDocument fd in mas) { DataRow row = dt.NewRow(); row["Id"] = fd.Name; string name = ""; if (MetaUIManager.MetaUITypeIsSystem(fd.MetaClassName, fd.MetaUITypeId)) { name = CHelper.GetFormName(fd.MetaUITypeId); } else { name = String.Format("{0} ({1})", CHelper.GetFormName(fd.Name), CHelper.GetFormName(fd.MetaUITypeId)); } row["PublicFormName"] = "-1"; row["Name"] = name; row["EditLink"] = String.Format("javascript:OpenSizableWindow(\"{5}?ClassName={0}&btn={1}&FormName={2}\", {3}, {4});", mc.Name, btnRefresh.UniqueID, fd.Name, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/MetaDataBase/MetaUI/Pages/Admin/CustomizeObjectView2.aspx")); //if (MetaUIManager.MetaUITypeIsSystem(fd.MetaUITypeId)) // row["CanDelete"] = false; //else row["CanDelete"] = true; dt.Rows.Add(row); } // History string historyClassName = HistoryManager.GetHistoryMetaClassName(mc.Name); mas = FormDocument.GetFormDocuments(historyClassName); foreach (FormDocument fd in mas) { DataRow row = dt.NewRow(); row["Id"] = String.Format(CultureInfo.InvariantCulture, "{0}{1}", fd.Name, historyPostfix); string name = ""; if (MetaUIManager.MetaUITypeIsSystem(fd.MetaClassName, fd.MetaUITypeId)) { name = CHelper.GetFormName(fd.MetaUITypeId); } else { name = String.Format("{0} ({1})", CHelper.GetFormName(fd.Name), CHelper.GetFormName(fd.MetaUITypeId)); } row["PublicFormName"] = "-1"; row["Name"] = name; row["EditLink"] = String.Format("javascript:OpenSizableWindow(\"{5}?ClassName={0}&btn={1}&FormName={2}\", {3}, {4});", historyClassName, btnRefresh.UniqueID, fd.Name, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/MetaDataBase/MetaUI/Pages/Admin/CustomizeObjectView2.aspx")); //if (MetaUIManager.MetaUITypeIsSystem(fd.MetaUITypeId)) // row["CanDelete"] = false; //else row["CanDelete"] = true; dt.Rows.Add(row); } grdMain.DataSource = dt; grdMain.DataBind(); foreach (DataGridItem row in grdMain.Items) { ImageButton ib = (ImageButton)row.FindControl("ibDelete"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("GlobalMetaInfo", "Delete").ToString() + "?')"); } } }
/// <summary> /// Handles the Click event of the lbNewForm 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 lbNewForm_Click(object sender, EventArgs e) { string param = Request.Params.Get("__EVENTARGUMENT"); if (String.IsNullOrEmpty(param)) { return; } FormDocumentData = (FormDocument)Session[param]; MetaClassName = FormDocumentData.MetaClassName; FormName = FormDocumentData.Name; fRenderer.FormDocumentData = FormDocumentData; fRenderer.DataBind(); #region Visibility Elements if (CanAddNewForm) { bool changeForms = (ddClasses.SelectedItem == null || ddClasses.SelectedValue != MetaClassName); CHelper.SafeSelect(ddClasses, MetaClassName); if (ddClasses.SelectedItem == null || ddClasses.SelectedValue != MetaClassName) { ddClasses.Visible = false; lblTempClassName.Visible = true; lblTempClassName.Text = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(MetaClassName).FriendlyName); } else { ddClasses.Visible = true; lblTempClassName.Visible = false; } if (changeForms) { ddFormName.Visible = false; lblTempFormName.Visible = true; lblTempFormName.Text = CHelper.GetFormName(FormName); } else { CHelper.SafeSelect(ddFormName, FormName); if (ddFormName.SelectedItem == null || ddFormName.SelectedValue != FormName) { ddFormName.Visible = false; lblTempFormName.Visible = true; lblTempFormName.Text = CHelper.GetFormName(FormName); } else { ddFormName.Visible = true; lblTempFormName.Visible = false; } } } else { lblTempClassName.Text = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(MetaClassName).FriendlyName); lblTempFormName.Text = CHelper.GetFormName(FormName); } lblTableName.Text = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(MetaClassName).FriendlyName); lblFormName.Text = CHelper.GetFormName(FormName); if (FormDocumentData == null) { ddFormName.Enabled = false; tblMove.Visible = false; tblLinks.Visible = false; } else { ddFormName.Enabled = true; tblMove.Visible = true; tblLinks.Visible = true; if (MetaUIManager.MetaUITypeIsSystem(FormDocumentData.MetaClassName, FormDocumentData.MetaUITypeId)) { lblFormName.Text = CHelper.GetFormName(FormDocumentData.Name); } else { lblFormName.Text = String.Format("{0} ({1})", CHelper.GetFormName(FormDocumentData.Name), CHelper.GetFormName(FormDocumentData.MetaUITypeId)); } } #endregion }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(Request["class"])) { throw new Exception("ClassName is required!"); } if (!Page.IsPostBack) { if (!String.IsNullOrEmpty(uid)) { #region Edit lblTitle.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "EditForm").ToString(); lblComments.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "EditFormComment").ToString(); FormDocumentData = ((FormDocument)Session[uid]).Copy(); lblClass.Text = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(FormDocumentData.MetaClassName).FriendlyName); ddClasses.Visible = false; if (MetaUIManager.MetaUITypeIsSystem(FormDocumentData.MetaClassName, FormDocumentData.MetaUITypeId) || FormDocumentData.Name == FormDocumentData.MetaUITypeId) { lblForm.Text = CHelper.GetFormName(FormDocumentData.Name); } else { lblForm.Text = String.Format("{0} ({1})", CHelper.GetFormName(FormDocumentData.Name), CHelper.GetFormName(FormDocumentData.MetaUITypeId)); } ddFormType.Visible = false; BindValues(); #endregion } else { #region Create lblTitle.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "AddForm").ToString(); lblComments.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "AddFormComment").ToString(); FormtypeLiteral.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "FormType").ToString(); //Dictionary<int, string> dic = Mediachase.Ibn.Data.Meta.Management.SqlSerialization.MetaClassId.GetIds(); //List<string> list = new List<string>(dic.Values); List <string> list = new List <string>(); foreach (MetaClass mc in DataContext.Current.MetaModel.MetaClasses) { list.Add(mc.Name); } list.Sort(); ddClasses.DataSource = list; ddClasses.DataBind(); string metaclassName = Request["class"]; if (!String.IsNullOrEmpty(metaclassName)) { CHelper.SafeSelect(ddClasses, metaclassName); } //lblClass.Visible = false; ddClasses.Visible = false; lblClass.Visible = true; lblClass.Text = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(ddClasses.SelectedValue).FriendlyName); ddFormType.Items.Clear(); MetaUITypeElement[] mas = MetaUIManager.GetCreatableUITypes(metaclassName, MetaUITypeElement.FormCategory); foreach (MetaUITypeElement elem in mas) { ddFormType.Items.Add(new ListItem(CHelper.GetFormName(elem.Name), elem.Id)); } txtCellPadding.Text = "5"; #endregion } // Ibn47 Lists if (ListManager.MetaClassIsList(Request["class"])) { TableLabel.Text = GetGlobalResourceObject("IbnFramework.ListInfo", "List").ToString(); } } lblError.Visible = false; btnSave.InnerText = GetGlobalResourceObject("IbnFramework.MetaForm", "Save").ToString(); btnCancel.InnerText = GetGlobalResourceObject("IbnFramework.MetaForm", "Cancel").ToString(); }