private void GetChildNode(Ext.Net.TreeNode ParentNode) { List <FormGroupInfo> formGroupList = FormGroupController.GetInstance().GetByParentID(int.Parse(ParentNode.NodeID)); foreach (FormGroupInfo item in formGroupList) { Ext.Net.TreeNode node = new Ext.Net.TreeNode(); node.Text = item.Title; node.NodeID = item.ID.ToString(); ParentNode.Nodes.Add(node); // node.Icon = item.IsTab ? Icon.Tab : Icon.Folder; if (item.IsTab) { node.Icon = Icon.Tab; } else { node.Icon = Icon.Folder; } node.Listeners.Click.Handler = string.Format(script, item.Title, item.ID); GetChildNode(node); LoadControl(node, item); } }
protected void GroupStore_Change(object sender, DirectEventArgs e) { if (string.IsNullOrEmpty(hdfGroupID.Text)) { return; } FormGroupInfo groupInfo = FormGroupController.GetInstance().Get(int.Parse(hdfGroupID.Text)); List <FormElementInfo> columnfield = groupInfo.GetFormElements(1); string menuStr = "<li style='display:none;'></li>"; foreach (FormElementInfo field in columnfield) { menuStr = string.Concat(menuStr, string.Format("<li id='{0}'>{1}<b onclick=RemoveField('{2}')>.</b></li>", field.ID.ToString(), field.LabelName, field.ID.ToString())); } string output = @" <div class='demo'> <ul id='sortable'> {0} </ul> </div>"; lblOutput.Html = string.Format(output, menuStr); txtGroupTitle.Text = groupInfo.Title; txtWidth.Text = groupInfo.Width.ToString(); txtHeight.Text = groupInfo.Height.ToString(); cbFormLayout.SelectedIndex = (groupInfo.Layout == "RowLayout") ? 0 : 1; chkDisplayText.Checked = groupInfo.DisplayText; chkIsTab.Checked = groupInfo.IsTab; for (int i = 0; i < 3; i++) { if (groupInfo.LabelAlign.Equals(cbLabelAlign.Items[i].Value)) { cbLabelAlign.SelectedIndex = i; break; } } if (groupInfo.ParentID != 0) { int index = 0; foreach (Ext.Net.ListItem item in cbGroup2.Items) { if (item.Value == groupInfo.ParentID.ToString()) { cbGroup2.SelectedIndex = index++; cbGroup2.SetValue(groupInfo.ParentID); break; } } } else { cbGroup2.Clear(); } hdfCommand.Text = "update"; }
public void UpdateGroup(object index, string nodeName, object nodeID, object newParentNodeID) { int i = int.Parse(index.ToString()); if (nodeName.Contains("_") == false) //Cập nhật thông tin FormGroup { try { List <FormGroupInfo> sameParentGroup = (from t in FormGroupController.GetInstance().GetByParentID(int.Parse(newParentNodeID.ToString())) where t.Position >= i select t).ToList(); foreach (var item in sameParentGroup) { item.Position += 1; FormGroupController.GetInstance().Update(item); } FormGroupInfo group = FormGroupController.GetInstance().Get(int.Parse(nodeID.ToString())); group.ParentID = int.Parse(newParentNodeID.ToString()); group.Position = int.Parse(index.ToString()); FormGroupController.GetInstance().Update(group); } catch (Exception ex) { Dialog.ShowError("FormConfigLayout/UpdateGroup " + ex.Message); } } else //Cập nhật thông tin Control { try { int controlId = int.Parse(nodeID.ToString()); int groupID = int.Parse(newParentNodeID.ToString()); if (_formInfo == null) { _formInfo = FormController.GetInstance().GetForm(_FormName); } List <FormElementInfo> controlList = (from t in FormElementController.GetInstance().GetFormElements(_formInfo.ID, 1) where t.Position >= i && t.GroupID == groupID select t).ToList(); foreach (var item in controlList) { item.Position += 1; FormElementController.GetInstance().Update(item); } FormElementInfo controlInfo = FormElementController.GetInstance().Get(controlId); controlInfo.Position = i; controlInfo.GroupID = groupID; FormElementController.GetInstance().Update(controlInfo); } catch (Exception ex) { Dialog.ShowError("FormConfigLayout/UpdateGroup/Update control = " + ex.Message); throw; } } }
private Ext.Net.TreeNodeCollection BuildTree(Ext.Net.TreeNodeCollection nodes) { try { script = ddfGroupTree.ClientID + ".collapse();" + ddfGroupTree.ClientID + ".setValue('{0}',false);" + hdfGroupID.ClientID + ".setValue('{1}');" + btnDeleteGroup.ClientID + ".enable();" + btnSaveFormGroupInformation.ClientID + ".enable();"; if (nodes == null) { nodes = new Ext.Net.TreeNodeCollection(); } Ext.Net.TreeNode root = new Ext.Net.TreeNode(); root.Text = "Danh mục nhóm"; root.NodeID = "0"; nodes.Add(root); root.Expanded = true; if (_formInfo == null) { _formInfo = FormController.GetInstance().GetForm(_FormName); } List <FormGroupInfo> formGroupList = FormGroupController.GetInstance().GetFromGroups(_formInfo.ID, 0); foreach (FormGroupInfo item in formGroupList) { Ext.Net.TreeNode node = new Ext.Net.TreeNode(); node.Expanded = true; node.Text = item.Title; node.NodeID = item.ID.ToString(); root.Nodes.Add(node); if (item.IsTab) { node.Icon = Icon.Tab; } else { node.Icon = Icon.Folder; } node.Listeners.Click.Handler = string.Format(script, item.Title, item.ID); GetChildNode(node); LoadControl(node, item); } } catch (Exception ex) { Dialog.ShowError("Form/FormConfigLayout = " + ex.Message); } return(nodes); }
public void btnDeleteGroup_Click()//object sender, DirectEventArgs e { if (string.IsNullOrEmpty(hdfGroupID.Text)) { Dialog.ShowNotification("Bạn chưa chọn nhóm !"); } try { FormGroupController.GetInstance().Delete(int.Parse(hdfGroupID.Text)); // btnDeleteGroup.Enabled = false; } catch (Exception ex) { Dialog.ShowError(ex.Message); } }
protected void GroupStoreRefresh(object sender, StoreRefreshDataEventArgs e) { try { if (_formInfo == null) { _formInfo = FormController.GetInstance().GetForm(_FormName); } List <FormGroupInfo> rs = new List <FormGroupInfo>(); List <FormGroupInfo> formGroupList = FormGroupController.GetInstance().GetFromGroups(_formInfo.ID, -1); GroupStore.DataSource = formGroupList; GroupStore.DataBind(); } catch (Exception ex) { Dialog.ShowError("FormConfigLayout/GroupStoreRefresh = " + ex.Message); } }
protected void btnSaveFormGroupInformation_Click(object sender, DirectEventArgs e) { if (hdfCommand.Text == "insert") { try { int groupid = 0; if (!string.IsNullOrEmpty(cbGroup2.SelectedItem.Value)) { groupid = int.Parse(cbGroup2.SelectedItem.Value); } if (_formInfo == null) { _formInfo = FormController.GetInstance().GetForm(_FormName); } double width = 0; if (txtWidth.Text.Contains("0.")) { width = Convert.ToDouble(txtWidth.Text) / 10; } else { width = Convert.ToDouble(txtWidth.Text); } int id = FormGroupController.GetInstance().CreateFormGroup(new FormGroupInfo(0, txtGroupTitle.Text, 0, _formInfo.ID, width, int.Parse(txtHeight.Text), groupid, cbFormLayout.SelectedItem.Text, chkDisplayText.Checked, cbLabelAlign.SelectedItem.Value, chkIsTab.Checked )); //reload lại store nhóm cấp trên GroupStoreRefresh(sender, null); //có khả năng gây lỗi } catch (Exception ex) { Dialog.ShowError(ex.Message); } txtGroupTitle.Text = ""; txtHeight.Text = "0"; txtWidth.Text = "0"; chkDisplayText.Checked = false; cbFormLayout.SelectedIndex = 0; } else if (hdfCommand.Text == "update") { try { FormGroupInfo formGroupInfo = FormGroupController.GetInstance().Get(int.Parse(hdfGroupID.Text)); formGroupInfo.DisplayText = chkDisplayText.Checked; formGroupInfo.Title = txtGroupTitle.Text; if (txtWidth.Text.Contains("0.")) { formGroupInfo.Width = double.Parse(txtWidth.Text) / 10; } else { formGroupInfo.Width = double.Parse(txtWidth.Text); } formGroupInfo.Height = int.Parse(txtHeight.Text); formGroupInfo.Layout = cbFormLayout.SelectedItem.Text; formGroupInfo.LabelAlign = cbLabelAlign.SelectedItem.Value; formGroupInfo.IsTab = chkIsTab.Checked; if (!string.IsNullOrEmpty(cbGroup2.SelectedItem.Value)) { formGroupInfo.ParentID = int.Parse(cbGroup2.SelectedItem.Value); } FormGroupController.GetInstance().Update(formGroupInfo); } catch (Exception ex) { Dialog.ShowNotification(ex.Message); } } // hdfCommand.Text = ""; // }