using CommonLib; using CommonLib.utils; using ControlLib.com; using ControlLib.inh; using DevExpress.XtraEditors; using DevExpress.XtraTab; using Lskj.Main.Properties; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows; using System.Diagnostics; using Lskj.Main.sub; using Lskj.MyControl; using Lskj.Common; using DevExpress.XtraEditors.Controls; using System.Net; namespace Lskj.Main { public partial class FrmMain3 : Form { #region 属性 // 生成地址 private bool m_isMouseDown = false;//窗体是否移动 private Point m_mousePos;//记录窗体的位置 private string qxCond; private int MainMenuType = 1; // 1.顶部菜单显示为当前菜单,2.顶部菜单显示为所有子系统 private bool isOpenDesktop = false; private IntPtr m_ClientTestHandle = IntPtr.Zero; private XtraTabPage CurrentPage = new XtraTabPage(); //存放当前选中tabpage private ToolStripMenuItem CurrentMenuItem; // 当前选中的MenuItem private Boolean isLeave = true; private string ConfigMenuVisible = ""; private string TargetMode; // 0 全部、1cs、 2 手机、3、bs private float dpiX, dpiY; private int memuEventType = 0, HeadMenuId = 0; private DataTable dtAllMenus = new DataTable(); // 菜单数据缓存 private DataTable dtSubMenus = new DataTable(); // 缓存当前选中的子系统数据 private Dictionary> dicMenus = new Dictionary>(); // 缓存菜单控件 /// /// 缓存菜单 /// private List _menuItemList = new List(); private DataTable dtDesktop = new DataTable(); // 我的桌面数据 private Dictionary dicGrids = new Dictionary(); #endregion #region 构造函数 public FrmMain3() { Graphics graphics = this.CreateGraphics(); dpiX = graphics.DpiX; dpiY = graphics.DpiY; InitializeComponent(); this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); } #endregion #region 窗体初始化 private void FrmMain_Load(object sender, EventArgs e) { //pl_top_left.BackgroundImage = BitMapHelper.getBitmap(BitMapEnum.logobg); ConfigMenuVisible = ""; string tmpsql = "select 1 from sys.columns where object_id=object_id('P_FormMenuConfigTab') and name='useFlag'"; object rlt = SqlHelper.ExecuteScalar(CommandType.Text, tmpsql); if (rlt+"" == "1") ConfigMenuVisible = " and isnull(useFlag,0)=1"; tmpsql = "select 1 from sys.columns where object_id=object_id('P_FormMenuConfigTab') and name='TargetMode'"; rlt = SqlHelper.ExecuteScalar(CommandType.Text, tmpsql); if (rlt + "" == "1") TargetMode = " and isnull(TargetMode,0) in (0,1)"; this.tsmi_time.Alignment = ToolStripItemAlignment.Right; this.tsmi_split.Alignment = ToolStripItemAlignment.Right; this.tsmi_time.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); this.lbUserName.Text = ERPInfo.Instance.EmployeeName; //this.lblSubTitle.Text = string.Format("朗速ERP{0}子系统", ERPInfo.Instance.SubSysName); this.tsslUserName.Text = "用户名:" + ERPInfo.Instance.EmployeeName; this.TabMain.HeaderButtons = ((DevExpress.XtraTab.TabButtons)((((DevExpress.XtraTab.TabButtons.Prev | DevExpress.XtraTab.TabButtons.Next) | DevExpress.XtraTab.TabButtons.Close) | DevExpress.XtraTab.TabButtons.Default))); this.TabMain.HeaderButtonsShowMode = DevExpress.XtraTab.TabButtonShowMode.Always; this.timer1.Start(); this.calcPanelWidth(); this.setMenuStripColor(Color.Gray); this.lblSubTitle.Focus(); LoadSystemConfig(); // 检查是否包含我的桌面 isOpenDesktop = CheckDesktopConfig(); if (!isOpenDesktop) { TabMain.TabPages.Remove(xtpDesktop); } else { TabMain.SelectedTabPage = xtpDesktop; this.initDesktop(); } // 检查是否包含固定模块 if (HeadMenuId > 0) { string sqlValue = string.Format("select * from P_FormMenuConfigTab where MenuId='{0}'", HeadMenuId); DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue); if (dtTable.Rows.Count > 0) { label1.Text = dtTable.Rows[0]["MenuCaption"] + ""; label1.Tag = dtTable.Rows[0]; } else { menuSearch.Size = new System.Drawing.Size(227, 25); menuSearch.Location = new Point(9, 27); label1.Visible = false; } } else { menuSearch.Size = new System.Drawing.Size(227, 25); menuSearch.Location = new Point(9, 27); label1.Visible = false; } if (MainMenuType > 2) qxCond = getQxCond(); menuSearch.searcherPropertyCollector.SQL = "SELECT MenuId,MenuCaption+'-'+b.SubSysName as MenuCaption FROM P_FormMenuConfigTab a\n" + "INNER JOIN P_SubSystemTab b ON a.SubSysId=b.SubSysId\n" + "WHERE ISNULL(b.UseEd,0)=1 and isnull(DllFileName,'')<>'' " + qxCond + ConfigMenuVisible + TargetMode; menuSearch.searcherPropertyCollector.QuerySQL = menuSearch.searcherPropertyCollector.SQL; this.initMainData(); new Thread(SetHostEntry).Start(); } private bool LoadSystemConfig() { bool Result = false; try { string strSql = string.Format("select * from p_systemtab "); DataTable dtTable = SqlHelper.ExecuteDataTable(strSql); foreach (DataRow dr in dtTable.Rows) { string ShortcutDll = (dr["ShortcutDll"] + "").Trim(); lblShortcutset.Tag = ShortcutDll; string OperatorNameDll = (dr["OperatorNameDll"] + "").Trim(); lbUserName.Tag = OperatorNameDll; Result = bool.Parse(dr["UseCustomTitleBar"] + ""); MainMenuType = Convert.ToInt32(dr["MainMenuType"]); this.tslCompany.Text = dr["ClientName"] + ""; this.lblSubTitle.Text = this.tslCompany.Text + "-" + ERPInfo.Instance.SubSysName; if (dtTable.Columns.Contains("MemuEventType")) { memuEventType = string.IsNullOrEmpty(dr["MemuEventType"] + "") ? 0 : Convert.ToInt32(dr["MemuEventType"] + ""); } if (dtTable.Columns.Contains("HeadMenuId")) { HeadMenuId = string.IsNullOrEmpty(dr["HeadMenuId"] + "") ? 0 : Convert.ToInt32(dr["HeadMenuId"] + ""); } } } catch (Exception ex) { PubUtil.WriteError("读取系统配置出错!", ex.Message); MessageBox.Show("读取系统配置出错!"); } return Result; } /// /// 检查是否配置我的桌面 /// /// private bool CheckDesktopConfig() { try { string sqlValue = string.Format("select 1 from P_SystemDesktopTab where 1<>1"); SqlHelper.ExecuteDataSet(sqlValue); return true; } catch (Exception ex) { } return false; } private string getQxCond() { // string Result = ""; // string qxCols = ""; // string strSql = "select name from sys.columns where object_id=object_id('p_SubsysPurviewTab') and name like '%purview'"; // try // { // DataTable dt = SqlHelper.ExecuteDataSet(strSql).Tables[0]; // foreach (DataRow dr in dt.Rows) // { // if (qxCols == "") // qxCols = "','+isnull(" + dr["name"].ToString() + ",'')+','"; // else // qxCols = qxCols + "+','+isnull(" + dr["name"].ToString() + ",'')+','"; // } // if (qxCols == "") // qxCols = @"','+isnull([KcPurview],'')+','+isnull([crmPurview],'')+','+isnull([bomPurview],'')+','+ // isnull([mrpPurview],'')+','+isnull([scmPurview],'')+','+isnull([sellPurview],'')+','+ // isnull([RdmPurview],'')+','+isnull([hrPurview],'')+','+isnull([costPurview],'')+','+ // isnull([eamPurview],'')+','+isnull([FmPurview],'')+','+isnull([oaPurview],'')+','+ // isnull([BiPurview],'')+','+isnull([QmsPurview],'')+','"; // else // qxCols = "','+" + qxCols; // Result = @"and (CHARINDEX(','+CAST(menuid as varchar)+',',(select top 1 // " + qxCols + @" // from [p_SubsysPurviewTab] // where employeeid=" + ERPInfo.Instance.EmployeeId.ToString() + "))>0 "+ // @" or CHARINDEX(','+CAST(menuid as varchar)+'|,',(select top 1 // " + qxCols + @" // from [p_SubsysPurviewTab] // where employeeid=" + ERPInfo.Instance.EmployeeId.ToString() + "))>0 "+ // "or len(menustruct)=2 or " + ERPInfo.Instance.EmployeeId.ToString() + "=1 or '" + ERPInfo.Instance.EmployeeName.ToString() + "'='管理员')"; // return Result; // } // catch (Exception ex) // { // PubUtil.WriteError("读取系统配置出错!", ex.Message); // MessageBox.Show("读取系统配置出错!"); // return ""; // } string Result = ""; string qxCols = ""; string qxCols1 = ""; string strSql = "select name from sys.columns where object_id=object_id('p_SubsysPurviewTab') and name like '%purview'"; try { DataTable dt = SqlHelper.ExecuteDataSet(strSql).Tables[0]; foreach (DataRow dr in dt.Rows) { if (qxCols == "") { qxCols = "','+isnull(" + dr["name"].ToString() + ",'')+','"; qxCols1 = "','+isnull(" + dr["name"].ToString() + ",'')+'|,'"; } else { qxCols = qxCols + "+','+isnull(" + dr["name"].ToString() + ",'')+','"; qxCols1 = qxCols1 + "+','+isnull(" + dr["name"].ToString() + ",'')+'|,'"; } } if (qxCols == "") { qxCols = @"','+isnull([KcPurview],'')+','+isnull([crmPurview],'')+','+isnull([bomPurview],'')+','+ isnull([mrpPurview],'')+','+isnull([scmPurview],'')+','+isnull([sellPurview],'')+','+ isnull([RdmPurview],'')+','+isnull([hrPurview],'')+','+isnull([costPurview],'')+','+ isnull([eamPurview],'')+','+isnull([FmPurview],'')+','+isnull([oaPurview],'')+','+ isnull([BiPurview],'')+','+isnull([QmsPurview],'')+','"; qxCols1 = @"','+isnull([KcPurview],'')+'|,'+isnull([crmPurview],'')+'|,'+isnull([bomPurview],'')+'|,'+ isnull([mrpPurview],'')+'|,'+isnull([scmPurview],'')+'|,'+isnull([sellPurview],'')+'|,'+ isnull([RdmPurview],'')+'|,'+isnull([hrPurview],'')+'|,'+isnull([costPurview],'')+'|,'+ isnull([eamPurview],'')+'|,'+isnull([FmPurview],'')+'|,'+isnull([oaPurview],'')+'|,'+ isnull([BiPurview],'')+',|'+isnull([QmsPurview],'')+'|,'"; } else { qxCols = "','+" + qxCols; qxCols1 = "','+" + qxCols1; } // Result = @"and (CHARINDEX(CAST(menuid as varchar)+',',(select top 1 // " + qxCols + @" // from [p_SubsysPurviewTab] // where employeeid=" + ERPInfo.Instance.EmployeeId.ToString() + "))>0 or len(menustruct)=2 or " + ERPInfo.Instance.EmployeeId.ToString() + "=1 or '" + ERPInfo.Instance.EmployeeName.ToString() + "'='管理员') "; Result = @"and (CHARINDEX(','+CAST(menuid as varchar)+',',(select top 1 " + qxCols + @" from [p_SubsysPurviewTab] where employeeid=" + ERPInfo.Instance.EmployeeId.ToString() + "))>0 " + @" or CHARINDEX(','+CAST(menuid as varchar)+'|,',(select top 1 " + qxCols1 + @" from [p_SubsysPurviewTab] where employeeid=" + ERPInfo.Instance.EmployeeId.ToString() + "))>0 " + "or len(menustruct)=2 or " + ERPInfo.Instance.EmployeeId.ToString() + "=1 or '" + ERPInfo.Instance.EmployeeName.ToString() + "'='管理员')"; return Result; } catch (Exception ex) { PubUtil.WriteError("读取系统配置出错!", ex.Message); MessageBox.Show("读取系统配置出错!"); return ""; } } /// /// 初始化系统DNS字段 /// private void InitHostEntryField() { try { // 创建DNS字段 string sqlValue = "alter table p_systemtab add DnsHostEntry varchar(50)"; int result = SqlHelper.ExecuteNonQuery(sqlValue); sqlValue = "update p_systemtab set DnsHostEntry = InternetIP"; result = SqlHelper.ExecuteNonQuery(sqlValue); } catch (Exception) { } } /// /// 解析DNS /// private void SetHostEntry() { try { this.InitHostEntryField(); string sqlValue = "select DnsHostEntry from p_systemtab"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue); if (dtTable != null && dtTable.Rows.Count > 0) { string dnsHostEntry = dtTable.Rows[0]["DnsHostEntry"] + ""; string startHost = dnsHostEntry.Substring(0, dnsHostEntry.IndexOf(".")); int startNumber = 0; if (!string.IsNullOrWhiteSpace(dnsHostEntry) && !Int32.TryParse(startHost, out startNumber)) { string ipAddress = Dns.GetHostEntry(dnsHostEntry).AddressList[0] + ""; sqlValue = string.Format("update p_systemtab set InternetIP = '{0}'", ipAddress); int result = SqlHelper.ExecuteNonQuery(sqlValue); } } } catch (Exception) { } } #endregion #region 窗口关闭 private void btnClose_Click(object sender, EventArgs e) { try { if (ERPInfo.Instance.SubCount == 1) { if (XtraMessageBox.Show("确定退出系统吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } this.Close(); //Process[] p = Process.GetProcessesByName("Ls_ERP"); //foreach (Process item in p) // item.Kill(); } else { PubUtil.ModuleForms.Clear(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void btnClose_MouseLeave(object sender, EventArgs e) { btnClose.BackgroundImage = Resources.close_default; } private void btnClose_MouseMove(object sender, MouseEventArgs e) { btnClose.BackgroundImage = Resources.close_select; } #endregion #region 窗口最大化 private void btnMax_Click(object sender, EventArgs e) { this.WindowState = this.WindowState == FormWindowState.Normal ? FormWindowState.Maximized : FormWindowState.Normal; btnMax.BackgroundImage = this.WindowState == FormWindowState.Normal ? Resources.max_default : Resources.window_default; this.calcPanelWidth(); } private void btnMax_MouseLeave(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Normal) { btnMax.BackgroundImage = Resources.max_default; } else { btnMax.BackgroundImage = Resources.window_default; } } private void btnMax_MouseMove(object sender, MouseEventArgs e) { if (this.WindowState == FormWindowState.Normal) { btnMax.BackgroundImage = Resources.max_select; } else { btnMax.BackgroundImage = Resources.window_select; } } #endregion #region 窗口最小化 private void btnMin_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; } private void btnMin_MouseLeave(object sender, EventArgs e) { btnMin.BackgroundImage = Resources.smail_default; } private void btnMin_MouseMove(object sender, MouseEventArgs e) { btnMin.BackgroundImage = Resources.smail_select; } #endregion #region 窗口拖动行为 private void plTop_MouseDoubleClick(object sender, MouseEventArgs e) { this.WindowState = this.WindowState == FormWindowState.Normal ? FormWindowState.Maximized : FormWindowState.Normal; btnMax.BackgroundImage = this.WindowState == FormWindowState.Normal ? Resources.max_default : Resources.window_default; this.calcPanelWidth(); this.calcMenuLocation(); } private void plTop_MouseDown(object sender, MouseEventArgs e) { base.OnMouseDown(e); m_mousePos = Cursor.Position; m_isMouseDown = true; } private void plTop_MouseUp(object sender, MouseEventArgs e) { base.OnMouseUp(e); m_isMouseDown = false; this.Focus(); } private void plTop_MouseMove(object sender, MouseEventArgs e) { base.OnMouseMove(e); if (m_isMouseDown) { Point tempPos = Cursor.Position; this.Location = new Point(Location.X + (tempPos.X - m_mousePos.X), Location.Y + (tempPos.Y - m_mousePos.Y)); m_mousePos = Cursor.Position; } } #endregion #region 底部状态栏 private void timer1_Tick(object sender, EventArgs e) { this.tsmi_time.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } #endregion #region 渲染顶部菜单 private void setMenuStripColor(Color color) { //menuStrip1.Renderer = new CustomProfessionalRenderer(color); } #endregion #region 重置界面宽度高度 /// /// 计算快速通道宽度 /// private void calcPanelWidth() { //int width = pl_center_main_bottom.Width; //pl_center_main_bottom_left_1.Width = pl_center_main_bottom_right_1.Width = width / 2; pl_center_main_bottom_left.Height = pl_center_main_bottom_right.Height = pl_center_main_right.Height / 2; } /// /// 重新计算菜单显示位置 /// private void calcMenuLocation() { int menuLeft = 5, menuTop = 5; // 模块距离左边距,模块距离顶部边距 int menuWidth = 110, menuHeight = 127; // 模块宽度,模块高度 int centerWidth = pl_center_main.Width - pl_center_main_right.Width; // 内容区域宽度-右侧快捷栏宽度 string defaultParentMenu = string.Empty; foreach (DataRow item in dtSubMenus.Rows) { defaultParentMenu = dtSubMenus.Rows[0]["menustruct"] + ""; string menuStruct = item["menustruct"] + ""; string menuCaption = item["menucaption"] + ""; string menuid = item["menuid"] + ""; if (menuStruct.Length == 2) { menuLeft = 5; menuTop = 5; } // 加载右侧模块 if (menuStruct.Length == 4) { Control[] ctrs = pl_center_main.Controls.Find(menuid, true); if (ctrs != null && ctrs.Length > 0) { if (ctrs[0] is Menu_Item) { ctrs[0].Location = new Point(menuLeft, menuTop); menuLeft += 116; // 换行显示 if (menuLeft + menuWidth > centerWidth) { menuLeft = 5; menuTop += menuHeight; } } } } } } #endregion #region 加载数据 /// /// 初始化数据 /// private void initMainData() { Application.DoEvents();// 处理当前消息队列中的所有windows消息 initMenus(); // 加载菜单、模块 initRightGallery(); // 加载通道数据 initTopMenu(); // 加载顶部菜单数据 } /// /// 加载左侧菜单 /// private void initMenus() { string sqlValue = string.Format(@"select * from (select a.* FROM p_formmenuconfigtab a WHERE SubSysId={0} " + qxCond + ConfigMenuVisible + TargetMode + @") x inner join (select left(MenuStruct,2) as MenuStruct,count(1) as menucount FROM p_formmenuconfigtab WHERE SubSysId={0} and isnull(dllfilename,'')<>'' " + qxCond + ConfigMenuVisible + TargetMode + @" group by left(MenuStruct,2) ) y on left(x.menustruct,2)=y.menustruct ORDER BY x.menustruct", ERPInfo.Instance.SubSysId); //MessageBox.Show(sqlValue); dtSubMenus = SqlHelper.ExecuteDataSet(sqlValue).Tables[0]; // buttonTop、menuLeft、menuTop=5 int buttonTop = Convert.ToInt32(0.05 * dpiY); // 按钮上边距 int menuLeft = Convert.ToInt32(0.05 * dpiY), menuTop = Convert.ToInt32(0.05 * dpiY); // 模块距离左边距,模块距离顶部边距 int menuWidth = Convert.ToInt32(1.14 * dpiX), menuHeight = Convert.ToInt32(1.32 * dpiY); // 模块宽度,模块高度 int centerWidth = pl_center_main.Width - pl_center_main_right.Width; // 内容区域宽度-右侧快捷栏宽度 string defaultParentMenu = string.Empty; Menu_Item_Button.ButtonHoverEventHandler hoverEvent = null; foreach (DataRow item in dtSubMenus.Rows) { string menuStruct = item["menustruct"] + ""; string menuCaption = item["menucaption"]+""; string menuid = item["menuid"] + ""; // 加载左侧菜单 if (menuStruct.Length == 2) { if (string.IsNullOrEmpty(defaultParentMenu)) defaultParentMenu = menuStruct; // menuLeft = 5; menuTop = 5; menuLeft = Convert.ToInt32(0.05 * dpiX); menuTop = Convert.ToInt32(0.05 * dpiY); Menu_Item_Button button = new Menu_Item_Button(); button.Size = new Size(Convert.ToInt32(1.52 * dpiX), Convert.ToInt32(0.46 * dpiX)); button.Location = new Point(2, buttonTop); button.BackColor = System.Drawing.Color.Transparent; button.GetButton().Text = item["menucaption"] + ""; button.GetButton().Tag = item; // 注册事件 hoverEvent += new Menu_Item_Button.ButtonHoverEventHandler(TriggerMenu); button.SetHoverEvent(hoverEvent, (MenuEventType)memuEventType); // 44 buttonTop += Convert.ToInt32(0.45 * dpiY); if (menuStruct == defaultParentMenu) { button.SetDefaultSelectMenu(button); button.SetButtonState(MenuButtonState.selectState); } pl_center_left.Controls.Add(button); // 缓存控件 if (!dicMenus.Keys.Contains(menuStruct)){ dicMenus.Add(menuStruct, new List()); } } // 加载右侧模块 if (menuStruct.Length == 4) { string defaultImg = PubUtil.AbsolutelyPath + "Images/main/module/" + item["MouseOutImg"] + ""; string hoverImg = PubUtil.AbsolutelyPath + "Images/main/module/" + item["MouseOverImg1"] + ""; Menu_Item menu = new Menu_Item(); menu.menuRow = item.Table.Columns.Contains("menuRow") && !string.IsNullOrEmpty(item["menuRow"] + "") ? Convert.ToInt32(item["menuRow"] + "") : 0; menu.Name = menuid; menu.Size = new Size(menuWidth, menuHeight); menu.menuNode = menuStruct.Substring(0, 2); menu.SetMenuCaption(menuCaption); menu.SetRoundRadius = 20; menu.GetButton().Tag = new string[] { item["DllFileName"] + "", item["PurviewId"] + "", item["MenuId"] + "", item["UrlParams"] + "", item["SubSysId"] + "", item["menucaption"] + "" }; menu.GetButton().Click += FrmMain_Click; try { menu.SetMenuImg(Image.FromFile(defaultImg)); } catch (Exception) { menu.SetMenuImg(Resources.default_icon); } // 116 //menuLeft += Convert.ToInt32(1.20 * dpiX); if (menu.menuRow > 0) { int count = _menuItemList.Where(o => o.menuRow == menu.menuRow && o.menuNode == menu.menuNode).Count(); menuLeft = count == 0 ? 5 : count * Convert.ToInt32(1.20 * dpiX) + 5; menuTop = menuHeight * (menu.menuRow - 1); menu.Location = new Point(menuLeft, menuTop); } else { menu.Location = new Point(menuLeft, menuTop); menuLeft += Convert.ToInt32(1.20 * dpiX); // 换行显示 if (menuLeft + menuWidth > centerWidth) { menuLeft = 5; menuTop += menuHeight; } } // 默认显示 if (defaultParentMenu != menuStruct.Substring(0, 2)) { menu.Visible = false; } pl_center_main.Controls.Add(menu); List controls = new List(); if (dicMenus.TryGetValue(menuStruct.Substring(0, 2), out controls)) { controls.Add(menu); } this._menuItemList.Add(menu); } } } /// /// 获取通道数据 /// private void initGallery() { string sqlValue = string.Format("select a.*,b.PurviewId from(select * from P_MessageToolLinkDllTab where employeeid={0} and grouptagid=1 " + " union " + " select * from P_MessageToolLinkDllTab where employeeid={0} and grouptagid=2 " + ")a join p_formmenuconfigtab b on a.LMenuId=b.MenuId where LinkModeTag=1 order by grouptagid,ItemTagId", ERPInfo.Instance.EmployeeId); DataTable dtTable = SqlHelper.ExecuteDataSet(sqlValue).Tables[0]; int top = 10, height = 30, left = 5; int width = pl_center_main_bottom_left_main.Width; int divide = width / 3; // 分为3等分 var baseTable = dtTable.Rows.Cast().Where(x => x["grouptagid"] + "" == "1").ToArray(); var reportTable = dtTable.Rows.Cast().Where(x => x["grouptagid"] + "" == "2").ToArray(); // 显示我的操作通道 for (int i = 0; i < baseTable.Count(); i++) { DataRow item = baseTable[i]; if (i > 0 && i % 3 == 0) { top += height; } Label label = new Label(); label.Location = new Point(i % 3 * divide + left, top); label.Text = item["DllShowCaption"] + ""; label.Font = new Font("微软雅黑", 10); label.Tag = item; label.MouseMove += label_MouseMove; label.MouseLeave += label_MouseLeave; pl_center_main_bottom_left_main.Controls.Add(label); } top = 10; // 显示我的报表通道 for (int i = 0; i < reportTable.Count(); i++) { DataRow item = reportTable[i]; if (i > 0 && i % 3 == 0) { top += height; } Label label = new Label(); label.Location = new Point(i % 3 * divide + left, top); label.Text = "· " + item["DllShowCaption"] + ""; label.Font = new Font("微软雅黑", 10); label.Tag = item; label.MouseMove += label_MouseMove; label.MouseLeave += label_MouseLeave; pl_center_main_bottom_right_main.Controls.Add(label); } } private void initRightGallery() { string sqlValue = string.Format("select a.*,b.PurviewId,b.UrlParams from(select * from P_MessageToolLinkDllTab where employeeid={0} and grouptagid=1 " + " union " + " select * from P_MessageToolLinkDllTab where employeeid={0} and grouptagid=2 " + ")a join p_formmenuconfigtab b on a.LMenuId=b.MenuId where LinkModeTag=1 order by grouptagid,ItemTagId", ERPInfo.Instance.EmployeeId); DataTable dtTable = SqlHelper.ExecuteDataSet(sqlValue).Tables[0]; int top = 10, height = 30, left = 12; int width = pl_center_main_bottom_left_main.Width; int divide = width / 3; // 分为3等分 var baseTable = dtTable.Rows.Cast().Where(x => x["grouptagid"] + "" == "1").ToArray(); var reportTable = dtTable.Rows.Cast().Where(x => x["grouptagid"] + "" == "2").ToArray(); // 显示我的操作通道 for (int i = 0; i < baseTable.Count(); i++) { DataRow item = baseTable[i]; if (i > 0) { top += height; } // 前方箭头 PictureBox pic = new PictureBox(); pic.BackgroundImage = Resources.arrows; pic.Size = new Size(16, 16); pic.Location = new Point(left, top); Label label = new Label(); label.Location = new Point(left + 20, top - 3); label.Text = item["DllShowCaption"] + ""; label.Font = new Font("微软雅黑", 10); label.ForeColor = ColorTranslator.FromHtml("#0a57a7"); label.Tag = item; label.MouseMove += label_MouseMove; label.MouseLeave += label_MouseLeave; label.MouseClick += label_MouseClick; pl_center_main_bottom_left_main.Controls.Add(pic); pl_center_main_bottom_left_main.Controls.Add(label); } top = 10; // 显示我的报表通道 for (int i = 0; i < reportTable.Count(); i++) { DataRow item = reportTable[i]; if (i > 0) { top += height; } // 前方箭头 PictureBox pic = new PictureBox(); pic.BackgroundImage = Resources.arrows; pic.Size = new Size(16, 16); pic.Location = new Point(left, top); Label label = new Label(); label.Location = new Point(left + 20, top - 3); label.Text = item["DllShowCaption"] + ""; label.Font = new Font("微软雅黑", 10); label.ForeColor = ColorTranslator.FromHtml("#0a57a7"); label.Tag = item; label.MouseMove += label_MouseMove; label.MouseLeave += label_MouseLeave; label.MouseClick += label_MouseClick; pl_center_main_bottom_right_main.Controls.Add(pic); pl_center_main_bottom_right_main.Controls.Add(label); } } /// /// 加载顶部菜单数据(有权限的) /// private void initTopMenu() { try { string sqlValue = "select SubSysId,SubSysName from P_SubSystemTab where UseEd=1 order by orderid,right('000'+cast(showid as varchar),3)+right('0000'+cast(SubSysId as varchar),4)"; DataTable dtTable = SqlHelper.ExecuteDataSet(sqlValue).Tables[0]; string sqlValue1 = string.Empty; // MainMenuType:1: 加载子系统菜单数据,2.加载所有菜单,3.加载子系统权限菜单,4.加载所有权限菜单 if (MainMenuType == 1 || MainMenuType == 3) { sqlValue1 = string.Format(@"select * from (select MenuId,MouseOutImg,MouseOverImg1,MenuCaption,DllFileName,MenuStruct,PurviewId,UrlParams,subsysid FROM p_formmenuconfigtab WHERE SubSysId={0} " + qxCond + ConfigMenuVisible + TargetMode + @") x inner join (select left(MenuStruct,2) as MenuStruct,count(1) as menucount FROM p_formmenuconfigtab WHERE SubSysId={0} and isnull(dllfilename,'')<>'' " + qxCond + ConfigMenuVisible + TargetMode + @" group by left(MenuStruct,2) ) y on left(x.menustruct,2)=y.menustruct ORDER BY x.menustruct", ERPInfo.Instance.SubSysId); } else { sqlValue1 = string.Format(@"select * from (select MenuId,MouseOutImg,MouseOverImg1,MenuCaption,DllFileName,MenuStruct,PurviewId,UrlParams,subsysid FROM p_formmenuconfigtab WHERE 1=1 " + qxCond + ConfigMenuVisible + TargetMode + @") x inner join (select left(MenuStruct,2) as MenuStruct,count(1) as menucount FROM p_formmenuconfigtab WHERE isnull(dllfilename,'')<>'' " + qxCond + ConfigMenuVisible + TargetMode + @" group by left(MenuStruct,2) ) y on left(x.menustruct,2)=y.menustruct ORDER BY x.menustruct"); } dtAllMenus = SqlHelper.ExecuteDataSet(sqlValue1).Tables[0]; foreach (DataRow item in dtTable.Rows) { string subSysName = item["SubSysName"] + ""; string subSysId = item["SubSysId"] + ""; bool hasContainMenu = false; ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Text = subSysName; menuItem.Tag = subSysId; menuItem.Font = new Font("微软雅黑", 12); menuItem.BackColor = Color.Transparent; menuItem.ForeColor = Color.White; menuItem.DropDownClosed += new EventHandler(menuItem_DropDownClosed); menuItem.DropDownOpened += new EventHandler(menuItem_DropDownOpened); //menuItem.MouseDown += menuItem_MouseDown; DataTable subTable = new DataTable(); try { subTable = dtAllMenus.Rows.Cast().Where(x => x["subsysid"] + "" == subSysId && (x["MenuStruct"] + "").Length == 2).CopyToDataTable(); } catch (Exception) { } if (subTable != null && subTable.Rows.Count > 0) { foreach (DataRow row in subTable.Rows) { Application.DoEvents();// 处理当前消息队列中的所有windows消息 string menuStruct = row["MenuStruct"] + ""; string menuCaption = row["MenuCaption"] + ""; ToolStripMenuItem subItem = new ToolStripMenuItem(menuCaption); subItem.Font = new Font("微软雅黑", 10); // 功能模块 try { DataTable childs = new DataTable(); try { childs = dtAllMenus.Rows.Cast().Where(x => x["subsysid"] + "" == subSysId && (x["MenuStruct"] + "").Length == 4 && (x["MenuStruct"] + "").Substring(0, 2) == menuStruct).CopyToDataTable(); } catch (Exception) { } if (childs != null && childs.Rows.Count > 0) { hasContainMenu = true; foreach (DataRow child in childs.Rows) { Application.DoEvents();// 处理当前消息队列中的所有windows消息 ToolStripMenuItem childItem = new ToolStripMenuItem(); childItem.Text = child["MenuCaption"] + ""; childItem.Font = new Font("微软雅黑", 10); childItem.Tag = new string[] { child["DllFileName"] + "", child["PurviewId"] + "", child["MenuId"] + "", child["UrlParams"] + "", subSysId + "" }; childItem.Click += subItem_Click; subItem.DropDownItems.Add(childItem); } menuItem.DropDownItems.Add(subItem); } } catch (Exception) { } } if (hasContainMenu) menuMain.Items.Add(menuItem); } } } catch (Exception ex) { PubUtil.WriteError("读取菜单数据出错!", ex.Message); MessageBox.Show("读取菜单数据出错!" + ex.Message); } } void menuItem_DropDownOpened(object sender, EventArgs e) { ToolStripMenuItem menuItem = (sender as ToolStripMenuItem); if (menuItem != null) { menuItem.ForeColor = Color.Black; } } void menuItem_DropDownClosed(object sender, EventArgs e) { ToolStripMenuItem menuItem = (sender as ToolStripMenuItem); if (menuItem != null) { menuItem.ForeColor = Color.White; } } /// /// 加载明细 /// /// /// /// private void initTopSubMenus(string subSysId, DataTable subTable, ToolStripMenuItem parent) { //foreach (DataRow row in subTable.Rows) //{ // if (menuStruct.Length == 2) // { // // if (childs.Rows.Count > 0) // { // initTopSubMenus(subSysId, childs, subItem); // } // } // else // { // ToolStripMenuItem subItem = new ToolStripMenuItem(); // subItem.Text = menuCaption; // subItem.Tag = new string[] { row["DllFileName"] + "", row["PurviewId"] + "", row["MenuId"] + "", row["UrlParams"] + "", subSysId + "" }; // subItem.Click += subItem_Click; // parent.DropDownItems.Add(subItem); // } //} } /// /// 顶部菜单打开模块 /// /// /// public void subItem_Click(object sender, EventArgs e) { try { ToolStripMenuItem item = (ToolStripMenuItem)sender; string[] arr = (string[])item.Tag; int subSysId = arr.Length == 5 ? Convert.ToInt32(arr[4]) : ERPInfo.Instance.SubSysId; this.OpenMenu(subSysId, int.Parse(arr[2]), item.Text, arr[0], arr[1], arr[3]); } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 功能图标打开模块 /// /// /// public void FrmMain_Click(object sender, EventArgs e) { try { Button item = (Button)sender; string[] arr = (string[])item.Tag; int subSysId = arr.Length == 6 ? Convert.ToInt32(arr[4]) : ERPInfo.Instance.SubSysId; this.OpenMenu(subSysId, int.Parse(arr[2]), arr[5], arr[0], arr[1], arr[3]); } catch (Exception ex) { MessageBox.Show(ex.Message); } } public void label_MouseLeave(object sender, EventArgs e) { Label label = sender as Label; label.Font = new Font("微软雅黑", 10); label.ForeColor = ColorTranslator.FromHtml("#0a57a7"); } /// /// 快速通道 /// /// /// public void label_MouseMove(object sender, MouseEventArgs e) { Label label = sender as Label; label.Font = new Font("微软雅黑", 10, FontStyle.Bold | FontStyle.Underline); label.ForeColor = ColorTranslator.FromHtml("#1ba109"); this.Cursor = Cursors.Hand; } // 打开模块 public void label_MouseClick(object sender, MouseEventArgs e) { Label label = sender as Label; DataRow item = label.Tag as DataRow; if (item != null) { this.OpenMenu(Convert.ToInt32(item["LSubSysId"] + ""), Convert.ToInt32(item["LMenuId"] + ""), item["DllShowCaption"] + "", item["ObjDll"] + "", item["PurviewId"] + "", item["UrlParams"] + ""); } } /// /// 切换模块 /// /// public void TriggerMenu(Button before,Button after) { if (before != null) { DataRow item_before = before.Tag as DataRow; DataRow item_after = after.Tag as DataRow; if (item_before != null) { List beforeButtons = new List(); List afterButtons = new List(); // 隐藏控件 if (dicMenus.TryGetValue(item_before["menustruct"] + "", out beforeButtons)) { foreach (Menu_Item item in beforeButtons) { item.Visible = false; } } // 显示控件 if (dicMenus.TryGetValue(item_after["menustruct"] + "", out afterButtons)) { foreach (Menu_Item item in afterButtons) { item.Visible = true; } } } } } public void image_OnFrameChanged(object sender, EventArgs e) { Invalidate(); } #endregion #region 加载我的桌面 /// /// 加载基础档案表格列头 /// /// public DataTable InitColumns(string dllcoid) { SqlParameter[] p = { new SqlParameter("@modid",SqlDbType.VarChar,20), new SqlParameter("@operatorname",SqlDbType.VarChar,20) }; p[0].Value = dllcoid; p[1].Value = ERPInfo.Instance.OperatorName; return SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "[p_getBaseModuleField]", "temp", p).Tables[0]; } /// /// 初始化我的桌面 /// public void initDesktop() { try { this.plDesktop.Controls.Clear(); this.dicGrids.Clear(); string sqlValue = string.Format(@"select b.MenuCaption,ISNULL(b.UrlParams,'') DllCoid,b.DllFileName,MAX(b.SubSysId) SubSysId,MAX(b.MenuId) MenuId,b.PurviewId,max(c.sql) sql from P_SystemDesktopTab a inner join P_FormMenuConfigTab b on a.Menuid=ISNULL(b.UrlParams,'') inner join p_systemDlltab c on a.Menuid=c.DllCoid where LOWER(b.DllFileName) IN ('lskj.pubmodule.dll','lskj.pubmoduledetail.dll','lskj.report.dll','lskj.pubmoduletd.dll') and a.OperatorId='{0}' group by b.MenuCaption,ISNULL(b.UrlParams,''),b.DllFileName,b.PurviewId,a.OrderId order by a.OrderId", ERPInfo.Instance.EmployeeId); dtDesktop = SqlHelper.ExecuteDataSet(sqlValue).Tables[0]; int height = this.plDesktop.Height; int width = this.plDesktop.Width; int top = 5, left = 5; for (int i = 1; i <= dtDesktop.Rows.Count; i++) { DataRow dr = dtDesktop.Rows[i - 1]; GroupBox gb = new GroupBox(); gb.Height = height / 2 - 10; gb.Width = width / 2 - 15; if (i > 2) { top = i % 2 == 1 ? top + gb.Height + 5 : top; } left = i % 2 == 0 ? width / 2 - 5 : 5; gb.Top = top; gb.Left = left; gb.Text = dr["MenuCaption"] + ""; DataTable dtColumns = InitColumns(dr["DllCoid"] + ""); string gcSql = dr["sql"] + ""; List listParam = PubClass.GetParamValue(gcSql); foreach (string s in listParam) { string filedName = s.Replace("{", "").Replace("}", ""); if (filedName.IndexOf("loginname", StringComparison.OrdinalIgnoreCase) != -1) { gcSql = gcSql.Replace(s, ERPInfo.Instance.OperatorName); } else if (filedName.IndexOf("loginid") != -1) { gcSql = gcSql.Replace(s, ERPInfo.Instance.EmployeeId + ""); } else { gcSql = gcSql.Replace(s, ""); } } GridControlEx gce = new GridControlEx(); gce.Dock = DockStyle.Fill; gce.Sql = gcSql; gce.SetColumns2(gce.ResetColumns(dtColumns)); gb.Controls.Add(gce); plDesktop.Controls.Add(gb); dicGrids.Add(i + "", gce); Application.DoEvents(); } FrmProgressBar bar = new FrmProgressBar(); bar.dicGrids = dicGrids; bar.ShowDialog(); } catch (Exception ex) { XtraMessageBox.Show("加载桌面失败" + ex.Message); } } #endregion #region 打开模块 /// /// 打开模块 /// /// /// /// /// /// public void OpenMenu(int subSysId, int menuId, string menuName, string dllName, string modelFlag, string urlParams, bool isVerify = true) { int OpenMode = ERPInfo.Instance.SoftOpenMode; int Code = 1; if (isVerify) { Code = GetOperatorPurview(subSysId, menuId); string showid = Convert.ToString(Code); if (Code == 0) { XtraMessageBox.Show("你无权操作此功能"); return; } } string Systmp = ServerTimer.ServerTime.ToString("yyyy-MM-dd HH:mm:ss:fff") + "@" + (new Random()).Next(1000).ToString(); PubUtil.WriteOpLog(Systmp, menuId.ToString(), "操作模块", menuName, menuName); DllModule dm = new DllModule(); dm.DllName = dllName; dm.Id = menuId.ToString(); dm.Name = menuName; string[] args = { menuName, ERPInfo.Instance.EmployeeId.ToString(), ERPInfo.Instance.EmployeeName, ERPInfo.Instance.Privilege, urlParams, menuId+"" }; if (string.IsNullOrEmpty(dllName) || string.IsNullOrEmpty(menuId + "")) { XtraMessageBox.Show("未找到对应模块参数,请联系管理员"); return; } dllName = dllName.Replace("{loginid}", ERPInfo.Instance.EmployeeId.ToString()); dllName = dllName.Replace("{loginname}", ERPInfo.Instance.EmployeeName.ToString()); //打开exe if (dllName.ToLower().IndexOf(".exe", 1) != -1) { PubUtil.WinExec(dllName, 0); } else if ((dllName.ToLower().IndexOf("http:", StringComparison.OrdinalIgnoreCase) != -1) || (dllName.ToLower().IndexOf("www.", StringComparison.OrdinalIgnoreCase) != -1) || (dllName.ToLower().IndexOf("ftp:", StringComparison.OrdinalIgnoreCase) != -1)) { try { System.Diagnostics.Process.Start(dllName); } catch (Exception) { Process.Start("iexplore.exe", dllName); } } else if (OpenMode == 0) { if (modelFlag == string.Empty) { //ModuleManager.AddModuleDelphiToTab(TabMain, dm, true); PubUtil.LoadDelphiDll(PubUtil.AbsolutelyPath + "lib/" + dllName, "", menuName, "", "", Code, urlParams); } else { ModuleManager.AddModuleToTab(TabMain, dm, args, true); } } else if (OpenMode == 1) { if (modelFlag == string.Empty) { //ModuleManager.AddModuleDelphiToShow(dm); PubUtil.LoadDelphiDll(PubUtil.AbsolutelyPath + "lib/" + dllName, "", menuName, "", "", Code, urlParams); } else { ModuleManager.AddModuleToShow(dm, args); } } else { if (modelFlag == string.Empty) PubUtil.LoadDelphiDll(PubUtil.AbsolutelyPath + "lib/" + dllName, "", menuName, "", "", Code, urlParams); else { IForm form = PubUtil.LoadDllForm(dllName, args); form.SubForm.Show(); } } PubUtil.WriteOpLog(Systmp); } private int GetOperatorPurview(int Gsysid, int I2) { if (ERPInfo.Instance.EmployeeName == "管理员") return 1; int OperatorPurview = 0; string strSql = "select * from P_SubSystemTab where subsysid=" + Gsysid.ToString(); try { string systempurview = ""; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, strSql, null)) { if (dr.Read()) { systempurview = dr["subsyscode"].ToString().Trim() + "purview"; } } strSql = "select * from p_SubsysPurviewTab where employeeid=" + ERPInfo.Instance.EmployeeId.ToString(); string purviewStr = ""; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, strSql, null)) { if (dr.Read()) { if (dr[systempurview].ToString().Trim() == "") purviewStr = ",0,"; else purviewStr = "," + dr[systempurview].ToString().Trim(); } } int i = 0; strSql = "select CHARINDEX('," + I2.ToString() + ",','" + purviewStr + "') as aaa"; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, strSql, null)) { if (dr.Read()) { i = int.Parse(dr["aaa"].ToString()); } } if (i != 0) { OperatorPurview = 1; return OperatorPurview; } strSql = "select CHARINDEX('," + I2.ToString() + "|,','" + purviewStr + "') as aaa"; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, strSql, null)) { if (dr.Read()) { i = int.Parse(dr["aaa"].ToString()); } } if (i != 0) { OperatorPurview = 2; } } catch (Exception ex) { PubUtil.WriteError("查询权限出错,请与管理员联系", ex.Message); MessageBox.Show("查询权限出错,请与管理员联系"); } return OperatorPurview; } #endregion #region 关闭模块 private void TabMain_HotTrackedPageChanged(object sender, TabPageChangedEventArgs e) { try { CurrentPage = e.Page; } catch (System.Exception ex) { CurrentPage = null; } } private void TabMain_CloseButtonClick(object sender, EventArgs e) { try { DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs EArg = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e; //XtraTabPage tp = this.TabMain.SelectedTabPage; //根据标题栏汉字决定,后台定义时注意功能描述必须唯一 //string pgText = EArg.Page.Text; //foreach (XtraTabPage page in TabMain.TabPages) //{ // if (page.Text == pgText) // { // tp = page; // break; // } //} XtraTabPage tp = EArg.Page as XtraTabPage; if (tp != null) { string guid = tp.Tag + ""; DllModule m = PubUtil.ModuleForms[guid]; if (PubUtil.ModuleForms.ContainsKey(guid)) { TabMain.TabPages.Remove(tp); PubUtil.UnLoadDLL(m.ModuleForm); PubUtil.ModuleForms.Remove(m.Id); } } } catch { } } private void TabMain_MouseDoubleClick(object sender, MouseEventArgs e) { if (CurrentPage == null) { return; } try { string guid = CurrentPage.Tag + ""; DllModule m = PubUtil.ModuleForms[guid]; if (PubUtil.ModuleForms.ContainsKey(guid)) { TabMain.TabPages.Remove(CurrentPage); PubUtil.UnLoadDLL(m.ModuleForm); PubUtil.ModuleForms.Remove(m.Id); } } catch { } } #endregion #region 筛选打开模块相关 /// /// 选择模块后 /// /// /// private void menuSearch_GetReturnValue(object sender, EventArgs e) { AutoSearcher search = sender as AutoSearcher; if (!string.IsNullOrEmpty(search.ReturnValue)) { if (XtraMessageBox.Show("确定打开[" + search.Text + "]模块?", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var item = dtAllMenus.Rows.Cast().FirstOrDefault(x => x["menuid"] + "" == search.ReturnValue); if (item != null) { this.OpenMenu(Convert.ToInt32(item["SubSysId"] + ""), Convert.ToInt32(item["MenuId"] + ""), item["menucaption"] + "", item["DllFileName"] + "", item["PurviewId"] + "", item["UrlParams"] + ""); } } } } /// /// OnTextChange之前调用 /// /// /// private void menuSearch_HandleSQL(object sender, EventArgs e) { ControlLib.inh.AutoSearcher search = (ControlLib.inh.AutoSearcher)sender; if (search.Text == "请输入模块名称") { search.Text = ""; } } #endregion #region 打开修改密码 private void lbUserName_Click(object sender, EventArgs e) { try { string OperatorNameDll = lbUserName.Tag + ""; if (string.IsNullOrEmpty(OperatorNameDll)) { PubUtil.LoadDelphiDll(PubUtil.AbsolutelyPath + "lib/" + OperatorNameDll); } else { PubUtil.LoadDelphiDll(PubUtil.AbsolutelyPath + "lib/p_PassWordMge.lsp"); } } catch (Exception) { XtraMessageBox.Show("打开修改密码出错,请联系管理员"); } } #endregion #region 切换用户 /// /// 切换用户 /// /// /// private void lblSwapUser_Click(object sender, EventArgs e) { FrmRelogin _FrmRelogin = new FrmRelogin(); _FrmRelogin.ShowDialog(); ENUMCloseAction eca = ERPInfo.Instance.ExitResult; if (eca == ENUMCloseAction.caRelogin) { PubUtil.ModuleForms.Clear(); this.Close(); } PubUtil.ReleaseForm(_FrmRelogin); _FrmRelogin = null; } #endregion #region 打开快捷通道配置 private void lblShortcutset_Click(object sender, EventArgs e) { try { string ShortcutDll = lblShortcutset.Tag + ""; if (!string.IsNullOrEmpty(ShortcutDll)) { PubUtil.LoadDelphiDll(PubUtil.AbsolutelyPath + "lib/" + ShortcutDll); } else { PubUtil.LoadDelphiDll(PubUtil.AbsolutelyPath + "lib/P_Lsplanes.lsp"); } } catch (Exception) { XtraMessageBox.Show("打开配置快捷通道出错,请联系管理员"); } } #endregion #region 无标题栏窗体最大化最小化 protected override CreateParams CreateParams { get { const int WS_MINIMIZEBOX = 0x00020000; // Winuser.h中定义 CreateParams cp = base.CreateParams; cp.Style = cp.Style | WS_MINIMIZEBOX; // 允许最小化操作 return cp; } } #endregion #region 设置我的桌面 private void lblSetting_Click(object sender, EventArgs e) { if (isOpenDesktop) { FrmSetDesktop frm = new FrmSetDesktop(); frm.userid = ERPInfo.Instance.EmployeeId; DialogResult result = frm.ShowDialog(); if (result == DialogResult.OK) { initDesktop(); } } else { XtraMessageBox.Show("检测到未开启我的桌面"); } } #endregion private void label1_Click(object sender, EventArgs e) { DataRow item = label1.Tag as DataRow; if (item != null) { this.OpenMenu(Convert.ToInt32(item["SubSysId"] + ""), Convert.ToInt32(item["MenuId"] + ""), item["menucaption"] + "", item["DllFileName"] + "", item["PurviewId"] + "", item["UrlParams"] + "", false); } } } }