public void BindData(string metaClassName) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("DisplayName", typeof(string))); dt.Columns.Add(new DataColumn("ClassName", typeof(string))); dt.Columns.Add(new DataColumn("IsForm", typeof(string))); string[] forms = MetaUIManager.GetMetaFormList(metaClassName); foreach (string name in forms) { AddRow(dt, metaClassName, name, true, false); } string[] views = MetaUIManager.GetMetaViewList(metaClassName); foreach (string name in views) { AddRow(dt, metaClassName, name, false, false); } grdMain.DataKeyField = "Name"; grdMain.DataSource = dt.DefaultView; grdMain.DataBind(); }
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 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(); }
/// <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); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnPreRender(EventArgs e) { divTitle.Visible = (ddFormType.Visible && !MetaUIManager.MetaUITypeIsSystem(ddClasses.SelectedValue, ddFormType.SelectedValue)); base.OnPreRender(e); }
public void BindData(string metaClassName) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("DisplayName", typeof(string))); dt.Columns.Add(new DataColumn("ClassName", typeof(string))); dt.Columns.Add(new DataColumn("IsForm", typeof(string))); bool isBaseFormAdded = false; bool isGeneralViewFormAdded = false; bool isShortViewFormAdded = false; // ListApp Fix: we don't use ShortViewForm for lists bool isList = ListManager.MetaClassIsList(metaClassName); if (isList) { isShortViewFormAdded = true; } string[] forms = MetaUIManager.GetMetaFormList(metaClassName); foreach (string name in forms) { if ((name == FormController.CreateFormType || name == FormController.ShortViewFormType) && isList) { continue; } AddRow(dt, metaClassName, name, String.Empty, true, false); if (name == FormController.BaseFormType) { isBaseFormAdded = true; } if (name == FormController.GeneralViewFormType) { isGeneralViewFormAdded = true; } if (name == FormController.ShortViewFormType) { isShortViewFormAdded = true; } } // Edit Form if (!isBaseFormAdded) { AddRow(dt, metaClassName, FormController.BaseFormType, String.Empty, true, false); } // View Form if (!isGeneralViewFormAdded) { AddRow(dt, metaClassName, FormController.GeneralViewFormType, String.Empty, true, false); } // Short View Form if (!isShortViewFormAdded) { AddRow(dt, metaClassName, FormController.ShortViewFormType, String.Empty, true, false); } if (ListManager.IsHistoryActivated(metaClassName)) { string[] formsHistory = MetaUIManager.GetMetaFormList(HistoryManager.GetHistoryMetaClassName(metaClassName)); foreach (string name in formsHistory) { if (name != FormController.GeneralViewHistoryFormType && isList) { continue; } AddRow(dt, HistoryManager.GetHistoryMetaClassName(metaClassName), name, String.Empty, true, true); } } ListViewProfile[] list = ListViewProfile.GetSystemProfiles(metaClassName, "EntityList"); foreach (ListViewProfile lvp in list) { AddRow(dt, metaClassName, lvp.Id, lvp.Name, false, false); } //string[] views = MetaUIManager.GetMetaViewList(metaClassName); //foreach (string name in views) // AddRow(dt, metaClassName, name, false, false); grdMain.DataKeyField = "Name"; grdMain.DataSource = dt.DefaultView; grdMain.DataBind(); }