예제 #1
0
 public DevExpress.XtraEditors.XtraUserControl Init()
 {
     DMTreeGroup dmTree = new DMTreeGroup();
     dmTree.Init(GroupElementType.ONLY_INPUT, "DEPARTMENT", "ID", "PARENT_ID",
         new string[] { "NAME" }, new String[] { "Tên phòng ban" }, HelpGen.G_FW_DM_ID,
         null,
         new FieldNameCheck[] {
             new FieldNameCheck("NAME",
                 new CheckType[]{ CheckType.Required, CheckType.RequireMaxLength },
                 "Tên phòng ban",
             new object[]{ null, 200 })
         }
     );
     if(isPermission) dmTree.DefinePermission(DanhMucParams.GetPermission(dmTree, N, "Danh mục phòng ban"));
     return dmTree;
 }
예제 #2
0
        public XtraUserControl Init()
        {
            DMTreeGroup dmTree = new DMTreeGroup();
            //dmTree.Init(GroupElementType.ONLY_INPUT, TABLE_MAP, "ID", "PARENT_ID",
            //   new string[] { "NAME", "VISIBLE_BIT" },
            //   new String[] { "Thư mục", GlobalConst.VISIBLE_TITLE },
            //   "G_FW_DT_ID",
            //   new object[] { TreeListColumnType.TextType, TreeListColumnType.CheckEdit },
            //   new FieldNameCheck[] {
            //        new FieldNameCheck("NAME",
            //            new CheckType[]{ CheckType.Required, CheckType.RequireMaxLength },
            //            "Thư mục",
            //        new object[]{ null, 200 })
            //    }
            //);
            if (FrameworkParams.currentUser.username == "admin" ||
               AppParams.LOGIN_GROUP.Contains("admins"))
            {
                dmTree.Init(GroupElementType.ONLY_INPUT, TABLE_MAP, null, "ID", "PARENT_ID",
                    new string[] { "NAME", "VISIBLE_BIT", "CONG_TY" },
                    new String[] { "Thư mục", GlobalConst.VISIBLE_TITLE, "Công ty" },
                    "G_FW_DT_ID",
                    new object[] { TreeListColumnType.TextType, TreeListColumnType.CheckEdit, TreeListColumnType.TextType },
                    new FieldNameCheck[] {
                    new FieldNameCheck("NAME",
                        new CheckType[]{ CheckType.Required, CheckType.RequireMaxLength },
                        "Thư mục",
                    new object[]{ null, 200 })
                },
                    new string[] { }, new string[] { });
                DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit repCT = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();
                string sql = "Select ID,SHORT_NAME from COMPANY_INFO";
                repCT.DataSource = HelpDB.getDBService().LoadDataSet(sql).Tables[0];
                repCT.ValueMember = "ID";
                repCT.DisplayMember = "SHORT_NAME";
                dmTree.TreeList_1.Columns["CONG_TY"].ColumnEdit = repCT;

            }
            else
            {
                dmTree.Init(GroupElementType.ONLY_INPUT, TABLE_MAP, null, "ID", "PARENT_ID",
                   new string[] { "NAME", "VISIBLE_BIT"},
                   new String[] { "Thư mục", GlobalConst.VISIBLE_TITLE },
                   "G_FW_DT_ID",
                   new object[] {TreeListColumnType.TextType, TreeListColumnType.CheckEdit },
                   new FieldNameCheck[] {
                    new FieldNameCheck("NAME",
                        new CheckType[]{ CheckType.Required, CheckType.RequireMaxLength },
                        "Thư mục",
                    new object[]{ null, 200 })
                },
                   new string[] { }, new string[] { });
            }

            dmTree.Load += delegate(object sender, EventArgs e)
            {                DataTable dt = dmTree.TreeList_1.DataSource as DataTable;
            if (FrameworkParams.currentUser.username == "admin" ||
               AppParams.LOGIN_GROUP.Contains("admins"))
            {

                dmTree.TreeList_1.DataSource = AppUtil.SortLogicalTable(dt, "NAME");
                dmTree.TreeList_1.Columns["CONG_TY"].OptionsColumn.AllowEdit = false;

            }
            else
            {

                dt.DefaultView.RowFilter = "CONG_TY=" +  FrameworkParams.LoginCompanyID;
                DataSet ds=new DataSet();
                ds.Tables.Add(dt.DefaultView.ToTable());
                ds.Tables[0].PrimaryKey = new DataColumn[]{
                    ds.Tables[0].Columns[dmTree.IDField]
                };
                dmTree.TreeList_1.DataSource = AppUtil.SortLogicalTable(ds.Tables[0], "NAME");
                dmTree.TreeList_1.ExpandAll();
            }
            };

            dmTree._AfterSaveSuccEvent += delegate(DMTreeGroup sender)
            {
                DataTable dt = dmTree.TreeList_1.DataSource as DataTable;
                dmTree.TreeList_1.DataSource = AppUtil.SortLogicalTable(dt, "NAME");
            };
            dmTree.TreeList_1.ValidateNode += delegate(object sender, DevExpress.XtraTreeList.ValidateNodeEventArgs e)
            {
                string name = e.Node["NAME"].ToString();
                if (name.Contains('\\') || name.Contains('|') ||
                    name.Contains('<') || name.Contains('>') ||
                    name.Contains(':') || name.Contains('*') ||
                    name.Contains('?') || name.Contains(':') || name.Contains('/'))
                {
                    e.Valid = false;
                    e.Node.TreeList.SetColumnError(e.Node.TreeList.Columns["NAME"],
                        "Tên thư mục không được chứa các ký tự \\ / | < > : * ? :");

                }
                foreach (TreeListNode n in e.Node.ParentNode.Nodes)
                {
                    if (n.Equals(e.Node)) continue;
                    if (n["NAME"].ToString().ToLower() == e.Node["NAME"].ToString().ToLower())
                    {
                        e.Valid = false;
                        e.Node.TreeList.SetColumnError(e.Node.TreeList.Columns["NAME"],
                            "Tên thư mục đã được sử dụng!");
                    }
                }

            };

            ImageList list = new ImageList();
            list.ImageSize = new System.Drawing.Size(16, 16);
            list.Images.Add(FrameworkParams.imageStore.GetImage1616("harddisk.png"));
            list.Images.Add(FrameworkParams.imageStore.GetImage1616("fwGroupClose.png"));
            dmTree.TreeList_1.SelectImageList=null;
            dmTree.TreeList_1.StateImageList=list;
            dmTree.TreeList_1.GetStateImage+=new DevExpress.XtraTreeList.GetStateImageEventHandler(TreeList_1_GetStateImage);

            dmTree.DefinePermission(AppDanhMuc.GetPermission(dmTree,
                AppPermission.OHardDisk.featureName, string.Empty));
            #region cách tạm để sửa caption danh mục
            try
            {
                dmTree.Load += delegate(object sender, EventArgs e)
                {
                    Form frm = dmTree.FindForm();
                    frmCategory frmdm = frm as frmCategory;
                    PanelControl panelControl1 = frm.Controls["panelControl1"] as PanelControl;
                    Label lblCat = panelControl1.Controls["lblCat"] as Label;
                    lblCat.Text = "Danh sách thư mục trên HD";

                };
            }
            catch
            {
            }
            dmTree.TreeList_1.ShownEditor += delegate(object sender, EventArgs e)
            {
                TreeListNode node = dmTree.TreeList_1.FocusedNode;
                if (node == null||node.RootNode==null) return;
                node["CONG_TY"] = node.RootNode["CONG_TY"];
            };
            #endregion
            return dmTree;
        }