public void ChonLoaiTaiLieu(DMTreeGroup Input)
 {
     Input.Init(GroupElementType.ONLY_INPUT, "DM_LOAI_TAI_LIEU", "ID", "PARENT_ID",
                       new string[] { "NAME" }, new string[] { "Loại tài liệu" }, null, null, null
                      );
     Input.btnClose.Visible = false;
 }
Beispiel #2
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;
 }
        private void InitControl()
        {
            DMHardDisks.InitCtrl(HD,false);

            HD.imgCombo.Properties.ReadOnly = ReadOnlyHD;
            HD.imgCombo.Properties.Buttons[0].Visible = !ReadOnlyHD;

            dmTree =new DMTreeGroup();
            string table = (this.IsAdd == true ? "V_HARD_DISKS_VISIBLE" : "HARD_DISKS");
            dmTree.Init(GroupElementType.ONLY_CHOICE, table, "ID", "PARENT_ID",
              new string[] { "NAME" }, new String[] { "Thư mục"}, "G_FW_DT_ID",
              new object[] { TreeListColumnType.TextType },
              new FieldNameCheck[] {
                    new FieldNameCheck("NAME",
                        new CheckType[]{ CheckType.Required, CheckType.RequireMaxLength },
                        "Thư mục",
                    new object[]{ null, 200 })
                }
               );
            dmTree.VisibleChanged += delegate(object sender, EventArgs e)
            {
                DataTable dtSource = dmTree.TreeList_1.DataSource as DataTable;
                dmTree.TreeList_1.DataSource = AppUtil.SortLogicalTable(dtSource, "NAME");
            };

            columnRoot = dmTree.TreeList_1.Columns.Add();
            columnRoot.FieldName = "ID_ROOT";
            columnRoot.Caption = "";
            columnRoot.Visible = false;
            dmTree.btnAdd.Owner.Visible = false;

            panel1.Controls.Add(dmTree);
            dmTree.Dock = DockStyle.Fill;
            if (hideTextFile)
            {
                textEdit1.Visible = false;
                pllblTenFile.Visible = false;
            }
        }
        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;
        }
        private void InitControl()
        {
            DMHardDisks.InitCtrl(HD,true);

            HD.imgCombo.Properties.ReadOnly = ReadOnlyHD;
            HD.imgCombo.Properties.Buttons[0].Visible = !ReadOnlyHD;

            dmTree =new DMTreeGroup();
            string table = (this.IsAdd == true ? "V_HARD_DISKS_VISIBLE" : "HARD_DISKS");
            if (FrameworkParams.currentUser.username == "admin" ||
                 AppParams.LOGIN_GROUP.Contains("admins"))
            {
                dmTree.Init(GroupElementType.ONLY_CHOICE, table, "ID", "PARENT_ID",
                  new string[] { "NAME","CONG_TY" }, new String[] { "Thư mục","Công ty" }, "G_FW_DT_ID",
                  new object[] { TreeListColumnType.TextType,TreeListColumnType.TextType },
                  new FieldNameCheck[] {
                    new FieldNameCheck("NAME",
                        new CheckType[]{ CheckType.Required, CheckType.RequireMaxLength },
                        "Thư mục",
                    new object[]{ null, 200 })
                }

               );
                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_CHOICE, table, "ID", "PARENT_ID",
                  new string[] { "NAME" }, new String[] { "Thư mục" }, "G_FW_DT_ID",
                  new object[] { TreeListColumnType.TextType },
                  new FieldNameCheck[] {
                    new FieldNameCheck("NAME",
                        new CheckType[]{ CheckType.Required, CheckType.RequireMaxLength },
                        "Thư mục",
                    new object[]{ null, 200 })
                }

               );
            }

            columnRoot = dmTree.TreeList_1.Columns.Add();
            columnRoot.FieldName = "ID_ROOT";
            columnRoot.Caption = "";
            columnRoot.Visible = false;
            dmTree.btnAdd.Owner.Visible = false;

            panel1.Controls.Add(dmTree);
            dmTree.Dock = DockStyle.Fill;
            if (hideTextFile)
            {
                textEdit1.Visible = false;
                pllblTenFile.Visible = false;
            }
            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);
        }