public UserPermissionMan() { InitializeComponent(); try { this.tvPermission.Nodes.Clear(); this.tvUser.Nodes.Clear(); string permissionPath = Application.StartupPath + "\\Permission.xml"; this.dtPermission = XmlFile.XmlToDataTable(permissionPath); TreeNode node = new TreeNode(); node.Text = "权限"; node.Checked = false; this.tvPermission.Nodes.Add(node); this.InitPermissionNode(node, "0"); node = new TreeNode(); node.Text = "用户"; node.Checked = false; this.tvUser.Nodes.Add(node); this.InitUserNode(node, ""); TreeNode childNode = null; foreach (var kvp in Global.DictDept) { childNode = new TreeNode(); childNode.Text = kvp.Value; childNode.Checked = false; node.Nodes.Add(childNode); this.InitUserNode(childNode, kvp.Value); } } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Process instance = RunningInstance(); if (instance == null) { Global.UsersConfigPath = Application.StartupPath + "\\Users.xml"; //检查用户文件是否存在 if (!File.Exists(Global.UsersConfigPath)) { XmlFile.CreateXmlFile(Global.UsersConfigPath); } else { Global.DtUser = XmlFile.XmlToDataTable(Global.UsersConfigPath); if (Global.DtUser == null) { XmlFile.CreateXmlFile(Global.UsersConfigPath); } else { DataRow[] dr = Global.DtUser.Select(string.Format("workNumber = 'admin' and userName = '******'")); if (dr.Length == 0) { XmlFile.CreateXmlFile(Global.UsersConfigPath); } } } //1.1 没有实例在运行 Application.Run(new FormLogIn()); } }