diff --git a/插件库/Lskj.Main/Control/MainPanelControlEx.cs b/插件库/Lskj.Main/Control/MainPanelControlEx.cs
index 56e8e14..5ec658a 100644
--- a/插件库/Lskj.Main/Control/MainPanelControlEx.cs
+++ b/插件库/Lskj.Main/Control/MainPanelControlEx.cs
@@ -1,4563 +1,4577 @@
-/***********************
-* 说明:主窗体界面的构建
-* 创建人:龚宇超
-* 创建日期:
-* 修改人:
-* 修改日期:
-* 修改备注:
-* 版本:1.0.0.0
-***********************/
-using DevExpress.LookAndFeel;
-using DevExpress.XtraEditors;
-using DevExpress.XtraTab;
-using DevExpress.XtraTab.ViewInfo;
-using Lskj.Business;
-using Lskj.Business.Impl;
-using Lskj.Control;
-using Lskj.Control.Model;
-using Lskj.Core;
-using Lskj.Data;
-using Lskj.Main.Model;
-using Lskj.Main.Properties;
-using Lskj.Model;
-using Lskj.Util;
-using Microsoft.Win32;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Diagnostics;
-using System.Drawing;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Reflection;
-using System.Text;
-using System.Threading;
-using System.Windows.Forms;
-
-namespace Lskj.Main.Control
-{
- public partial class MainPanelControlEx : UserControl
- {
- #region 公有属性
- ///
- /// 屏幕dpix、dpiy
- ///
- public float DpiX, DpiY;
- public int plTopHeight
- {
- get { return plTop.Height; }
- }
-
- ///
- /// 最大化回调
- ///
- public event EventHandler OnMaxButtonCallBack;
- ///
- /// 最小化回调
- ///
- public event EventHandler OnMinButtonCallBack;
- ///
- /// 关闭回调
- ///
- public event EventHandler OnCloseButtonCallBack;
- ///
- /// 顶部双击回调
- ///
- public event EventHandler OnTopPanelMouseDoubleClickCallBack;
- ///
- /// Occurs when [on top mouse down callback].
- ///
- public event MouseEventHandler OnTopMouseDownCallback;
- ///
- /// Occurs when [on top mouse up call back].
- ///
- public event MouseEventHandler OnTopMouseUpCallBack;
- ///
- /// Occurs when [on top mouse move call back].
- ///
- public event MouseEventHandler OnTopMouseMoveCallBack;
- ///
- /// 窗口状态
- ///
- public FormWindowState State;
- ///
- /// 界面主页签
- ///
- public XtraTabControl TabMain { get { return this.tabMain; } }
- ///
- /// 主Panel
- ///
- public Panel MainPanel { get { return this.plMain; } }
- ///
- /// 锁屏窗口
- ///
- public AwaitScreenControl AwaitControl { get { return this.awaitScreenControl; } }
- #endregion
-
- #region 私有属性
- private MenuBar _firstMenuBar;
- private bool _firstSubItemFocus;
- private bool _firstAccountsFocus;
- ///
- /// 模块sql
- ///
- private string _menuSql;
- ///
- /// 权限条件
- ///
- private string _purviewCond = string.Empty;
- ///
- /// 上次点击的按钮
- ///
- private Button _lastMenuButton;
- ///
- /// 当前配置的模块
- ///
- private DataTable _allMenus = new DataTable();
- ///
- /// 子系统菜单
- ///
- private DataTable _subItemMenu;
- ///
- /// 缓存菜单控件
- ///
- private Dictionary> _menus = new Dictionary>();
- ///
- /// 缓存分组控件
- ///
- private Dictionary _groupItems = new Dictionary();
- ///
- /// 缓存右上菜单控件
- ///
- private Dictionary topLayoutPanelDic = new Dictionary();
- ///
- /// 缓存右下菜单控件
- ///
- private Dictionary botLayoutPanelDic = new Dictionary();
- ///
- /// 缓存菜单
- ///
- private List _menuItemList = new List();
- ///
- /// 第一个menuItem
- ///
- private ToolStripMenuItem _firstMenuItem;
- ///
- /// 上次点击的菜单
- ///
- private ToolStripMenuItem _lastMenuItem;
- ///
- /// 子系统小窗口
- ///
- private SubItemForm _subItemForm;
- ///
- /// 套账小窗口
- ///
- private SubItemForm _accountsItemForm;
- ///
- /// 判断消息框是否加载完成
- ///
- private bool _isFinish = true;
- ///
- /// 分辨率选择小窗口
- ///
- private ResSelectForm _resSelectForm = new ResSelectForm();
- ///
- /// 快捷窗口圆角
- ///
- private Dictionary _quickPageHeaders = new Dictionary();
- ///
- /// 默认模块(右上角)圆角
- ///
- private List defaultModuleRoundedCornerss = new List();
-
- ///
- /// 当前所有配置了countSql的模块和对于的模块号
- ///
- private Dictionary countSqls = new Dictionary();
- ///
- /// 初始化完成
- ///
- private bool _isInitFinish = false;
- ///
- ///是否为流布局
- ///
- private bool isFlowLayout = false;
- ///
- ///分组时快捷菜单是否显示在内部
- ///
- private bool isShowGrallyInTop = false;
- ///
- ///模式3打开,上一次点击的时间
- ///
- public DateTime lastClickTime;
- ///
- ///子目录是否已经存在 更多 选项
- ///
- public bool isMore;
- ///
- /// 更多
- ///
- public ToolStripMenuItem more = new ToolStripMenuItem();
- ///
- /// 主页面默认模块数据
- ///
- public List DefaultModules = new List();
-
- ///
- /// 隐藏账套
- ///
- public bool HiddenAccountSet = false;
-
- ///
- /// 上一次选中的页签
- ///
- public XtraTabPage PreviousTab = null;
- ///
- /// 鼠标点击状态
- ///
- private MouseButtons mouseButtons;
-
- #endregion
-
- #region 初始加载
- public MainPanelControlEx()
- {
- InitializeComponent();
- }
- ///
- /// 说明:初始加载时
- /// 创建人 龚宇超
- /// 创建日期:2018-04-24
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- public void OnLoad()
- {
- try
- {
- WaitForm.ShowForm();
-
- ContextMenuStrip headMenuStrip = new ContextMenuStrip();
- headMenuStrip.Opening += HeadMenuStripOpening;
- ToolStripMenuItem removeOtherItem = new ToolStripMenuItem();
- removeOtherItem.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("关闭其他") : "关闭其他";
- removeOtherItem.Click += new EventHandler(RemoveItemClick);
- ToolStripMenuItem removeLeftItem = new ToolStripMenuItem();
- removeLeftItem.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("关闭左侧") : "关闭左侧";
- removeLeftItem.Click += new EventHandler(RemoveItemClick);
- ToolStripMenuItem removeRightItem = new ToolStripMenuItem();
- removeRightItem.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("关闭右侧") : "关闭右侧";
- removeRightItem.Click += new EventHandler(RemoveItemClick);
- headMenuStrip.Items.Add(removeOtherItem);
- headMenuStrip.Items.Add(removeLeftItem);
- headMenuStrip.Items.Add(removeRightItem);
- tabMain.ContextMenuStrip = headMenuStrip;
- //设置文件存放路径 ()
- try
- {
- string DownloadFileDirectory = string.Format("{0}\\{1}", Application.StartupPath, "RightDownloadFile");
- if (Directory.Exists(DownloadFileDirectory))
- {
- Directory.Delete(DownloadFileDirectory, true);
- }
- Directory.CreateDirectory(DownloadFileDirectory);
- }
- catch (Exception)
- {
- }
- //SystemInfo.Instance.IsCacheRun = true;
- try
- {
- RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);
- key.SetValue("EnableLUA", "0");
- key.Close();
- }
- catch (Exception)
- {
- }
- this.isFlowLayout = SystemInfo.Instance.isFlowLayout;
- if (isFlowLayout)
- {
- this.pl_center_main_middle_FlowLayout.Visible = true;
- this.pl_center_main_middle.Visible = false;
- this.pl_center_main_middle_FlowLayout.BackColor = this.pl_center_main_middle.BackColor;
- }
- this.pl_top_left.Visible = false;
- this.menuMain.Visible = false;
- this.lblSubTitle.Visible = false;
- this.toolStripLabel1.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("版本号") + ":" + SystemInfo.Instance.Version : "版本号:" + SystemInfo.Instance.Version;
- this.SetDesktop();
- this.SetFormObject();
- this.SetAccounts();//设置账套
- //没有账套,并且模式3没有切换系统,就把右上方宽度缩小
- if (HiddenAccountSet && (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4))
- {
- pl_top_right.Width = pl_top_right.Width - this.label1.Left - this.label1.Width;
- }
- if (SystemInfo.Instance.HideSkin)
- {
- this.button3.Visible = false;
- this.lblSetting.Visible = false;
- }
- this.SetTopMenus();
- InitializeSplitterPosition();
- this.SetGallerys();
- this.SetDefaultMenu();
- this.SetSubItemForm();
-
- if (SystemInfo.Instance.HideGallerys)
- {
- this.splitMainControl.Panel2Collapsed = true;
- }
- //控件事件订阅
- ResSelectForm.MouseClickEventHanlder clickEvent = null;
- clickEvent += new ResSelectForm.MouseClickEventHanlder(OnBtnCloseClick);
- _resSelectForm.SetClickEvent(clickEvent);
- //传统模式
- if (SystemInfo.Instance.DefaultMainTag == 2)
- {
- //非传统模式左部分菜单
- this.InitLeftMenu();
- }
- else
- {
- this.SetMenus();
- this.SetSearchMenus();
- this.tv_left.Visible = false;
- }
- if (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4)
- {
- this.button5.Visible = false;
- this.label2.Visible = false;
- }
- if (!SystemInfo.Instance.RefreshNotify) this.SetNotifys();
- this.SetHostEntry();
- // 解析dns
- new Thread(MainImpl.DnsHostEntry).Start();
- this.mark_timer.Start();
-
- ERPInfo.Instance.PageControl = this.tabMain;
- ERPInfo.Instance.ModuleForms = Manager.ModuleForms;
- if ((!this._allMenus.Columns.Contains("menuposition") || (!SystemInfo.Instance.IsOpenWork && !SystemInfo.Instance.ShowGallerysFromMenu)) && (!SystemInfo.Instance.HideGallerys || SystemInfo.Instance.DesktopFormatShowGallerys))
- {
- this.lblShortcutset.DoubleClick += OnShortCutDoubleClick;
- this.lblReportcutset.DoubleClick += OnShortCutDoubleClick;
- }
- splitMainControl.SplitterMoved += new SplitterEventHandler(OnSplitterPositionChanged);
- //workSplitMainControl.SplitterPositionChanged += new EventHandler(OnWorkSplitPositionChanged);
- OnLayoutSizeChanged();
- //有我的桌面并且是特殊展示时,默认选中我的桌面
- if (!string.IsNullOrEmpty(SystemInfo.Instance.DesktopUrl) && SystemInfo.Instance.DesktopFormat) this.tabMain.SelectedTabPage = this.xtpDesktop;
- //加密狗验证
- if (SystemInfo.Instance.IsDogVerify) this.DogVerify();
-
- if (SystemInfo.Instance.DisableFormalization)
- {
- this.btnMax.Visible = false;
- this.btnMin.Location = new Point(this.btnMax.Location.X, this.btnMax.Location.Y);
- }
-
- if (SystemInfo.Instance.CancelDoubleClickClose)
- {
- this.tabMain.DoubleClick -= this.OnTabMainClick;
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- finally
- {
- Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
- WaitForm.HideForm();
- Manager.frmHeight = Screen.PrimaryScreen.WorkingArea.Height - this.plTopHeight;
- //this.Information_timer.Start();
- _isInitFinish = true;
- }
- }
- ///
- /// 说明:加载速度优化
- /// 创建人:唐德馨
- /// 创建日期:2021-09-03
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- ///
- ///
- //protected override CreateParams CreateParams
- //{
- // get
- // {
- // CreateParams cp = base.CreateParams;
- // if (Lskj.Control.Model.AutoSizeChange.value != 1)
- // {
- // cp = base.CreateParams;
- // cp.ExStyle |= 0x02000000;
- // return cp;
- // }
- // else
- // return cp;
- // }
- //}
-
- ///
- /// 刷新上一次切换的页面
- ///
- //private void SetLastFormObject()
- //{
- // try
- // {
-
- // if (Manager.LastModuleForm != null)
- // {
- // int num = Manager.LastModuleForm.Count;
- // if (num > 0)
- // {
- // DllModule model = Manager.LastModuleForm[num - 1];
- // DataRow[] rowItems = this._allMenus.Select("MenuId=" + model.Id);
- // Manager.ModuleForms.Clear();
- // Manager.LastModuleForm.Clear();
- // if (rowItems != null && rowItems.Length > 0)
- // {
- // DataRow rowItem = rowItems[0];
- // Manager.TabMain = this.tabMain;
- // Manager.OpenModule(rowItem["menuId"] + "", rowItem["MenuCaption"] + "", rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["UrlParams"] + "");
- // }
- // }
- // }
- // }
- // catch (Exception)
- // {
-
- // throw;
- // }
-
- //}
- ///
- /// 说明:设置主界面控件值
- /// 创建人:龚宇超
- /// 创建日期:2017-08-15
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetFormObject()
- {
- this.lbUserName.Text = ERPInfo.Instance.UserName;
-
- this.tsmi_userName.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("用户名") + ":" + ERPInfo.Instance.UserName : "用户名:" + ERPInfo.Instance.UserName;
- this.tsmi_account_book.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("账套") + ":" + ERPInfo.Instance.AccountBook : "账套:" + ERPInfo.Instance.AccountBook;
- this.tsmi_version.Text = string.Format("Version:{0}", Assembly.GetExecutingAssembly().GetName().Version + "");
- string updateTime = IniHelper.Read("ApplicationUpdateTime");
- this.tsmi_upTime.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("更新时间") + ":" + updateTime : "更新时间:" + updateTime;
- //this.lblSubTitle.Text = !string.IsNullOrEmpty(ERPInfo.Instance.SubSysName) ? SystemInfo.Instance.ClientName + "-" + ERPInfo.Instance.SubSysName : SystemInfo.Instance.ClientName;
- this.lblSubTitle.Text = (!string.IsNullOrEmpty(ERPInfo.Instance.SubSysName) && SystemInfo.Instance.ShowSubSysName) ? SystemInfo.Instance.ClientName + "-" + ERPInfo.Instance.SubSysName : SystemInfo.Instance.ClientName;
-
- this.pl_top_left.BackgroundImage = BitMapHelper.getBitmap(BitMapEnum.logobg);
- //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainPanelControlEx));
- //this.pl_top_left.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pl_top_left.BackgroundImage")));
- this.pl_top_left.Visible = true;
- this.menuMain.Visible = true;
- this.lblSubTitle.Visible = SystemInfo.Instance.HideSubtitle ? false : true;
- this.ResetPanelWidth();
-
- if (LanguageTranslation.Translatable)
- {
- foreach (XtraTabPage page in tabMain.TabPages)
- {
- string text = page.Text;
- text = LanguageTranslation.GetTranslatedText(text.Trim());
- if (!text.Equals(page.Text.Trim())) page.Text = text;
- }
- }
- }
- ///
- /// 说明:子系统快捷窗口
- /// 创建人:龚宇超
- /// 创建日期:2018-08-09
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetSubItemForm()
- {
- //添加子系统快捷窗口
- _subItemForm = new SubItemForm();
- _subItemForm.Location = new Point(180, 40);
- this.Controls.Add(_subItemForm);
- _subItemForm.BringToFront();
- _subItemForm.OnbtnSubItemClick += new EventHandler(OnSubItemClick);
- _subItemForm.LostFocus += new EventHandler(OnSubFormLostFocus);
- _subItemForm.SetDataSource(GetSubItem());
- }
- ///
- /// 说明:切换账套快捷窗口
- /// 创建人:王一帆
- /// 创建日期:2019-12-09
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetAccounts()
- {
- string condition = string.Format("where ShowName !='{0}'", ERPInfo.Instance.AccountBook);
- //获取套账表格
- DataTable dt = MainImpl.GetLedgerList(condition);
-
- if (dt.Rows.Count == 0)
- {
- this.button4.Visible = false;
- this.label1.Visible = false;
- HiddenAccountSet = true;
- }
- else
- {
- if (SystemInfo.Instance.AccountSwitchingRestrictions > 0 && SystemInfo.Instance.AccountSwitchingRestrictions < int.Parse(ERPInfo.Instance.UserId))
- {
- this.button4.Visible = false;
- this.label1.Visible = false;
- HiddenAccountSet = true;
- }
-
- //添加子系统快捷窗口
- _accountsItemForm = new SubItemForm();
- //this.Controls.Add(this._accountsItemForm);
- _accountsItemForm.BackColor = Color.Transparent;
- this.xtpFirst.Controls.Add(_accountsItemForm);
- this.Resize += new System.EventHandler(this.FrmMain_Resize);
- //_accountsItemForm.LostFocus += new EventHandler(OnAccountLostFocus);
- _accountsItemForm.OnbtnSubItemClick += new EventHandler(OnAccountsClick);
- _accountsItemForm.SetAccountsSource(dt);
-
- }
-
- }
- ///
- /// 说明:初始化窗口大小
- /// 创建人:龚宇超
- /// 创建日期:2018-03-05/para>
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void FrmMain_Resize(object sender, EventArgs e)
- {
- try
- {
- this.CalcPopupLocation();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:计算弹出账套控件位置
- /// 创建人:龚宇超
- /// 创建日期:2018-03-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void CalcPopupLocation()
- {
- this._accountsItemForm.Parent = this.GetParent(this.Parent);
- Form form = this._accountsItemForm.Parent as Form;
-
- if (form != null)
- {
- int iTop = this.label1.Top + this.label1.Height;
- int iLeft = this.label1.Left;
- System.Windows.Forms.Control ctr = this.Parent;
-
- while (ctr != form)
- {
- iTop += ctr.Top;
- iLeft += ctr.Left;
- ctr = ctr.Parent;
- }
- if (ctr.Height > 100)
- {
- if (iTop + this.label1.Height + this._accountsItemForm.Height > ctr.Height)
- {
- if (iTop - this.label1.Height > ctr.Height - iTop)
- {
- if (this._accountsItemForm.Height > iTop - this.label1.Height)
- {
- this._accountsItemForm.Height = iTop - this.label1.Height;
- iTop = 0;
- }
- else
- {
- iTop = iTop - this.label1.Height - this._accountsItemForm.Height;
- }
- }
- else
- {
- this._accountsItemForm.Height = ctr.Height - iTop - 30;
- }
- }
- if (iLeft + this._accountsItemForm.Width > ctr.Width)
- {
- if (iLeft + this.label1.Width > ctr.Width - iLeft)
- {
- if (this._accountsItemForm.Width > iLeft + this.label1.Width)
- {
- this._accountsItemForm.Width = iLeft + this.label1.Width;
- iLeft = 0;
- }
- else
- iLeft = iLeft + this.label1.Width - this._accountsItemForm.Width;
- }
- else
- this._accountsItemForm.Width = ctr.Width - iLeft - 30;
- }
-
- this._accountsItemForm.Left = (iLeft + (this.Width - this.pl_top_right.Width) + this.label1.Width / 2) - _accountsItemForm.Width / 2;
- this._accountsItemForm.Top = iTop;
- }
- this._accountsItemForm.BringToFront();
- }
- }
- ///
- /// 说明:获取顶层窗口
- /// 创建人:龚宇超
- /// 创建日期:2018-03-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// Control.
- private Form GetParent(System.Windows.Forms.Control ctr)
- {
- if (ctr == null) return null;
-
- return ctr is Form ? ctr as Form : GetParent(ctr.Parent);
- }
- ///
- /// 说明:设置左侧菜单
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetMenus()
- {
- this._menus.Clear();
- var groupMenus = this._allMenus.AsEnumerable().Where(n => n.Table.Columns.Contains("groupcaption") && !string.IsNullOrEmpty(n["groupcaption"] + ""));
- if (groupMenus.Count() == 0 && this._allMenus.Columns.Contains("groupcaption"))
- {
- this._allMenus.Columns.Remove("groupcaption");
- }
- FontFamily fontFamily = FontUtil.Fonts.Families.Where(n => n.Name.Equals("MiSans")).FirstOrDefault();
- if (fontFamily != null)
- {
- collectTipsLab.Font = new Font(fontFamily, 10.5f, FontStyle.Regular);
- allTipsLab.Font = new Font(fontFamily, 10.5f, FontStyle.Regular);
- }
- string[] menuFiles = null;
- if (Directory.Exists(PubUtil.ModuleDefaultPath))
- {
- menuFiles = Directory.GetFiles(PubUtil.ModuleDefaultPath);
- }
- Random rand = new Random();
- DataTable gallerys = MainImpl.GetGallerysByUserId();
- var baseTable = gallerys.Select("grouptagid=1");
- var reportTable = gallerys.Select("grouptagid=2");
- DataRow[] subrows = MainImpl.GetSubSystems().Select(string.Format("SubSysId={0}", ERPInfo.Instance.SubSysId));
- if (subrows.Length > 0 && "False".Equals(subrows[0]["UseEd"] + ""))
- {
- DataRow rt = MainImpl.GetSubSystems().Select("UseEd=true")[0];
- ERPInfo.Instance.SubSysId = rt["SubSysId"] + "";
- ERPInfo.Instance.SubSysName = rt["SubSysName"] + "";
- }
- //DataRow[] rows = this._allMenus.Select("subsysid=" + ERPInfo.Instance.SubSysId);
- List rows = this._allMenus.AsEnumerable().Where(n => (n["subsysid"] + "").Equals(ERPInfo.Instance.SubSysId) && !string.IsNullOrEmpty(n["menustruct"] + "")).ToList();
- if (rows != null && rows.Count > 0)
- {
- int buttonTop = Convert.ToInt32(0.05 * DpiY); // 按钮上边距
- int menuLeft = Convert.ToInt32(0.05 * DpiY), menuTop = Convert.ToInt32(0.05 * DpiY); // 模块距离左边距,模块距离顶部边距
- int menuWidthOld = Convert.ToInt32(1.14 * DpiX), menuHeightOld = Convert.ToInt32(1.32 * DpiY); // 旧模块宽度,模块高度
- int menuWidth = Convert.ToInt32(2.5 * DpiX), menuHeight = Convert.ToInt32(0.73 * DpiY); // 模块宽度,模块高度
- int buttonWidth = Convert.ToInt32(0.44 * DpiX), buttonHeight = Convert.ToInt32(0.44 * DpiY); // 模块宽度,模块高度
- //int centerWidth = pl_center_main.Width - pl_center_main_right.Width; // 内容区域宽度-右侧快捷栏宽度
- int centerWidth = pl_center_main_middle.Width; // 内容区域宽度
- if (this.splitMainControl.Panel2Collapsed)
- {
- this.splitMainControl.Panel2Collapsed = false;
- centerWidth = pl_center_main_middle.Width;
- this.splitMainControl.Panel2Collapsed = true;
- }
- string defaultParentMenu = string.Empty;
- MenuBar.ButtonHoverEventHandler hoverEvent = null;
- hoverEvent += new MenuBar.ButtonHoverEventHandler(OnTriggerMenu);
-
- if (SystemInfo.Instance.MenuBarWidth > 0)
- {
- pl_center_left.Width = SystemInfo.Instance.MenuBarWidth;
- }
- #region 添加我的收藏快捷菜单
- isShowGrallyInTop = SystemInfo.Instance.ShowGrallyInTop;
- if (groupMenus.Count() == 0)
- {
- isShowGrallyInTop = false;
- this.pl_center_main_middle.Controls.Clear();
- }
- else
- {
- if (!isShowGrallyInTop)
- {
- collectPanel.Visible = false;
- panelSplit.Visible = false;
- botTipsPanel.Visible = false;
- }
- this.allMenuPanel.Controls.Clear();
- }
- if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout && isShowGrallyInTop)
- {
- GroupControl baseGroupControl = new GroupControl();
- baseGroupControl.TipsLabel.ForeColor = Color.DimGray;
- if (fontFamily != null)
- {
- baseGroupControl.TipsLabel.Font = new Font(fontFamily, 10.5f, FontStyle.Regular);
- }
- GroupControl reportGroupControl = new GroupControl();
- reportGroupControl.TipsLabel.ForeColor = Color.DimGray;
- if (fontFamily != null)
- {
- baseGroupControl.TipsLabel.Font = new Font(fontFamily, 10.5f, FontStyle.Regular);
- }
- FlowLayoutPanel baseFlowPanel = new FlowLayoutPanel();
- FlowLayoutPanel reportFlowPanel = new FlowLayoutPanel();
- baseFlowPanel.Padding = new Padding(menuLeft, 0, 0, 0);
- baseFlowPanel.Margin = new Padding(0, 0, 0, 0);
- reportFlowPanel.Padding = new Padding(menuLeft, 0, 0, 0);
- reportFlowPanel.Margin = new Padding(0, 0, 0, 0);
- if (baseTable.Count() > 0)
- {
- baseFlowPanel.Dock = DockStyle.Fill;
- baseFlowPanel.FlowDirection = FlowDirection.LeftToRight;
- baseGroupControl.MenuPanel.Controls.Add(baseFlowPanel);
- foreach (DataRow dataRow in baseTable)
- {
- string groupMenuId = dataRow["LMenuId"] + "";
- string defaultImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOutImg"] + "";
- string hoverImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOverImg1"] + "";
- string[] menuTag = new string[] { dataRow["DllFileName"] + "", dataRow["PurviewId"] + "", dataRow["LMenuId"] + "", dataRow["UrlParams"] + "", dataRow["LSubSysId"] + "", dataRow["dllShowCaption"] + "" };
- Menu_ItemNew menu = new Menu_ItemNew();
- if (fontFamily != null)
- {
- menu.GetLabelTitle().Font = new Font(fontFamily, 9.75f, FontStyle.Bold);
- menu.GetLabelTitleSub().Font = new Font(fontFamily, 8.5f, FontStyle.Regular);
- }
- menu.GetLabelTitle().ForeColor = Color.FromArgb(71, 73, 79);
- menu.Margin = new Padding(0, 0, 20, 0);
- menu.Name = groupMenuId;
- menu.Size = new Size(menuWidth, menuHeight);
- menu.GetLabelTitle().ForeColor = Color.FromArgb(88, 85, 85);
- menu.GetButton().Size = new Size(buttonWidth, buttonHeight);
- menu.SetMenuCaption(dataRow["dllShowCaption"] + "");
- menu.SetSubCaption(dataRow["SubSysName"] + "-" + dataRow["menucaption"]);
- menu.SetRoundRadius = 20;
- menu.Tag = menuTag;
- menu.Click += OnMenuItemClick;
- string randomImage = "";
- if (Directory.Exists(PubUtil.ModuleDefaultPath))
- {
- string[] files = Directory.GetFiles("Images\\Main\\Module\\Default");
- if (files.Length > 0)
- {
- int index = rand.Next(files.Length);
- randomImage = files[index];
- }
- }
- menu.SetMenuImg(File.Exists(defaultImg) ? Image.FromFile(defaultImg) : File.Exists(randomImage) ? Image.FromFile(randomImage) : Resources.default_icon);
- menu.SetMenuHoverImg(File.Exists(hoverImg) ? Image.FromFile(hoverImg) : File.Exists(PubUtil.ModuleHoverImg) ? Image.FromFile(PubUtil.ModuleHoverImg) : Resources.default_icon);
- menu.SetMenuHoverBorderImg(File.Exists(PubUtil.ModuleChooesImg) ? Image.FromFile(PubUtil.ModuleChooesImg) : null);
- baseFlowPanel.Controls.Add(menu);
- this._menuItemList.Add(menu);
- //DataRow modelRow = MainImpl.GetSystemdllTab(item["PurviewId"] + "");
- //string countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
- string countSql = dataRow.Table.Columns.Contains("countSql") ? dataRow["countSql"] + "" : "";
- if (!string.IsNullOrWhiteSpace(countSql) && !"0".Equals(countSql.TrimEnd()) && !countSqls.ContainsKey(groupMenuId))
- {
- countSqls.Add(groupMenuId, countSql);
- }
- }
- baseGroupControl.Dock = DockStyle.Top;
- collectMenuPanel.Controls.Add(baseGroupControl);
- baseGroupControl.TipsText = $"快捷操作通道({baseTable.Count()})";
- }
- if (reportTable.Count() > 0)
- {
- reportFlowPanel.Dock = DockStyle.Fill;
- reportFlowPanel.FlowDirection = FlowDirection.LeftToRight;
- reportGroupControl.MenuPanel.Controls.Add(reportFlowPanel);
- foreach (DataRow dataRow in reportTable)
- {
- string groupMenuId = dataRow["LMenuId"] + "";
- string defaultImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOutImg"] + "";
- string hoverImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOverImg1"] + "";
- string[] menuTag = new string[] { dataRow["DllFileName"] + "", dataRow["PurviewId"] + "", dataRow["LMenuId"] + "", dataRow["UrlParams"] + "", dataRow["LSubSysId"] + "", dataRow["dllShowCaption"] + "" };
- Menu_ItemNew menu = new Menu_ItemNew();
- if (fontFamily != null)
- {
- menu.GetLabelTitle().Font = new Font(fontFamily, 9.75f, FontStyle.Bold);
- menu.GetLabelTitleSub().Font = new Font(fontFamily, 8.5f, FontStyle.Regular);
- }
- menu.GetLabelTitle().ForeColor = Color.FromArgb(71, 73, 79);
- menu.Margin = new Padding(0, 0, 20, 0);
- menu.Name = groupMenuId;
- menu.Size = new Size(menuWidth, menuHeight);
- menu.GetLabelTitle().ForeColor = Color.FromArgb(88, 85, 85);
- menu.GetButton().Size = new Size(buttonWidth, buttonHeight);
- menu.SetMenuCaption(dataRow["dllShowCaption"] + "");
- menu.SetSubCaption(dataRow["SubSysName"] + "-" + dataRow["menucaption"]);
- menu.SetRoundRadius = 20;
- menu.Tag = menuTag;
- menu.Click += OnMenuItemClick;
- string randomImage = "";
- if (Directory.Exists(PubUtil.ModuleDefaultPath))
- {
- if (menuFiles.Length > 0)
- {
- int index = rand.Next(menuFiles.Length);
- randomImage = menuFiles[index];
- }
- }
- menu.SetMenuImg(File.Exists(defaultImg) ? Image.FromFile(defaultImg) : File.Exists(randomImage) ? Image.FromFile(randomImage) : Resources.default_icon);
- menu.SetMenuHoverImg(File.Exists(hoverImg) ? Image.FromFile(hoverImg) : File.Exists(PubUtil.ModuleHoverImg) ? Image.FromFile(PubUtil.ModuleHoverImg) : Resources.default_icon);
- menu.SetMenuHoverBorderImg(File.Exists(PubUtil.ModuleChooesImg) ? Image.FromFile(PubUtil.ModuleChooesImg) : null);
- reportFlowPanel.Controls.Add(menu);
- this._menuItemList.Add(menu);
- //DataRow modelRow = MainImpl.GetSystemdllTab(item["PurviewId"] + "");
- //string countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
- string countSql = dataRow.Table.Columns.Contains("countSql") ? dataRow["countSql"] + "" : "";
- if (!string.IsNullOrWhiteSpace(countSql) && !"0".Equals(countSql.TrimEnd()) && !countSqls.ContainsKey(groupMenuId))
- {
- countSqls.Add(groupMenuId, countSql);
- }
- }
- reportGroupControl.Dock = DockStyle.Top;
- collectMenuPanel.Controls.Add(reportGroupControl);
- reportGroupControl.TipsText = $"快捷报表通道({reportTable.Count()})";
- }
- if (reportTable.Count() > 0)
- {
- reportGroupControl.Height = reportFlowPanel.Controls[reportFlowPanel.Controls.Count - 1].Location.Y + menuHeight + 28 + 16;
- }
- if (baseTable.Count() > 0)
- {
- baseGroupControl.Height = baseFlowPanel.Controls[baseFlowPanel.Controls.Count - 1].Location.Y + menuHeight + 28 + 16;
- }
- collectPanel.Height = baseGroupControl.Height + reportGroupControl.Height + 26;
- if (reportTable.Count() == 0 && baseTable.Count() == 0)
- {
- collectPanel.Visible = false;
- panelSplit.Visible = false;
- }
- if (reportTable.Count() > 0 || baseTable.Count() > 0)
- {
- collectPanel.SizeChanged += (s, e) =>
- {
- if (reportTable.Count() > 0)
- {
- reportGroupControl.Height = reportFlowPanel.Controls[reportFlowPanel.Controls.Count - 1].Location.Y + menuHeight + 28 + 16;
- }
- if (baseTable.Count() > 0)
- {
- baseGroupControl.Height = baseFlowPanel.Controls[baseFlowPanel.Controls.Count - 1].Location.Y + menuHeight + 28 + 16;
- }
- collectPanel.Height = baseGroupControl.Height + reportGroupControl.Height + 26;
- };
- }
- this.splitMainControl.Panel2Collapsed = true;
- }
- #endregion
- foreach (DataRow item in rows)
- {
- string menuStruct = item["menustruct"] + "";
- string menuCaption = item["menucaption"] + "";
- string menuid = item["menuid"] + "";
- string menuposition = item.Table.Columns.Contains("menuposition") ? item["menuposition"] + "" : "0";
- if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.SplitBar) && menuCaption.StartsWith(SystemInfo.Instance.SplitBar)) continue;
- // 加载左侧菜单
- if (menuStruct.Length == 2)
- {
- DataTable childs = rows.Cast().Where(x => (x["MenuStruct"] + "").Substring(0, 2) == menuStruct).CopyToDataTable();
- if (childs != null && childs.Rows.Count > 1)
- {
- if (string.IsNullOrEmpty(defaultParentMenu))
- defaultParentMenu = menuStruct;
- // menuLeft = 5; menuTop = 5;
- menuLeft = Convert.ToInt32(0.05 * DpiX); menuTop = Convert.ToInt32(0.05 * DpiY);
- MenuBar button = new MenuBar();
- 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;
-
- if (SystemInfo.Instance.MenuBarWidth > 0)
- {
- button.Size = new Size(SystemInfo.Instance.MenuBarWidth, Convert.ToInt32(0.46 * DpiX));
- button.GetButton().Width = SystemInfo.Instance.MenuBarWidth - 10;
- }
-
- if (_firstMenuBar == null)
- {
- _firstMenuBar = button;
- }
- // 注册事件
- button.SetHoverEvent(hoverEvent, (MenuEventType)SystemInfo.Instance.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 (!_menus.Keys.Contains(menuStruct))
- {
- _menus.Add(menuStruct, new List());
- }
- #region 添加右侧菜单模块
- if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu) && !SystemInfo.Instance.HideGallerys)
- {
- List layoutTopDataRows = rows.Where(n => (n["menuposition"] + "").Equals("1") && (n["menustruct"] + "").Length == 4 && (n["menustruct"] + "").Substring(0, 2).Equals(menuStruct) && !(!string.IsNullOrWhiteSpace(SystemInfo.Instance.SplitBar) && (n["menucaption"] + "").StartsWith(SystemInfo.Instance.SplitBar))).ToList();
- List layoutBotDataRows = rows.Where(n => (n["menuposition"] + "").Equals("2") && (n["menustruct"] + "").Length == 4 && (n["menustruct"] + "").Substring(0, 2).Equals(menuStruct) && !(!string.IsNullOrWhiteSpace(SystemInfo.Instance.SplitBar) && (n["menucaption"] + "").StartsWith(SystemInfo.Instance.SplitBar))).ToList();
- TableLayoutPanel topLayoutPanel = new TableLayoutPanel();
- topLayoutPanel.Dock = DockStyle.Fill;
- topLayoutPanel.RowCount = layoutTopDataRows.Count() + 1;
- topLayoutPanel.RowStyles.Clear();
- TableLayoutPanel botLayoutPanel = new TableLayoutPanel();
- botLayoutPanel.Dock = DockStyle.Fill;
- botLayoutPanel.RowCount = layoutBotDataRows.Count() + 1;
- botLayoutPanel.RowStyles.Clear();
- if (!topLayoutPanelDic.ContainsKey(menuStruct))
- {
- topLayoutPanelDic.Add(menuStruct, topLayoutPanel);
- }
- if (!botLayoutPanelDic.ContainsKey(menuStruct))
- {
- botLayoutPanelDic.Add(menuStruct, botLayoutPanel);
- }
- for (int i = 0; i < layoutTopDataRows.Count; i++)
- {
- RowStyle rowStyle = new RowStyle();
- rowStyle.SizeType = SizeType.Absolute;
- rowStyle.Height = 25;
- topLayoutPanel.RowStyles.Add(rowStyle);
- SimpleControl simpleControl = new SimpleControl();
- simpleControl.Dock = DockStyle.Fill;
- DataRow topItem = layoutTopDataRows[i];
- // 前方箭头
- simpleControl.PicBox.BackgroundImage = Resources.arrows;
- simpleControl.Label.Text = topItem["menucaption"] + "";
- simpleControl.Label.Font = new Font("微软雅黑", 10);
- simpleControl.Label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
- simpleControl.Label.Tag = topItem;
- simpleControl.Label.MouseMove += OnLabelMouseMove;
- simpleControl.Label.MouseLeave += OnLabelMouseLeave;
- simpleControl.Label.MouseClick += OnLabelMouseClick;
- simpleControl.CornerLab.Visible = false;
- topLayoutPanel.Controls.Add(simpleControl, 0, i);
- if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text))
- _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
- simpleControl.CornerLab.BringToFront();
- if (topItem.Table.Columns.Contains("GroupCaption") && (topLayoutPanel.Tag == null || !string.IsNullOrEmpty(topLayoutPanel.Tag + "")))
- {
- topLayoutPanel.Tag = topItem["GroupCaption"] + "";
- }
- }
- if (menuStruct == defaultParentMenu)
- {
- this.pl_center_main_bottom_right_main.Controls.Clear();
- this.pl_center_main_bottom_right_main.Controls.Add(topLayoutPanel);
- string labelCaption = topLayoutPanel.Tag + "";
- this.lblShortcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblShortcutset.Tag + "";
- }
- for (int i = 0; i < layoutBotDataRows.Count; i++)
- {
- RowStyle rowStyle = new RowStyle();
- rowStyle.SizeType = SizeType.Absolute;
- rowStyle.Height = 25;
- botLayoutPanel.RowStyles.Add(rowStyle);
- SimpleControl simpleControl = new SimpleControl();
- simpleControl.Dock = DockStyle.Fill;
- DataRow botItem = layoutBotDataRows[i];
- // 前方箭头
- simpleControl.PicBox.BackgroundImage = Resources.arrows;
- simpleControl.Label.Text = botItem["menucaption"] + "";
- simpleControl.Label.Font = new Font("微软雅黑", 10);
- simpleControl.Label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
- simpleControl.Label.Tag = botItem;
- simpleControl.Label.MouseMove += OnLabelMouseMove;
- simpleControl.Label.MouseLeave += OnLabelMouseLeave;
- simpleControl.Label.MouseClick += OnLabelMouseClick;
- simpleControl.CornerLab.Visible = false;
- botLayoutPanel.Controls.Add(simpleControl, 0, i);
- if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text))
- _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
- simpleControl.CornerLab.BringToFront();
- if (botItem.Table.Columns.Contains("GroupCaption") && (botLayoutPanel.Tag == null || !string.IsNullOrEmpty(botLayoutPanel.Tag + "")))
- {
- botLayoutPanel.Tag = botItem["GroupCaption"] + "";
- }
- }
- if (menuStruct == defaultParentMenu)
- {
- this.pl_center_main_bottom_left_main.Controls.Clear();
- this.pl_center_main_bottom_left_main.Controls.Add(botLayoutPanel);
- string labelCaption = botLayoutPanel.Tag + "";
- this.lblReportcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblReportcutset.Tag + "";
- }
- }
- #endregion
- #region 添加分组菜单控件
- if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout)
- {
- //添加全部应用菜单
- List groupDataRows = new List();
- if (this._allMenus.Columns.Contains("menuposition"))
- {
- groupDataRows = rows.Where(n => (n["menuposition"] + "").Equals("0") && (n["menustruct"] + "").Length == 4 && (n["menustruct"] + "").Substring(0, 2).Equals(menuStruct) && !(!string.IsNullOrEmpty(SystemInfo.Instance.SplitBar) && (n["menucaption"] + "").StartsWith(SystemInfo.Instance.SplitBar))).ToList();
- }
- else
- {
- groupDataRows = rows.Where(n => (n["menustruct"] + "").Length == 4 && (n["menustruct"] + "").Substring(0, 2).Equals(menuStruct) && !(!string.IsNullOrEmpty(SystemInfo.Instance.SplitBar) && (n["menucaption"] + "").StartsWith(SystemInfo.Instance.SplitBar))).ToList();
- }
- foreach (DataRow dataRow in groupDataRows)
- {
- int groupcaptionInt = 0;
- string groupcaption = dataRow["groupcaption"] + "";
- if (!string.IsNullOrWhiteSpace(groupcaption) && groupcaption.Length > 2 && int.TryParse(groupcaption.Substring(0, 2), out groupcaptionInt) && groupcaptionInt > 0)
- {
- dataRow["groupcaption"] = groupcaption;
- }
- else
- {
- dataRow["groupcaption"] = "99默认分组";
- }
- if (dataRow.Table.Columns.Contains("menuRow"))
- {
- int menRow = 0;
- int.TryParse(dataRow["menuRow"] + "", out menRow);
- dataRow["menuRow"] = menRow > 0 ? menRow : 1;
- }
- }
- IEnumerable> groupByDataRows = groupDataRows.GroupBy(n => Convert.ToInt32((n["groupcaption"] + "").Substring(0, 2))).OrderByDescending(n => n.Key);
- Panel groupPanel = new Panel();
- groupPanel.AutoScroll = true;
- groupPanel.Dock = DockStyle.Fill;
- int groupControlIndex = 0;
- foreach (IGrouping groupByDataRow in groupByDataRows)
- {
- int nowRowCount = 1;//当前行数
- int minMenuRow = this._allMenus.Columns.Contains("menuRow") ? groupByDataRow.Min(n => Convert.ToInt32(n["menuRow"])) : 1;
- int menuGroupLeft = Convert.ToInt32(0.05 * DpiY);
- int menuGroupTop = 0; // 模块距离左边距,模块距离顶部边距
- GroupControl groupControl = new GroupControl();
- groupControl.TipsLabel.ForeColor = Color.DimGray;
- groupControl.Dock = DockStyle.Top;
- if (groupControlIndex == groupByDataRows.Count() - 1 && !isShowGrallyInTop)
- {
- groupControl.Padding = new Padding(0, 0, 0, 0);
- }
- groupPanel.Controls.Add(groupControl);
- List groupOrderDataRow = groupByDataRow.ToList();
- if (this._allMenus.Columns.Contains("menuRow"))
- {
- groupOrderDataRow = groupByDataRow.OrderBy(n => Convert.ToInt32(n["menuRow"] + "")).ToList();
- }
- int count = 0;
- foreach (DataRow dataRow in groupOrderDataRow)
- {
- string groupMenuId = dataRow["menuid"] + "";
- groupControl.TipsText = (dataRow["groupcaption"] + "").Remove(0, 2);
- if (menuposition.Equals("0"))
- {
- string defaultImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOutImg"] + "";
- string hoverImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOverImg1"] + "";
- string[] menuTag = new string[] { dataRow["DllFileName"] + "", dataRow["PurviewId"] + "", dataRow["MenuId"] + "", dataRow["UrlParams"] + "", dataRow["SubSysId"] + "", dataRow["menucaption"] + "" };
- int groupIndex = groupByDataRow.Key;
- if (groupIndex == 99)
- {
- groupIndex = groupByDataRows.Where(n => !n.Key.Equals(99)).Count() > 0 ? groupByDataRows.Where(n => !n.Key.Equals(99)).Max(n => n.Key) + 1 : 1;
- }
- Menu_ItemNew menu = new Menu_ItemNew();
- if (fontFamily != null)
- {
- menu.GetLabelTitle().Font = new Font(fontFamily, 10f, FontStyle.Bold);
- menu.GetLabelTitleSub().Font = new Font(fontFamily, 8.5f, FontStyle.Regular);
- }
- menu.GetLabelTitle().ForeColor = Color.FromArgb(71, 73, 79);
- menu.menuRow = dataRow.Table.Columns.Contains("menuRow") && !string.IsNullOrEmpty(dataRow["menuRow"] + "") ? Convert.ToInt32(dataRow["menuRow"] + "") : 1;
- menu.menuGroup = groupIndex;
- if ((menu.menuRow - minMenuRow + 1) > nowRowCount + 1)
- {
- foreach (DataRow row in dataRow.Table.Rows)
- {
- if ((row["menuRow"] + "").Equals(menu.menuRow + ""))
- {
- row["menuRow"] = nowRowCount + 1;
- }
- }
- menu.menuRow = nowRowCount + 1;
- }
- menu.Name = groupMenuId;
- menu.Size = new Size(menuWidth, menuHeight);
- menu.GetButton().Size = new Size(buttonWidth, buttonHeight);
- menu.menuNode = (dataRow["menustruct"] + "").Substring(0, 2);
- menu.SetMenuCaption(dataRow["menucaption"] + "");
- menu.SetSubCaption(dataRow["SubSysName"] + "-" + item["menucaption"]);
- menu.SetRoundRadius = 20;
- menu.Tag = menuTag;
- menu.Click += OnMenuItemClick;
- string randomImage = "";
- if (Directory.Exists(PubUtil.ModuleDefaultPath))
- {
- if (menuFiles.Length > 0)
- {
- int index = rand.Next(menuFiles.Length);
- randomImage = menuFiles[index];
- }
- }
- menu.SetMenuImg(File.Exists(defaultImg) ? Image.FromFile(defaultImg) : File.Exists(randomImage) ? Image.FromFile(randomImage) : Resources.default_icon);
- menu.SetMenuHoverImg(File.Exists(hoverImg) ? Image.FromFile(hoverImg) : File.Exists(PubUtil.ModuleHoverImg) ? Image.FromFile(PubUtil.ModuleHoverImg) : Resources.default_icon);
- menu.SetMenuHoverBorderImg(File.Exists(PubUtil.ModuleChooesImg) ? Image.FromFile(PubUtil.ModuleChooesImg) : null);
- // 116
- //menuGroupLeft += Convert.ToInt32(1.20 * DpiX);
- //后台配置模块所在行数
- if ((menu.menuRow - minMenuRow + 1) > 0)
- {
- if ((menu.menuRow - minMenuRow + 1) != nowRowCount || menuGroupLeft + menuWidth > centerWidth)
- {
- menuGroupLeft = 5;
- if ((menu.menuRow - minMenuRow + 1) != nowRowCount)
- {
- menuGroupTop += menuHeight * ((menu.menuRow - minMenuRow + 1) - nowRowCount);
- }
- else
- {
- menuGroupTop += menuHeight;
- }
- nowRowCount = (menu.menuRow - minMenuRow + 1);
- }
- menu.Location = new Point(menuGroupLeft, menuGroupTop);
- menuGroupLeft += Convert.ToInt32(2.5 * DpiX) + 20;
- //int count = _menuItemList.Where(o => o.menuGroup == menu.menuGroup && o.menuRow == menu.menuRow && o.menuNode == menu.menuNode).Count();
- //menuGroupLeft = count == 0 ? 5 : count * Convert.ToInt32(1.20 * DpiX) + 5;
- //menuGroupTop = menuHeight * (menu.menuRow - minMenuRow);
- //menu.Location = new Point(menuGroupLeft, menuGroupTop);
- }
- else
- {
- menu.Location = new Point(menuGroupLeft, menuGroupTop);
- menuGroupLeft += Convert.ToInt32(2.5 * DpiX) + 20;
- // 换行显示
- if (menuGroupLeft + menuWidth > centerWidth)
- {
- menuGroupLeft = 5;
- menuGroupTop += menuHeight;
- }
- }
- groupControl.MenuPanel.Controls.Add(menu);
- List controls = new List();
- if (_menus.TryGetValue(menuStruct, out controls))
- {
- controls.Add(menu);
- }
- this._menuItemList.Add(menu);
- //DataRow modelRow = MainImpl.GetSystemdllTab(dataRow["PurviewId"] + "");
- //string countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
- string countSql = dataRow.Table.Columns.Contains("countSql") ? dataRow["countSql"] + "" : "";
- if (!string.IsNullOrWhiteSpace(countSql) && !"0".Equals(countSql.TrimEnd()) && !countSqls.ContainsKey(groupMenuId))
- {
- countSqls.Add(groupMenuId, countSql);
- }
-
- //string countSqlBill = dataRow.Table.Columns.Contains("countSqlBill") ? dataRow["countSqlBill"] + "" : "";
- //if (!string.IsNullOrWhiteSpace(countSqlBill) && !"0".Equals(countSqlBill.TrimEnd()) && !countSqls.ContainsKey(groupMenuId))
- //{
- // countSqls.Add(groupMenuId, countSqlBill);
- //}
- count += 1;
- }
- }
- groupControlIndex += 1;
- groupControl.TipsText = $"{groupControl.TipsText}({count})";
- groupControl.Height = (int)(menuGroupTop + menuHeight + 28 + 16);
- }
- if (groupPanel.Controls.Count == 1)
- {
- (groupPanel.Controls[0] as GroupControl).TipsVisable = false;
- }
- if (!_groupItems.ContainsKey(menuStruct))
- {
- _groupItems.Add(menuStruct, groupPanel);
- }
- // 默认显示
- if (defaultParentMenu == menuStruct)
- {
- this.allMenuPanel.Controls.Add(groupPanel);
- groupPanel.Visible = true;
- }
- else
- {
- this.allMenuPanel.Controls.Add(groupPanel);
- groupPanel.Visible = false;
- }
- }
- #endregion
- }
- }
- // 加载右侧模块
- if (menuStruct.Length == 4)
- {
- if (menuposition.Equals("0") && (!this._allMenus.Columns.Contains("groupcaption") || isFlowLayout))
- {
- string defaultImg = PubUtil.MainMenuDefaultImage + item["MouseOutImg"] + "";
- string hoverImg = PubUtil.MainMenuDefaultImage + item["MouseOverImg1"] + "";
- string[] menuTag = new string[] { item["DllFileName"] + "", item["PurviewId"] + "", item["MenuId"] + "", item["UrlParams"] + "", item["SubSysId"] + "", item["menucaption"] + "" };
- 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(menuWidthOld, menuHeightOld);
- menu.menuNode = menuStruct.Substring(0, 2);
- menu.SetMenuCaption(menuCaption);
- menu.SetRoundRadius = 20;
- menu.GetButton().Tag = menuTag;
- menu.GetButton().Click += OnMenuItemClick;
- menu.SetMenuImg(File.Exists(defaultImg) ? Image.FromFile(defaultImg) : Resources.default_icon);
- menu.SetMenuHoverImg(File.Exists(hoverImg) ? Image.FromFile(hoverImg) : Resources.default_icon);
- // 116
- //menuLeft += Convert.ToInt32(1.20 * DpiX);
- //后台配置模块所在行数
- if (menu.menuRow > 0)
- {
- int count = _menuItemList.Cast().Where(o => o.menuRow == menu.menuRow && o.menuNode == menu.menuNode).Count();
- menuLeft = count == 0 ? 5 : count * Convert.ToInt32(1.20 * DpiX) + 5;
- menuTop = menuHeightOld * (menu.menuRow - 1);
- menu.Location = new Point(menuLeft, menuTop);
- }
- else
- {
- menu.Location = new Point(menuLeft, menuTop);
- menuLeft += Convert.ToInt32(1.20 * DpiX);
- // 换行显示
- if (menuLeft + menuWidthOld > centerWidth)
- {
- menuLeft = 5;
- menuTop += menuHeightOld;
- }
- }
- // 默认显示
- if (defaultParentMenu != menuStruct.Substring(0, 2))
- {
- menu.Visible = false;
- }
- if (isFlowLayout)
- {
- pl_center_main_middle_FlowLayout.Controls.Add(menu);
- }
- else
- {
- pl_center_main_middle.Controls.Add(menu);
- }
- List controls = new List();
- if (_menus.TryGetValue(menuStruct.Substring(0, 2), out controls))
- {
- controls.Add(menu);
- }
- this._menuItemList.Add(menu);
- //DataRow modelRow = MainImpl.GetSystemdllTab(item["PurviewId"] + "");
- //string countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
- string countSql = item.Table.Columns.Contains("countSql") ? item["countSql"] + "" : "";
- if (!string.IsNullOrWhiteSpace(countSql) && !"0".Equals(countSql.TrimEnd()) && !countSqls.ContainsKey(menuid))
- {
- countSqls.Add(menuid, countSql);
- }
-
- //string countSqlBill = item.Table.Columns.Contains("countSqlBill") ? item["countSqlBill"] + "" : "";
- //if (!string.IsNullOrWhiteSpace(countSqlBill) && !"0".Equals(countSqlBill.TrimEnd()) && !countSqls.ContainsKey(menuid))
- //{
- // countSqls.Add(menuid, countSqlBill);
- //}
- }
- }
- }
- }
- }
- ///
- /// 说明:设置筛选模块
- /// 创建人:龚宇超
- /// 创建日期:2017-11-20
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetSearchMenus()
- {
- lueUserName.ValueMember = lueUserName.ValueField = "MenuId";
- lueUserName.TextMember = "SearchMenuCaption";
- lueUserName.SourceSQL = this._menuSql;
- lueUserName.IsHomepage = true;
- lueUserName.DataSource = this._allMenus.Select("len(MenuStruct)=4").CopyToDataTable();
- //lueUserName.IsSetDataSource = true;
- }
- ///
- /// 说明:设置快捷通道
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetGallerys()
- {
- DataTable gallerys = MainImpl.GetGallerysByUserId();
- if (Business.Impl.LanguageTranslation.Translatable)
- {
- gallerys = Business.Impl.LanguageTranslation.TranslationTableColumn(gallerys, "DllShowCaption");
- }
- var baseTable = gallerys.Select("grouptagid=1");
- var reportTable = gallerys.Select("grouptagid=2");
- if ((!this._allMenus.Columns.Contains("menuposition") || (!SystemInfo.Instance.IsOpenWork && !SystemInfo.Instance.ShowGallerysFromMenu)))
- {
- this.pl_center_main_bottom_right_main.Controls.Clear();
- this.xtpWorktop.PageVisible = false;
- _quickPageHeaders.Clear();
- TableLayoutPanel topLayoutPanel = new TableLayoutPanel();
- this.pl_center_main_bottom_right_main.Controls.Add(topLayoutPanel);
- topLayoutPanel.Dock = DockStyle.Fill;
- topLayoutPanel.RowCount = baseTable.Count() + 1;
- topLayoutPanel.RowStyles.Clear();
- //显示我的操作通道
- for (int i = 0; i < baseTable.Count(); i++)
- {
- RowStyle rowStyle = new RowStyle();
- rowStyle.SizeType = SizeType.Absolute;
- rowStyle.Height = 25;
- topLayoutPanel.RowStyles.Add(rowStyle);
- SimpleControl simpleControl = new SimpleControl();
- simpleControl.Dock = DockStyle.Fill;
- DataRow item = baseTable[i];
- // 前方箭头
- simpleControl.PicBox.BackgroundImage = Resources.arrows;
- simpleControl.Label.Text = item["DllShowCaption"] + "";
- simpleControl.Label.Font = new Font("微软雅黑", 10);
- simpleControl.Label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
- simpleControl.Label.Tag = item;
- simpleControl.Label.MouseMove += OnLabelMouseMove;
- simpleControl.Label.MouseLeave += OnLabelMouseLeave;
- simpleControl.Label.MouseClick += OnLabelMouseClick;
- simpleControl.CornerLab.Visible = false;
- topLayoutPanel.Controls.Add(simpleControl, 0, i);
- if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text))
- _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
- simpleControl.CornerLab.BringToFront();
- }
- pl_center_main_bottom_left_main.Controls.Clear();
- TableLayoutPanel bottomLayoutPanel = new TableLayoutPanel();
- this.pl_center_main_bottom_left_main.Controls.Add(bottomLayoutPanel);
- bottomLayoutPanel.Dock = DockStyle.Fill;
- bottomLayoutPanel.RowCount = reportTable.Count() + 1;
- bottomLayoutPanel.RowStyles.Clear();
- // 显示我的报表通道
- for (int i = 0; i < reportTable.Count(); i++)
- {
- RowStyle rowStyle = new RowStyle();
- rowStyle.SizeType = SizeType.Absolute;
- rowStyle.Height = 25;
- bottomLayoutPanel.RowStyles.Add(rowStyle);
- SimpleControl simpleControl = new SimpleControl();
- simpleControl.Dock = DockStyle.Fill;
- DataRow item = reportTable[i];
- // 前方箭头
- simpleControl.PicBox.BackgroundImage = Resources.arrows;
- simpleControl.Label.Text = item["DllShowCaption"] + "";
- simpleControl.Label.Font = new Font("微软雅黑", 10);
- simpleControl.Label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
- simpleControl.Label.Tag = item;
- simpleControl.Label.MouseMove += OnLabelMouseMove;
- simpleControl.Label.MouseLeave += OnLabelMouseLeave;
- simpleControl.Label.MouseClick += OnLabelMouseClick;
- simpleControl.CornerLab.Visible = false;
- bottomLayoutPanel.Controls.Add(simpleControl, 0, i);
- if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text))
- _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
- simpleControl.CornerLab.BringToFront();
- }
- }
- else if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu))
- {
- if (SystemInfo.Instance.IsOpenWork)
- {
- this.xtpWorktop.PageVisible = true;
- }
- else
- {
- this.xtpWorktop.PageVisible = false;
- }
- // 显示我的操作通道
- this.workTopPanel.Controls.Clear();
- int menuWidth = Convert.ToInt32(1.14 * DpiX);
- int menuHeight = Convert.ToInt32(1.32 * DpiY); //模块宽度,模块高度
- int menuLeft = Convert.ToInt32(0.2 * DpiY);
- int menuTop = Convert.ToInt32(0.2 * DpiY); //模块距离左边距,模块距离顶部边距
- int centerWidth = this.workTopPanel.Width; //内容区域宽度
- for (int i = 0; i < baseTable.Count(); i++)
- {
- DataRow item = baseTable[i];
- string defaultImg = item.Table.Columns.Contains("MouseOutImg") ? PubUtil.MainMenuDefaultImage + item["MouseOutImg"] + "" : "";
- string hoverImg = item.Table.Columns.Contains("MouseOverImg1") ? PubUtil.MainMenuDefaultImage + item["MouseOverImg1"] + "" : "";
- string[] menuTag = new string[] { item["ObjDll"] + "", item["LinkModeTag"] + "", item["LMenuId"] + "", item["PurviewId"] + "", "", item["DllShowCaption"] + "" };
- string menuCaption = item["DllShowCaption"] + "";
- Menu_ItemNew menu = new Menu_ItemNew();
- menu.Size = new Size(menuWidth, menuHeight);
- menu.SetMenuCaption(menuCaption);
- menu.SetSubCaption(item["SubSysName"] + "-" + item["menucaption"]);
- menu.SetRoundRadius = 20;
- menu.Tag = menuTag;
- menu.Click += OnMenuItemClick;
- //menu.GetButton().Click += OnMenuItemClick;
- menu.SetMenuImg(!string.IsNullOrEmpty(defaultImg) && File.Exists(defaultImg) ? Image.FromFile(defaultImg) : Resources.default_icon);
- menu.SetMenuHoverImg(!string.IsNullOrEmpty(hoverImg) && File.Exists(hoverImg) ? Image.FromFile(hoverImg) : Resources.default_icon);
- menu.Location = new Point(menuLeft, menuTop);
- menuLeft += Convert.ToInt32(1.3 * DpiX);
- // 换行显示
- if (menuLeft + menuWidth > centerWidth)
- {
- menuLeft = 5;
- menuTop += menuHeight;
- }
- this.workTopPanel.Controls.Add(menu);
- }
- this.workSplitMainControl.SplitterPosition = menuTop + menuHeight + 5;
- // 显示我的报表通道
- this.workBottomPanel.Controls.Clear();
- menuWidth = Convert.ToInt32(1.14 * DpiX);
- menuHeight = Convert.ToInt32(1.32 * DpiY); //模块宽度,模块高度
- menuLeft = Convert.ToInt32(0.2 * DpiY);
- menuTop = Convert.ToInt32(0.2 * DpiY); //模块距离左边距,模块距离顶部边距
- centerWidth = this.workBottomPanel.Width; //内容区域宽度
- for (int i = 0; i < reportTable.Count(); i++)
- {
- DataRow item = reportTable[i];
- string defaultImg = item.Table.Columns.Contains("MouseOutImg") ? PubUtil.MainMenuDefaultImage + item["MouseOutImg"] + "" : "";
- string hoverImg = item.Table.Columns.Contains("MouseOverImg1") ? PubUtil.MainMenuDefaultImage + item["MouseOverImg1"] + "" : "";
- string[] menuTag = new string[] { item["ObjDll"] + "", item["LinkModeTag"] + "", item["LMenuId"] + "", item["PurviewId"] + "", "", item["DllShowCaption"] + "" };
- string menuCaption = item["DllShowCaption"] + "";
- Menu_ItemNew menu = new Menu_ItemNew();
- menu.Size = new Size(menuWidth, menuHeight);
- menu.SetMenuCaption(menuCaption);
- menu.SetSubCaption(item["SubSysName"] + "-" + item["menucaption"]);
- menu.SetRoundRadius = 20;
- menu.Tag = menuTag;
- menu.Click += OnMenuItemClick;
- menu.SetMenuImg(!string.IsNullOrEmpty(defaultImg) && File.Exists(defaultImg) ? Image.FromFile(defaultImg) : Resources.default_icon);
- menu.SetMenuHoverImg(!string.IsNullOrEmpty(hoverImg) && File.Exists(hoverImg) ? Image.FromFile(hoverImg) : Resources.default_icon);
- menu.Location = new Point(menuLeft, menuTop);
- menuLeft += Convert.ToInt32(1.3 * DpiX);
- // 换行显示
- if (menuLeft + menuWidth > centerWidth)
- {
- menuLeft = 5;
- menuTop += menuHeight;
- }
- this.workBottomPanel.Controls.Add(menu);
- }
- Menu_ItemNew addBotMenu = new Menu_ItemNew();
- addBotMenu.Size = new Size(menuWidth, menuHeight);
- addBotMenu.SetMenuCaption("添加");
- addBotMenu.SetRoundRadius = 20;
- addBotMenu.GetButton().Click += OnWorkMenuItemClick;
- addBotMenu.SetMenuImg(Resources.add);
- addBotMenu.SetMenuHoverImg(Resources.add);
- addBotMenu.Location = new Point(menuLeft, menuTop);
- menuLeft += Convert.ToInt32(1.3 * DpiX);
- // 换行显示
- if (menuLeft + menuWidth > centerWidth)
- {
- menuLeft = 5;
- menuTop += menuHeight;
- }
- this.workBottomPanel.Controls.Add(addBotMenu);
- }
- }
- #region
- ///
- /// 说明:重绘圆角
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void MenuItem_Paint(object sender, PaintEventArgs e)
- {
- try
- {
- System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
- int x = 0;
- int y = 0;
- int thisWidth = this.Width;
- int thisHeight = this.Height;
- int angle = 20;
- if (angle > 0)
- {
- System.Drawing.Graphics g = CreateGraphics();
- oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角
- oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角
- oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角
- oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角
- oPath.CloseAllFigures();
- Region = new System.Drawing.Region(oPath);
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- #endregion
- ///
- /// 说明:获取子系统小窗口内容
- /// 创建人:龚宇超
- /// 创建日期:2018-08-02
- /// 修改人:`
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private DataRow[] GetSubItem()
- {
- DataRow[] rows = _subItemMenu.Select(string.Format("SubSysId <>'{0}'", ERPInfo.Instance.SubSysId));
- return rows;
- }
- ///
- /// 说明:左菜单初始化(左边为树)
- /// 创建人:龚宇超
- /// 创建日期:2018-04-24
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void InitLeftMenu()
- {
- DataTable dtLvTree = MainImpl.GetLeftTreeView();
- tv_left.ParentField = "speciesno";
- tv_left.ParentKeyLength = 2;
- tv_left.TextField = "speciesname";
- tv_left.OnButtonClickEvent += new TreeViewCustom.ButtonClickEventHandler(OnMenuButtonClick);
- tv_left.SetDataSource(dtLvTree);
- }
- ///
- /// 说明:加载顶部菜单
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetTopMenus()
- {
- string where = string.IsNullOrEmpty(ERPInfo.Instance.SeriesId) ? "" : string.Format("and SeriesId={0}", ERPInfo.Instance.SeriesId);
- DataTable subSystems = MainImpl.GetSubSystems(where);
- if (Business.Impl.LanguageTranslation.Translatable)
- {
- subSystems = Business.Impl.LanguageTranslation.TranslationTableColumn(subSystems, "SubSysName");
- }
-
- _subItemMenu = subSystems.Clone();
- // 模式处理
- if (SystemInfo.Instance.DefaultMainTag == 2)
- {
- DataTable dtTable = MainImpl.GetMenusByMenuType(out _menuSql);
- for (int i = 0; i < dtTable.Rows.Count; i++)
- {
- DataRow item = dtTable.Rows[i];
- string menuCaption = item["MenuCaption"] + "";
- ToolStripMenuItem menuItem = new ToolStripMenuItem();
- menuItem.Text = menuCaption;
- menuItem.Tag = item;
- menuItem.Font = new Font("微软雅黑", 12);
- menuItem.BackColor = Color.Transparent;
- menuItem.ForeColor = Color.White;
- menuItem.Click += new EventHandler(OnMenuTopItemClick);
- menuMain.Items.Add(menuItem);
- if (i == 0) _firstMenuItem = menuItem;
- }
- }
- else
- {
- _allMenus = MainImpl.GetMenusByMenuType(out _menuSql);
- if (Business.Impl.LanguageTranslation.Translatable)
- {
- _allMenus = Business.Impl.LanguageTranslation.InitialTableTranslation(_allMenus);
- }
- foreach (DataRow item in subSystems.Rows)
- {
- string subSysName = item["SubSysName"] + "";
- string subSysId = item["SubSysId"] + "";
- string useed = item["useed"] + "";
- if (!"True".Equals(useed)) continue; // 禁用的系统不显示
- bool hasMenu = false; // 是否包含模块,不包含不显示
- ToolStripMenuItem menuItem = new ToolStripMenuItem();
- menuItem.Text = subSysName;
- menuItem.Tag = subSysId;
- menuItem.Font = new Font("微软雅黑", 12);
-
- //子目录长度超过界面,把之后的子目录存入 更多 中
- if (isMore)
- {
- menuItem.Click += MenuItem_Click;
- more.DropDownItems.Add(menuItem);
- _subItemMenu.ImportRow(item);
- continue;
- }
-
- menuItem.BackColor = Color.Transparent;
- menuItem.ForeColor = Color.White;
- menuItem.DropDownClosed += new EventHandler(OnMenuItemDropDownClosed);
- menuItem.DropDownOpened += new EventHandler(OnMenuItemDropDownOpened);
-
- if (SystemInfo.Instance.DefaultMainTag == 3)
- {
- menuItem.Click += OnMenuItemDoubleClick;
- menuMain.Items.Add(menuItem);
- //获取有权限的系统
- _subItemMenu.ImportRow(item);
- //把当前子目录加上后,子目录没有全部加完并且上方剩余宽度小于50,就添加 更多 选项。
- if (subSystems.Rows.Count - menuMain.Items.Count > 0 && menuMain.Width > pl_top_center.Width - 50)
- {
- menuMain.Items.Remove(menuItem);
- if (!isMore)
- {
- more = new ToolStripMenuItem();
- more.Text = "更多";
- more.Font = new Font("微软雅黑", 12);
- more.BackColor = Color.Transparent;
- more.ForeColor = Color.White;
- more.DropDownClosed += new EventHandler(OnMenuItemDropDownClosed);
- more.DropDownOpened += new EventHandler(OnMenuItemDropDownOpened);
- menuMain.Items.Add(more);
- isMore = true;
- }
- ToolStripMenuItem Item = new ToolStripMenuItem();
- Item.Text = subSysName;
- Item.Tag = subSysId;
- Item.Font = new Font("微软雅黑", 12);
- Item.Click += MenuItem_Click;
- more.DropDownItems.Add(Item);
- }
- continue;
- }
- if (SystemInfo.Instance.DefaultMainTag == 4)
- {
- menuItem.Click += OnMenuItemDoubleClick;
- }
-
- DataTable subTable = new DataTable();
- try
- {
- subTable = _allMenus.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)
- {
- string menuStruct = row["MenuStruct"] + "";
- string menuCaption = row["MenuCaption"] + "";
- ToolStripMenuItem subItem = new ToolStripMenuItem(menuCaption);
- subItem.Font = new Font("微软雅黑", 10);
- if (!string.IsNullOrEmpty(SystemInfo.Instance.SplitBar) && menuCaption.StartsWith(SystemInfo.Instance.SplitBar)) subItem.Enabled = false;
- // 功能模块
- try
- {
- DataTable childs = new DataTable();
- try
- {
- childs = _allMenus.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)
- {
- hasMenu = true;
- foreach (DataRow child in childs.Rows)
- {
- 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 + "", child["MenuCaption"] + "" };
- if (!(!string.IsNullOrEmpty(SystemInfo.Instance.SplitBar) && childItem.Text.StartsWith(SystemInfo.Instance.SplitBar)))
- {
- childItem.Click += OnItemClick; ;
- }
- else
- {
- childItem.Enabled = false;
- }
-
- subItem.DropDownItems.Add(childItem);
- }
- menuItem.DropDownItems.Add(subItem);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.Show(ex);
- }
- }
- if (hasMenu)
- {
- menuMain.Items.Add(menuItem);
- //获取有权限的系统
- _subItemMenu.ImportRow(item);
- //把当前子目录加上后,子目录没有全部加完并且上方剩余宽度小于50,就添加 更多 选项。
- if (subSystems.Rows.Count - menuMain.Items.Count > 0 && menuMain.Width > pl_top_center.Width - 50)
- {
- menuMain.Items.Remove(menuItem);
- if (!isMore)
- {
- more = new ToolStripMenuItem();
- more.Text = "更多";
- more.Font = new Font("微软雅黑", 12);
- more.BackColor = Color.Transparent;
- more.ForeColor = Color.White;
- more.DropDownClosed += new EventHandler(OnMenuItemDropDownClosed);
- more.DropDownOpened += new EventHandler(OnMenuItemDropDownOpened);
- menuMain.Items.Add(more);
- isMore = true;
- }
- ToolStripMenuItem Item = new ToolStripMenuItem();
- Item.Text = subSysName;
- Item.Tag = subSysId;
- Item.Font = new Font("微软雅黑", 12);
- Item.Click += MenuItem_Click;
- more.DropDownItems.Add(Item);
- }
- }
- }
-
- }
-
- }
- }
-
-
-
- ///
- /// 说明:加载默认模块
- /// 创建人:龚宇超
- /// 创建日期:2018-03-22
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetDefaultMenu()
- {
- // 加载默认模块
- //DataRow rowItem = this._allMenus.Rows.OfType().FirstOrDefault(x => SystemInfo.Instance.HeadMenuId == x["menuid"] + "");
- if (string.IsNullOrWhiteSpace(SystemInfo.Instance.HeadMenuId)) return;
- string[] headMenuIds = SystemInfo.Instance.HeadMenuId.Split(',');
- int i = 0;
- this.lblMenuTitle.Visible = false;
- this.lblMenuTitle2.Visible = false;
- foreach (string item in headMenuIds)
- {
-
- DataRow rowItem = MainImpl.GetDataRowResult(string.Format("select * from p_formmenuconfigtab where menuid='{0}'", item));
- if (rowItem != null)
- {
- if (i == 0)
- {
- DataRow DefaultModule = rowItem;
- this.lblMenuTitle.Text = rowItem["menucaption"] + "";
- this.lblMenuTitle.Tag = new string[] { rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["MenuId"] + "", rowItem["UrlParams"] + "", rowItem["SubSysId"] + "", rowItem["menucaption"] + "" };
- this.lblMenuTitle.Visible = true;
-
- DefaultModules.Add(DefaultModule);
-
- CornerLab cornerLab = new CornerLab();
- cornerLab.Location = new Point(this.lblMenuTitle.Left + this.lblMenuTitle.Width - 5, this.lblMenuTitle.Top - 8);
- cornerLab.Height = 20;
- cornerLab.Width = 20;
- cornerLab.LabelNum.Location = new Point(2, 4);
-
- cornerLab.Visible = false;
- this.pl_top_right.Controls.Add(cornerLab);
- cornerLab.BringToFront();
-
- defaultModuleRoundedCornerss.Add(cornerLab);
- i++;
-
- }
- else if (i == 1)
- {
-
- DataRow DefaultModule = rowItem;
- this.lblMenuTitle2.Text = rowItem["menucaption"] + "";
- this.lblMenuTitle2.Tag = new string[] { rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["MenuId"] + "", rowItem["UrlParams"] + "", rowItem["SubSysId"] + "", rowItem["menucaption"] + "" };
- this.lblMenuTitle2.Visible = true;
- this.lblMenuTitle2.Location = new Point(defaultModuleRoundedCornerss[0].Left + defaultModuleRoundedCornerss[0].Width + 5, this.lblMenuTitle.Top);
-
- DefaultModules.Add(DefaultModule);
-
- CornerLab cornerLab = new CornerLab();
- cornerLab.Location = new Point(this.lblMenuTitle2.Left + this.lblMenuTitle2.Width - 5, this.lblMenuTitle2.Top - 8);
- cornerLab.Height = 20;
- cornerLab.Width = 20;
- cornerLab.LabelNum.Location = new Point(2, 4);
-
- cornerLab.Visible = false;
- this.pl_top_right.Controls.Add(cornerLab);
- cornerLab.BringToFront();
- defaultModuleRoundedCornerss.Add(cornerLab);
- i++;
- }
- }
-
-
- }
-
-
- }
- ///
- /// 说明:获取通知表数据
- /// 创建人:龚宇超
- /// 创建日期:2018-04-17
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The subsysid.
- private void SetNotifys()
- {
- try
- {
- this.Invoke((EventHandler)delegate
- {
- if (this._menuItemList == null || this._menuItemList.Count == 0) return;
- DataTable notifys = MainImpl.GetNotifys(ERPInfo.Instance.SubSysId, ERPInfo.Instance.UserId);
- DataTable ShortcutDt = MainImpl.GetGallerysByUserIdAndReviewAmount();
- foreach (UserControl menuControl in _menuItemList)
- {
- if (menuControl is Menu_Item menu_Item)
- {
- menu_Item.SetMenuNum(0);
- }
- else if (menuControl is Menu_ItemNew menu_ItemNew)
- {
- menu_ItemNew.SetMenuNum(0);
- }
- }
- //快捷栏
- if (ShortcutDt != null)
- {
- foreach (string key in _quickPageHeaders.Keys)
- {
- DataRow items = ShortcutDt.Rows.Cast().FirstOrDefault(x => x["DllShowCaption"].ToString() == key);
- if (items != null)
- {
- string groupMenuId = items["LMenuId"] + "";
- UserControl menuItem = this._menuItemList.Cast().FirstOrDefault(x => x.Name == groupMenuId);
- Lskj.Control.CircleButton corLab = _quickPageHeaders[key];
- corLab.Visible = true;
- string number = items["amount"] + "";
-
- if (ShortcutDt.Columns.Contains("countsql") && !string.IsNullOrWhiteSpace(items["countsql"] + ""))
- {
- string num = SqlHelper.ExecuteScalar(ReplaceHelper.ReplaceUserInfo(items["countsql"] + "")) + "";
- number = IsNumberic(num) ? num : "0";
- }
- if (string.IsNullOrWhiteSpace(number))
- {
- corLab.Visible = false;
- }
- else
- {
- corLab.SetMenuNum(int.Parse(number));
- if (menuItem != null)
- {
- if (menuItem is Menu_Item menu_Item)
- {
- menu_Item.SetMenuNum(int.Parse(number));
- }
- else if (menuItem is Menu_ItemNew menu_ItemNew)
- {
- menu_ItemNew.SetMenuNum(int.Parse(number));
- }
- }
- }
- }
- }
- }
- //前登录用户对应子系统
- foreach (DataRow item in notifys.Rows)
- {
- string menuId = item["menuid"] + "";
- string moduleId = item["moduleid"] + "";
- string num = item["num"] + ""; // 显示数量
-
- if (string.IsNullOrWhiteSpace(menuId) && string.IsNullOrWhiteSpace(moduleId)) continue;
-
- UserControl menuItem = null;
- // 存在menuid则按照menuid来匹配数据,否则按照moduleid来匹配数据
- if (!string.IsNullOrWhiteSpace(menuId))
- {
- menuItem = this._menuItemList.Cast().FirstOrDefault(x => x.Name == menuId);
- }
- else
- {
- try
- {
- menuItem = this._menuItemList.Cast().FirstOrDefault(x => ((x is Menu_Item menu_Item && (menu_Item.GetButton().Tag as string[])[1] == moduleId) || ((x is Menu_ItemNew menu_ItemNew && (menu_ItemNew.GetButton().Tag as string[])[1] == moduleId))));
- }
- catch (Exception ex)
- {
- MessageUtil.Show(ex);
- }
- }
- int markNum = 0;
- if (menuItem != null && int.TryParse(num, out markNum))
- {
- if (menuItem is Menu_Item menu_Item)
- {
- menu_Item.SetMenuNum(markNum);
- }
- else if (menuItem is Menu_ItemNew menu_ItemNew)
- {
- menu_ItemNew.SetMenuNum(markNum);
- }
- }
- }
- //设置了数量sql的模块
- foreach (string key in countSqls.Keys)
- {
- UserControl menuItem = this._menuItemList.Cast().FirstOrDefault(x => x.Name == key);
- //DataRow dr = MainImpl.GetModuleDisplayQuantity(ReplaceHelper.ReplaceUserInfo(countSqls[key]));
- //string num = dr["value"] + "";
- string num = SqlHelper.ExecuteScalar(ReplaceHelper.ReplaceUserInfo(countSqls[key])) + "";
- if (IsNumberic(num))
- {
- if (menuItem is Menu_Item menu_Item)
- {
- menu_Item.SetMenuNum(int.Parse(num));
- }
- else if (menuItem is Menu_ItemNew menu_ItemNew)
- {
- menu_ItemNew.SetMenuNum(int.Parse(num));
- }
- }
- }
- //默认模块,右上角
- if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.HeadMenuId))
- {
- int index = 0;
- foreach (DataRow DefaultModule in DefaultModules)
- {
- if (DefaultModule == null) return;
- string countSql = string.Empty;
- string number = string.Empty;
- if (DefaultModule.Table.Columns.Contains("PurviewId"))
- {
- string DllCoid = DefaultModule["PurviewId"] + "";
- DataRow modelRow = MainImpl.GetSystemdllTab(DllCoid);
- countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
- }
- if (!string.IsNullOrWhiteSpace(countSql))
- {
- //DataRow dr = MainImpl.GetModuleDisplayQuantity(ReplaceHelper.ReplaceUserInfo(countSql));
- //number = dr["value"] + "";
- string num = SqlHelper.ExecuteScalar(ReplaceHelper.ReplaceUserInfo(countSql)) + "";
- if (IsNumberic(num))
- {
- number = num;
- }
- }
- else
- {
- number = MainImpl.GetModuleDisplayQuantityDefault(DefaultModule["MenuId"] + "", ERPInfo.Instance.UserId);
- }
- defaultModuleRoundedCornerss[index].SetMenuNum_special(!string.IsNullOrWhiteSpace(number) && !number.Equals("0") ? int.Parse(number) : 0);
- defaultModuleRoundedCornerss[index].Visible = !string.IsNullOrWhiteSpace(number) && !number.Equals("0") ? true : false;
- index++;
- }
-
- }
-
- });
- }
- catch (Exception)
- {
- //throw;
- }
- }
- ///
- /// 解析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)
- {
-
- }
- }
- ///
- /// 说明:设置我的桌面
- /// 创建人:龚宇超
- /// 创建日期:
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void SetDesktop()
- {
- if (!string.IsNullOrEmpty(SystemInfo.Instance.DesktopUrl))
- {
- this.xtpDesktop.PageVisible = true;
- this.webBrowser.FrmLoad(ReplaceHelper.ReplaceUserInfo(SystemInfo.Instance.DesktopUrl));
- //我的桌面特殊展示模式
- if (SystemInfo.Instance.DesktopFormat)
- {
- this.xtpDesktop.Controls.Clear();
- splitMainControl.Panel1.Controls.Add(this.webBrowser);
- this.webBrowser.Hide();
- this.webBrowser.SendToBack();//放到底层
- }
-
-
- }
- else
- {
- this.xtpDesktop.PageVisible = false;
- }
- }
-
- ///
- /// 初始化系统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)
- {
- }
- }
- #endregion
-
- #region 顶部菜单相关
-
-
- ///
- /// 点击上方子系统,切换系统
- ///
- ///
- ///
- private void OnMenuItemDoubleClick(object sender, EventArgs e)
- {
- try
- {
- if (sender != null)
- {
- DateTime now = DateTime.Now;
- TimeSpan timeSinceLastClick = now - lastClickTime;
- if (timeSinceLastClick.TotalMilliseconds < 500)
- {
- this.tabMain.SelectedTabPageIndex = 0;
- ToolStripMenuItem Item = sender as ToolStripMenuItem;
- if (ERPInfo.Instance.SubSysId == Item.Tag + "") return;
- ERPInfo.Instance.SubSysName = Item.Text;
- ERPInfo.Instance.SubSysId = Item.Tag as string;
- //Manager.ReStartMain(true);
- this.pl_center_left.Controls.Clear();
- this.countSqls.Clear();
- if (isFlowLayout)
- {
- pl_center_main_middle_FlowLayout.Controls.Clear();
- }
- else
- {
- allMenuPanel.Controls.Clear();
- }
- this._menus.Clear();
- this._menuItemList.Clear();
- this._groupItems.Clear();
- this.topLayoutPanelDic.Clear();
- this.botLayoutPanelDic.Clear();
- this.SetMenus();
- this.lblSubTitle.Text = (!string.IsNullOrEmpty(ERPInfo.Instance.SubSysName) && SystemInfo.Instance.ShowSubSysName) ? SystemInfo.Instance.ClientName + "-" + ERPInfo.Instance.SubSysName : SystemInfo.Instance.ClientName;
- OnLayoutSizeChanged();
- }
- lastClickTime = now;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
-
- ///
- /// 存入更多中的子目录,点击切换
- ///
- ///
- ///
- private void MenuItem_Click(object sender, EventArgs e)
- {
- try
- {
- if (sender != null)
- {
-
-
- this.tabMain.SelectedTabPageIndex = 0;
- ToolStripMenuItem Item = sender as ToolStripMenuItem;
- if (ERPInfo.Instance.SubSysId == Item.Tag + "") return;
- ERPInfo.Instance.SubSysName = Item.Text;
- ERPInfo.Instance.SubSysId = Item.Tag as string;
- //Manager.ReStartMain(true);
- this.pl_center_left.Controls.Clear();
- this.countSqls.Clear();
- if (isFlowLayout)
- {
- pl_center_main_middle_FlowLayout.Controls.Clear();
- }
- else
- {
- allMenuPanel.Controls.Clear();
- }
- this._menus.Clear();
- this._menuItemList.Clear();
- this._groupItems.Clear();
- this.topLayoutPanelDic.Clear();
- this.botLayoutPanelDic.Clear();
- this.SetMenus();
- this.lblSubTitle.Text = (!string.IsNullOrEmpty(ERPInfo.Instance.SubSysName) && SystemInfo.Instance.ShowSubSysName) ? SystemInfo.Instance.ClientName + "-" + ERPInfo.Instance.SubSysName : SystemInfo.Instance.ClientName;
- OnLayoutSizeChanged();
-
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
-
- ///
- /// 说明:菜单展开后
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnMenuItemDropDownOpened(object sender, EventArgs e)
- {
- try
- {
- ToolStripMenuItem menuItem = (sender as ToolStripMenuItem);
- if (menuItem != null)
- {
- menuItem.ForeColor = Color.Black;
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:菜单关闭后
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnMenuItemDropDownClosed(object sender, EventArgs e)
- {
- try
- {
- ToolStripMenuItem menuItem = (sender as ToolStripMenuItem);
- if (menuItem != null)
- {
- menuItem.ForeColor = Color.White;
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:顶部菜单打开模块
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnItemClick(object sender, EventArgs e)
- {
- try
- {
- ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
- string[] arr = (string[])menuItem.Tag;
-
- Manager.TabMain = this.tabMain;
- Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
- Manager.OpenModule(arr[2], arr[5], arr[0], arr[1], arr[3]);
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- #endregion
-
- #region 快捷通道相关
- ///
- /// 说明:快捷通道功能鼠标离开时
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- public void OnLabelMouseLeave(object sender, EventArgs e)
- {
- try
- {
- Label label = sender as Label;
- label.Font = new Font("微软雅黑", label.Font.SizeInPoints);
- label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
- this.Cursor = Cursors.Default;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:快速通道鼠标移动时
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- public void OnLabelMouseMove(object sender, MouseEventArgs e)
- {
- try
- {
- Label label = sender as Label;
- label.Font = new Font("微软雅黑", label.Font.SizeInPoints, FontStyle.Bold | FontStyle.Underline);
- label.ForeColor = ColorTranslator.FromHtml("#1ba109");
- this.Cursor = Cursors.Hand;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:快捷通道打开模块
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- public void OnLabelMouseClick(object sender, MouseEventArgs e)
- {
- try
- {
- Label label = sender as Label;
- DataRow item = label.Tag as DataRow;
- if (item != null)
- {
- Manager.TabMain = this.tabMain;
- Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
- if (!item.Table.Columns.Contains("menuposition"))
- {
- //2024-05-16 优先使用P_FormMenuConfigTab中的DllFileName为dll名(设置了快捷通道模块后,在工具里改dll名,无法同步改到快捷通道)
- string dllName = item.Table.Columns.Contains("DllFileName") && !string.IsNullOrWhiteSpace(item["DllFileName"] + "") ? item["DllFileName"] + "" : item["ObjDll"] + "";
- Manager.OpenModule(item["LMenuId"] + "", item["DllShowCaption"] + "", dllName, item["LinkModeTag"] + "", item["PurviewId"] + "");
- }
- else
- {
- string[] menuTag = new string[] { item["DllFileName"] + "", item["PurviewId"] + "", item["MenuId"] + "", item["UrlParams"] + "", "", item["menucaption"] + "" };
- Manager.OpenModule(menuTag[2], menuTag[5], menuTag[0], menuTag[1], menuTag[3]);
- }
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- #endregion
-
- #region 功能菜单相关
-
- ///
- /// 说明:切换模块
- /// 创建人:龚宇超
- /// 创建日期:2017-08-16
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The before.
- /// The after.
- public void OnTriggerMenu(Button before, Button after)
- {
- try
- {
- if (before != null)
- {
- DataRow item_before = before.Tag != null ? before.Tag as DataRow : null;
- DataRow item_after = after.Tag != null ? after.Tag as DataRow : null;
- if (item_before != null)
- {
- List beforeButtons = new List();
- List afterButtons = new List();
- if (isFlowLayout)
- {
- pl_center_main_middle_FlowLayout.Hide();
- }
- else
- {
- //this.pl_center_main_middle.Hide();
- }
- if (before.Parent != null && before.Parent is MenuBar)
- {
- (before.Parent as MenuBar).isSelect = false;
- }
- // 隐藏控件
- if (_menus.TryGetValue(item_before["menustruct"] + "", out beforeButtons))
- {
- if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout)
- {
- allMenuPanel.Controls.Clear();
- }
- else
- {
- foreach (UserControl item in beforeButtons)
- {
- item.Visible = false;
- }
- }
- if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu) && !SystemInfo.Instance.HideGallerys)
- {
- this.pl_center_main_bottom_right_main.Controls.Clear();
- this.pl_center_main_bottom_left_main.Controls.Clear();
- }
- }
- if (after.Parent != null && after.Parent is MenuBar)
- {
- (after.Parent as MenuBar).isSelect = true;
- }
- // 显示控件
- if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout)
- {
- if (this._groupItems.ContainsKey(item_after["menustruct"] + ""))
- {
- Panel groupPanel = this._groupItems[item_after["menustruct"] + ""];
- groupPanel.Visible = true;
- allMenuPanel.Controls.Add(groupPanel);
- }
- }
- else
- {
- if (_menus.TryGetValue(item_after["menustruct"] + "", out afterButtons))
- {
- foreach (UserControl item in afterButtons)
- {
- item.Visible = true;
- }
- }
- }
- if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu) && !SystemInfo.Instance.HideGallerys)
- {
- if (this.topLayoutPanelDic.ContainsKey(item_after["menustruct"] + ""))
- {
- TableLayoutPanel tableLayoutPanel = this.topLayoutPanelDic[item_after["menustruct"] + ""];
- this.pl_center_main_bottom_right_main.Controls.Add(tableLayoutPanel);
- string labelCaption = tableLayoutPanel.Tag + "";
- this.lblShortcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblShortcutset.Tag + "";
- }
- if (this.botLayoutPanelDic.ContainsKey(item_after["menustruct"] + ""))
- {
- TableLayoutPanel tableLayoutPanel = this.botLayoutPanelDic[item_after["menustruct"] + ""];
- this.pl_center_main_bottom_left_main.Controls.Add(tableLayoutPanel);
- string labelCaption = tableLayoutPanel.Tag + "";
- this.lblReportcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblReportcutset.Tag + "";
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- finally
- {
- if (isFlowLayout)
- {
- pl_center_main_middle_FlowLayout.Show();
- this.pl_center_main_middle_FlowLayout.Invalidate();
- this.pl_center_main_middle_FlowLayout.Update();
- }
- else
- {
- this.pl_center_main_middle.Show();
- this.pl_center_main_middle.Invalidate();
- this.pl_center_main_middle.Update();
- }
- //我的桌面特殊展示,鼠标点击切换模块,当前页签为我的桌面
- if (SystemInfo.Instance.DesktopFormat && this.tabMain.SelectedTabPage == this.xtpDesktop)
- {
- this.webBrowser.Hide();
- this.webBrowser.SendToBack();//放到底层
- this.tabMain.SelectedTabPage = this.xtpFirst;
- }
-
- }
- }
- ///
- /// 功能图标打开模块
- ///
- ///
- ///
- public void OnMenuItemClick(object sender, EventArgs e)
- {
- try
- {
- pic_search.Focus();
-
- /* 取 Tag */
- string[] arr = (string[])((System.Windows.Forms.Control)sender).Tag;
-
- Manager.TabMain = tabMain;
- Manager.MinusTheHeight = pl_top_center.Height + toolStrip1.Height;
- Manager.OpenModule(arr[2], arr[5], arr[0], arr[1], arr[3]);
- }
- catch (Exception ex)
- {
- string msg = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(msg, ex.Message);
- }
- }
-
- ///
- /// 快捷图标点击
- ///
- ///
- ///
- public void OnWorkMenuItemClick(object sender, EventArgs e)
- {
- try
- {
- if (!string.IsNullOrEmpty(SystemInfo.Instance.ShortCutDll))
- {
- DelphiHelper.LoadDelphiDll(SystemInfo.Instance.ShortCutDll);
- }
- else
- {
- DelphiHelper.LoadDelphiDll("P_Lsplanes.lsp");
- }
- }
- catch (Exception)
- {
- MessageUtil.Show(ResourceKeys.OpenShortCutError);
- }
- finally
- {
- this.SetGallerys();
- }
- }
- ///
- /// 说明:打开模块
- /// 创建人:龚宇超
- /// 创建日期:2018-01-27
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnMenuTitleClick(object sender, EventArgs e)
- {
- try
- {
- Label item = (Label)sender;
- string[] arr = (string[])item.Tag;
-
- Manager.TabMain = this.tabMain;
- Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
- Manager.OpenModule(arr[2], arr[5], arr[0], arr[1], arr[3]);
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:左菜单树点击事件
- /// 创建人:龚宇超
- /// 创建日期:2018-04-25
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void OnMenuButtonClick(Button button)
- {
- try
- {
- if (this._lastMenuButton != button && tabMain.TabPages.Count > 2)
- {
- if (MessageUtil.Show(ResourceKeys.ChangeMenu, MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- int count = tabMain.TabPages.Count;
- for (int i = count; i > 0; i--)
- {
- XtraTabPage item = tabMain.TabPages[i - 1];
- string guid = item.Tag + "";
- if (Manager.ModuleForms.ContainsKey(guid))
- {
- DllModule m = Manager.ModuleForms[guid];
- tabMain.TabPages.Remove(item);
- Manager.ModuleForms.Remove(m.Tag + "");
- }
- }
- }
- else
- {
- return;
- }
-
- }
- this.lblSubTitle.Text = SystemInfo.Instance.ClientName + "-" + button.Text;
- this.pl_top_left.Width = this.lblSubTitle.Width + 50;
- this._lastMenuButton = button;
- ERPInfo.Instance.GroupId = (_lastMenuButton.Tag as DataRow)["smid"] + "";
- OnMenuTopItemClick(_firstMenuItem, null);
-
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:上菜单按钮点击事件
- /// 创建人:龚宇超
- /// 创建日期:2018-04-24
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void OnMenuTopItemClick(object sender, EventArgs e)
- {
- try
- {
- ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
- if (menuItem == null || _lastMenuButton == null || _lastMenuItem == menuItem) return;
- this._lastMenuItem = menuItem;
- DataRow row = menuItem.Tag as DataRow;
- DataTable dtChilds = MainImpl.GetChildsMenu(row["subsysid"] + "", row["MenuStruct"] + "", _purviewCond);
- //位置设置
- 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; // 内容区域宽度-右侧快捷栏宽度
- //pl_center_main.Controls.Clear();
- int centerWidth = pl_center_main_middle.Width; // 内容区域宽度
-
- if (isFlowLayout)
- {
- pl_center_main_middle_FlowLayout.Controls.Clear();
- }
- else
- {
- allMenuPanel.Controls.Clear();
- }
-
- if (dtChilds != null && dtChilds.Rows.Count > 0)
- {
- foreach (DataRow item in dtChilds.Rows)
- {
- Application.DoEvents();// 处理当前消息队列中的所有windows消息
-
- string defaultImg = PubUtil.MainMenuDefaultImage + item["MouseOutImg"] + "";
- string hoverImg = PubUtil.MainMenuDefaultImage + item["MouseOverImg1"] + "";
-
- Menu_ItemNew menu = new Menu_ItemNew();
- menu.Name = item["menuid"] + "";
- menu.Size = new Size(menuWidth, menuHeight);
- menu.Location = new Point(menuLeft, menuTop);
- menu.SetMenuCaption(item["menuCaption"] + "");
- menu.SetSubCaption(item["SubSysName"] + "-" + item["menucaption"]);
- menu.SetRoundRadius = 20;
- menu.Tag = new string[] { item["DllFileName"] + "", item["PurviewId"] + "", item["MenuId"] + "", item["UrlParams"] + "", item["SubSysId"] + "", item["menucaption"] + "" };
- menu.Click += OnMenuItemClick;
- try
- {
- menu.SetMenuImg(Image.FromFile(defaultImg));
- }
- catch (Exception)
- {
- menu.SetMenuImg(Resources.default_icon);
- }
-
- // 116
- menuLeft += Convert.ToInt32(2.92 * DpiX);
- // 换行显示
- if (menuLeft + menuWidth > centerWidth)
- {
- menuLeft = 5;
- menuTop += menuHeight;
- }
-
- //pl_center_main.Controls.Add(menu);
- if (isFlowLayout)
- {
- pl_center_main_middle_FlowLayout.Controls.Add(menu);
- }
- else
- {
- pl_center_main_middle.Controls.Add(menu);
- }
- }
- }
-
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
-
- }
- }
- #endregion
-
- #region 重置界面宽度高度
- ///
- /// 说明:计算快速通道宽度
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void ResetPanelWidth()
- {
- pl_center_main_bottom_left.Height = pl_center_main_bottom_right.Height = pl_center_main_right.Height / 2;
- }
- ///
- /// 说明:重新计算菜单显示位置
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void ResetMenuLocation()
- {
- //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_ItemNew)
- // {
- // ctrs[0].Location = new Point(menuLeft, menuTop);
-
- // menuLeft += 116;
- // 换行显示
- // if (menuLeft + menuWidth > centerWidth)
- // {
- // menuLeft = 5;
- // menuTop += menuHeight;
- // }
- // }
- // }
- // }
- //}
- }
-
- #endregion
-
- #region 窗口拖动行为
- ///
- /// 说明:鼠标双击最大化、还原
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnTopMouseDoubleClick(object sender, MouseEventArgs e)
- {
- try
- {
- if (SystemInfo.Instance.DisableFormalization) return;
- if (OnTopPanelMouseDoubleClickCallBack != null)
- {
- OnTopPanelMouseDoubleClickCallBack(null, null);
- btnMax.BackgroundImage = this.State == FormWindowState.Normal ? Resources.max_default : Resources.window_default;
- this.ResetPanelWidth();
- this.ResetMenuLocation();
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:鼠标按下
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnTopMouseDown(object sender, MouseEventArgs e)
- {
- try
- {
- if (this.OnTopMouseDownCallback != null)
- this.OnTopMouseDownCallback(sender, e);
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:鼠标放开
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnTopMouseUp(object sender, MouseEventArgs e)
- {
- try
- {
- if (this.OnTopMouseUpCallBack != null)
- this.OnTopMouseUpCallBack(sender, e);
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:鼠标移动
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnTopMouseMove(object sender, MouseEventArgs e)
- {
- try
- {
- if (this.OnTopMouseMoveCallBack != null)
- this.OnTopMouseMoveCallBack(sender, e);
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- #endregion
-
- #region 最小化相关
- ///
- /// 说明:最小化按钮点击
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnMinClick(object sender, EventArgs e)
- {
- try
- {
- if (OnMinButtonCallBack != null)
- {
- OnMinButtonCallBack(null, null);
- }
- this.ResetPanelWidth();
- this.ResetMenuLocation();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:最小化鼠标离开时
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnMinMouseLeave(object sender, EventArgs e)
- {
- try
- {
- btnMin.BackgroundImage = Resources.smail_default;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:最小化鼠标移动时
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnMinMouseMove(object sender, MouseEventArgs e)
- {
- try
- {
- btnMin.BackgroundImage = Resources.smail_select;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- #endregion
-
- #region 最大化相关
- ///
- /// 说明:最大化点击
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnMaxClick(object sender, EventArgs e)
- {
- try
- {
- if (OnMaxButtonCallBack != null)
- {
- OnMaxButtonCallBack(null, null);
- btnMax.BackgroundImage = this.State == FormWindowState.Normal ? Resources.max_default : Resources.window_default;
- this.ResetPanelWidth();
- this.ResetMenuLocation();
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:最大化鼠标离开时
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnMaxMouseLeave(object sender, EventArgs e)
- {
- try
- {
- if (this.State == FormWindowState.Normal)
- {
- btnMax.BackgroundImage = Resources.max_default;
- }
- else
- {
- btnMax.BackgroundImage = Resources.window_default;
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:最大化鼠标移动时
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnMaxMouseMove(object sender, MouseEventArgs e)
- {
- try
- {
- if (this.State == FormWindowState.Normal)
- {
- btnMax.BackgroundImage = Resources.max_select;
- }
- else
- {
- btnMax.BackgroundImage = Resources.window_select;
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- #endregion
-
- #region 关闭相关
- ///
- /// 说明:关闭事件
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnCloseClick(object sender, EventArgs e)
- {
- try
- {
- if (ERPInfo.Instance.SubMenuCount == 1)
- {
- if (MessageUtil.Show(ResourceKeys.IsExit, MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- OnCloseButtonCallBack(null, null);
- }
- }
- else
- {
- OnCloseButtonCallBack(null, null);
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:关闭按钮离开时
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnCloseMouseLeave(object sender, EventArgs e)
- {
- try
- {
- btnClose.BackgroundImage = Resources.close_default;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:关闭按钮移动时
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnBtnCloseMouseMove(object sender, MouseEventArgs e)
- {
- try
- {
- btnClose.BackgroundImage = Resources.close_select;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:关闭tabpage窗口
- /// 创建人:龚宇超
- /// 创建日期:2017-09-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnTabMainClick(object sender, EventArgs e)
- {
- try
- {
- Point pt = MousePosition;
- XtraTabHitInfo info = this.tabMain.CalcHitInfo(tabMain.PointToClient(pt));
- if (info.HitTest == XtraTabHitTest.PageHeader && info.Page.TabIndex != 0)
- {
- XtraTabPage tabPage = this.tabMain.SelectedTabPage;
- if (tabPage == this.xtpDesktop)
- {
- this.webBrowser.cefBrowserSettings.Reload();
- return;
- }
- string guid = tabPage.Tag + "";
- if (!string.IsNullOrWhiteSpace(guid))
- {
- DllModule m = Manager.ModuleForms[guid];
- if (Manager.ModuleForms.ContainsKey(guid))
- {
- Form form = m.ModuleForm as Form;
- if (form != null)
- {
- form.Close();
- }
- if (m.ModuleInPtr != null)
- {
- HandleHelper.SendMessage(m.ModuleInPtr, 0x0010, 0, 0);
- }
- if (m.ModuleProcess != null)
- {
- m.ModuleProcess.Kill();
- }
- bool isclose = true;
- try
- {
- //BaseForm baseForm = form as BaseForm;
- isclose = m.IsClose;
- }
- catch (Exception)
- {
- }
- if (isclose)
- {
- if (this.PreviousTab != null) this.tabMain.SelectedTabPage = this.PreviousTab;
- tabMain.TabPages.Remove(tabPage);
- Manager.ModuleForms.Remove(m.Tag + "");
- LogUtil.WriteDebug(m.Code, "关闭模块", m.Name, m.Name, m.Id);
- }
-
-
- //审核双击打开界面关闭后回到双击界面
- XtraTabPage beforePage = m.BeforePage;
- if (beforePage != null)
- {
- foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
- {
-
- if (tablepage == beforePage)
- {
- ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
- if (isclose) tabPage.Dispose();
- }
- }
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogHelper.Instance.WriteError(ex);
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 惨淡打开时
- ///
- ///
- ///
- private void HeadMenuStripOpening(object sender, CancelEventArgs e)
- {
- XtraTabHitInfo info = tabMain.CalcHitInfo(tabMain.PointToClient(MousePosition));
- if (info.HitTest != XtraTabHitTest.PageHeader || info.Page == xtpFirst || info.Page == xtpDesktop || info.Page == xtpWorktop)
- {
- e.Cancel = true;
- }
- }
- ///
- /// 右键关闭页签
- ///
- ///
- ///
- private void RemoveItemClick(object sender, EventArgs e)
- {
- int selectIndex = tabMain.SelectedTabPageIndex;
- ToolStripMenuItem stripMenuItem = (ToolStripMenuItem)sender;
- ContextMenuStrip contextMenuStrip = (ContextMenuStrip)stripMenuItem.Owner;
- Point pt = new Point(contextMenuStrip.Left, contextMenuStrip.Top);
- XtraTabHitInfo info = this.tabMain.CalcHitInfo(tabMain.PointToClient(pt));
- int infoPageIndex = this.tabMain.TabPages.IndexOf(info.Page);
- if (info.HitTest == XtraTabHitTest.PageHeader && info.Page != xtpFirst && info.Page != xtpDesktop && info.Page != xtpWorktop)
- {
- ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
- List removeList = new List();
- if (menuItem.Text.Equals("关闭其他"))
- {
- foreach (XtraTabPage page in tabMain.TabPages)
- {
- if (page != xtpFirst && page != xtpDesktop && page != xtpWorktop && page != info.Page)
- {
- removeList.Add(page);
- }
- }
- tabMain.SelectedTabPage = info.Page;
- }
- else if (menuItem.Text.Equals("关闭左侧"))
- {
- foreach (XtraTabPage page in tabMain.TabPages)
- {
- int pageIndex = tabMain.TabPages.IndexOf(page);
- if (page != xtpFirst && page != xtpDesktop && page != xtpWorktop && page != info.Page && pageIndex < infoPageIndex)
- {
- removeList.Add(page);
- }
- }
- if (selectIndex < infoPageIndex)
- {
- tabMain.SelectedTabPage = info.Page;
- }
- }
- else if (menuItem.Text.Equals("关闭右侧"))
- {
- foreach (XtraTabPage page in tabMain.TabPages)
- {
- int pageIndex = tabMain.TabPages.IndexOf(page);
- if (page != xtpFirst && page != xtpDesktop && page != xtpWorktop && page != info.Page && pageIndex > infoPageIndex)
- {
- removeList.Add(page);
- }
- }
- if (selectIndex > infoPageIndex)
- {
- tabMain.SelectedTabPage = info.Page;
- }
- }
- foreach (XtraTabPage page in removeList)
- {
- string guid = page.Tag + "";
- if (!string.IsNullOrWhiteSpace(guid))
- {
- DllModule m = Manager.ModuleForms[guid];
- if (Manager.ModuleForms.ContainsKey(guid))
- {
- Form form = m.ModuleForm as Form;
- if (form != null) form.Close();
-
- bool isclose = true;
- try
- {
- //BaseForm baseForm = form as BaseForm;
- isclose = m.IsClose;
- }
- catch (Exception)
- {
- }
- if (isclose)
- {
- if (this.PreviousTab != null) this.tabMain.SelectedTabPage = this.PreviousTab;
- tabMain.TabPages.Remove(page);
- Manager.ModuleForms.Remove(m.Tag + "");
- LogUtil.WriteDebug(m.Code, "关闭模块", m.Name, m.Name, m.Id);
- }
- }
- }
- }
- }
- }
- #endregion
-
- #region 用户相关
- ///
- /// 说明:切换用户
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnSwapUserClick(object sender, EventArgs e)
- {
- try
- {
- FrmSwap frmSwap = new FrmSwap();
- frmSwap.ShowDialog();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:修改密码
- /// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnUserNameClick(object sender, EventArgs e)
- {
- try
- {
- FrmUpdatePassword frmPass = new FrmUpdatePassword();
- frmPass.ShowDialog();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- #endregion
-
- #region 换肤
- ///
- /// 说明:打开换肤界面
- /// 创建人:龚宇超
- /// 创建日期:2017-09-13
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnSettingClick(object sender, EventArgs e)
- {
- try
- {
- this.Cursor = Cursors.Hand;
- FrmSkins skins = new FrmSkins();
- skins.ShowDialog();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:
- /// 创建人:龚宇超
- /// 创建日期:2017-09-13
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnSettingMouseLeave(object sender, EventArgs e)
- {
- try
- {
- this.Cursor = Cursors.Default;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- #endregion
-
- #region 模块搜索
- ///
- /// 说明:打开界面
- /// 创建人:龚宇超
- /// 创建日期:2017-12-06
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnUserNamePopupClosed(object sender, EventArgs e)
- {
- try
- {
- this.OnOpenSearchModule();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:模块搜索
- /// 创建人:龚宇超
- /// 创建日期:2018-04-23
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnSearchClick(object sender, EventArgs e)
- {
- try
- {
- this.OnOpenSearchModule();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:打开搜索模块
- /// 创建人:龚宇超
- /// 创建日期:2018-04-23
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void OnOpenSearchModule()
- {
- try
- {
- string menuId = lueUserName.EditValue;
-
- if (lueUserName._popup.GridViewObj.GetFocusedDataRow() == null)
- {
- menuId = "";
- }
-
- if (!string.IsNullOrEmpty(menuId))
- {
- DataRow[] rowItems = this._allMenus.Select("MenuId=" + menuId);
- if (rowItems != null && rowItems.Length > 0)
- {
- DialogResult result = MessageUtil.Show(string.Format(ResourceKeys.OpenMenuConfirm, lueUserName.Text), MessageBoxButtons.YesNo);
- if (result == DialogResult.Yes)
- {
- DataRow rowItem = rowItems[0];
- Manager.TabMain = this.tabMain;
- Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
- Manager.OpenModule(menuId, rowItem["MenuCaption"] + "", rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["UrlParams"] + "");
- }
- }
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- #endregion
-
- #region 更新角标
- ///
- /// 说明:每隔5s取一次通知数据
- /// 创建人:龚宇超
- /// 创建日期:2018-04-17
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void OnMarkTimerTick(object sender, EventArgs e)
- {
- //SetNotifys();
- }
- #endregion
-
- #region 子系统小窗口相关
- ///
- /// 说明:快捷窗口中子系统点击
- /// 创建人:龚宇超
- /// 创建日期:2018-08-03
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The sender.
- /// The instance containing the event data.
- private void OnSubItemClick(object sender, EventArgs e)
- {
- try
- {
- if (sender != null)
- {
- SimpleButton btnSubItem = sender as SimpleButton;
- ERPInfo.Instance.SubSysName = btnSubItem.Text;
- ERPInfo.Instance.SubSysId = btnSubItem.Tag as string;
- // Manager.LastModuleForm.Clear();
- Manager.ReStartMain(true);
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:快捷窗口中子系统点击
- /// 创建人:龚宇超
- /// 创建日期:2018-08-03
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The sender.
- /// The instance containing the event data.
- private void OnAccountsClick(object sender, EventArgs e)
- {
- try
- {
- string condition = string.Format("where ShowName ='{0}'", ERPInfo.Instance.AccountBook);
- //获取套账表格
- DataTable dt = MainImpl.GetLedgerList(condition);
- string AccountBookOld = ERPInfo.Instance.AccountBook;
-
- if (sender != null)
- {
- SimpleButton btnSubItem = sender as SimpleButton;
- DataRow RT = btnSubItem.Tag as DataRow;
- string serverIP = RT["IP"] + "";
- string dbName = RT["DBName"] + "";
- string dataBook = RT["ShowName"] + "";
- bool isInternal = RT.Table.Columns.Contains("IsInternalNetwork") && !string.IsNullOrEmpty(RT["IsInternalNetwork"] + "") ? "1".Equals(RT["IsInternalNetwork"] + "") : false;
-
- if (!ToLoginMatching(serverIP, dbName, dataBook, btnSubItem.Text, false, isInternal))
- {
- MessageUtil.Show("切换账套失败");
- DataRow dr = dt.Rows[0];
- isInternal = dr.Table.Columns.Contains("IsInternalNetwork") && !string.IsNullOrEmpty(dr["IsInternalNetwork"] + "") ? "1".Equals(dr["IsInternalNetwork"] + "") : false;
-
- ToLoginMatching(dr["IP"] + "", dr["DBName"] + "", dr["ShowName"] + "", AccountBookOld, true, isInternal);
- }
-
-
- //DBConfig.Instance.DataBook = dataBook;
- //DBConfig.Instance.ServerName = serverIP;
- //DBConfig.Instance.DataBase = dbName;
- //if (!DBConfig.Instance.CreateConnection())
- //{
- // MessageUtil.Show(ResourceKeys.ServerAddressFault);
- // return;
- //}
- //else
- //{
- // if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection())) == 0)
- // {
- // MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
- // return;
- // }
- // string skinName = MainImpl.GetUserSkin(ERPInfo.Instance.UserId);
- // skinName = string.IsNullOrEmpty(skinName) ? ERPInfo.Instance.SkinName : skinName;
- // UserLookAndFeel.Default.SetSkinStyle(skinName);
- // ERPInfo.Instance.SkinName = skinName;
- // ERPInfo.Instance.AccountBook = btnSubItem.Text;
- // SystemInfo.RefreshSystemParam();
- // DBConfig.Instance.WriteConfig();
- // if (!SystemInfo.Instance.ForceUpdatePassword)
- // {
- // this.SetDelphiDllParams(); // 设置调用delphi参数
- // //FormHelper.OverProcess("Lskj.FrmMessages");//切换账套关闭消息页签
- // IniHelper.Write("isRefresh", "1");
- // DataTable table = MainImpl.GetEmployeeList();//获取员工信息存到表中
- // DataRow[] drRows = table.Select("UserName='" + ERPInfo.Instance.UserName + "' or UserCode='" + ERPInfo.Instance.UserId + "'");//找到所有UserNAme或UserCode为xxx的用户
-
- // DataRow drRow = drRows[0];
-
- // if (SystemInfo.Instance.SpecialSwitchingCover)
- // {
- // drRows = table.Select( "UserCode='" + ERPInfo.Instance.UserId + "'");//找到所有UserCode为xxx的用户
- // drRow = drRows[0];
- // }
-
- // //DataRow drRow = table.Rows.Cast().FirstOrDefault(x => userName.Equals(x["UserName"] + ""));
- // if (drRow != null)
- // {
-
- // if (SystemInfo.Instance.SpecialSwitchingCover)
- // {
- // int loginResult = MainImpl.Login(drRow["UserId"] + "", ERPInfo.Instance.InPassWord, true);
- // switch (loginResult)
- // {
- // case 0: // 登录成功
- // ERPInfo.Instance.UserId = drRow["UserId"] + "";
- // ERPInfo.Instance.UserName = drRow["UserName"] + "";
- // break;
- // case 1: // 密码不正确
- // MessageUtil.Show(ResourceKeys.NameOrPasswordError);
- // return;
- // break;
- // case 2: // 已有此用户登录
- // MessageUtil.Show(ResourceKeys.AlreadyLogin);
- // return;
- // break;
- // case -1: // 登录失败
- // default:
- // MessageUtil.Show(ResourceKeys.LoginFault);
- // return;
- // break;
- // }
- // }
- // else {
- // ERPInfo.Instance.UserId = drRow["UserId"] + "";
- // ERPInfo.Instance.UserName = drRow["UserName"] + "";
- // }
- // }
-
- // Manager.ReStartMain(!SystemInfo.Instance.IsChangeZTReturnMainForm);
- // }
- //}
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
-
- ///
- /// 说明:切换账号后重新登录
- /// 创建人:龚宇超
- /// 创建日期:2018-08-03
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// ip
- /// 数据库名
- /// 当前账套名
- /// 登录帐套
- /// 是否为重新登录初始账套
- private bool ToLoginMatching(string serverIP, string dbName, string dataBook, string AccountBook, bool Reset, bool isInternal)
- {
- try
- {
- DBConfig.Instance.DataBook = dataBook;
- DBConfig.Instance.ServerName = serverIP;
- DBConfig.Instance.DataBase = dbName;
- DBConfig.Instance.IsInternalNetwork = isInternal;
- if (!DBConfig.Instance.CreateConnection(DBConfig.Instance.Connection))
- {
- MessageUtil.Show(ResourceKeys.ServerAddressFault);
- return false;
- }
- else
- {
- if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection(DBConfig.Instance.dephiConnection))) == 0)
- {
- MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
- return false;
- }
- string skinName = MainImpl.GetUserSkin(ERPInfo.Instance.UserId);
- skinName = string.IsNullOrEmpty(skinName) ? ERPInfo.Instance.SkinName : skinName;
- UserLookAndFeel.Default.SetSkinStyle(skinName);
- ERPInfo.Instance.SkinName = skinName;
- ERPInfo.Instance.AccountBook = AccountBook;
- SystemInfo.RefreshSystemParam();
- DBConfig.Instance.WriteConfig();
-
- if (!SystemInfo.Instance.MainProhibitSwitchingAccount || Reset)
- {
- this.SetDelphiDllParams(); // 设置调用delphi参数
- //FormHelper.OverProcess("Lskj.FrmMessages");//切换账套关闭消息页签
- IniHelper.Write("isRefresh", "1");
- DataTable table = MainImpl.GetEmployeeList();//获取员工信息存到表中
- DataRow[] drRows = table.Select("UserName='" + ERPInfo.Instance.UserName + "' or UserCode='" + ERPInfo.Instance.LoginAccount + "'");//找到所有UserNAme或UserCode为xxx的用户
-
- DataRow drRow = drRows.Count() == 0 ? null : drRows[0]; //drRows[0];
-
- if (SystemInfo.Instance.SpecialSwitchingCover)
- {
- drRows = table.Select("UserCode='" + ERPInfo.Instance.LoginAccount + "'");//找到所有UserCode为xxx的用户
-
- drRow = drRows.Count() == 0 ? null : drRows[0];
- if (drRow != null)
- {
- string userId = drRow["UserID"] + "";
- if (SystemInfo.Instance.IsEncrypt)
- {
- int[] keyHandles = ERPInfo.Instance.keyHandles = new int[8];
- int[] keyNumber = ERPInfo.Instance.keyNumber = new int[8];
- string appId = DBConfig.Instance.ServerName;
- int frtn = SmartX1Api.SmartX1Find(appId, keyHandles, keyNumber);
- int keyHandle = ERPInfo.Instance.keyHandles[0];
- int uPin1 = Convert.ToInt32("0x987F6BCD", 16);
- int uPin2 = Convert.ToInt32("0xE193C5B2", 16);
- int uPin3 = Convert.ToInt32("0xD507CC28", 16);
- int uPin4 = Convert.ToInt32("0x4B125AF6", 16);
- int rtn = SmartX1Api.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4);
- if (rtn == 0)
- {
- //string writeKey = string.Format("{0}_{1}", DBConfig.Instance.ServerName, DBConfig.Instance.DataBase);
- //int length = 256;
- //byte[] readBuffer = new byte[length];
- //int readRtn = SmartX1Api.SmartX1ReadPage(keyHandle, 0, 0, ref length, readBuffer);
- //if (readRtn == 0)
- //{
- // Dictionary readKeysValues = new Dictionary();
- // string readVerifyStr = Encoding.Default.GetString(readBuffer);
- // string[] readVerifyStrArray = readVerifyStr.Replace("\0", "").Split(';');//获取多个账套设置
- // foreach (string readVerify in readVerifyStrArray)
- // {
- // string[] readKeyValue = readVerify.Split('^');//获取单个账套
- // if (readKeyValue.Length == 2)
- // {
- // readKeysValues.Add(readKeyValue[0], readKeyValue[1]);
- // }
- // }
- // if (readKeysValues.ContainsKey(writeKey))//如果存在当前账套
- // {
- // string[] verifyArray = readKeysValues[writeKey].Split('^');
- // if (!verifyArray.Contains(userId))
- // {
- // MessageUtil.Show("当前人员未拥有登录权限");
- // return false;
- // }
- // }
- // else
- // {
- // MessageUtil.Show("当前人员未拥有登录权限");
- // return false;
- // }
- //}
- //else
- //{
- // MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
- // return false;
- //}
- }
- else
- {
- MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
- return false;
- }
- }
-
- int loginResult = MainImpl.Login(drRow["UserId"] + "", ERPInfo.Instance.InPassWord, true);
- switch (loginResult)
- {
- case 0: // 登录成功
- break;
- case 1: // 密码不正确
- MessageUtil.Show(ResourceKeys.NameOrPasswordError);
- return false;
- break;
- case 2: // 已有此用户登录
- MessageUtil.Show(ResourceKeys.AlreadyLogin);
- return false;
- break;
- case -1: // 登录失败
- default:
- MessageUtil.Show(ResourceKeys.LoginFault);
- return false;
- break;
- }
- }
-
- }
-
- //DataRow drRow = table.Rows.Cast().FirstOrDefault(x => userName.Equals(x["UserName"] + ""));
- if (drRow != null)
- {
- string userId = drRow["UserID"] + "";
-
- if (!MainImpl.CheckingMacAddress(userId))
- {
- MessageUtil.Show(ResourceKeys.MacAddressError + ",当前地址:" + ERPInfo.Instance.MacAddress);
- System.Windows.Forms.Clipboard.SetText(ERPInfo.Instance.MacAddress);
- return false;
- }
- if (SystemInfo.Instance.IsEncrypt)
- {
- int[] keyHandles = ERPInfo.Instance.keyHandles = new int[8];
- int[] keyNumber = ERPInfo.Instance.keyNumber = new int[8];
- string appId = DBConfig.Instance.ServerName;
- int frtn = SmartX1Api.SmartX1Find(appId, keyHandles, keyNumber);
- int keyHandle = ERPInfo.Instance.keyHandles[0];
- int uPin1 = Convert.ToInt32("0x987F6BCD", 16);
- int uPin2 = Convert.ToInt32("0xE193C5B2", 16);
- int uPin3 = Convert.ToInt32("0xD507CC28", 16);
- int uPin4 = Convert.ToInt32("0x4B125AF6", 16);
- int rtn = SmartX1Api.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4);
- if (rtn == 0)
- {
- //string writeKey = string.Format("{0}_{1}", DBConfig.Instance.ServerName, DBConfig.Instance.DataBase);
- //int length = 256;
- //byte[] readBuffer = new byte[length];
- //int readRtn = SmartX1Api.SmartX1ReadPage(keyHandle, 0, 0, ref length, readBuffer);
- //if (readRtn == 0)
- //{
- // Dictionary readKeysValues = new Dictionary();
- // string readVerifyStr = Encoding.Default.GetString(readBuffer);
- // string[] readVerifyStrArray = readVerifyStr.Replace("\0", "").Split(';');//获取多个账套设置
- // foreach (string readVerify in readVerifyStrArray)
- // {
- // string[] readKeyValue = readVerify.Split('^');//获取单个账套
- // if (readKeyValue.Length == 2)
- // {
- // readKeysValues.Add(readKeyValue[0], readKeyValue[1]);
- // }
- // }
- // if (readKeysValues.ContainsKey(writeKey))//如果存在当前账套
- // {
- // string[] verifyArray = readKeysValues[writeKey].Split('^');
- // if (!verifyArray.Contains(userId))
- // {
- // MessageUtil.Show("当前人员未拥有登录权限");
- // return false;
- // }
- // }
- // else
- // {
- // MessageUtil.Show("当前人员未拥有登录权限");
- // return false;
- // }
- //}
- //else
- //{
- // MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
- // return false;
- //}
- }
- else
- {
- MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
- return false;
- }
- }
-
- ERPInfo.Instance.UserId = drRow["UserId"] + "";
- ERPInfo.Instance.UserName = drRow["UserName"] + "";
- }
- else
- {
- MessageUtil.Show("目标账套没有当前人员");
- return false;
- }
-
- Manager.ReStartMain(!SystemInfo.Instance.IsChangeZTReturnMainForm);
- return true;
- }
- else
- {
-
- }
- }
- return false;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- return false;
- }
-
-
- }
-
-
- ///
- /// 说明:设置delphi参数
- /// 创建人:龚宇超
- /// 创建日期:2018-03-12
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- void SetDelphiDllParams()
- {
- try
- {
- StringBuilder sb1 = new StringBuilder();
- sb1.Append(ERPInfo.Instance.UserName);
-
- StringBuilder sb2 = new StringBuilder();
- sb2.Append(ERPInfo.Instance.WindowName);
-
- StringBuilder sb3 = new StringBuilder();
- sb3.Append(ERPInfo.Instance.SkinName);
-
- //给delphi库设置参数(用户id、子系统id、操作员名称、计算机名称)
- DelphiHelper.Delphi_SetParams(Convert.ToInt32(ERPInfo.Instance.UserId), Convert.ToInt32(ERPInfo.Instance.SubSysId), sb1, sb2, sb3);
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- LogHelper.Instance.WriteError(ex);
- }
- }
- ///
- /// 说明:子系统面板弹出事件
- /// 创建人:龚宇超
- /// 创建日期:2018-08-02
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The sender.
- /// The instance containing the event data.
- private void OnTabMouseClick(object sender, MouseEventArgs e)
- {
-
- }
- ///
- /// 说明:子系统失去焦点
- /// 创建人:龚宇超
- /// 创建日期:2018-08-03
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The sender.
- /// The instance containing the event data.
- private void OnSubFormLostFocus(object sender, EventArgs e)
- {
- try
- {
- if (!_firstSubItemFocus)
- {
- _subItemForm.Hide();
- _subItemForm._isFocus = false;
- }
- _firstSubItemFocus = false;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- ///
- /// 说明:切换账套失去焦点
- /// 创建人:王一帆
- /// 创建日期:2019-12-10
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The sender.
- /// The instance containing the event data.
- private void OnAccountLostFocus(object sender, EventArgs e)
- {
- try
- {
- if (!_firstAccountsFocus)
- {
- _accountsItemForm.Hide();
- _accountsItemForm._isFocus = false;
- }
- _firstAccountsFocus = false;
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- #endregion
-
- #region 快捷通道双击操作
- ///
- /// 说明:快捷通道双击操作
- /// 创建人:龚宇超
- /// 创建日期:2018-08-13
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The sender.
- /// The instance containing the event data.
- private void OnShortCutDoubleClick(object sender, EventArgs e)
- {
- try
- {
- if (!string.IsNullOrEmpty(SystemInfo.Instance.ShortCutDll))
- {
- DelphiHelper.LoadDelphiDll(SystemInfo.Instance.ShortCutDll);
- }
- else
- {
- DelphiHelper.LoadDelphiDll("P_Lsplanes.lsp");
- }
- }
- catch (Exception)
- {
- MessageUtil.Show(ResourceKeys.OpenShortCutError);
- }
- finally
- {
- this.SetGallerys();
- this.OnLayoutSizeChanged();
- }
- }
- ///
- /// 选中切换套账
- ///
- ///
- ///
- private void label1_Click(object sender, EventArgs e)
- {
- try
- {
- if (label1.Visible)
- {
- CalcPopupLocation();
- _accountsItemForm.Show();
- this.label1.Focus();
- }
- //if (!_accountsItemForm._isFocus)
- //{
- // _firstAccountsFocus = true;
- // _accountsItemForm.Focus();
- // _accountsItemForm._isFocus = true;
- //}
- //else
- //{
- // _accountsItemForm.Hide();
- // _accountsItemForm._isFocus = false;
- // _firstAccountsFocus = false;
- //}
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 隐藏账套控件
- ///
- ///
- ///
- private void label1_LostFocus(object sender, EventArgs e)
- {
- try
- {
- _accountsItemForm.Hide();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- #endregion
- #region 自检功能操作
- ///
- /// 说明:程序自检功能
- /// 创建人:王一帆
- /// 创建日期:2022-07-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- ///
- ///
- private void OnMouseClick(object sender, MouseEventArgs e)
- {
- try
- {
- //if (laSelfTest.Visible)
- //{
-
- //}
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- #endregion
- private void label2_MouseClick(object sender, MouseEventArgs e)
- {
- try
- {
- if (label2.Visible)
- {
- _subItemForm.Location = this.plMain.PointToClient(MousePosition);
- _subItemForm.Show();
- this.label2.Focus();
- }
- //if (!_subItemForm._isFocus)
- //{
- // _subItemForm.Location = this.plMain.PointToClient(MousePosition);
- // _subItemForm.Show();
- // if (!_subItemForm._isFocus)
- // {
- // _firstSubItemFocus = true;
- // _subItemForm.Focus();
- // _subItemForm._isFocus = true;
- // }
- //}
- //else
- //{
- // _subItemForm.Hide();
- // _subItemForm._isFocus = false;
- // _firstSubItemFocus = false;
- //}
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- private void label2_LostFocus(object sender, EventArgs e)
- {
- try
- {
- _subItemForm.Hide();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- private void label3_MouseClick(object sender, MouseEventArgs e)
- {
- try
- {
- if (label3.Visible)
- {
- this.Controls.Add(_resSelectForm);
- _resSelectForm.BringToFront();
- _resSelectForm.Location = this.plMain.PointToClient(MousePosition);
- _resSelectForm.Show();
- this.label3.Focus();
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- private void label3_LostFocus(object sender, EventArgs e)
- {
- try
- {
- _resSelectForm.Hide();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// PageHead点击时
- ///
- ///
- ///
- private void OnPageHeadMouseDown(object sender, MouseEventArgs e)
- {
- mouseButtons = e.Button;
- }
- ///
- /// 页签切换时判断
- ///
- ///
- ///
- private void OnSelectedPageChanging(object sender, TabPageChangingEventArgs e)
- {
- Point pt = MousePosition;
- XtraTabHitInfo info = this.tabMain.CalcHitInfo(tabMain.PointToClient(pt));
- if (info.HitTest == XtraTabHitTest.PageHeader)
- {
- if (mouseButtons == MouseButtons.Left)
- {
- e.Cancel = false;
- }
- else
- {
- e.Cancel = true;
- }
- }
- }
- ///
- /// 页面刷新角标
- ///
- ///
- ///
- private void OnSelectedPageChanged(object sender, TabPageChangedEventArgs e)
- {
- try
- {
- XtraTabPage tabPage = this.tabMain.SelectedTabPage;
- string guid = tabPage.Tag + "";
- if (!string.IsNullOrWhiteSpace(guid) && Manager.ModuleForms.ContainsKey(guid))
- {
- DllModule m = Manager.ModuleForms[guid];
- ERPInfo.Instance.selectFormModleId = m.Id;
- }
- if (tabPage.TabIndex == 0)
- {
- if (!SystemInfo.Instance.RefreshNotify)
- {
- Thread thread = new Thread(SetNotifys);
- thread.IsBackground = true;
- thread.Start();
- }
- }
- //点击我的桌面时,在中间显示网页。选中功能导航时,隐藏网页
- if (this.xtpDesktop.PageVisible && SystemInfo.Instance.DesktopFormat)
- {
- //选中功能导航
- if (this.tabMain.SelectedTabPageIndex == 0)
- {
- this.xtpFirst.Controls.Clear();
- this.xtpFirst.Controls.Add(this.FirstMain);
- this.webBrowser.Hide();
- this.webBrowser.SendToBack();
- //左侧二级目录菜单恢复为配置模式
- foreach (System.Windows.Forms.Control item in pl_center_left.Controls)
- {
- if (item != null && item is MenuBar)
- {
- MenuBar mb = item as MenuBar;
- mb.ReleaseEvent();
- mb.RebindEvent((MenuEventType)SystemInfo.Instance.MemuEventType);
- }
- }
- if (SystemInfo.Instance.DesktopFormatShowGallerys)
- {
- this.splitMainControl.Panel2Collapsed = false;
- if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout && isShowGrallyInTop)
- {
- this.splitMainControl.Panel2Collapsed = true;
- }
- else
- {
- this.splitMainControl.Panel2Collapsed = false;
- }
- }
- }
- //选中我的桌面
- if (this.tabMain.SelectedTabPage == this.xtpDesktop)
- {
- this.PreviousTab = this.xtpDesktop;
- tabPage.Controls.Clear();
- tabPage.Controls.Add(this.FirstMain);
- this.webBrowser.Show();
- this.webBrowser.BringToFront();
- //if (this.webBrowser.cefBrowserSettings != null) this.webBrowser.cefBrowserSettings.Reload();
- int MemuEventType = 1;
- //左侧二级目录菜单设置为单击切换模式
- foreach (System.Windows.Forms.Control item in pl_center_left.Controls)
- {
- if (item != null && item is MenuBar)
- {
- MenuBar mb = item as MenuBar;
- mb.ReleaseEvent();
- mb.RebindEvent((MenuEventType)MemuEventType);
- }
- }
- if (SystemInfo.Instance.HideGallerys)
- {
- this.splitMainControl.Panel2Collapsed = true;
- }
- }
- if (this.tabMain.SelectedTabPage == this.xtpFirst)
- {
- this.PreviousTab = this.xtpFirst;
- }
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- ///
- /// 说明:初始化分割条位置
- /// 创建人:龚宇超
- /// 创建日期:2017-01-24
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void InitializeSplitterPosition()
- {
- try
- {
- string splitterPosition = IniHelper.Read("MainPanelControlEx");
- if (!string.IsNullOrEmpty(splitterPosition))
- {
- this.splitMainControl.SplitterDistance = Convert.ToInt32(splitterPosition);
- }
- else
- {
- this.splitMainControl.SplitterDistance = this.splitMainControl.Width / 11 * 10;
- }
- //string workSplitterPosition = IniHelper.Read("WorkMainPanelControlEx");
- //if (!string.IsNullOrEmpty(workSplitterPosition))
- //{
- // this.workSplitMainControl.SplitterPosition = Convert.ToInt32(workSplitterPosition);
- //}
- }
- catch (Exception e)
- {
- LogHelper.Instance.WriteError(e);
- }
- }
- ///
- /// 说明:并行分割条位置变化事件
- /// 创建人:王一帆
- /// 创建日期:2020-08-24
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- private void OnSplitterPositionChanged(object sender, SplitterEventArgs e)
- {
- try
- {
- if (_isInitFinish)
- {
- IniHelper.Write("MainPanelControlEx", this.splitMainControl.SplitterDistance + "");
- }
- OnLayoutSizeChanged();
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- private void OnWorkSplitPositionChanged(object sender, EventArgs e)
- {
- try
- {
- //if (_isInitFinish)
- //{
- // IniHelper.Write("WorkMainPanelControlEx", this.workSplitMainControl.SplitterPosition + "");
- //}
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- private void OnLayoutSizeChanged()
- {
- TableLayoutPanel topLayoutPanel = new TableLayoutPanel();
- TableLayoutPanel bottomLayoutPanel = new TableLayoutPanel();
- foreach (System.Windows.Forms.Control item in this.pl_center_main_bottom_right_main.Controls)
- {
- if (item is TableLayoutPanel)
- {
- topLayoutPanel = (TableLayoutPanel)item;
- break;
- }
- }
- foreach (System.Windows.Forms.Control item in this.pl_center_main_bottom_left_main.Controls)
- {
- if (item is TableLayoutPanel)
- {
- bottomLayoutPanel = (TableLayoutPanel)item;
- break;
- }
- }
- for (int i = 0; i < topLayoutPanel.RowCount - 1; i++)
- {
- try
- {
- SimpleControl simpleControl = (SimpleControl)topLayoutPanel.GetControlFromPosition(0, i);
- if (simpleControl != null)
- {
- simpleControl.PicBox.Width = 16;
- simpleControl.CornerLab.Width = 24;
- simpleControl.Label.UseCompatibleTextRendering = true;
- Graphics g = simpleControl.Label.CreateGraphics();
- SizeF sizeF = g.MeasureString(simpleControl.Label.Text, simpleControl.Label.Font);
- if (simpleControl.Label.Width < sizeF.Width)
- {
- simpleControl.IsNextLine = true;
- }
- else
- {
- simpleControl.IsNextLine = false;
- }
- topLayoutPanel.RowStyles[i].SizeType = SizeType.Absolute;
- if (simpleControl.IsNextLine)
- {
- topLayoutPanel.RowStyles[i].Height = 50;
- }
- else
- {
- topLayoutPanel.RowStyles[i].Height = 25;
- }
- }
- }
- catch (Exception)
- {
- }
- }
- for (int i = 0; i < bottomLayoutPanel.RowCount - 1; i++)
- {
- try
- {
- SimpleControl simpleControl = (SimpleControl)bottomLayoutPanel.GetControlFromPosition(0, i);
- if (simpleControl != null)
- {
- simpleControl.PicBox.Width = 16;
- simpleControl.CornerLab.Width = 24;
- simpleControl.Label.UseCompatibleTextRendering = true;
- Graphics g = simpleControl.Label.CreateGraphics();
- SizeF sizeF = g.MeasureString(simpleControl.Label.Text, simpleControl.Label.Font);
- if (simpleControl.Label.Width < sizeF.Width)
- {
- simpleControl.IsNextLine = true;
- }
- else
- {
- simpleControl.IsNextLine = false;
- }
- bottomLayoutPanel.RowStyles[i].SizeType = SizeType.Absolute;
- if (simpleControl.IsNextLine)
- {
- bottomLayoutPanel.RowStyles[i].Height = 50;
- }
- else
- {
- bottomLayoutPanel.RowStyles[i].Height = 25;
- }
-
\ No newline at end of file
+/***********************
+* 说明:主窗体界面的构建
+* 创建人:龚宇超
+* 创建日期:
+* 修改人:
+* 修改日期:
+* 修改备注:
+* 版本:1.0.0.0
+***********************/
+using DevExpress.LookAndFeel;
+using DevExpress.XtraEditors;
+using DevExpress.XtraTab;
+using DevExpress.XtraTab.ViewInfo;
+using Lskj.Business;
+using Lskj.Business.Impl;
+using Lskj.Control;
+using Lskj.Control.Model;
+using Lskj.Core;
+using Lskj.Data;
+using Lskj.Main.Model;
+using Lskj.Main.Properties;
+using Lskj.Model;
+using Lskj.Util;
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Reflection;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+
+namespace Lskj.Main.Control
+{
+ public partial class MainPanelControlEx : UserControl
+ {
+ #region 公有属性
+ ///
+ /// 屏幕dpix、dpiy
+ ///
+ public float DpiX, DpiY;
+ public int plTopHeight
+ {
+ get { return plTop.Height; }
+ }
+
+ ///
+ /// 最大化回调
+ ///
+ public event EventHandler OnMaxButtonCallBack;
+ ///
+ /// 最小化回调
+ ///
+ public event EventHandler OnMinButtonCallBack;
+ ///
+ /// 关闭回调
+ ///
+ public event EventHandler OnCloseButtonCallBack;
+ ///
+ /// 顶部双击回调
+ ///
+ public event EventHandler OnTopPanelMouseDoubleClickCallBack;
+ ///
+ /// Occurs when [on top mouse down callback].
+ ///
+ public event MouseEventHandler OnTopMouseDownCallback;
+ ///
+ /// Occurs when [on top mouse up call back].
+ ///
+ public event MouseEventHandler OnTopMouseUpCallBack;
+ ///
+ /// Occurs when [on top mouse move call back].
+ ///
+ public event MouseEventHandler OnTopMouseMoveCallBack;
+ ///
+ /// 窗口状态
+ ///
+ public FormWindowState State;
+ ///
+ /// 界面主页签
+ ///
+ public XtraTabControl TabMain { get { return this.tabMain; } }
+ ///
+ /// 主Panel
+ ///
+ public Panel MainPanel { get { return this.plMain; } }
+ ///
+ /// 锁屏窗口
+ ///
+ public AwaitScreenControl AwaitControl { get { return this.awaitScreenControl; } }
+ #endregion
+
+ #region 私有属性
+ private MenuBar _firstMenuBar;
+ private bool _firstSubItemFocus;
+ private bool _firstAccountsFocus;
+ ///
+ /// 模块sql
+ ///
+ private string _menuSql;
+ ///
+ /// 权限条件
+ ///
+ private string _purviewCond = string.Empty;
+ ///
+ /// 上次点击的按钮
+ ///
+ private Button _lastMenuButton;
+ ///
+ /// 当前配置的模块
+ ///
+ private DataTable _allMenus = new DataTable();
+ ///
+ /// 子系统菜单
+ ///
+ private DataTable _subItemMenu;
+ ///
+ /// 缓存菜单控件
+ ///
+ private Dictionary> _menus = new Dictionary>();
+ ///
+ /// 缓存分组控件
+ ///
+ private Dictionary _groupItems = new Dictionary();
+ ///
+ /// 缓存右上菜单控件
+ ///
+ private Dictionary topLayoutPanelDic = new Dictionary();
+ ///
+ /// 缓存右下菜单控件
+ ///
+ private Dictionary botLayoutPanelDic = new Dictionary();
+ ///
+ /// 缓存菜单
+ ///
+ private List _menuItemList = new List();
+ ///
+ /// 第一个menuItem
+ ///
+ private ToolStripMenuItem _firstMenuItem;
+ ///
+ /// 上次点击的菜单
+ ///
+ private ToolStripMenuItem _lastMenuItem;
+ ///
+ /// 子系统小窗口
+ ///
+ private SubItemForm _subItemForm;
+ ///
+ /// 套账小窗口
+ ///
+ private SubItemForm _accountsItemForm;
+ ///
+ /// 判断消息框是否加载完成
+ ///
+ private bool _isFinish = true;
+ ///
+ /// 分辨率选择小窗口
+ ///
+ private ResSelectForm _resSelectForm = new ResSelectForm();
+ ///
+ /// 快捷窗口圆角
+ ///
+ private Dictionary _quickPageHeaders = new Dictionary();
+ ///
+ /// 默认模块(右上角)圆角
+ ///
+ private List defaultModuleRoundedCornerss = new List();
+
+ ///
+ /// 当前所有配置了countSql的模块和对于的模块号
+ ///
+ private Dictionary countSqls = new Dictionary();
+ ///
+ /// 初始化完成
+ ///
+ private bool _isInitFinish = false;
+ ///
+ ///是否为流布局
+ ///
+ private bool isFlowLayout = false;
+ ///
+ ///分组时快捷菜单是否显示在内部
+ ///
+ private bool isShowGrallyInTop = false;
+ ///
+ ///模式3打开,上一次点击的时间
+ ///
+ public DateTime lastClickTime;
+ ///
+ ///子目录是否已经存在 更多 选项
+ ///
+ public bool isMore;
+ ///
+ /// 更多
+ ///
+ public ToolStripMenuItem more = new ToolStripMenuItem();
+ ///
+ /// 主页面默认模块数据
+ ///
+ public List DefaultModules = new List();
+
+ ///
+ /// 隐藏账套
+ ///
+ public bool HiddenAccountSet = false;
+
+ ///
+ /// 上一次选中的页签
+ ///
+ public XtraTabPage PreviousTab = null;
+ ///
+ /// 鼠标点击状态
+ ///
+ private MouseButtons mouseButtons;
+
+ #endregion
+
+ #region 初始加载
+ public MainPanelControlEx()
+ {
+ InitializeComponent();
+ }
+ ///
+ /// 说明:初始加载时
+ /// 创建人 龚宇超
+ /// 创建日期:2018-04-24
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ public void OnLoad()
+ {
+ try
+ {
+ WaitForm.ShowForm();
+
+ ContextMenuStrip headMenuStrip = new ContextMenuStrip();
+ headMenuStrip.Opening += HeadMenuStripOpening;
+ ToolStripMenuItem removeOtherItem = new ToolStripMenuItem();
+ removeOtherItem.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("关闭其他") : "关闭其他";
+ removeOtherItem.Click += new EventHandler(RemoveItemClick);
+ ToolStripMenuItem removeLeftItem = new ToolStripMenuItem();
+ removeLeftItem.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("关闭左侧") : "关闭左侧";
+ removeLeftItem.Click += new EventHandler(RemoveItemClick);
+ ToolStripMenuItem removeRightItem = new ToolStripMenuItem();
+ removeRightItem.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("关闭右侧") : "关闭右侧";
+ removeRightItem.Click += new EventHandler(RemoveItemClick);
+ headMenuStrip.Items.Add(removeOtherItem);
+ headMenuStrip.Items.Add(removeLeftItem);
+ headMenuStrip.Items.Add(removeRightItem);
+ tabMain.ContextMenuStrip = headMenuStrip;
+ //设置文件存放路径 ()
+ try
+ {
+ string DownloadFileDirectory = string.Format("{0}\\{1}", Application.StartupPath, "RightDownloadFile");
+ if (Directory.Exists(DownloadFileDirectory))
+ {
+ Directory.Delete(DownloadFileDirectory, true);
+ }
+ Directory.CreateDirectory(DownloadFileDirectory);
+ }
+ catch (Exception)
+ {
+ }
+ //SystemInfo.Instance.IsCacheRun = true;
+ try
+ {
+ RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);
+ key.SetValue("EnableLUA", "0");
+ key.Close();
+ }
+ catch (Exception)
+ {
+ }
+ this.isFlowLayout = SystemInfo.Instance.isFlowLayout;
+ if (isFlowLayout)
+ {
+ this.pl_center_main_middle_FlowLayout.Visible = true;
+ this.pl_center_main_middle.Visible = false;
+ this.pl_center_main_middle_FlowLayout.BackColor = this.pl_center_main_middle.BackColor;
+ }
+ this.pl_top_left.Visible = false;
+ this.menuMain.Visible = false;
+ this.lblSubTitle.Visible = false;
+ this.toolStripLabel1.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("版本号") + ":" + SystemInfo.Instance.Version : "版本号:" + SystemInfo.Instance.Version;
+ this.SetDesktop();
+ this.SetFormObject();
+ this.SetAccounts();//设置账套
+ //没有账套,并且模式3没有切换系统,就把右上方宽度缩小
+ if (HiddenAccountSet && (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4))
+ {
+ pl_top_right.Width = pl_top_right.Width - this.label1.Left - this.label1.Width;
+ }
+ if (SystemInfo.Instance.HideSkin)
+ {
+ this.button3.Visible = false;
+ this.lblSetting.Visible = false;
+ }
+ this.SetTopMenus();
+ InitializeSplitterPosition();
+ this.SetGallerys();
+ this.SetDefaultMenu();
+ this.SetSubItemForm();
+
+ if (SystemInfo.Instance.HideGallerys)
+ {
+ this.splitMainControl.Panel2Collapsed = true;
+ }
+ //控件事件订阅
+ ResSelectForm.MouseClickEventHanlder clickEvent = null;
+ clickEvent += new ResSelectForm.MouseClickEventHanlder(OnBtnCloseClick);
+ _resSelectForm.SetClickEvent(clickEvent);
+ //传统模式
+ if (SystemInfo.Instance.DefaultMainTag == 2)
+ {
+ //非传统模式左部分菜单
+ this.InitLeftMenu();
+ }
+ else
+ {
+ this.SetMenus();
+ this.SetSearchMenus();
+ this.tv_left.Visible = false;
+ }
+ if (SystemInfo.Instance.DefaultMainTag == 3 || SystemInfo.Instance.DefaultMainTag == 4)
+ {
+ this.button5.Visible = false;
+ this.label2.Visible = false;
+ }
+ if (!SystemInfo.Instance.RefreshNotify) this.SetNotifys();
+
+ this.SetHostEntry();
+ // 解析dns
+ new Thread(MainImpl.DnsHostEntry).Start();
+ this.mark_timer.Start();
+
+ ERPInfo.Instance.PageControl = this.tabMain;
+ ERPInfo.Instance.ModuleForms = Manager.ModuleForms;
+ if ((!this._allMenus.Columns.Contains("menuposition") || (!SystemInfo.Instance.IsOpenWork && !SystemInfo.Instance.ShowGallerysFromMenu)) && (!SystemInfo.Instance.HideGallerys || SystemInfo.Instance.DesktopFormatShowGallerys))
+ {
+ this.lblShortcutset.DoubleClick += OnShortCutDoubleClick;
+ this.lblReportcutset.DoubleClick += OnShortCutDoubleClick;
+ }
+ splitMainControl.SplitterMoved += new SplitterEventHandler(OnSplitterPositionChanged);
+ //workSplitMainControl.SplitterPositionChanged += new EventHandler(OnWorkSplitPositionChanged);
+ OnLayoutSizeChanged();
+ //有我的桌面并且是特殊展示时,默认选中我的桌面
+ if (!string.IsNullOrEmpty(SystemInfo.Instance.DesktopUrl) && SystemInfo.Instance.DesktopFormat) this.tabMain.SelectedTabPage = this.xtpDesktop;
+ //加密狗验证
+ if (SystemInfo.Instance.IsDogVerify) this.DogVerify();
+
+ if (SystemInfo.Instance.DisableFormalization)
+ {
+ this.btnMax.Visible = false;
+ this.btnMin.Location = new Point(this.btnMax.Location.X, this.btnMax.Location.Y);
+ }
+
+ if (SystemInfo.Instance.CancelDoubleClickClose)
+ {
+ this.tabMain.DoubleClick -= this.OnTabMainClick;
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ finally
+ {
+ Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
+ WaitForm.HideForm();
+ Manager.frmHeight = Screen.PrimaryScreen.WorkingArea.Height - this.plTopHeight;
+ //this.Information_timer.Start();
+ _isInitFinish = true;
+ }
+ }
+ ///
+ /// 说明:加载速度优化
+ /// 创建人:唐德馨
+ /// 创建日期:2021-09-03
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ ///
+ ///
+ //protected override CreateParams CreateParams
+ //{
+ // get
+ // {
+ // CreateParams cp = base.CreateParams;
+ // if (Lskj.Control.Model.AutoSizeChange.value != 1)
+ // {
+ // cp = base.CreateParams;
+ // cp.ExStyle |= 0x02000000;
+ // return cp;
+ // }
+ // else
+ // return cp;
+ // }
+ //}
+
+ ///
+ /// 刷新上一次切换的页面
+ ///
+ //private void SetLastFormObject()
+ //{
+ // try
+ // {
+
+ // if (Manager.LastModuleForm != null)
+ // {
+ // int num = Manager.LastModuleForm.Count;
+ // if (num > 0)
+ // {
+ // DllModule model = Manager.LastModuleForm[num - 1];
+ // DataRow[] rowItems = this._allMenus.Select("MenuId=" + model.Id);
+ // Manager.ModuleForms.Clear();
+ // Manager.LastModuleForm.Clear();
+ // if (rowItems != null && rowItems.Length > 0)
+ // {
+ // DataRow rowItem = rowItems[0];
+ // Manager.TabMain = this.tabMain;
+ // Manager.OpenModule(rowItem["menuId"] + "", rowItem["MenuCaption"] + "", rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["UrlParams"] + "");
+ // }
+ // }
+ // }
+ // }
+ // catch (Exception)
+ // {
+
+ // throw;
+ // }
+
+ //}
+ ///
+ /// 说明:设置主界面控件值
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-15
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetFormObject()
+ {
+ this.lbUserName.Text = ERPInfo.Instance.UserName;
+
+ this.tsmi_userName.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("用户名") + ":" + ERPInfo.Instance.UserName : "用户名:" + ERPInfo.Instance.UserName;
+ this.tsmi_account_book.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("账套") + ":" + ERPInfo.Instance.AccountBook : "账套:" + ERPInfo.Instance.AccountBook;
+ this.tsmi_version.Text = string.Format("Version:{0}", Assembly.GetExecutingAssembly().GetName().Version + "");
+ string updateTime = IniHelper.Read("ApplicationUpdateTime");
+ this.tsmi_upTime.Text = LanguageTranslation.Translatable ? LanguageTranslation.GetTranslatedText("更新时间") + ":" + updateTime : "更新时间:" + updateTime;
+ //this.lblSubTitle.Text = !string.IsNullOrEmpty(ERPInfo.Instance.SubSysName) ? SystemInfo.Instance.ClientName + "-" + ERPInfo.Instance.SubSysName : SystemInfo.Instance.ClientName;
+ this.lblSubTitle.Text = (!string.IsNullOrEmpty(ERPInfo.Instance.SubSysName) && SystemInfo.Instance.ShowSubSysName) ? SystemInfo.Instance.ClientName + "-" + ERPInfo.Instance.SubSysName : SystemInfo.Instance.ClientName;
+
+ this.pl_top_left.BackgroundImage = BitMapHelper.getBitmap(BitMapEnum.logobg);
+ //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainPanelControlEx));
+ //this.pl_top_left.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pl_top_left.BackgroundImage")));
+ this.pl_top_left.Visible = true;
+ this.menuMain.Visible = true;
+ this.lblSubTitle.Visible = SystemInfo.Instance.HideSubtitle ? false : true;
+ this.ResetPanelWidth();
+
+ if (LanguageTranslation.Translatable)
+ {
+ foreach (XtraTabPage page in tabMain.TabPages)
+ {
+ string text = page.Text;
+ text = LanguageTranslation.GetTranslatedText(text.Trim());
+ if (!text.Equals(page.Text.Trim())) page.Text = text;
+ }
+ }
+ }
+ ///
+ /// 说明:子系统快捷窗口
+ /// 创建人:龚宇超
+ /// 创建日期:2018-08-09
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetSubItemForm()
+ {
+ //添加子系统快捷窗口
+ _subItemForm = new SubItemForm();
+ _subItemForm.Location = new Point(180, 40);
+ this.Controls.Add(_subItemForm);
+ _subItemForm.BringToFront();
+ _subItemForm.OnbtnSubItemClick += new EventHandler(OnSubItemClick);
+ _subItemForm.LostFocus += new EventHandler(OnSubFormLostFocus);
+ _subItemForm.SetDataSource(GetSubItem());
+ }
+ ///
+ /// 说明:切换账套快捷窗口
+ /// 创建人:王一帆
+ /// 创建日期:2019-12-09
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetAccounts()
+ {
+ string condition = string.Format("where ShowName !='{0}'", ERPInfo.Instance.AccountBook);
+ //获取套账表格
+ DataTable dt = MainImpl.GetLedgerList(condition);
+
+ if (dt.Rows.Count == 0)
+ {
+ this.button4.Visible = false;
+ this.label1.Visible = false;
+ HiddenAccountSet = true;
+ }
+ else
+ {
+ if (SystemInfo.Instance.AccountSwitchingRestrictions > 0 && SystemInfo.Instance.AccountSwitchingRestrictions < int.Parse(ERPInfo.Instance.UserId))
+ {
+ this.button4.Visible = false;
+ this.label1.Visible = false;
+ HiddenAccountSet = true;
+ }
+
+ //添加子系统快捷窗口
+ _accountsItemForm = new SubItemForm();
+ //this.Controls.Add(this._accountsItemForm);
+ _accountsItemForm.BackColor = Color.Transparent;
+ this.xtpFirst.Controls.Add(_accountsItemForm);
+ this.Resize += new System.EventHandler(this.FrmMain_Resize);
+ //_accountsItemForm.LostFocus += new EventHandler(OnAccountLostFocus);
+ _accountsItemForm.OnbtnSubItemClick += new EventHandler(OnAccountsClick);
+ _accountsItemForm.SetAccountsSource(dt);
+
+ }
+
+ }
+ ///
+ /// 说明:初始化窗口大小
+ /// 创建人:龚宇超
+ /// 创建日期:2018-03-05/para>
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void FrmMain_Resize(object sender, EventArgs e)
+ {
+ try
+ {
+ this.CalcPopupLocation();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:计算弹出账套控件位置
+ /// 创建人:龚宇超
+ /// 创建日期:2018-03-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void CalcPopupLocation()
+ {
+ this._accountsItemForm.Parent = this.GetParent(this.Parent);
+ Form form = this._accountsItemForm.Parent as Form;
+
+ if (form != null)
+ {
+ int iTop = this.label1.Top + this.label1.Height;
+ int iLeft = this.label1.Left;
+ System.Windows.Forms.Control ctr = this.Parent;
+
+ while (ctr != form)
+ {
+ iTop += ctr.Top;
+ iLeft += ctr.Left;
+ ctr = ctr.Parent;
+ }
+ if (ctr.Height > 100)
+ {
+ if (iTop + this.label1.Height + this._accountsItemForm.Height > ctr.Height)
+ {
+ if (iTop - this.label1.Height > ctr.Height - iTop)
+ {
+ if (this._accountsItemForm.Height > iTop - this.label1.Height)
+ {
+ this._accountsItemForm.Height = iTop - this.label1.Height;
+ iTop = 0;
+ }
+ else
+ {
+ iTop = iTop - this.label1.Height - this._accountsItemForm.Height;
+ }
+ }
+ else
+ {
+ this._accountsItemForm.Height = ctr.Height - iTop - 30;
+ }
+ }
+ if (iLeft + this._accountsItemForm.Width > ctr.Width)
+ {
+ if (iLeft + this.label1.Width > ctr.Width - iLeft)
+ {
+ if (this._accountsItemForm.Width > iLeft + this.label1.Width)
+ {
+ this._accountsItemForm.Width = iLeft + this.label1.Width;
+ iLeft = 0;
+ }
+ else
+ iLeft = iLeft + this.label1.Width - this._accountsItemForm.Width;
+ }
+ else
+ this._accountsItemForm.Width = ctr.Width - iLeft - 30;
+ }
+
+ this._accountsItemForm.Left = (iLeft + (this.Width - this.pl_top_right.Width) + this.label1.Width / 2) - _accountsItemForm.Width / 2;
+ this._accountsItemForm.Top = iTop;
+ }
+ this._accountsItemForm.BringToFront();
+ }
+ }
+ ///
+ /// 说明:获取顶层窗口
+ /// 创建人:龚宇超
+ /// 创建日期:2018-03-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// Control.
+ private Form GetParent(System.Windows.Forms.Control ctr)
+ {
+ if (ctr == null) return null;
+
+ return ctr is Form ? ctr as Form : GetParent(ctr.Parent);
+ }
+ ///
+ /// 说明:设置左侧菜单
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetMenus()
+ {
+ this._menus.Clear();
+ var groupMenus = this._allMenus.AsEnumerable().Where(n => n.Table.Columns.Contains("groupcaption") && !string.IsNullOrEmpty(n["groupcaption"] + ""));
+ if (groupMenus.Count() == 0 && this._allMenus.Columns.Contains("groupcaption"))
+ {
+ this._allMenus.Columns.Remove("groupcaption");
+ }
+ FontFamily fontFamily = FontUtil.Fonts.Families.Where(n => n.Name.Equals("MiSans")).FirstOrDefault();
+ if (fontFamily != null)
+ {
+ collectTipsLab.Font = new Font(fontFamily, 10.5f, FontStyle.Regular);
+ allTipsLab.Font = new Font(fontFamily, 10.5f, FontStyle.Regular);
+ }
+ string[] menuFiles = null;
+ if (Directory.Exists(PubUtil.ModuleDefaultPath))
+ {
+ menuFiles = Directory.GetFiles(PubUtil.ModuleDefaultPath);
+ }
+ Random rand = new Random();
+ DataTable gallerys = MainImpl.GetGallerysByUserId();
+ var baseTable = gallerys.Select("grouptagid=1");
+ var reportTable = gallerys.Select("grouptagid=2");
+ DataRow[] subrows = MainImpl.GetSubSystems().Select(string.Format("SubSysId={0}", ERPInfo.Instance.SubSysId));
+ if (subrows.Length > 0 && "False".Equals(subrows[0]["UseEd"] + ""))
+ {
+ DataRow rt = MainImpl.GetSubSystems().Select("UseEd=true")[0];
+ ERPInfo.Instance.SubSysId = rt["SubSysId"] + "";
+ ERPInfo.Instance.SubSysName = rt["SubSysName"] + "";
+ }
+ //DataRow[] rows = this._allMenus.Select("subsysid=" + ERPInfo.Instance.SubSysId);
+ List rows = this._allMenus.AsEnumerable().Where(n => (n["subsysid"] + "").Equals(ERPInfo.Instance.SubSysId) && !string.IsNullOrEmpty(n["menustruct"] + "")).ToList();
+ if (rows != null && rows.Count > 0)
+ {
+ int buttonTop = Convert.ToInt32(0.05 * DpiY); // 按钮上边距
+ int menuLeft = Convert.ToInt32(0.05 * DpiY), menuTop = Convert.ToInt32(0.05 * DpiY); // 模块距离左边距,模块距离顶部边距
+ int menuWidthOld = Convert.ToInt32(1.14 * DpiX), menuHeightOld = Convert.ToInt32(1.32 * DpiY); // 旧模块宽度,模块高度
+ int menuWidth = Convert.ToInt32(2.5 * DpiX), menuHeight = Convert.ToInt32(0.73 * DpiY); // 模块宽度,模块高度
+ int buttonWidth = Convert.ToInt32(0.44 * DpiX), buttonHeight = Convert.ToInt32(0.44 * DpiY); // 模块宽度,模块高度
+ //int centerWidth = pl_center_main.Width - pl_center_main_right.Width; // 内容区域宽度-右侧快捷栏宽度
+ int centerWidth = pl_center_main_middle.Width; // 内容区域宽度
+ if (this.splitMainControl.Panel2Collapsed)
+ {
+ this.splitMainControl.Panel2Collapsed = false;
+ centerWidth = pl_center_main_middle.Width;
+ this.splitMainControl.Panel2Collapsed = true;
+ }
+ string defaultParentMenu = string.Empty;
+ MenuBar.ButtonHoverEventHandler hoverEvent = null;
+ hoverEvent += new MenuBar.ButtonHoverEventHandler(OnTriggerMenu);
+
+ if (SystemInfo.Instance.MenuBarWidth > 0)
+ {
+ pl_center_left.Width = SystemInfo.Instance.MenuBarWidth;
+ }
+ #region 添加我的收藏快捷菜单
+ isShowGrallyInTop = SystemInfo.Instance.ShowGrallyInTop;
+ if (groupMenus.Count() == 0)
+ {
+ isShowGrallyInTop = false;
+ this.pl_center_main_middle.Controls.Clear();
+ }
+ else
+ {
+ if (!isShowGrallyInTop)
+ {
+ collectPanel.Visible = false;
+ panelSplit.Visible = false;
+ botTipsPanel.Visible = false;
+ }
+ this.allMenuPanel.Controls.Clear();
+ }
+ if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout && isShowGrallyInTop)
+ {
+ GroupControl baseGroupControl = new GroupControl();
+ baseGroupControl.TipsLabel.ForeColor = Color.DimGray;
+ if (fontFamily != null)
+ {
+ baseGroupControl.TipsLabel.Font = new Font(fontFamily, 10.5f, FontStyle.Regular);
+ }
+ GroupControl reportGroupControl = new GroupControl();
+ reportGroupControl.TipsLabel.ForeColor = Color.DimGray;
+ if (fontFamily != null)
+ {
+ baseGroupControl.TipsLabel.Font = new Font(fontFamily, 10.5f, FontStyle.Regular);
+ }
+ FlowLayoutPanel baseFlowPanel = new FlowLayoutPanel();
+ FlowLayoutPanel reportFlowPanel = new FlowLayoutPanel();
+ baseFlowPanel.Padding = new Padding(menuLeft, 0, 0, 0);
+ baseFlowPanel.Margin = new Padding(0, 0, 0, 0);
+ reportFlowPanel.Padding = new Padding(menuLeft, 0, 0, 0);
+ reportFlowPanel.Margin = new Padding(0, 0, 0, 0);
+ if (baseTable.Count() > 0)
+ {
+ baseFlowPanel.Dock = DockStyle.Fill;
+ baseFlowPanel.FlowDirection = FlowDirection.LeftToRight;
+ baseGroupControl.MenuPanel.Controls.Add(baseFlowPanel);
+ foreach (DataRow dataRow in baseTable)
+ {
+ string groupMenuId = dataRow["LMenuId"] + "";
+ string defaultImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOutImg"] + "";
+ string hoverImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOverImg1"] + "";
+ string[] menuTag = new string[] { dataRow["DllFileName"] + "", dataRow["PurviewId"] + "", dataRow["LMenuId"] + "", dataRow["UrlParams"] + "", dataRow["LSubSysId"] + "", dataRow["dllShowCaption"] + "" };
+ Menu_ItemNew menu = new Menu_ItemNew();
+ if (fontFamily != null)
+ {
+ menu.GetLabelTitle().Font = new Font(fontFamily, 9.75f, FontStyle.Bold);
+ menu.GetLabelTitleSub().Font = new Font(fontFamily, 8.5f, FontStyle.Regular);
+ }
+ menu.GetLabelTitle().ForeColor = Color.FromArgb(71, 73, 79);
+ menu.Margin = new Padding(0, 0, 20, 0);
+ menu.Name = groupMenuId;
+ menu.Size = new Size(menuWidth, menuHeight);
+ menu.GetLabelTitle().ForeColor = Color.FromArgb(88, 85, 85);
+ menu.GetButton().Size = new Size(buttonWidth, buttonHeight);
+ menu.SetMenuCaption(dataRow["dllShowCaption"] + "");
+ menu.SetSubCaption(dataRow["SubSysName"] + "-" + dataRow["menucaption"]);
+ menu.SetRoundRadius = 20;
+ menu.Tag = menuTag;
+ menu.Click += OnMenuItemClick;
+ string randomImage = "";
+ if (Directory.Exists(PubUtil.ModuleDefaultPath))
+ {
+ string[] files = Directory.GetFiles("Images\\Main\\Module\\Default");
+ if (files.Length > 0)
+ {
+ int index = rand.Next(files.Length);
+ randomImage = files[index];
+ }
+ }
+ menu.SetMenuImg(File.Exists(defaultImg) ? Image.FromFile(defaultImg) : File.Exists(randomImage) ? Image.FromFile(randomImage) : Resources.default_icon);
+ menu.SetMenuHoverImg(File.Exists(hoverImg) ? Image.FromFile(hoverImg) : File.Exists(PubUtil.ModuleHoverImg) ? Image.FromFile(PubUtil.ModuleHoverImg) : Resources.default_icon);
+ menu.SetMenuHoverBorderImg(File.Exists(PubUtil.ModuleChooesImg) ? Image.FromFile(PubUtil.ModuleChooesImg) : null);
+ baseFlowPanel.Controls.Add(menu);
+ this._menuItemList.Add(menu);
+ //DataRow modelRow = MainImpl.GetSystemdllTab(item["PurviewId"] + "");
+ //string countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
+ string countSql = dataRow.Table.Columns.Contains("countSql") ? dataRow["countSql"] + "" : "";
+ if (!string.IsNullOrWhiteSpace(countSql) && !"0".Equals(countSql.TrimEnd()) && !countSqls.ContainsKey(groupMenuId))
+ {
+ countSqls.Add(groupMenuId, countSql);
+ }
+ }
+ baseGroupControl.Dock = DockStyle.Top;
+ collectMenuPanel.Controls.Add(baseGroupControl);
+ baseGroupControl.TipsText = $"快捷操作通道({baseTable.Count()})";
+ }
+ if (reportTable.Count() > 0)
+ {
+ reportFlowPanel.Dock = DockStyle.Fill;
+ reportFlowPanel.FlowDirection = FlowDirection.LeftToRight;
+ reportGroupControl.MenuPanel.Controls.Add(reportFlowPanel);
+ foreach (DataRow dataRow in reportTable)
+ {
+ string groupMenuId = dataRow["LMenuId"] + "";
+ string defaultImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOutImg"] + "";
+ string hoverImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOverImg1"] + "";
+ string[] menuTag = new string[] { dataRow["DllFileName"] + "", dataRow["PurviewId"] + "", dataRow["LMenuId"] + "", dataRow["UrlParams"] + "", dataRow["LSubSysId"] + "", dataRow["dllShowCaption"] + "" };
+ Menu_ItemNew menu = new Menu_ItemNew();
+ if (fontFamily != null)
+ {
+ menu.GetLabelTitle().Font = new Font(fontFamily, 9.75f, FontStyle.Bold);
+ menu.GetLabelTitleSub().Font = new Font(fontFamily, 8.5f, FontStyle.Regular);
+ }
+ menu.GetLabelTitle().ForeColor = Color.FromArgb(71, 73, 79);
+ menu.Margin = new Padding(0, 0, 20, 0);
+ menu.Name = groupMenuId;
+ menu.Size = new Size(menuWidth, menuHeight);
+ menu.GetLabelTitle().ForeColor = Color.FromArgb(88, 85, 85);
+ menu.GetButton().Size = new Size(buttonWidth, buttonHeight);
+ menu.SetMenuCaption(dataRow["dllShowCaption"] + "");
+ menu.SetSubCaption(dataRow["SubSysName"] + "-" + dataRow["menucaption"]);
+ menu.SetRoundRadius = 20;
+ menu.Tag = menuTag;
+ menu.Click += OnMenuItemClick;
+ string randomImage = "";
+ if (Directory.Exists(PubUtil.ModuleDefaultPath))
+ {
+ if (menuFiles.Length > 0)
+ {
+ int index = rand.Next(menuFiles.Length);
+ randomImage = menuFiles[index];
+ }
+ }
+ menu.SetMenuImg(File.Exists(defaultImg) ? Image.FromFile(defaultImg) : File.Exists(randomImage) ? Image.FromFile(randomImage) : Resources.default_icon);
+ menu.SetMenuHoverImg(File.Exists(hoverImg) ? Image.FromFile(hoverImg) : File.Exists(PubUtil.ModuleHoverImg) ? Image.FromFile(PubUtil.ModuleHoverImg) : Resources.default_icon);
+ menu.SetMenuHoverBorderImg(File.Exists(PubUtil.ModuleChooesImg) ? Image.FromFile(PubUtil.ModuleChooesImg) : null);
+ reportFlowPanel.Controls.Add(menu);
+ this._menuItemList.Add(menu);
+ //DataRow modelRow = MainImpl.GetSystemdllTab(item["PurviewId"] + "");
+ //string countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
+ string countSql = dataRow.Table.Columns.Contains("countSql") ? dataRow["countSql"] + "" : "";
+ if (!string.IsNullOrWhiteSpace(countSql) && !"0".Equals(countSql.TrimEnd()) && !countSqls.ContainsKey(groupMenuId))
+ {
+ countSqls.Add(groupMenuId, countSql);
+ }
+ }
+ reportGroupControl.Dock = DockStyle.Top;
+ collectMenuPanel.Controls.Add(reportGroupControl);
+ reportGroupControl.TipsText = $"快捷报表通道({reportTable.Count()})";
+ }
+ if (reportTable.Count() > 0)
+ {
+ reportGroupControl.Height = reportFlowPanel.Controls[reportFlowPanel.Controls.Count - 1].Location.Y + menuHeight + 28 + 16;
+ }
+ if (baseTable.Count() > 0)
+ {
+ baseGroupControl.Height = baseFlowPanel.Controls[baseFlowPanel.Controls.Count - 1].Location.Y + menuHeight + 28 + 16;
+ }
+ collectPanel.Height = baseGroupControl.Height + reportGroupControl.Height + 26;
+ if (reportTable.Count() == 0 && baseTable.Count() == 0)
+ {
+ collectPanel.Visible = false;
+ panelSplit.Visible = false;
+ }
+ if (reportTable.Count() > 0 || baseTable.Count() > 0)
+ {
+ collectPanel.SizeChanged += (s, e) =>
+ {
+ if (reportTable.Count() > 0)
+ {
+ reportGroupControl.Height = reportFlowPanel.Controls[reportFlowPanel.Controls.Count - 1].Location.Y + menuHeight + 28 + 16;
+ }
+ if (baseTable.Count() > 0)
+ {
+ baseGroupControl.Height = baseFlowPanel.Controls[baseFlowPanel.Controls.Count - 1].Location.Y + menuHeight + 28 + 16;
+ }
+ collectPanel.Height = baseGroupControl.Height + reportGroupControl.Height + 26;
+ };
+ }
+ this.splitMainControl.Panel2Collapsed = true;
+ }
+ #endregion
+ foreach (DataRow item in rows)
+ {
+ string menuStruct = item["menustruct"] + "";
+ string menuCaption = item["menucaption"] + "";
+ string menuid = item["menuid"] + "";
+ string menuposition = item.Table.Columns.Contains("menuposition") ? item["menuposition"] + "" : "0";
+ if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.SplitBar) && menuCaption.StartsWith(SystemInfo.Instance.SplitBar)) continue;
+ // 加载左侧菜单
+ if (menuStruct.Length == 2)
+ {
+ DataTable childs = rows.Cast().Where(x => (x["MenuStruct"] + "").Substring(0, 2) == menuStruct).CopyToDataTable();
+ if (childs != null && childs.Rows.Count > 1)
+ {
+ if (string.IsNullOrEmpty(defaultParentMenu))
+ defaultParentMenu = menuStruct;
+ // menuLeft = 5; menuTop = 5;
+ menuLeft = Convert.ToInt32(0.05 * DpiX); menuTop = Convert.ToInt32(0.05 * DpiY);
+ MenuBar button = new MenuBar();
+ 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;
+
+ if (SystemInfo.Instance.MenuBarWidth > 0)
+ {
+ button.Size = new Size(SystemInfo.Instance.MenuBarWidth, Convert.ToInt32(0.46 * DpiX));
+ button.GetButton().Width = SystemInfo.Instance.MenuBarWidth - 10;
+ }
+
+ if (_firstMenuBar == null)
+ {
+ _firstMenuBar = button;
+ }
+ // 注册事件
+ button.SetHoverEvent(hoverEvent, (MenuEventType)SystemInfo.Instance.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 (!_menus.Keys.Contains(menuStruct))
+ {
+ _menus.Add(menuStruct, new List());
+ }
+ #region 添加右侧菜单模块
+ if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu) && !SystemInfo.Instance.HideGallerys)
+ {
+ List layoutTopDataRows = rows.Where(n => (n["menuposition"] + "").Equals("1") && (n["menustruct"] + "").Length == 4 && (n["menustruct"] + "").Substring(0, 2).Equals(menuStruct) && !(!string.IsNullOrWhiteSpace(SystemInfo.Instance.SplitBar) && (n["menucaption"] + "").StartsWith(SystemInfo.Instance.SplitBar))).ToList();
+ List layoutBotDataRows = rows.Where(n => (n["menuposition"] + "").Equals("2") && (n["menustruct"] + "").Length == 4 && (n["menustruct"] + "").Substring(0, 2).Equals(menuStruct) && !(!string.IsNullOrWhiteSpace(SystemInfo.Instance.SplitBar) && (n["menucaption"] + "").StartsWith(SystemInfo.Instance.SplitBar))).ToList();
+ TableLayoutPanel topLayoutPanel = new TableLayoutPanel();
+ topLayoutPanel.Dock = DockStyle.Fill;
+ topLayoutPanel.RowCount = layoutTopDataRows.Count() + 1;
+ topLayoutPanel.RowStyles.Clear();
+ TableLayoutPanel botLayoutPanel = new TableLayoutPanel();
+ botLayoutPanel.Dock = DockStyle.Fill;
+ botLayoutPanel.RowCount = layoutBotDataRows.Count() + 1;
+ botLayoutPanel.RowStyles.Clear();
+ if (!topLayoutPanelDic.ContainsKey(menuStruct))
+ {
+ topLayoutPanelDic.Add(menuStruct, topLayoutPanel);
+ }
+ if (!botLayoutPanelDic.ContainsKey(menuStruct))
+ {
+ botLayoutPanelDic.Add(menuStruct, botLayoutPanel);
+ }
+ for (int i = 0; i < layoutTopDataRows.Count; i++)
+ {
+ RowStyle rowStyle = new RowStyle();
+ rowStyle.SizeType = SizeType.Absolute;
+ rowStyle.Height = 25;
+ topLayoutPanel.RowStyles.Add(rowStyle);
+ SimpleControl simpleControl = new SimpleControl();
+ simpleControl.Dock = DockStyle.Fill;
+ DataRow topItem = layoutTopDataRows[i];
+ // 前方箭头
+ simpleControl.PicBox.BackgroundImage = Resources.arrows;
+ simpleControl.Label.Text = topItem["menucaption"] + "";
+ simpleControl.Label.Font = new Font("微软雅黑", 10);
+ simpleControl.Label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
+ simpleControl.Label.Tag = topItem;
+ simpleControl.Label.MouseMove += OnLabelMouseMove;
+ simpleControl.Label.MouseLeave += OnLabelMouseLeave;
+ simpleControl.Label.MouseClick += OnLabelMouseClick;
+ simpleControl.CornerLab.Visible = false;
+ topLayoutPanel.Controls.Add(simpleControl, 0, i);
+ if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text))
+ _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
+ simpleControl.CornerLab.BringToFront();
+ if (topItem.Table.Columns.Contains("GroupCaption") && (topLayoutPanel.Tag == null || !string.IsNullOrEmpty(topLayoutPanel.Tag + "")))
+ {
+ topLayoutPanel.Tag = topItem["GroupCaption"] + "";
+ }
+ }
+ if (menuStruct == defaultParentMenu)
+ {
+ this.pl_center_main_bottom_right_main.Controls.Clear();
+ this.pl_center_main_bottom_right_main.Controls.Add(topLayoutPanel);
+ string labelCaption = topLayoutPanel.Tag + "";
+ this.lblShortcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblShortcutset.Tag + "";
+ }
+ for (int i = 0; i < layoutBotDataRows.Count; i++)
+ {
+ RowStyle rowStyle = new RowStyle();
+ rowStyle.SizeType = SizeType.Absolute;
+ rowStyle.Height = 25;
+ botLayoutPanel.RowStyles.Add(rowStyle);
+ SimpleControl simpleControl = new SimpleControl();
+ simpleControl.Dock = DockStyle.Fill;
+ DataRow botItem = layoutBotDataRows[i];
+ // 前方箭头
+ simpleControl.PicBox.BackgroundImage = Resources.arrows;
+ simpleControl.Label.Text = botItem["menucaption"] + "";
+ simpleControl.Label.Font = new Font("微软雅黑", 10);
+ simpleControl.Label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
+ simpleControl.Label.Tag = botItem;
+ simpleControl.Label.MouseMove += OnLabelMouseMove;
+ simpleControl.Label.MouseLeave += OnLabelMouseLeave;
+ simpleControl.Label.MouseClick += OnLabelMouseClick;
+ simpleControl.CornerLab.Visible = false;
+ botLayoutPanel.Controls.Add(simpleControl, 0, i);
+ if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text))
+ _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
+ simpleControl.CornerLab.BringToFront();
+ if (botItem.Table.Columns.Contains("GroupCaption") && (botLayoutPanel.Tag == null || !string.IsNullOrEmpty(botLayoutPanel.Tag + "")))
+ {
+ botLayoutPanel.Tag = botItem["GroupCaption"] + "";
+ }
+ }
+ if (menuStruct == defaultParentMenu)
+ {
+ this.pl_center_main_bottom_left_main.Controls.Clear();
+ this.pl_center_main_bottom_left_main.Controls.Add(botLayoutPanel);
+ string labelCaption = botLayoutPanel.Tag + "";
+ this.lblReportcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblReportcutset.Tag + "";
+ }
+ }
+ #endregion
+ #region 添加分组菜单控件
+ if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout)
+ {
+ //添加全部应用菜单
+ List groupDataRows = new List();
+ if (this._allMenus.Columns.Contains("menuposition"))
+ {
+ groupDataRows = rows.Where(n => (n["menuposition"] + "").Equals("0") && (n["menustruct"] + "").Length == 4 && (n["menustruct"] + "").Substring(0, 2).Equals(menuStruct) && !(!string.IsNullOrEmpty(SystemInfo.Instance.SplitBar) && (n["menucaption"] + "").StartsWith(SystemInfo.Instance.SplitBar))).ToList();
+ }
+ else
+ {
+ groupDataRows = rows.Where(n => (n["menustruct"] + "").Length == 4 && (n["menustruct"] + "").Substring(0, 2).Equals(menuStruct) && !(!string.IsNullOrEmpty(SystemInfo.Instance.SplitBar) && (n["menucaption"] + "").StartsWith(SystemInfo.Instance.SplitBar))).ToList();
+ }
+ foreach (DataRow dataRow in groupDataRows)
+ {
+ int groupcaptionInt = 0;
+ string groupcaption = dataRow["groupcaption"] + "";
+ if (!string.IsNullOrWhiteSpace(groupcaption) && groupcaption.Length > 2 && int.TryParse(groupcaption.Substring(0, 2), out groupcaptionInt) && groupcaptionInt > 0)
+ {
+ dataRow["groupcaption"] = groupcaption;
+ }
+ else
+ {
+ dataRow["groupcaption"] = "99默认分组";
+ }
+ if (dataRow.Table.Columns.Contains("menuRow"))
+ {
+ int menRow = 0;
+ int.TryParse(dataRow["menuRow"] + "", out menRow);
+ dataRow["menuRow"] = menRow > 0 ? menRow : 1;
+ }
+ }
+ IEnumerable> groupByDataRows = groupDataRows.GroupBy(n => Convert.ToInt32((n["groupcaption"] + "").Substring(0, 2))).OrderByDescending(n => n.Key);
+ Panel groupPanel = new Panel();
+ groupPanel.AutoScroll = true;
+ groupPanel.Dock = DockStyle.Fill;
+ int groupControlIndex = 0;
+ foreach (IGrouping groupByDataRow in groupByDataRows)
+ {
+ int nowRowCount = 1;//当前行数
+ int minMenuRow = this._allMenus.Columns.Contains("menuRow") ? groupByDataRow.Min(n => Convert.ToInt32(n["menuRow"])) : 1;
+ int menuGroupLeft = Convert.ToInt32(0.05 * DpiY);
+ int menuGroupTop = 0; // 模块距离左边距,模块距离顶部边距
+ GroupControl groupControl = new GroupControl();
+ groupControl.TipsLabel.ForeColor = Color.DimGray;
+ groupControl.Dock = DockStyle.Top;
+ if (groupControlIndex == groupByDataRows.Count() - 1 && !isShowGrallyInTop)
+ {
+ groupControl.Padding = new Padding(0, 0, 0, 0);
+ }
+ groupPanel.Controls.Add(groupControl);
+ List groupOrderDataRow = groupByDataRow.ToList();
+ if (this._allMenus.Columns.Contains("menuRow"))
+ {
+ groupOrderDataRow = groupByDataRow.OrderBy(n => Convert.ToInt32(n["menuRow"] + "")).ToList();
+ }
+ int count = 0;
+ foreach (DataRow dataRow in groupOrderDataRow)
+ {
+ string groupMenuId = dataRow["menuid"] + "";
+ groupControl.TipsText = (dataRow["groupcaption"] + "").Remove(0, 2);
+ if (menuposition.Equals("0"))
+ {
+ string defaultImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOutImg"] + "";
+ string hoverImg = PubUtil.MainMenuDefaultImage + dataRow["MouseOverImg1"] + "";
+ string[] menuTag = new string[] { dataRow["DllFileName"] + "", dataRow["PurviewId"] + "", dataRow["MenuId"] + "", dataRow["UrlParams"] + "", dataRow["SubSysId"] + "", dataRow["menucaption"] + "" };
+ int groupIndex = groupByDataRow.Key;
+ if (groupIndex == 99)
+ {
+ groupIndex = groupByDataRows.Where(n => !n.Key.Equals(99)).Count() > 0 ? groupByDataRows.Where(n => !n.Key.Equals(99)).Max(n => n.Key) + 1 : 1;
+ }
+ Menu_ItemNew menu = new Menu_ItemNew();
+ if (fontFamily != null)
+ {
+ menu.GetLabelTitle().Font = new Font(fontFamily, 10f, FontStyle.Bold);
+ menu.GetLabelTitleSub().Font = new Font(fontFamily, 8.5f, FontStyle.Regular);
+ }
+ menu.GetLabelTitle().ForeColor = Color.FromArgb(71, 73, 79);
+ menu.menuRow = dataRow.Table.Columns.Contains("menuRow") && !string.IsNullOrEmpty(dataRow["menuRow"] + "") ? Convert.ToInt32(dataRow["menuRow"] + "") : 1;
+ menu.menuGroup = groupIndex;
+ if ((menu.menuRow - minMenuRow + 1) > nowRowCount + 1)
+ {
+ foreach (DataRow row in dataRow.Table.Rows)
+ {
+ if ((row["menuRow"] + "").Equals(menu.menuRow + ""))
+ {
+ row["menuRow"] = nowRowCount + 1;
+ }
+ }
+ menu.menuRow = nowRowCount + 1;
+ }
+ menu.Name = groupMenuId;
+ menu.Size = new Size(menuWidth, menuHeight);
+ menu.GetButton().Size = new Size(buttonWidth, buttonHeight);
+ menu.menuNode = (dataRow["menustruct"] + "").Substring(0, 2);
+ menu.SetMenuCaption(dataRow["menucaption"] + "");
+ menu.SetSubCaption(dataRow["SubSysName"] + "-" + item["menucaption"]);
+ menu.SetRoundRadius = 20;
+ menu.Tag = menuTag;
+ menu.Click += OnMenuItemClick;
+ string randomImage = "";
+ if (Directory.Exists(PubUtil.ModuleDefaultPath))
+ {
+ if (menuFiles.Length > 0)
+ {
+ int index = rand.Next(menuFiles.Length);
+ randomImage = menuFiles[index];
+ }
+ }
+ menu.SetMenuImg(File.Exists(defaultImg) ? Image.FromFile(defaultImg) : File.Exists(randomImage) ? Image.FromFile(randomImage) : Resources.default_icon);
+ menu.SetMenuHoverImg(File.Exists(hoverImg) ? Image.FromFile(hoverImg) : File.Exists(PubUtil.ModuleHoverImg) ? Image.FromFile(PubUtil.ModuleHoverImg) : Resources.default_icon);
+ menu.SetMenuHoverBorderImg(File.Exists(PubUtil.ModuleChooesImg) ? Image.FromFile(PubUtil.ModuleChooesImg) : null);
+ // 116
+ //menuGroupLeft += Convert.ToInt32(1.20 * DpiX);
+ //后台配置模块所在行数
+ if ((menu.menuRow - minMenuRow + 1) > 0)
+ {
+ if ((menu.menuRow - minMenuRow + 1) != nowRowCount || menuGroupLeft + menuWidth > centerWidth)
+ {
+ menuGroupLeft = 5;
+ if ((menu.menuRow - minMenuRow + 1) != nowRowCount)
+ {
+ menuGroupTop += menuHeight * ((menu.menuRow - minMenuRow + 1) - nowRowCount);
+ }
+ else
+ {
+ menuGroupTop += menuHeight;
+ }
+ nowRowCount = (menu.menuRow - minMenuRow + 1);
+ }
+ menu.Location = new Point(menuGroupLeft, menuGroupTop);
+ menuGroupLeft += Convert.ToInt32(2.5 * DpiX) + 20;
+ //int count = _menuItemList.Where(o => o.menuGroup == menu.menuGroup && o.menuRow == menu.menuRow && o.menuNode == menu.menuNode).Count();
+ //menuGroupLeft = count == 0 ? 5 : count * Convert.ToInt32(1.20 * DpiX) + 5;
+ //menuGroupTop = menuHeight * (menu.menuRow - minMenuRow);
+ //menu.Location = new Point(menuGroupLeft, menuGroupTop);
+ }
+ else
+ {
+ menu.Location = new Point(menuGroupLeft, menuGroupTop);
+ menuGroupLeft += Convert.ToInt32(2.5 * DpiX) + 20;
+ // 换行显示
+ if (menuGroupLeft + menuWidth > centerWidth)
+ {
+ menuGroupLeft = 5;
+ menuGroupTop += menuHeight;
+ }
+ }
+ groupControl.MenuPanel.Controls.Add(menu);
+ List controls = new List();
+ if (_menus.TryGetValue(menuStruct, out controls))
+ {
+ controls.Add(menu);
+ }
+ this._menuItemList.Add(menu);
+ //DataRow modelRow = MainImpl.GetSystemdllTab(dataRow["PurviewId"] + "");
+ //string countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
+ string countSql = dataRow.Table.Columns.Contains("countSql") ? dataRow["countSql"] + "" : "";
+ if (!string.IsNullOrWhiteSpace(countSql) && !"0".Equals(countSql.TrimEnd()) && !countSqls.ContainsKey(groupMenuId))
+ {
+ countSqls.Add(groupMenuId, countSql);
+ }
+
+ //string countSqlBill = dataRow.Table.Columns.Contains("countSqlBill") ? dataRow["countSqlBill"] + "" : "";
+ //if (!string.IsNullOrWhiteSpace(countSqlBill) && !"0".Equals(countSqlBill.TrimEnd()) && !countSqls.ContainsKey(groupMenuId))
+ //{
+ // countSqls.Add(groupMenuId, countSqlBill);
+ //}
+ count += 1;
+ }
+ }
+ groupControlIndex += 1;
+ groupControl.TipsText = $"{groupControl.TipsText}({count})";
+ groupControl.Height = (int)(menuGroupTop + menuHeight + 28 + 16);
+ }
+ if (groupPanel.Controls.Count == 1)
+ {
+ (groupPanel.Controls[0] as GroupControl).TipsVisable = false;
+ }
+ if (!_groupItems.ContainsKey(menuStruct))
+ {
+ _groupItems.Add(menuStruct, groupPanel);
+ }
+ // 默认显示
+ if (defaultParentMenu == menuStruct)
+ {
+ this.allMenuPanel.Controls.Add(groupPanel);
+ groupPanel.Visible = true;
+ }
+ else
+ {
+ this.allMenuPanel.Controls.Add(groupPanel);
+ groupPanel.Visible = false;
+ }
+ }
+ #endregion
+ }
+ }
+ // 加载右侧模块
+ if (menuStruct.Length == 4)
+ {
+ if (menuposition.Equals("0") && (!this._allMenus.Columns.Contains("groupcaption") || isFlowLayout))
+ {
+ string defaultImg = PubUtil.MainMenuDefaultImage + item["MouseOutImg"] + "";
+ string hoverImg = PubUtil.MainMenuDefaultImage + item["MouseOverImg1"] + "";
+ string[] menuTag = new string[] { item["DllFileName"] + "", item["PurviewId"] + "", item["MenuId"] + "", item["UrlParams"] + "", item["SubSysId"] + "", item["menucaption"] + "" };
+ 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(menuWidthOld, menuHeightOld);
+ menu.menuNode = menuStruct.Substring(0, 2);
+ menu.SetMenuCaption(menuCaption);
+ menu.SetRoundRadius = 20;
+ menu.GetButton().Tag = menuTag;
+ menu.GetButton().Click += OnMenuItemClick;
+ menu.SetMenuImg(File.Exists(defaultImg) ? Image.FromFile(defaultImg) : Resources.default_icon);
+ menu.SetMenuHoverImg(File.Exists(hoverImg) ? Image.FromFile(hoverImg) : Resources.default_icon);
+ // 116
+ //menuLeft += Convert.ToInt32(1.20 * DpiX);
+ //后台配置模块所在行数
+ if (menu.menuRow > 0)
+ {
+ int count = _menuItemList.Cast().Where(o => o.menuRow == menu.menuRow && o.menuNode == menu.menuNode).Count();
+ menuLeft = count == 0 ? 5 : count * Convert.ToInt32(1.20 * DpiX) + 5;
+ menuTop = menuHeightOld * (menu.menuRow - 1);
+ menu.Location = new Point(menuLeft, menuTop);
+ }
+ else
+ {
+ menu.Location = new Point(menuLeft, menuTop);
+ menuLeft += Convert.ToInt32(1.20 * DpiX);
+ // 换行显示
+ if (menuLeft + menuWidthOld > centerWidth)
+ {
+ menuLeft = 5;
+ menuTop += menuHeightOld;
+ }
+ }
+ // 默认显示
+ if (defaultParentMenu != menuStruct.Substring(0, 2))
+ {
+ menu.Visible = false;
+ }
+ if (isFlowLayout)
+ {
+ pl_center_main_middle_FlowLayout.Controls.Add(menu);
+ }
+ else
+ {
+ pl_center_main_middle.Controls.Add(menu);
+ }
+ List controls = new List();
+ if (_menus.TryGetValue(menuStruct.Substring(0, 2), out controls))
+ {
+ controls.Add(menu);
+ }
+ this._menuItemList.Add(menu);
+ //DataRow modelRow = MainImpl.GetSystemdllTab(item["PurviewId"] + "");
+ //string countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
+ string countSql = item.Table.Columns.Contains("countSql") ? item["countSql"] + "" : "";
+ if (!string.IsNullOrWhiteSpace(countSql) && !"0".Equals(countSql.TrimEnd()) && !countSqls.ContainsKey(menuid))
+ {
+ countSqls.Add(menuid, countSql);
+ }
+
+ //string countSqlBill = item.Table.Columns.Contains("countSqlBill") ? item["countSqlBill"] + "" : "";
+ //if (!string.IsNullOrWhiteSpace(countSqlBill) && !"0".Equals(countSqlBill.TrimEnd()) && !countSqls.ContainsKey(menuid))
+ //{
+ // countSqls.Add(menuid, countSqlBill);
+ //}
+ }
+ }
+ }
+ }
+ }
+ ///
+ /// 说明:设置筛选模块
+ /// 创建人:龚宇超
+ /// 创建日期:2017-11-20
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetSearchMenus()
+ {
+ lueUserName.ValueMember = lueUserName.ValueField = "MenuId";
+ lueUserName.TextMember = "SearchMenuCaption";
+ lueUserName.SourceSQL = this._menuSql;
+ lueUserName.IsHomepage = true;
+ lueUserName.DataSource = this._allMenus.Select("len(MenuStruct)=4").CopyToDataTable();
+ //lueUserName.IsSetDataSource = true;
+ }
+ ///
+ /// 说明:设置快捷通道
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetGallerys()
+ {
+ DataTable gallerys = MainImpl.GetGallerysByUserId();
+ if (Business.Impl.LanguageTranslation.Translatable)
+ {
+ gallerys = Business.Impl.LanguageTranslation.TranslationTableColumn(gallerys, "DllShowCaption");
+ }
+ var baseTable = gallerys.Select("grouptagid=1");
+ var reportTable = gallerys.Select("grouptagid=2");
+ if ((!this._allMenus.Columns.Contains("menuposition") || (!SystemInfo.Instance.IsOpenWork && !SystemInfo.Instance.ShowGallerysFromMenu)))
+ {
+ this.pl_center_main_bottom_right_main.Controls.Clear();
+ this.xtpWorktop.PageVisible = false;
+ _quickPageHeaders.Clear();
+ TableLayoutPanel topLayoutPanel = new TableLayoutPanel();
+ this.pl_center_main_bottom_right_main.Controls.Add(topLayoutPanel);
+ topLayoutPanel.Dock = DockStyle.Fill;
+ topLayoutPanel.RowCount = baseTable.Count() + 1;
+ topLayoutPanel.RowStyles.Clear();
+ //显示我的操作通道
+ for (int i = 0; i < baseTable.Count(); i++)
+ {
+ RowStyle rowStyle = new RowStyle();
+ rowStyle.SizeType = SizeType.Absolute;
+ rowStyle.Height = 25;
+ topLayoutPanel.RowStyles.Add(rowStyle);
+ SimpleControl simpleControl = new SimpleControl();
+ simpleControl.Dock = DockStyle.Fill;
+ DataRow item = baseTable[i];
+ // 前方箭头
+ simpleControl.PicBox.BackgroundImage = Resources.arrows;
+ simpleControl.Label.Text = item["DllShowCaption"] + "";
+ simpleControl.Label.Font = new Font("微软雅黑", 10);
+ simpleControl.Label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
+ simpleControl.Label.Tag = item;
+ simpleControl.Label.MouseMove += OnLabelMouseMove;
+ simpleControl.Label.MouseLeave += OnLabelMouseLeave;
+ simpleControl.Label.MouseClick += OnLabelMouseClick;
+ simpleControl.CornerLab.Visible = false;
+ topLayoutPanel.Controls.Add(simpleControl, 0, i);
+ if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text))
+ _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
+ simpleControl.CornerLab.BringToFront();
+ }
+ pl_center_main_bottom_left_main.Controls.Clear();
+ TableLayoutPanel bottomLayoutPanel = new TableLayoutPanel();
+ this.pl_center_main_bottom_left_main.Controls.Add(bottomLayoutPanel);
+ bottomLayoutPanel.Dock = DockStyle.Fill;
+ bottomLayoutPanel.RowCount = reportTable.Count() + 1;
+ bottomLayoutPanel.RowStyles.Clear();
+ // 显示我的报表通道
+ for (int i = 0; i < reportTable.Count(); i++)
+ {
+ RowStyle rowStyle = new RowStyle();
+ rowStyle.SizeType = SizeType.Absolute;
+ rowStyle.Height = 25;
+ bottomLayoutPanel.RowStyles.Add(rowStyle);
+ SimpleControl simpleControl = new SimpleControl();
+ simpleControl.Dock = DockStyle.Fill;
+ DataRow item = reportTable[i];
+ // 前方箭头
+ simpleControl.PicBox.BackgroundImage = Resources.arrows;
+ simpleControl.Label.Text = item["DllShowCaption"] + "";
+ simpleControl.Label.Font = new Font("微软雅黑", 10);
+ simpleControl.Label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
+ simpleControl.Label.Tag = item;
+ simpleControl.Label.MouseMove += OnLabelMouseMove;
+ simpleControl.Label.MouseLeave += OnLabelMouseLeave;
+ simpleControl.Label.MouseClick += OnLabelMouseClick;
+ simpleControl.CornerLab.Visible = false;
+ bottomLayoutPanel.Controls.Add(simpleControl, 0, i);
+ if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text))
+ _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
+ simpleControl.CornerLab.BringToFront();
+ }
+ }
+ else if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu))
+ {
+ if (SystemInfo.Instance.IsOpenWork)
+ {
+ this.xtpWorktop.PageVisible = true;
+ }
+ else
+ {
+ this.xtpWorktop.PageVisible = false;
+ }
+ // 显示我的操作通道
+ this.workTopPanel.Controls.Clear();
+ int menuWidth = Convert.ToInt32(1.14 * DpiX);
+ int menuHeight = Convert.ToInt32(1.32 * DpiY); //模块宽度,模块高度
+ int menuLeft = Convert.ToInt32(0.2 * DpiY);
+ int menuTop = Convert.ToInt32(0.2 * DpiY); //模块距离左边距,模块距离顶部边距
+ int centerWidth = this.workTopPanel.Width; //内容区域宽度
+ for (int i = 0; i < baseTable.Count(); i++)
+ {
+ DataRow item = baseTable[i];
+ string defaultImg = item.Table.Columns.Contains("MouseOutImg") ? PubUtil.MainMenuDefaultImage + item["MouseOutImg"] + "" : "";
+ string hoverImg = item.Table.Columns.Contains("MouseOverImg1") ? PubUtil.MainMenuDefaultImage + item["MouseOverImg1"] + "" : "";
+ string[] menuTag = new string[] { item["ObjDll"] + "", item["LinkModeTag"] + "", item["LMenuId"] + "", item["PurviewId"] + "", "", item["DllShowCaption"] + "" };
+ string menuCaption = item["DllShowCaption"] + "";
+ Menu_ItemNew menu = new Menu_ItemNew();
+ menu.Size = new Size(menuWidth, menuHeight);
+ menu.SetMenuCaption(menuCaption);
+ menu.SetSubCaption(item["SubSysName"] + "-" + item["menucaption"]);
+ menu.SetRoundRadius = 20;
+ menu.Tag = menuTag;
+ menu.Click += OnMenuItemClick;
+ //menu.GetButton().Click += OnMenuItemClick;
+ menu.SetMenuImg(!string.IsNullOrEmpty(defaultImg) && File.Exists(defaultImg) ? Image.FromFile(defaultImg) : Resources.default_icon);
+ menu.SetMenuHoverImg(!string.IsNullOrEmpty(hoverImg) && File.Exists(hoverImg) ? Image.FromFile(hoverImg) : Resources.default_icon);
+ menu.Location = new Point(menuLeft, menuTop);
+ menuLeft += Convert.ToInt32(1.3 * DpiX);
+ // 换行显示
+ if (menuLeft + menuWidth > centerWidth)
+ {
+ menuLeft = 5;
+ menuTop += menuHeight;
+ }
+ this.workTopPanel.Controls.Add(menu);
+ }
+ this.workSplitMainControl.SplitterPosition = menuTop + menuHeight + 5;
+ // 显示我的报表通道
+ this.workBottomPanel.Controls.Clear();
+ menuWidth = Convert.ToInt32(1.14 * DpiX);
+ menuHeight = Convert.ToInt32(1.32 * DpiY); //模块宽度,模块高度
+ menuLeft = Convert.ToInt32(0.2 * DpiY);
+ menuTop = Convert.ToInt32(0.2 * DpiY); //模块距离左边距,模块距离顶部边距
+ centerWidth = this.workBottomPanel.Width; //内容区域宽度
+ for (int i = 0; i < reportTable.Count(); i++)
+ {
+ DataRow item = reportTable[i];
+ string defaultImg = item.Table.Columns.Contains("MouseOutImg") ? PubUtil.MainMenuDefaultImage + item["MouseOutImg"] + "" : "";
+ string hoverImg = item.Table.Columns.Contains("MouseOverImg1") ? PubUtil.MainMenuDefaultImage + item["MouseOverImg1"] + "" : "";
+ string[] menuTag = new string[] { item["ObjDll"] + "", item["LinkModeTag"] + "", item["LMenuId"] + "", item["PurviewId"] + "", "", item["DllShowCaption"] + "" };
+ string menuCaption = item["DllShowCaption"] + "";
+ Menu_ItemNew menu = new Menu_ItemNew();
+ menu.Size = new Size(menuWidth, menuHeight);
+ menu.SetMenuCaption(menuCaption);
+ menu.SetSubCaption(item["SubSysName"] + "-" + item["menucaption"]);
+ menu.SetRoundRadius = 20;
+ menu.Tag = menuTag;
+ menu.Click += OnMenuItemClick;
+ menu.SetMenuImg(!string.IsNullOrEmpty(defaultImg) && File.Exists(defaultImg) ? Image.FromFile(defaultImg) : Resources.default_icon);
+ menu.SetMenuHoverImg(!string.IsNullOrEmpty(hoverImg) && File.Exists(hoverImg) ? Image.FromFile(hoverImg) : Resources.default_icon);
+ menu.Location = new Point(menuLeft, menuTop);
+ menuLeft += Convert.ToInt32(1.3 * DpiX);
+ // 换行显示
+ if (menuLeft + menuWidth > centerWidth)
+ {
+ menuLeft = 5;
+ menuTop += menuHeight;
+ }
+ this.workBottomPanel.Controls.Add(menu);
+ }
+ Menu_ItemNew addBotMenu = new Menu_ItemNew();
+ addBotMenu.Size = new Size(menuWidth, menuHeight);
+ addBotMenu.SetMenuCaption("添加");
+ addBotMenu.SetRoundRadius = 20;
+ addBotMenu.GetButton().Click += OnWorkMenuItemClick;
+ addBotMenu.SetMenuImg(Resources.add);
+ addBotMenu.SetMenuHoverImg(Resources.add);
+ addBotMenu.Location = new Point(menuLeft, menuTop);
+ menuLeft += Convert.ToInt32(1.3 * DpiX);
+ // 换行显示
+ if (menuLeft + menuWidth > centerWidth)
+ {
+ menuLeft = 5;
+ menuTop += menuHeight;
+ }
+ this.workBottomPanel.Controls.Add(addBotMenu);
+ }
+ }
+ #region
+ ///
+ /// 说明:重绘圆角
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void MenuItem_Paint(object sender, PaintEventArgs e)
+ {
+ try
+ {
+ System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
+ int x = 0;
+ int y = 0;
+ int thisWidth = this.Width;
+ int thisHeight = this.Height;
+ int angle = 20;
+ if (angle > 0)
+ {
+ System.Drawing.Graphics g = CreateGraphics();
+ oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角
+ oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角
+ oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角
+ oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角
+ oPath.CloseAllFigures();
+ Region = new System.Drawing.Region(oPath);
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ #endregion
+ ///
+ /// 说明:获取子系统小窗口内容
+ /// 创建人:龚宇超
+ /// 创建日期:2018-08-02
+ /// 修改人:`
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private DataRow[] GetSubItem()
+ {
+ DataRow[] rows = _subItemMenu.Select(string.Format("SubSysId <>'{0}'", ERPInfo.Instance.SubSysId));
+ return rows;
+ }
+ ///
+ /// 说明:左菜单初始化(左边为树)
+ /// 创建人:龚宇超
+ /// 创建日期:2018-04-24
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void InitLeftMenu()
+ {
+ DataTable dtLvTree = MainImpl.GetLeftTreeView();
+ tv_left.ParentField = "speciesno";
+ tv_left.ParentKeyLength = 2;
+ tv_left.TextField = "speciesname";
+ tv_left.OnButtonClickEvent += new TreeViewCustom.ButtonClickEventHandler(OnMenuButtonClick);
+ tv_left.SetDataSource(dtLvTree);
+ }
+ ///
+ /// 说明:加载顶部菜单
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetTopMenus()
+ {
+ string where = string.IsNullOrEmpty(ERPInfo.Instance.SeriesId) ? "" : string.Format("and SeriesId={0}", ERPInfo.Instance.SeriesId);
+ DataTable subSystems = MainImpl.GetSubSystems(where);
+ if (Business.Impl.LanguageTranslation.Translatable)
+ {
+ subSystems = Business.Impl.LanguageTranslation.TranslationTableColumn(subSystems, "SubSysName");
+ }
+
+ _subItemMenu = subSystems.Clone();
+ // 模式处理
+ if (SystemInfo.Instance.DefaultMainTag == 2)
+ {
+ DataTable dtTable = MainImpl.GetMenusByMenuType(out _menuSql);
+ for (int i = 0; i < dtTable.Rows.Count; i++)
+ {
+ DataRow item = dtTable.Rows[i];
+ string menuCaption = item["MenuCaption"] + "";
+ ToolStripMenuItem menuItem = new ToolStripMenuItem();
+ menuItem.Text = menuCaption;
+ menuItem.Tag = item;
+ menuItem.Font = new Font("微软雅黑", 12);
+ menuItem.BackColor = Color.Transparent;
+ menuItem.ForeColor = Color.White;
+ menuItem.Click += new EventHandler(OnMenuTopItemClick);
+ menuMain.Items.Add(menuItem);
+ if (i == 0) _firstMenuItem = menuItem;
+ }
+ }
+ else
+ {
+ _allMenus = MainImpl.GetMenusByMenuType(out _menuSql);
+ if (Business.Impl.LanguageTranslation.Translatable)
+ {
+ _allMenus = Business.Impl.LanguageTranslation.InitialTableTranslation(_allMenus);
+ }
+ foreach (DataRow item in subSystems.Rows)
+ {
+ string subSysName = item["SubSysName"] + "";
+ string subSysId = item["SubSysId"] + "";
+ string useed = item["useed"] + "";
+ if (!"True".Equals(useed)) continue; // 禁用的系统不显示
+ bool hasMenu = false; // 是否包含模块,不包含不显示
+ ToolStripMenuItem menuItem = new ToolStripMenuItem();
+ menuItem.Text = subSysName;
+ menuItem.Tag = subSysId;
+ menuItem.Font = new Font("微软雅黑", 12);
+
+ //子目录长度超过界面,把之后的子目录存入 更多 中
+ if (isMore)
+ {
+ menuItem.Click += MenuItem_Click;
+ more.DropDownItems.Add(menuItem);
+ _subItemMenu.ImportRow(item);
+ continue;
+ }
+
+ menuItem.BackColor = Color.Transparent;
+ menuItem.ForeColor = Color.White;
+ menuItem.DropDownClosed += new EventHandler(OnMenuItemDropDownClosed);
+ menuItem.DropDownOpened += new EventHandler(OnMenuItemDropDownOpened);
+
+ if (SystemInfo.Instance.DefaultMainTag == 3)
+ {
+ menuItem.Click += OnMenuItemDoubleClick;
+ menuMain.Items.Add(menuItem);
+ //获取有权限的系统
+ _subItemMenu.ImportRow(item);
+ //把当前子目录加上后,子目录没有全部加完并且上方剩余宽度小于50,就添加 更多 选项。
+ if (subSystems.Rows.Count - menuMain.Items.Count > 0 && menuMain.Width > pl_top_center.Width - 50)
+ {
+ menuMain.Items.Remove(menuItem);
+ if (!isMore)
+ {
+ more = new ToolStripMenuItem();
+ more.Text = Business.Impl.LanguageTranslation.Translatable ? Business.Impl.LanguageTranslation.GetTranslatedText("更多") : "更多";
+ more.Font = new Font("微软雅黑", 12);
+ more.BackColor = Color.Transparent;
+ more.ForeColor = Color.White;
+ more.DropDownClosed += new EventHandler(OnMenuItemDropDownClosed);
+ more.DropDownOpened += new EventHandler(OnMenuItemDropDownOpened);
+ menuMain.Items.Add(more);
+ isMore = true;
+ }
+ ToolStripMenuItem Item = new ToolStripMenuItem();
+ Item.Text = subSysName;
+ Item.Tag = subSysId;
+ Item.Font = new Font("微软雅黑", 12);
+ Item.Click += MenuItem_Click;
+ more.DropDownItems.Add(Item);
+ }
+ continue;
+ }
+ if (SystemInfo.Instance.DefaultMainTag == 4)
+ {
+ menuItem.Click += OnMenuItemDoubleClick;
+ }
+
+ DataTable subTable = new DataTable();
+ try
+ {
+ subTable = _allMenus.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)
+ {
+ string menuStruct = row["MenuStruct"] + "";
+ string menuCaption = row["MenuCaption"] + "";
+ ToolStripMenuItem subItem = new ToolStripMenuItem(menuCaption);
+ subItem.Font = new Font("微软雅黑", 10);
+ if (!string.IsNullOrEmpty(SystemInfo.Instance.SplitBar) && menuCaption.StartsWith(SystemInfo.Instance.SplitBar)) subItem.Enabled = false;
+ // 功能模块
+ try
+ {
+ DataTable childs = new DataTable();
+ try
+ {
+ childs = _allMenus.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)
+ {
+ hasMenu = true;
+ foreach (DataRow child in childs.Rows)
+ {
+ 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 + "", child["MenuCaption"] + "" };
+ if (!(!string.IsNullOrEmpty(SystemInfo.Instance.SplitBar) && childItem.Text.StartsWith(SystemInfo.Instance.SplitBar)))
+ {
+ childItem.Click += OnItemClick; ;
+ }
+ else
+ {
+ childItem.Enabled = false;
+ }
+
+ subItem.DropDownItems.Add(childItem);
+ }
+ menuItem.DropDownItems.Add(subItem);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageUtil.Show(ex);
+ }
+ }
+ if (hasMenu)
+ {
+ menuMain.Items.Add(menuItem);
+ //获取有权限的系统
+ _subItemMenu.ImportRow(item);
+ //把当前子目录加上后,子目录没有全部加完并且上方剩余宽度小于50,就添加 更多 选项。
+ if (subSystems.Rows.Count - menuMain.Items.Count > 0 && menuMain.Width > pl_top_center.Width - 50)
+ {
+ menuMain.Items.Remove(menuItem);
+ if (!isMore)
+ {
+ more = new ToolStripMenuItem();
+ more.Text = Business.Impl.LanguageTranslation.Translatable ? Business.Impl.LanguageTranslation.GetTranslatedText("更多") : "更多";
+ more.Font = new Font("微软雅黑", 12);
+ more.BackColor = Color.Transparent;
+ more.ForeColor = Color.White;
+ more.DropDownClosed += new EventHandler(OnMenuItemDropDownClosed);
+ more.DropDownOpened += new EventHandler(OnMenuItemDropDownOpened);
+ menuMain.Items.Add(more);
+ isMore = true;
+ }
+ ToolStripMenuItem Item = new ToolStripMenuItem();
+ Item.Text = subSysName;
+ Item.Tag = subSysId;
+ Item.Font = new Font("微软雅黑", 12);
+ Item.Click += MenuItem_Click;
+ more.DropDownItems.Add(Item);
+ }
+ }
+ }
+
+ }
+
+ }
+ }
+
+
+
+ ///
+ /// 说明:加载默认模块
+ /// 创建人:龚宇超
+ /// 创建日期:2018-03-22
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetDefaultMenu()
+ {
+ // 加载默认模块
+ //DataRow rowItem = this._allMenus.Rows.OfType().FirstOrDefault(x => SystemInfo.Instance.HeadMenuId == x["menuid"] + "");
+ if (string.IsNullOrWhiteSpace(SystemInfo.Instance.HeadMenuId)) return;
+ string[] headMenuIds = SystemInfo.Instance.HeadMenuId.Split(',');
+ int i = 0;
+ this.lblMenuTitle.Visible = false;
+ this.lblMenuTitle2.Visible = false;
+ foreach (string item in headMenuIds)
+ {
+
+ DataRow rowItem = MainImpl.GetDataRowResult(string.Format("select * from p_formmenuconfigtab where menuid='{0}'", item));
+ if (rowItem != null)
+ {
+ if (i == 0)
+ {
+ DataRow DefaultModule = rowItem;
+ this.lblMenuTitle.Text = rowItem["menucaption"] + "";
+ this.lblMenuTitle.Tag = new string[] { rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["MenuId"] + "", rowItem["UrlParams"] + "", rowItem["SubSysId"] + "", rowItem["menucaption"] + "" };
+ this.lblMenuTitle.Visible = true;
+
+ DefaultModules.Add(DefaultModule);
+
+ CornerLab cornerLab = new CornerLab();
+ cornerLab.Location = new Point(this.lblMenuTitle.Left + this.lblMenuTitle.Width - 5, this.lblMenuTitle.Top - 8);
+ cornerLab.Height = 20;
+ cornerLab.Width = 20;
+ cornerLab.LabelNum.Location = new Point(2, 4);
+
+ cornerLab.Visible = false;
+ this.pl_top_right.Controls.Add(cornerLab);
+ cornerLab.BringToFront();
+
+ defaultModuleRoundedCornerss.Add(cornerLab);
+ i++;
+
+ }
+ else if (i == 1)
+ {
+
+ DataRow DefaultModule = rowItem;
+ this.lblMenuTitle2.Text = rowItem["menucaption"] + "";
+ this.lblMenuTitle2.Tag = new string[] { rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["MenuId"] + "", rowItem["UrlParams"] + "", rowItem["SubSysId"] + "", rowItem["menucaption"] + "" };
+ this.lblMenuTitle2.Visible = true;
+ this.lblMenuTitle2.Location = new Point(defaultModuleRoundedCornerss[0].Left + defaultModuleRoundedCornerss[0].Width + 5, this.lblMenuTitle.Top);
+
+ DefaultModules.Add(DefaultModule);
+
+ CornerLab cornerLab = new CornerLab();
+ cornerLab.Location = new Point(this.lblMenuTitle2.Left + this.lblMenuTitle2.Width - 5, this.lblMenuTitle2.Top - 8);
+ cornerLab.Height = 20;
+ cornerLab.Width = 20;
+ cornerLab.LabelNum.Location = new Point(2, 4);
+
+ cornerLab.Visible = false;
+ this.pl_top_right.Controls.Add(cornerLab);
+ cornerLab.BringToFront();
+ defaultModuleRoundedCornerss.Add(cornerLab);
+ i++;
+ }
+ }
+
+
+ }
+
+
+ }
+ ///
+ /// 说明:获取通知表数据
+ /// 创建人:龚宇超
+ /// 创建日期:2018-04-17
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The subsysid.
+ private void SetNotifys()
+ {
+ try
+ {
+ this.Invoke((EventHandler)delegate
+ {
+ if (this._menuItemList == null || this._menuItemList.Count == 0) return;
+ DataTable notifys = MainImpl.GetNotifys(ERPInfo.Instance.SubSysId, ERPInfo.Instance.UserId);
+ DataTable ShortcutDt = MainImpl.GetGallerysByUserIdAndReviewAmount();
+ foreach (UserControl menuControl in _menuItemList)
+ {
+ if (menuControl is Menu_Item menu_Item)
+ {
+ menu_Item.SetMenuNum(0);
+ }
+ else if (menuControl is Menu_ItemNew menu_ItemNew)
+ {
+ menu_ItemNew.SetMenuNum(0);
+ }
+ }
+ //快捷栏
+ if (ShortcutDt != null)
+ {
+ foreach (string key in _quickPageHeaders.Keys)
+ {
+ DataRow items = ShortcutDt.Rows.Cast().FirstOrDefault(x => x["DllShowCaption"].ToString() == key);
+ if (items != null)
+ {
+ string groupMenuId = items["LMenuId"] + "";
+ UserControl menuItem = this._menuItemList.Cast().FirstOrDefault(x => x.Name == groupMenuId);
+ Lskj.Control.CircleButton corLab = _quickPageHeaders[key];
+ corLab.Visible = true;
+ string number = items["amount"] + "";
+
+ if (ShortcutDt.Columns.Contains("countsql") && !string.IsNullOrWhiteSpace(items["countsql"] + ""))
+ {
+ string num = SqlHelper.ExecuteScalar(ReplaceHelper.ReplaceUserInfo(items["countsql"] + "")) + "";
+ number = IsNumberic(num) ? num : "0";
+ }
+ if (string.IsNullOrWhiteSpace(number))
+ {
+ corLab.Visible = false;
+ }
+ else
+ {
+ corLab.SetMenuNum(int.Parse(number));
+ if (menuItem != null)
+ {
+ if (menuItem is Menu_Item menu_Item)
+ {
+ menu_Item.SetMenuNum(int.Parse(number));
+ }
+ else if (menuItem is Menu_ItemNew menu_ItemNew)
+ {
+ menu_ItemNew.SetMenuNum(int.Parse(number));
+ }
+ }
+ }
+ }
+ }
+ }
+ //前登录用户对应子系统
+ foreach (DataRow item in notifys.Rows)
+ {
+ string menuId = item["menuid"] + "";
+ string moduleId = item["moduleid"] + "";
+ string num = item["num"] + ""; // 显示数量
+
+ if (string.IsNullOrWhiteSpace(menuId) && string.IsNullOrWhiteSpace(moduleId)) continue;
+
+ UserControl menuItem = null;
+ // 存在menuid则按照menuid来匹配数据,否则按照moduleid来匹配数据
+ if (!string.IsNullOrWhiteSpace(menuId))
+ {
+ menuItem = this._menuItemList.Cast().FirstOrDefault(x => x.Name == menuId);
+ }
+ else
+ {
+ try
+ {
+ menuItem = this._menuItemList.Cast().FirstOrDefault(x => ((x is Menu_Item menu_Item && (menu_Item.GetButton().Tag as string[])[1] == moduleId) || ((x is Menu_ItemNew menu_ItemNew && (menu_ItemNew.GetButton().Tag as string[])[1] == moduleId))));
+ }
+ catch (Exception ex)
+ {
+ MessageUtil.Show(ex);
+ }
+ }
+ int markNum = 0;
+ if (menuItem != null && int.TryParse(num, out markNum))
+ {
+ if (menuItem is Menu_Item menu_Item)
+ {
+ menu_Item.SetMenuNum(markNum);
+ }
+ else if (menuItem is Menu_ItemNew menu_ItemNew)
+ {
+ menu_ItemNew.SetMenuNum(markNum);
+ }
+ }
+ }
+ //设置了数量sql的模块
+ foreach (string key in countSqls.Keys)
+ {
+ UserControl menuItem = this._menuItemList.Cast().FirstOrDefault(x => x.Name == key);
+ //DataRow dr = MainImpl.GetModuleDisplayQuantity(ReplaceHelper.ReplaceUserInfo(countSqls[key]));
+ //string num = dr["value"] + "";
+ string num = SqlHelper.ExecuteScalar(ReplaceHelper.ReplaceUserInfo(countSqls[key])) + "";
+ if (IsNumberic(num))
+ {
+ if (menuItem is Menu_Item menu_Item)
+ {
+ menu_Item.SetMenuNum(int.Parse(num));
+ }
+ else if (menuItem is Menu_ItemNew menu_ItemNew)
+ {
+ menu_ItemNew.SetMenuNum(int.Parse(num));
+ }
+ }
+ }
+ //默认模块,右上角
+ if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.HeadMenuId))
+ {
+ int index = 0;
+ foreach (DataRow DefaultModule in DefaultModules)
+ {
+ if (DefaultModule == null) return;
+ string countSql = string.Empty;
+ string number = string.Empty;
+ if (DefaultModule.Table.Columns.Contains("PurviewId"))
+ {
+ string DllCoid = DefaultModule["PurviewId"] + "";
+ DataRow modelRow = MainImpl.GetSystemdllTab(DllCoid);
+ countSql = modelRow != null && modelRow.Table.Columns.Contains("countSql") ? modelRow["countSql"] + "" : "";
+ }
+ if (!string.IsNullOrWhiteSpace(countSql))
+ {
+ //DataRow dr = MainImpl.GetModuleDisplayQuantity(ReplaceHelper.ReplaceUserInfo(countSql));
+ //number = dr["value"] + "";
+ string num = SqlHelper.ExecuteScalar(ReplaceHelper.ReplaceUserInfo(countSql)) + "";
+ if (IsNumberic(num))
+ {
+ number = num;
+ }
+ }
+ else
+ {
+ number = MainImpl.GetModuleDisplayQuantityDefault(DefaultModule["MenuId"] + "", ERPInfo.Instance.UserId);
+ }
+ defaultModuleRoundedCornerss[index].SetMenuNum_special(!string.IsNullOrWhiteSpace(number) && !number.Equals("0") ? int.Parse(number) : 0);
+ defaultModuleRoundedCornerss[index].Visible = !string.IsNullOrWhiteSpace(number) && !number.Equals("0") ? true : false;
+ index++;
+ }
+
+ }
+
+ });
+ }
+ catch (Exception)
+ {
+ //throw;
+ }
+ }
+ ///
+ /// 解析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)
+ {
+
+ }
+ }
+ ///
+ /// 说明:设置我的桌面
+ /// 创建人:龚宇超
+ /// 创建日期:
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void SetDesktop()
+ {
+ if (!string.IsNullOrEmpty(SystemInfo.Instance.DesktopUrl))
+ {
+ this.xtpDesktop.PageVisible = true;
+ this.webBrowser.FrmLoad(ReplaceHelper.ReplaceUserInfo(SystemInfo.Instance.DesktopUrl));
+ //我的桌面特殊展示模式
+ if (SystemInfo.Instance.DesktopFormat)
+ {
+ this.xtpDesktop.Controls.Clear();
+ splitMainControl.Panel1.Controls.Add(this.webBrowser);
+ this.webBrowser.Hide();
+ this.webBrowser.SendToBack();//放到底层
+ }
+
+
+ }
+ else
+ {
+ this.xtpDesktop.PageVisible = false;
+ }
+ }
+
+ ///
+ /// 初始化系统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)
+ {
+ }
+ }
+ #endregion
+
+ #region 顶部菜单相关
+
+
+ ///
+ /// 点击上方子系统,切换系统
+ ///
+ ///
+ ///
+ private void OnMenuItemDoubleClick(object sender, EventArgs e)
+ {
+ try
+ {
+ if (sender != null)
+ {
+ DateTime now = DateTime.Now;
+ TimeSpan timeSinceLastClick = now - lastClickTime;
+ if (timeSinceLastClick.TotalMilliseconds < 500)
+ {
+ this.tabMain.SelectedTabPageIndex = 0;
+ ToolStripMenuItem Item = sender as ToolStripMenuItem;
+ if (ERPInfo.Instance.SubSysId == Item.Tag + "") return;
+ ERPInfo.Instance.SubSysName = Item.Text;
+ ERPInfo.Instance.SubSysId = Item.Tag as string;
+ //Manager.ReStartMain(true);
+ this.pl_center_left.Controls.Clear();
+ this.countSqls.Clear();
+ if (isFlowLayout)
+ {
+ pl_center_main_middle_FlowLayout.Controls.Clear();
+ }
+ else
+ {
+ allMenuPanel.Controls.Clear();
+ }
+ this._menus.Clear();
+ this._menuItemList.Clear();
+ this._groupItems.Clear();
+ this.topLayoutPanelDic.Clear();
+ this.botLayoutPanelDic.Clear();
+ this.SetMenus();
+ this.lblSubTitle.Text = (!string.IsNullOrEmpty(ERPInfo.Instance.SubSysName) && SystemInfo.Instance.ShowSubSysName) ? SystemInfo.Instance.ClientName + "-" + ERPInfo.Instance.SubSysName : SystemInfo.Instance.ClientName;
+ OnLayoutSizeChanged();
+ }
+ lastClickTime = now;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+
+ ///
+ /// 存入更多中的子目录,点击切换
+ ///
+ ///
+ ///
+ private void MenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (sender != null)
+ {
+
+
+ this.tabMain.SelectedTabPageIndex = 0;
+ ToolStripMenuItem Item = sender as ToolStripMenuItem;
+ if (ERPInfo.Instance.SubSysId == Item.Tag + "") return;
+ ERPInfo.Instance.SubSysName = Item.Text;
+ ERPInfo.Instance.SubSysId = Item.Tag as string;
+ //Manager.ReStartMain(true);
+ this.pl_center_left.Controls.Clear();
+ this.countSqls.Clear();
+ if (isFlowLayout)
+ {
+ pl_center_main_middle_FlowLayout.Controls.Clear();
+ }
+ else
+ {
+ allMenuPanel.Controls.Clear();
+ }
+ this._menus.Clear();
+ this._menuItemList.Clear();
+ this._groupItems.Clear();
+ this.topLayoutPanelDic.Clear();
+ this.botLayoutPanelDic.Clear();
+ this.SetMenus();
+ this.lblSubTitle.Text = (!string.IsNullOrEmpty(ERPInfo.Instance.SubSysName) && SystemInfo.Instance.ShowSubSysName) ? SystemInfo.Instance.ClientName + "-" + ERPInfo.Instance.SubSysName : SystemInfo.Instance.ClientName;
+ OnLayoutSizeChanged();
+
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+
+ ///
+ /// 说明:菜单展开后
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnMenuItemDropDownOpened(object sender, EventArgs e)
+ {
+ try
+ {
+ ToolStripMenuItem menuItem = (sender as ToolStripMenuItem);
+ if (menuItem != null)
+ {
+ menuItem.ForeColor = Color.Black;
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:菜单关闭后
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnMenuItemDropDownClosed(object sender, EventArgs e)
+ {
+ try
+ {
+ ToolStripMenuItem menuItem = (sender as ToolStripMenuItem);
+ if (menuItem != null)
+ {
+ menuItem.ForeColor = Color.White;
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:顶部菜单打开模块
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnItemClick(object sender, EventArgs e)
+ {
+ try
+ {
+ ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
+ string[] arr = (string[])menuItem.Tag;
+
+ Manager.TabMain = this.tabMain;
+ Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
+ Manager.OpenModule(arr[2], arr[5], arr[0], arr[1], arr[3]);
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ #endregion
+
+ #region 快捷通道相关
+ ///
+ /// 说明:快捷通道功能鼠标离开时
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ public void OnLabelMouseLeave(object sender, EventArgs e)
+ {
+ try
+ {
+ Label label = sender as Label;
+ label.Font = new Font("微软雅黑", label.Font.SizeInPoints);
+ label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
+ this.Cursor = Cursors.Default;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:快速通道鼠标移动时
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ public void OnLabelMouseMove(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ Label label = sender as Label;
+ label.Font = new Font("微软雅黑", label.Font.SizeInPoints, FontStyle.Bold | FontStyle.Underline);
+ label.ForeColor = ColorTranslator.FromHtml("#1ba109");
+ this.Cursor = Cursors.Hand;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:快捷通道打开模块
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ public void OnLabelMouseClick(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ Label label = sender as Label;
+ DataRow item = label.Tag as DataRow;
+ if (item != null)
+ {
+ Manager.TabMain = this.tabMain;
+ Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
+ if (!item.Table.Columns.Contains("menuposition"))
+ {
+ //2024-05-16 优先使用P_FormMenuConfigTab中的DllFileName为dll名(设置了快捷通道模块后,在工具里改dll名,无法同步改到快捷通道)
+ string dllName = item.Table.Columns.Contains("DllFileName") && !string.IsNullOrWhiteSpace(item["DllFileName"] + "") ? item["DllFileName"] + "" : item["ObjDll"] + "";
+ Manager.OpenModule(item["LMenuId"] + "", item["DllShowCaption"] + "", dllName, item["LinkModeTag"] + "", item["PurviewId"] + "");
+ }
+ else
+ {
+ string[] menuTag = new string[] { item["DllFileName"] + "", item["PurviewId"] + "", item["MenuId"] + "", item["UrlParams"] + "", "", item["menucaption"] + "" };
+ Manager.OpenModule(menuTag[2], menuTag[5], menuTag[0], menuTag[1], menuTag[3]);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ #endregion
+
+ #region 功能菜单相关
+
+ ///
+ /// 说明:切换模块
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-16
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The before.
+ /// The after.
+ public void OnTriggerMenu(Button before, Button after)
+ {
+ try
+ {
+ if (before != null)
+ {
+ DataRow item_before = before.Tag != null ? before.Tag as DataRow : null;
+ DataRow item_after = after.Tag != null ? after.Tag as DataRow : null;
+ if (item_before != null)
+ {
+ List beforeButtons = new List();
+ List afterButtons = new List();
+ if (isFlowLayout)
+ {
+ pl_center_main_middle_FlowLayout.Hide();
+ }
+ else
+ {
+ //this.pl_center_main_middle.Hide();
+ }
+ if (before.Parent != null && before.Parent is MenuBar)
+ {
+ (before.Parent as MenuBar).isSelect = false;
+ }
+ // 隐藏控件
+ if (_menus.TryGetValue(item_before["menustruct"] + "", out beforeButtons))
+ {
+ if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout)
+ {
+ allMenuPanel.Controls.Clear();
+ }
+ else
+ {
+ foreach (UserControl item in beforeButtons)
+ {
+ item.Visible = false;
+ }
+ }
+ if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu) && !SystemInfo.Instance.HideGallerys)
+ {
+ this.pl_center_main_bottom_right_main.Controls.Clear();
+ this.pl_center_main_bottom_left_main.Controls.Clear();
+ }
+ }
+ if (after.Parent != null && after.Parent is MenuBar)
+ {
+ (after.Parent as MenuBar).isSelect = true;
+ }
+ // 显示控件
+ if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout)
+ {
+ if (this._groupItems.ContainsKey(item_after["menustruct"] + ""))
+ {
+ Panel groupPanel = this._groupItems[item_after["menustruct"] + ""];
+ groupPanel.Visible = true;
+ allMenuPanel.Controls.Add(groupPanel);
+ }
+ }
+ else
+ {
+ if (_menus.TryGetValue(item_after["menustruct"] + "", out afterButtons))
+ {
+ foreach (UserControl item in afterButtons)
+ {
+ item.Visible = true;
+ }
+ }
+ }
+ if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu) && !SystemInfo.Instance.HideGallerys)
+ {
+ if (this.topLayoutPanelDic.ContainsKey(item_after["menustruct"] + ""))
+ {
+ TableLayoutPanel tableLayoutPanel = this.topLayoutPanelDic[item_after["menustruct"] + ""];
+ this.pl_center_main_bottom_right_main.Controls.Add(tableLayoutPanel);
+ string labelCaption = tableLayoutPanel.Tag + "";
+ this.lblShortcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblShortcutset.Tag + "";
+ }
+ if (this.botLayoutPanelDic.ContainsKey(item_after["menustruct"] + ""))
+ {
+ TableLayoutPanel tableLayoutPanel = this.botLayoutPanelDic[item_after["menustruct"] + ""];
+ this.pl_center_main_bottom_left_main.Controls.Add(tableLayoutPanel);
+ string labelCaption = tableLayoutPanel.Tag + "";
+ this.lblReportcutset.Text = !string.IsNullOrEmpty(labelCaption) ? string.Format(" {0}", labelCaption) : this.lblReportcutset.Tag + "";
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ finally
+ {
+ if (isFlowLayout)
+ {
+ pl_center_main_middle_FlowLayout.Show();
+ this.pl_center_main_middle_FlowLayout.Invalidate();
+ this.pl_center_main_middle_FlowLayout.Update();
+ }
+ else
+ {
+ this.pl_center_main_middle.Show();
+ this.pl_center_main_middle.Invalidate();
+ this.pl_center_main_middle.Update();
+ }
+ //我的桌面特殊展示,鼠标点击切换模块,当前页签为我的桌面
+ if (SystemInfo.Instance.DesktopFormat && this.tabMain.SelectedTabPage == this.xtpDesktop)
+ {
+ this.webBrowser.Hide();
+ this.webBrowser.SendToBack();//放到底层
+ this.tabMain.SelectedTabPage = this.xtpFirst;
+ }
+
+ }
+ }
+ ///
+ /// 功能图标打开模块
+ ///
+ ///
+ ///
+ public void OnMenuItemClick(object sender, EventArgs e)
+ {
+ try
+ {
+ pic_search.Focus();
+
+ /* 取 Tag */
+ string[] arr = (string[])((System.Windows.Forms.Control)sender).Tag;
+
+ Manager.TabMain = tabMain;
+ Manager.MinusTheHeight = pl_top_center.Height + toolStrip1.Height;
+ Manager.OpenModule(arr[2], arr[5], arr[0], arr[1], arr[3]);
+ }
+ catch (Exception ex)
+ {
+ string msg = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(msg, ex.Message);
+ }
+ }
+
+ ///
+ /// 快捷图标点击
+ ///
+ ///
+ ///
+ public void OnWorkMenuItemClick(object sender, EventArgs e)
+ {
+ try
+ {
+ if (!string.IsNullOrEmpty(SystemInfo.Instance.ShortCutDll))
+ {
+ DelphiHelper.LoadDelphiDll(SystemInfo.Instance.ShortCutDll);
+ }
+ else
+ {
+ DelphiHelper.LoadDelphiDll("P_Lsplanes.lsp");
+ }
+ }
+ catch (Exception)
+ {
+ MessageUtil.Show(ResourceKeys.OpenShortCutError);
+ }
+ finally
+ {
+ this.SetGallerys();
+ }
+ }
+ ///
+ /// 说明:打开模块
+ /// 创建人:龚宇超
+ /// 创建日期:2018-01-27
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnMenuTitleClick(object sender, EventArgs e)
+ {
+ try
+ {
+ Label item = (Label)sender;
+ string[] arr = (string[])item.Tag;
+
+ Manager.TabMain = this.tabMain;
+ Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
+ Manager.OpenModule(arr[2], arr[5], arr[0], arr[1], arr[3]);
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:左菜单树点击事件
+ /// 创建人:龚宇超
+ /// 创建日期:2018-04-25
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void OnMenuButtonClick(Button button)
+ {
+ try
+ {
+ if (this._lastMenuButton != button && tabMain.TabPages.Count > 2)
+ {
+ if (MessageUtil.Show(ResourceKeys.ChangeMenu, MessageBoxButtons.YesNo) == DialogResult.Yes)
+ {
+ int count = tabMain.TabPages.Count;
+ for (int i = count; i > 0; i--)
+ {
+ XtraTabPage item = tabMain.TabPages[i - 1];
+ string guid = item.Tag + "";
+ if (Manager.ModuleForms.ContainsKey(guid))
+ {
+ DllModule m = Manager.ModuleForms[guid];
+ tabMain.TabPages.Remove(item);
+ Manager.ModuleForms.Remove(m.Tag + "");
+ }
+ }
+ }
+ else
+ {
+ return;
+ }
+
+ }
+ this.lblSubTitle.Text = SystemInfo.Instance.ClientName + "-" + button.Text;
+ this.pl_top_left.Width = this.lblSubTitle.Width + 50;
+ this._lastMenuButton = button;
+ ERPInfo.Instance.GroupId = (_lastMenuButton.Tag as DataRow)["smid"] + "";
+ OnMenuTopItemClick(_firstMenuItem, null);
+
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:上菜单按钮点击事件
+ /// 创建人:龚宇超
+ /// 创建日期:2018-04-24
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void OnMenuTopItemClick(object sender, EventArgs e)
+ {
+ try
+ {
+ ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
+ if (menuItem == null || _lastMenuButton == null || _lastMenuItem == menuItem) return;
+ this._lastMenuItem = menuItem;
+ DataRow row = menuItem.Tag as DataRow;
+ DataTable dtChilds = MainImpl.GetChildsMenu(row["subsysid"] + "", row["MenuStruct"] + "", _purviewCond);
+ //位置设置
+ 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; // 内容区域宽度-右侧快捷栏宽度
+ //pl_center_main.Controls.Clear();
+ int centerWidth = pl_center_main_middle.Width; // 内容区域宽度
+
+ if (isFlowLayout)
+ {
+ pl_center_main_middle_FlowLayout.Controls.Clear();
+ }
+ else
+ {
+ allMenuPanel.Controls.Clear();
+ }
+
+ if (dtChilds != null && dtChilds.Rows.Count > 0)
+ {
+ foreach (DataRow item in dtChilds.Rows)
+ {
+ Application.DoEvents();// 处理当前消息队列中的所有windows消息
+
+ string defaultImg = PubUtil.MainMenuDefaultImage + item["MouseOutImg"] + "";
+ string hoverImg = PubUtil.MainMenuDefaultImage + item["MouseOverImg1"] + "";
+
+ Menu_ItemNew menu = new Menu_ItemNew();
+ menu.Name = item["menuid"] + "";
+ menu.Size = new Size(menuWidth, menuHeight);
+ menu.Location = new Point(menuLeft, menuTop);
+ menu.SetMenuCaption(item["menuCaption"] + "");
+ menu.SetSubCaption(item["SubSysName"] + "-" + item["menucaption"]);
+ menu.SetRoundRadius = 20;
+ menu.Tag = new string[] { item["DllFileName"] + "", item["PurviewId"] + "", item["MenuId"] + "", item["UrlParams"] + "", item["SubSysId"] + "", item["menucaption"] + "" };
+ menu.Click += OnMenuItemClick;
+ try
+ {
+ menu.SetMenuImg(Image.FromFile(defaultImg));
+ }
+ catch (Exception)
+ {
+ menu.SetMenuImg(Resources.default_icon);
+ }
+
+ // 116
+ menuLeft += Convert.ToInt32(2.92 * DpiX);
+ // 换行显示
+ if (menuLeft + menuWidth > centerWidth)
+ {
+ menuLeft = 5;
+ menuTop += menuHeight;
+ }
+
+ //pl_center_main.Controls.Add(menu);
+ if (isFlowLayout)
+ {
+ pl_center_main_middle_FlowLayout.Controls.Add(menu);
+ }
+ else
+ {
+ pl_center_main_middle.Controls.Add(menu);
+ }
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+
+ }
+ }
+ #endregion
+
+ #region 重置界面宽度高度
+ ///
+ /// 说明:计算快速通道宽度
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void ResetPanelWidth()
+ {
+ pl_center_main_bottom_left.Height = pl_center_main_bottom_right.Height = pl_center_main_right.Height / 2;
+ }
+ ///
+ /// 说明:重新计算菜单显示位置
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void ResetMenuLocation()
+ {
+ //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_ItemNew)
+ // {
+ // ctrs[0].Location = new Point(menuLeft, menuTop);
+
+ // menuLeft += 116;
+ // 换行显示
+ // if (menuLeft + menuWidth > centerWidth)
+ // {
+ // menuLeft = 5;
+ // menuTop += menuHeight;
+ // }
+ // }
+ // }
+ // }
+ //}
+ }
+
+ #endregion
+
+ #region 窗口拖动行为
+ ///
+ /// 说明:鼠标双击最大化、还原
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnTopMouseDoubleClick(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ if (SystemInfo.Instance.DisableFormalization) return;
+ if (OnTopPanelMouseDoubleClickCallBack != null)
+ {
+ OnTopPanelMouseDoubleClickCallBack(null, null);
+ btnMax.BackgroundImage = this.State == FormWindowState.Normal ? Resources.max_default : Resources.window_default;
+ this.ResetPanelWidth();
+ this.ResetMenuLocation();
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:鼠标按下
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnTopMouseDown(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ if (this.OnTopMouseDownCallback != null)
+ this.OnTopMouseDownCallback(sender, e);
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:鼠标放开
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnTopMouseUp(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ if (this.OnTopMouseUpCallBack != null)
+ this.OnTopMouseUpCallBack(sender, e);
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:鼠标移动
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnTopMouseMove(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ if (this.OnTopMouseMoveCallBack != null)
+ this.OnTopMouseMoveCallBack(sender, e);
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ #endregion
+
+ #region 最小化相关
+ ///
+ /// 说明:最小化按钮点击
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnMinClick(object sender, EventArgs e)
+ {
+ try
+ {
+ if (OnMinButtonCallBack != null)
+ {
+ OnMinButtonCallBack(null, null);
+ }
+ this.ResetPanelWidth();
+ this.ResetMenuLocation();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:最小化鼠标离开时
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnMinMouseLeave(object sender, EventArgs e)
+ {
+ try
+ {
+ btnMin.BackgroundImage = Resources.smail_default;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:最小化鼠标移动时
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnMinMouseMove(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ btnMin.BackgroundImage = Resources.smail_select;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ #endregion
+
+ #region 最大化相关
+ ///
+ /// 说明:最大化点击
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnMaxClick(object sender, EventArgs e)
+ {
+ try
+ {
+ if (OnMaxButtonCallBack != null)
+ {
+ OnMaxButtonCallBack(null, null);
+ btnMax.BackgroundImage = this.State == FormWindowState.Normal ? Resources.max_default : Resources.window_default;
+ this.ResetPanelWidth();
+ this.ResetMenuLocation();
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:最大化鼠标离开时
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnMaxMouseLeave(object sender, EventArgs e)
+ {
+ try
+ {
+ if (this.State == FormWindowState.Normal)
+ {
+ btnMax.BackgroundImage = Resources.max_default;
+ }
+ else
+ {
+ btnMax.BackgroundImage = Resources.window_default;
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:最大化鼠标移动时
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnMaxMouseMove(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ if (this.State == FormWindowState.Normal)
+ {
+ btnMax.BackgroundImage = Resources.max_select;
+ }
+ else
+ {
+ btnMax.BackgroundImage = Resources.window_select;
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ #endregion
+
+ #region 关闭相关
+ ///
+ /// 说明:关闭事件
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnCloseClick(object sender, EventArgs e)
+ {
+ try
+ {
+ if (ERPInfo.Instance.SubMenuCount == 1)
+ {
+ if (MessageUtil.Show(ResourceKeys.IsExit, MessageBoxButtons.YesNo) == DialogResult.Yes)
+ {
+ OnCloseButtonCallBack(null, null);
+ }
+ }
+ else
+ {
+ OnCloseButtonCallBack(null, null);
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:关闭按钮离开时
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnCloseMouseLeave(object sender, EventArgs e)
+ {
+ try
+ {
+ btnClose.BackgroundImage = Resources.close_default;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:关闭按钮移动时
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnBtnCloseMouseMove(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ btnClose.BackgroundImage = Resources.close_select;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:关闭tabpage窗口
+ /// 创建人:龚宇超
+ /// 创建日期:2017-09-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnTabMainClick(object sender, EventArgs e)
+ {
+ try
+ {
+ Point pt = MousePosition;
+ XtraTabHitInfo info = this.tabMain.CalcHitInfo(tabMain.PointToClient(pt));
+ if (info.HitTest == XtraTabHitTest.PageHeader && info.Page.TabIndex != 0)
+ {
+ XtraTabPage tabPage = this.tabMain.SelectedTabPage;
+ if (tabPage == this.xtpDesktop)
+ {
+ this.webBrowser.cefBrowserSettings.Reload();
+ return;
+ }
+ string guid = tabPage.Tag + "";
+ if (!string.IsNullOrWhiteSpace(guid))
+ {
+ DllModule m = Manager.ModuleForms[guid];
+ if (Manager.ModuleForms.ContainsKey(guid))
+ {
+ Form form = m.ModuleForm as Form;
+ if (form != null)
+ {
+ form.Close();
+ }
+ if (m.ModuleInPtr != null)
+ {
+ HandleHelper.SendMessage(m.ModuleInPtr, 0x0010, 0, 0);
+ }
+ if (m.ModuleProcess != null)
+ {
+ m.ModuleProcess.Kill();
+ }
+ bool isclose = true;
+ try
+ {
+ //BaseForm baseForm = form as BaseForm;
+ isclose = m.IsClose;
+ }
+ catch (Exception)
+ {
+ }
+ if (isclose)
+ {
+ if (this.PreviousTab != null) this.tabMain.SelectedTabPage = this.PreviousTab;
+ tabMain.TabPages.Remove(tabPage);
+ Manager.ModuleForms.Remove(m.Tag + "");
+ LogUtil.WriteDebug(m.Code, "关闭模块", m.Name, m.Name, m.Id);
+ }
+
+
+ //审核双击打开界面关闭后回到双击界面
+ XtraTabPage beforePage = m.BeforePage;
+ if (beforePage != null)
+ {
+ foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
+ {
+
+ if (tablepage == beforePage)
+ {
+ ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
+ if (isclose) tabPage.Dispose();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.Instance.WriteError(ex);
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 惨淡打开时
+ ///
+ ///
+ ///
+ private void HeadMenuStripOpening(object sender, CancelEventArgs e)
+ {
+ XtraTabHitInfo info = tabMain.CalcHitInfo(tabMain.PointToClient(MousePosition));
+ if (info.HitTest != XtraTabHitTest.PageHeader || info.Page == xtpFirst || info.Page == xtpDesktop || info.Page == xtpWorktop)
+ {
+ e.Cancel = true;
+ }
+ }
+ ///
+ /// 右键关闭页签
+ ///
+ ///
+ ///
+ private void RemoveItemClick(object sender, EventArgs e)
+ {
+ int selectIndex = tabMain.SelectedTabPageIndex;
+ ToolStripMenuItem stripMenuItem = (ToolStripMenuItem)sender;
+ ContextMenuStrip contextMenuStrip = (ContextMenuStrip)stripMenuItem.Owner;
+ Point pt = new Point(contextMenuStrip.Left, contextMenuStrip.Top);
+ XtraTabHitInfo info = this.tabMain.CalcHitInfo(tabMain.PointToClient(pt));
+ int infoPageIndex = this.tabMain.TabPages.IndexOf(info.Page);
+ if (info.HitTest == XtraTabHitTest.PageHeader && info.Page != xtpFirst && info.Page != xtpDesktop && info.Page != xtpWorktop)
+ {
+ ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
+ List removeList = new List();
+ if (menuItem.Text.Equals("关闭其他"))
+ {
+ foreach (XtraTabPage page in tabMain.TabPages)
+ {
+ if (page != xtpFirst && page != xtpDesktop && page != xtpWorktop && page != info.Page)
+ {
+ removeList.Add(page);
+ }
+ }
+ tabMain.SelectedTabPage = info.Page;
+ }
+ else if (menuItem.Text.Equals("关闭左侧"))
+ {
+ foreach (XtraTabPage page in tabMain.TabPages)
+ {
+ int pageIndex = tabMain.TabPages.IndexOf(page);
+ if (page != xtpFirst && page != xtpDesktop && page != xtpWorktop && page != info.Page && pageIndex < infoPageIndex)
+ {
+ removeList.Add(page);
+ }
+ }
+ if (selectIndex < infoPageIndex)
+ {
+ tabMain.SelectedTabPage = info.Page;
+ }
+ }
+ else if (menuItem.Text.Equals("关闭右侧"))
+ {
+ foreach (XtraTabPage page in tabMain.TabPages)
+ {
+ int pageIndex = tabMain.TabPages.IndexOf(page);
+ if (page != xtpFirst && page != xtpDesktop && page != xtpWorktop && page != info.Page && pageIndex > infoPageIndex)
+ {
+ removeList.Add(page);
+ }
+ }
+ if (selectIndex > infoPageIndex)
+ {
+ tabMain.SelectedTabPage = info.Page;
+ }
+ }
+ foreach (XtraTabPage page in removeList)
+ {
+ string guid = page.Tag + "";
+ if (!string.IsNullOrWhiteSpace(guid))
+ {
+ DllModule m = Manager.ModuleForms[guid];
+ if (Manager.ModuleForms.ContainsKey(guid))
+ {
+ Form form = m.ModuleForm as Form;
+ if (form != null) form.Close();
+
+ bool isclose = true;
+ try
+ {
+ //BaseForm baseForm = form as BaseForm;
+ isclose = m.IsClose;
+ }
+ catch (Exception)
+ {
+ }
+ if (isclose)
+ {
+ if (this.PreviousTab != null) this.tabMain.SelectedTabPage = this.PreviousTab;
+ tabMain.TabPages.Remove(page);
+ Manager.ModuleForms.Remove(m.Tag + "");
+ LogUtil.WriteDebug(m.Code, "关闭模块", m.Name, m.Name, m.Id);
+ }
+ }
+ }
+ }
+ }
+ }
+ #endregion
+
+ #region 用户相关
+ ///
+ /// 说明:切换用户
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnSwapUserClick(object sender, EventArgs e)
+ {
+ try
+ {
+ FrmSwap frmSwap = new FrmSwap();
+ frmSwap.ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:修改密码
+ /// 创建人:龚宇超
+ /// 创建日期:2017-08-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnUserNameClick(object sender, EventArgs e)
+ {
+ try
+ {
+ FrmUpdatePassword frmPass = new FrmUpdatePassword();
+ frmPass.ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ #endregion
+
+ #region 换肤
+ ///
+ /// 说明:打开换肤界面
+ /// 创建人:龚宇超
+ /// 创建日期:2017-09-13
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnSettingClick(object sender, EventArgs e)
+ {
+ try
+ {
+ this.Cursor = Cursors.Hand;
+ FrmSkins skins = new FrmSkins();
+ skins.ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:
+ /// 创建人:龚宇超
+ /// 创建日期:2017-09-13
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnSettingMouseLeave(object sender, EventArgs e)
+ {
+ try
+ {
+ this.Cursor = Cursors.Default;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ #endregion
+
+ #region 模块搜索
+ ///
+ /// 说明:打开界面
+ /// 创建人:龚宇超
+ /// 创建日期:2017-12-06
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnUserNamePopupClosed(object sender, EventArgs e)
+ {
+ try
+ {
+ this.OnOpenSearchModule();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:模块搜索
+ /// 创建人:龚宇超
+ /// 创建日期:2018-04-23
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnSearchClick(object sender, EventArgs e)
+ {
+ try
+ {
+ this.OnOpenSearchModule();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:打开搜索模块
+ /// 创建人:龚宇超
+ /// 创建日期:2018-04-23
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void OnOpenSearchModule()
+ {
+ try
+ {
+ string menuId = lueUserName.EditValue;
+
+ if (lueUserName._popup.GridViewObj.GetFocusedDataRow() == null)
+ {
+ menuId = "";
+ }
+
+ if (!string.IsNullOrEmpty(menuId))
+ {
+ DataRow[] rowItems = this._allMenus.Select("MenuId=" + menuId);
+ if (rowItems != null && rowItems.Length > 0)
+ {
+ DialogResult result = MessageUtil.Show(string.Format(ResourceKeys.OpenMenuConfirm, lueUserName.Text), MessageBoxButtons.YesNo);
+ if (result == DialogResult.Yes)
+ {
+ DataRow rowItem = rowItems[0];
+ Manager.TabMain = this.tabMain;
+ Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
+ Manager.OpenModule(menuId, rowItem["MenuCaption"] + "", rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["UrlParams"] + "");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ #endregion
+
+ #region 更新角标
+ ///
+ /// 说明:每隔5s取一次通知数据
+ /// 创建人:龚宇超
+ /// 创建日期:2018-04-17
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void OnMarkTimerTick(object sender, EventArgs e)
+ {
+ //SetNotifys();
+ }
+ #endregion
+
+ #region 子系统小窗口相关
+ ///
+ /// 说明:快捷窗口中子系统点击
+ /// 创建人:龚宇超
+ /// 创建日期:2018-08-03
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The sender.
+ /// The instance containing the event data.
+ private void OnSubItemClick(object sender, EventArgs e)
+ {
+ try
+ {
+ if (sender != null)
+ {
+ SimpleButton btnSubItem = sender as SimpleButton;
+ ERPInfo.Instance.SubSysName = btnSubItem.Text;
+ ERPInfo.Instance.SubSysId = btnSubItem.Tag as string;
+ // Manager.LastModuleForm.Clear();
+ Manager.ReStartMain(true);
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:快捷窗口中子系统点击
+ /// 创建人:龚宇超
+ /// 创建日期:2018-08-03
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The sender.
+ /// The instance containing the event data.
+ private void OnAccountsClick(object sender, EventArgs e)
+ {
+ try
+ {
+ string condition = string.Format("where ShowName ='{0}'", ERPInfo.Instance.AccountBook);
+ //获取套账表格
+ DataTable dt = MainImpl.GetLedgerList(condition);
+ string AccountBookOld = ERPInfo.Instance.AccountBook;
+
+ if (sender != null)
+ {
+ SimpleButton btnSubItem = sender as SimpleButton;
+ DataRow RT = btnSubItem.Tag as DataRow;
+ string serverIP = RT["IP"] + "";
+ string dbName = RT["DBName"] + "";
+ string dataBook = RT["ShowName"] + "";
+ bool isInternal = RT.Table.Columns.Contains("IsInternalNetwork") && !string.IsNullOrEmpty(RT["IsInternalNetwork"] + "") ? "1".Equals(RT["IsInternalNetwork"] + "") : false;
+
+ if (!ToLoginMatching(serverIP, dbName, dataBook, btnSubItem.Text, false, isInternal))
+ {
+ MessageUtil.Show("切换账套失败");
+ DataRow dr = dt.Rows[0];
+ isInternal = dr.Table.Columns.Contains("IsInternalNetwork") && !string.IsNullOrEmpty(dr["IsInternalNetwork"] + "") ? "1".Equals(dr["IsInternalNetwork"] + "") : false;
+
+ ToLoginMatching(dr["IP"] + "", dr["DBName"] + "", dr["ShowName"] + "", AccountBookOld, true, isInternal);
+ }
+
+
+ //DBConfig.Instance.DataBook = dataBook;
+ //DBConfig.Instance.ServerName = serverIP;
+ //DBConfig.Instance.DataBase = dbName;
+ //if (!DBConfig.Instance.CreateConnection())
+ //{
+ // MessageUtil.Show(ResourceKeys.ServerAddressFault);
+ // return;
+ //}
+ //else
+ //{
+ // if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection())) == 0)
+ // {
+ // MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
+ // return;
+ // }
+ // string skinName = MainImpl.GetUserSkin(ERPInfo.Instance.UserId);
+ // skinName = string.IsNullOrEmpty(skinName) ? ERPInfo.Instance.SkinName : skinName;
+ // UserLookAndFeel.Default.SetSkinStyle(skinName);
+ // ERPInfo.Instance.SkinName = skinName;
+ // ERPInfo.Instance.AccountBook = btnSubItem.Text;
+ // SystemInfo.RefreshSystemParam();
+ // DBConfig.Instance.WriteConfig();
+ // if (!SystemInfo.Instance.ForceUpdatePassword)
+ // {
+ // this.SetDelphiDllParams(); // 设置调用delphi参数
+ // //FormHelper.OverProcess("Lskj.FrmMessages");//切换账套关闭消息页签
+ // IniHelper.Write("isRefresh", "1");
+ // DataTable table = MainImpl.GetEmployeeList();//获取员工信息存到表中
+ // DataRow[] drRows = table.Select("UserName='" + ERPInfo.Instance.UserName + "' or UserCode='" + ERPInfo.Instance.UserId + "'");//找到所有UserNAme或UserCode为xxx的用户
+
+ // DataRow drRow = drRows[0];
+
+ // if (SystemInfo.Instance.SpecialSwitchingCover)
+ // {
+ // drRows = table.Select( "UserCode='" + ERPInfo.Instance.UserId + "'");//找到所有UserCode为xxx的用户
+ // drRow = drRows[0];
+ // }
+
+ // //DataRow drRow = table.Rows.Cast().FirstOrDefault(x => userName.Equals(x["UserName"] + ""));
+ // if (drRow != null)
+ // {
+
+ // if (SystemInfo.Instance.SpecialSwitchingCover)
+ // {
+ // int loginResult = MainImpl.Login(drRow["UserId"] + "", ERPInfo.Instance.InPassWord, true);
+ // switch (loginResult)
+ // {
+ // case 0: // 登录成功
+ // ERPInfo.Instance.UserId = drRow["UserId"] + "";
+ // ERPInfo.Instance.UserName = drRow["UserName"] + "";
+ // break;
+ // case 1: // 密码不正确
+ // MessageUtil.Show(ResourceKeys.NameOrPasswordError);
+ // return;
+ // break;
+ // case 2: // 已有此用户登录
+ // MessageUtil.Show(ResourceKeys.AlreadyLogin);
+ // return;
+ // break;
+ // case -1: // 登录失败
+ // default:
+ // MessageUtil.Show(ResourceKeys.LoginFault);
+ // return;
+ // break;
+ // }
+ // }
+ // else {
+ // ERPInfo.Instance.UserId = drRow["UserId"] + "";
+ // ERPInfo.Instance.UserName = drRow["UserName"] + "";
+ // }
+ // }
+
+ // Manager.ReStartMain(!SystemInfo.Instance.IsChangeZTReturnMainForm);
+ // }
+ //}
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+
+ ///
+ /// 说明:切换账号后重新登录
+ /// 创建人:龚宇超
+ /// 创建日期:2018-08-03
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// ip
+ /// 数据库名
+ /// 当前账套名
+ /// 登录帐套
+ /// 是否为重新登录初始账套
+ private bool ToLoginMatching(string serverIP, string dbName, string dataBook, string AccountBook, bool Reset, bool isInternal)
+ {
+ try
+ {
+ DBConfig.Instance.DataBook = dataBook;
+ DBConfig.Instance.ServerName = serverIP;
+ DBConfig.Instance.DataBase = dbName;
+ DBConfig.Instance.IsInternalNetwork = isInternal;
+ if (!DBConfig.Instance.CreateConnection(DBConfig.Instance.Connection))
+ {
+ MessageUtil.Show(ResourceKeys.ServerAddressFault);
+ return false;
+ }
+ else
+ {
+ if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection(DBConfig.Instance.dephiConnection))) == 0)
+ {
+ MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
+ return false;
+ }
+ string skinName = MainImpl.GetUserSkin(ERPInfo.Instance.UserId);
+ skinName = string.IsNullOrEmpty(skinName) ? ERPInfo.Instance.SkinName : skinName;
+ UserLookAndFeel.Default.SetSkinStyle(skinName);
+ ERPInfo.Instance.SkinName = skinName;
+ ERPInfo.Instance.AccountBook = AccountBook;
+ SystemInfo.RefreshSystemParam();
+ DBConfig.Instance.WriteConfig();
+
+ if (!SystemInfo.Instance.MainProhibitSwitchingAccount || Reset)
+ {
+ this.SetDelphiDllParams(); // 设置调用delphi参数
+ //FormHelper.OverProcess("Lskj.FrmMessages");//切换账套关闭消息页签
+ IniHelper.Write("isRefresh", "1");
+ DataTable table = MainImpl.GetEmployeeList();//获取员工信息存到表中
+ DataRow[] drRows = table.Select("UserName='" + ERPInfo.Instance.UserName + "' or UserCode='" + ERPInfo.Instance.LoginAccount + "'");//找到所有UserNAme或UserCode为xxx的用户
+
+ DataRow drRow = drRows.Count() == 0 ? null : drRows[0]; //drRows[0];
+
+ if (SystemInfo.Instance.SpecialSwitchingCover)
+ {
+ drRows = table.Select("UserCode='" + ERPInfo.Instance.LoginAccount + "'");//找到所有UserCode为xxx的用户
+
+ drRow = drRows.Count() == 0 ? null : drRows[0];
+ if (drRow != null)
+ {
+ string userId = drRow["UserID"] + "";
+ if (SystemInfo.Instance.IsEncrypt)
+ {
+ int[] keyHandles = ERPInfo.Instance.keyHandles = new int[8];
+ int[] keyNumber = ERPInfo.Instance.keyNumber = new int[8];
+ string appId = DBConfig.Instance.ServerName;
+ int frtn = SmartX1Api.SmartX1Find(appId, keyHandles, keyNumber);
+ int keyHandle = ERPInfo.Instance.keyHandles[0];
+ int uPin1 = Convert.ToInt32("0x987F6BCD", 16);
+ int uPin2 = Convert.ToInt32("0xE193C5B2", 16);
+ int uPin3 = Convert.ToInt32("0xD507CC28", 16);
+ int uPin4 = Convert.ToInt32("0x4B125AF6", 16);
+ int rtn = SmartX1Api.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4);
+ if (rtn == 0)
+ {
+ //string writeKey = string.Format("{0}_{1}", DBConfig.Instance.ServerName, DBConfig.Instance.DataBase);
+ //int length = 256;
+ //byte[] readBuffer = new byte[length];
+ //int readRtn = SmartX1Api.SmartX1ReadPage(keyHandle, 0, 0, ref length, readBuffer);
+ //if (readRtn == 0)
+ //{
+ // Dictionary readKeysValues = new Dictionary();
+ // string readVerifyStr = Encoding.Default.GetString(readBuffer);
+ // string[] readVerifyStrArray = readVerifyStr.Replace("\0", "").Split(';');//获取多个账套设置
+ // foreach (string readVerify in readVerifyStrArray)
+ // {
+ // string[] readKeyValue = readVerify.Split('^');//获取单个账套
+ // if (readKeyValue.Length == 2)
+ // {
+ // readKeysValues.Add(readKeyValue[0], readKeyValue[1]);
+ // }
+ // }
+ // if (readKeysValues.ContainsKey(writeKey))//如果存在当前账套
+ // {
+ // string[] verifyArray = readKeysValues[writeKey].Split('^');
+ // if (!verifyArray.Contains(userId))
+ // {
+ // MessageUtil.Show("当前人员未拥有登录权限");
+ // return false;
+ // }
+ // }
+ // else
+ // {
+ // MessageUtil.Show("当前人员未拥有登录权限");
+ // return false;
+ // }
+ //}
+ //else
+ //{
+ // MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
+ // return false;
+ //}
+ }
+ else
+ {
+ MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
+ return false;
+ }
+ }
+
+ int loginResult = MainImpl.Login(drRow["UserId"] + "", ERPInfo.Instance.InPassWord, true);
+ switch (loginResult)
+ {
+ case 0: // 登录成功
+ break;
+ case 1: // 密码不正确
+ MessageUtil.Show(ResourceKeys.NameOrPasswordError);
+ return false;
+ break;
+ case 2: // 已有此用户登录
+ MessageUtil.Show(ResourceKeys.AlreadyLogin);
+ return false;
+ break;
+ case -1: // 登录失败
+ default:
+ MessageUtil.Show(ResourceKeys.LoginFault);
+ return false;
+ break;
+ }
+ }
+
+ }
+
+ //DataRow drRow = table.Rows.Cast().FirstOrDefault(x => userName.Equals(x["UserName"] + ""));
+ if (drRow != null)
+ {
+ string userId = drRow["UserID"] + "";
+
+ if (!MainImpl.CheckingMacAddress(userId))
+ {
+ MessageUtil.Show(ResourceKeys.MacAddressError + ",当前地址:" + ERPInfo.Instance.MacAddress);
+ System.Windows.Forms.Clipboard.SetText(ERPInfo.Instance.MacAddress);
+ return false;
+ }
+ if (SystemInfo.Instance.IsEncrypt)
+ {
+ int[] keyHandles = ERPInfo.Instance.keyHandles = new int[8];
+ int[] keyNumber = ERPInfo.Instance.keyNumber = new int[8];
+ string appId = DBConfig.Instance.ServerName;
+ int frtn = SmartX1Api.SmartX1Find(appId, keyHandles, keyNumber);
+ int keyHandle = ERPInfo.Instance.keyHandles[0];
+ int uPin1 = Convert.ToInt32("0x987F6BCD", 16);
+ int uPin2 = Convert.ToInt32("0xE193C5B2", 16);
+ int uPin3 = Convert.ToInt32("0xD507CC28", 16);
+ int uPin4 = Convert.ToInt32("0x4B125AF6", 16);
+ int rtn = SmartX1Api.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4);
+ if (rtn == 0)
+ {
+ //string writeKey = string.Format("{0}_{1}", DBConfig.Instance.ServerName, DBConfig.Instance.DataBase);
+ //int length = 256;
+ //byte[] readBuffer = new byte[length];
+ //int readRtn = SmartX1Api.SmartX1ReadPage(keyHandle, 0, 0, ref length, readBuffer);
+ //if (readRtn == 0)
+ //{
+ // Dictionary readKeysValues = new Dictionary();
+ // string readVerifyStr = Encoding.Default.GetString(readBuffer);
+ // string[] readVerifyStrArray = readVerifyStr.Replace("\0", "").Split(';');//获取多个账套设置
+ // foreach (string readVerify in readVerifyStrArray)
+ // {
+ // string[] readKeyValue = readVerify.Split('^');//获取单个账套
+ // if (readKeyValue.Length == 2)
+ // {
+ // readKeysValues.Add(readKeyValue[0], readKeyValue[1]);
+ // }
+ // }
+ // if (readKeysValues.ContainsKey(writeKey))//如果存在当前账套
+ // {
+ // string[] verifyArray = readKeysValues[writeKey].Split('^');
+ // if (!verifyArray.Contains(userId))
+ // {
+ // MessageUtil.Show("当前人员未拥有登录权限");
+ // return false;
+ // }
+ // }
+ // else
+ // {
+ // MessageUtil.Show("当前人员未拥有登录权限");
+ // return false;
+ // }
+ //}
+ //else
+ //{
+ // MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
+ // return false;
+ //}
+ }
+ else
+ {
+ MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
+ return false;
+ }
+ }
+
+ ERPInfo.Instance.UserId = drRow["UserId"] + "";
+ ERPInfo.Instance.UserName = drRow["UserName"] + "";
+ }
+ else
+ {
+ MessageUtil.Show("目标账套没有当前人员");
+ return false;
+ }
+
+ Manager.ReStartMain(!SystemInfo.Instance.IsChangeZTReturnMainForm);
+ return true;
+ }
+ else
+ {
+
+ }
+ }
+ return false;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ return false;
+ }
+
+
+ }
+
+
+ ///
+ /// 说明:设置delphi参数
+ /// 创建人:龚宇超
+ /// 创建日期:2018-03-12
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ void SetDelphiDllParams()
+ {
+ try
+ {
+ StringBuilder sb1 = new StringBuilder();
+ sb1.Append(ERPInfo.Instance.UserName);
+
+ StringBuilder sb2 = new StringBuilder();
+ sb2.Append(ERPInfo.Instance.WindowName);
+
+ StringBuilder sb3 = new StringBuilder();
+ sb3.Append(ERPInfo.Instance.SkinName);
+
+ //给delphi库设置参数(用户id、子系统id、操作员名称、计算机名称)
+ DelphiHelper.Delphi_SetParams(Convert.ToInt32(ERPInfo.Instance.UserId), Convert.ToInt32(ERPInfo.Instance.SubSysId), sb1, sb2, sb3);
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ LogHelper.Instance.WriteError(ex);
+ }
+ }
+ ///
+ /// 说明:子系统面板弹出事件
+ /// 创建人:龚宇超
+ /// 创建日期:2018-08-02
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The sender.
+ /// The instance containing the event data.
+ private void OnTabMouseClick(object sender, MouseEventArgs e)
+ {
+
+ }
+ ///
+ /// 说明:子系统失去焦点
+ /// 创建人:龚宇超
+ /// 创建日期:2018-08-03
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The sender.
+ /// The instance containing the event data.
+ private void OnSubFormLostFocus(object sender, EventArgs e)
+ {
+ try
+ {
+ if (!_firstSubItemFocus)
+ {
+ _subItemForm.Hide();
+ _subItemForm._isFocus = false;
+ }
+ _firstSubItemFocus = false;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+
+ }
+ ///
+ /// 说明:切换账套失去焦点
+ /// 创建人:王一帆
+ /// 创建日期:2019-12-10
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The sender.
+ /// The instance containing the event data.
+ private void OnAccountLostFocus(object sender, EventArgs e)
+ {
+ try
+ {
+ if (!_firstAccountsFocus)
+ {
+ _accountsItemForm.Hide();
+ _accountsItemForm._isFocus = false;
+ }
+ _firstAccountsFocus = false;
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ #endregion
+
+ #region 快捷通道双击操作
+ ///
+ /// 说明:快捷通道双击操作
+ /// 创建人:龚宇超
+ /// 创建日期:2018-08-13
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ /// The sender.
+ /// The instance containing the event data.
+ private void OnShortCutDoubleClick(object sender, EventArgs e)
+ {
+ try
+ {
+ if (!string.IsNullOrEmpty(SystemInfo.Instance.ShortCutDll))
+ {
+ DelphiHelper.LoadDelphiDll(SystemInfo.Instance.ShortCutDll);
+ }
+ else
+ {
+ DelphiHelper.LoadDelphiDll("P_Lsplanes.lsp");
+ }
+ }
+ catch (Exception)
+ {
+ MessageUtil.Show(ResourceKeys.OpenShortCutError);
+ }
+ finally
+ {
+ this.SetGallerys();
+ this.OnLayoutSizeChanged();
+ }
+ }
+ ///
+ /// 选中切换套账
+ ///
+ ///
+ ///
+ private void label1_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (label1.Visible)
+ {
+ CalcPopupLocation();
+ _accountsItemForm.Show();
+ this.label1.Focus();
+ }
+ //if (!_accountsItemForm._isFocus)
+ //{
+ // _firstAccountsFocus = true;
+ // _accountsItemForm.Focus();
+ // _accountsItemForm._isFocus = true;
+ //}
+ //else
+ //{
+ // _accountsItemForm.Hide();
+ // _accountsItemForm._isFocus = false;
+ // _firstAccountsFocus = false;
+ //}
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 隐藏账套控件
+ ///
+ ///
+ ///
+ private void label1_LostFocus(object sender, EventArgs e)
+ {
+ try
+ {
+ _accountsItemForm.Hide();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ #endregion
+ #region 自检功能操作
+ ///
+ /// 说明:程序自检功能
+ /// 创建人:王一帆
+ /// 创建日期:2022-07-14
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ ///
+ ///
+ private void OnMouseClick(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ //if (laSelfTest.Visible)
+ //{
+
+ //}
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ #endregion
+ private void label2_MouseClick(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ if (label2.Visible)
+ {
+ _subItemForm.Location = this.plMain.PointToClient(MousePosition);
+ _subItemForm.Show();
+ this.label2.Focus();
+ }
+ //if (!_subItemForm._isFocus)
+ //{
+ // _subItemForm.Location = this.plMain.PointToClient(MousePosition);
+ // _subItemForm.Show();
+ // if (!_subItemForm._isFocus)
+ // {
+ // _firstSubItemFocus = true;
+ // _subItemForm.Focus();
+ // _subItemForm._isFocus = true;
+ // }
+ //}
+ //else
+ //{
+ // _subItemForm.Hide();
+ // _subItemForm._isFocus = false;
+ // _firstSubItemFocus = false;
+ //}
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ private void label2_LostFocus(object sender, EventArgs e)
+ {
+ try
+ {
+ _subItemForm.Hide();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ private void label3_MouseClick(object sender, MouseEventArgs e)
+ {
+ try
+ {
+ if (label3.Visible)
+ {
+ this.Controls.Add(_resSelectForm);
+ _resSelectForm.BringToFront();
+ _resSelectForm.Location = this.plMain.PointToClient(MousePosition);
+ _resSelectForm.Show();
+ this.label3.Focus();
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ private void label3_LostFocus(object sender, EventArgs e)
+ {
+ try
+ {
+ _resSelectForm.Hide();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// PageHead点击时
+ ///
+ ///
+ ///
+ private void OnPageHeadMouseDown(object sender, MouseEventArgs e)
+ {
+ mouseButtons = e.Button;
+ }
+ ///
+ /// 页签切换时判断
+ ///
+ ///
+ ///
+ private void OnSelectedPageChanging(object sender, TabPageChangingEventArgs e)
+ {
+ Point pt = MousePosition;
+ XtraTabHitInfo info = this.tabMain.CalcHitInfo(tabMain.PointToClient(pt));
+ if (info.HitTest == XtraTabHitTest.PageHeader)
+ {
+ if (mouseButtons == MouseButtons.Left)
+ {
+ e.Cancel = false;
+ }
+ else
+ {
+ e.Cancel = true;
+ }
+ }
+ }
+ ///
+ /// 页面刷新角标
+ ///
+ ///
+ ///
+ private void OnSelectedPageChanged(object sender, TabPageChangedEventArgs e)
+ {
+ try
+ {
+ XtraTabPage tabPage = this.tabMain.SelectedTabPage;
+ string guid = tabPage.Tag + "";
+ if (!string.IsNullOrWhiteSpace(guid) && Manager.ModuleForms.ContainsKey(guid))
+ {
+ DllModule m = Manager.ModuleForms[guid];
+ ERPInfo.Instance.selectFormModleId = m.Id;
+ }
+ if (tabPage.TabIndex == 0)
+ {
+ if (!SystemInfo.Instance.RefreshNotify)
+ {
+ Thread thread = new Thread(SetNotifys);
+ thread.IsBackground = true;
+ thread.Start();
+ }
+ }
+ //点击我的桌面时,在中间显示网页。选中功能导航时,隐藏网页
+ if (this.xtpDesktop.PageVisible && SystemInfo.Instance.DesktopFormat)
+ {
+ //选中功能导航
+ if (this.tabMain.SelectedTabPageIndex == 0)
+ {
+ this.xtpFirst.Controls.Clear();
+ this.xtpFirst.Controls.Add(this.FirstMain);
+ this.webBrowser.Hide();
+ this.webBrowser.SendToBack();
+ //左侧二级目录菜单恢复为配置模式
+ foreach (System.Windows.Forms.Control item in pl_center_left.Controls)
+ {
+ if (item != null && item is MenuBar)
+ {
+ MenuBar mb = item as MenuBar;
+ mb.ReleaseEvent();
+ mb.RebindEvent((MenuEventType)SystemInfo.Instance.MemuEventType);
+ }
+ }
+ if (SystemInfo.Instance.DesktopFormatShowGallerys)
+ {
+ this.splitMainControl.Panel2Collapsed = false;
+ if (this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout && isShowGrallyInTop)
+ {
+ this.splitMainControl.Panel2Collapsed = true;
+ }
+ else
+ {
+ this.splitMainControl.Panel2Collapsed = false;
+ }
+ }
+ }
+ //选中我的桌面
+ if (this.tabMain.SelectedTabPage == this.xtpDesktop)
+ {
+ this.PreviousTab = this.xtpDesktop;
+ tabPage.Controls.Clear();
+ tabPage.Controls.Add(this.FirstMain);
+ this.webBrowser.Show();
+ this.webBrowser.BringToFront();
+ //if (this.webBrowser.cefBrowserSettings != null) this.webBrowser.cefBrowserSettings.Reload();
+ int MemuEventType = 1;
+ //左侧二级目录菜单设置为单击切换模式
+ foreach (System.Windows.Forms.Control item in pl_center_left.Controls)
+ {
+ if (item != null && item is MenuBar)
+ {
+ MenuBar mb = item as MenuBar;
+ mb.ReleaseEvent();
+ mb.RebindEvent((MenuEventType)MemuEventType);
+ }
+ }
+ if (SystemInfo.Instance.HideGallerys)
+ {
+ this.splitMainControl.Panel2Collapsed = true;
+ }
+ }
+ if (this.tabMain.SelectedTabPage == this.xtpFirst)
+ {
+ this.PreviousTab = this.xtpFirst;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ ///
+ /// 说明:初始化分割条位置
+ /// 创建人:龚宇超
+ /// 创建日期:2017-01-24
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void InitializeSplitterPosition()
+ {
+ try
+ {
+ string splitterPosition = IniHelper.Read("MainPanelControlEx");
+ if (!string.IsNullOrEmpty(splitterPosition))
+ {
+ this.splitMainControl.SplitterDistance = Convert.ToInt32(splitterPosition);
+ }
+ else
+ {
+ this.splitMainControl.SplitterDistance = this.splitMainControl.Width / 11 * 10;
+ }
+ //string workSplitterPosition = IniHelper.Read("WorkMainPanelControlEx");
+ //if (!string.IsNullOrEmpty(workSplitterPosition))
+ //{
+ // this.workSplitMainControl.SplitterPosition = Convert.ToInt32(workSplitterPosition);
+ //}
+ }
+ catch (Exception e)
+ {
+ LogHelper.Instance.WriteError(e);
+ }
+ }
+ ///
+ /// 说明:并行分割条位置变化事件
+ /// 创建人:王一帆
+ /// 创建日期:2020-08-24
+ /// 修改人:
+ /// 修改日期:
+ /// 修改备注:
+ /// 版本:1.0
+ ///
+ private void OnSplitterPositionChanged(object sender, SplitterEventArgs e)
+ {
+ try
+ {
+ if (_isInitFinish)
+ {
+ IniHelper.Write("MainPanelControlEx", this.splitMainControl.SplitterDistance + "");
+ }
+ OnLayoutSizeChanged();
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ private void OnWorkSplitPositionChanged(object sender, EventArgs e)
+ {
+ try
+ {
+ //if (_isInitFinish)
+ //{
+ // IniHelper.Write("WorkMainPanelControlEx", this.workSplitMainControl.SplitterPosition + "");
+ //}
+ }
+ catch (Exception ex)
+ {
+ string Message = ErrorMessage.PromptErrorMessage(ex);
+ MessageUtil.Show(Message, ex.Message);
+ }
+ }
+ private void OnLayoutSizeChanged()
+ {
+ TableLayoutPanel topLayoutPanel = new TableLayoutPanel();
+ TableLayoutPanel bottomLayoutPanel = new TableLayoutPanel();
+ foreach (System.Windows.Forms.Control item in this.pl_center_main_bottom_right_main.Controls)
+ {
+ if (item is TableLayoutPanel)
+ {
+ topLayoutPanel = (TableLayoutPanel)item;
+ break;
+ }
+ }
+ foreach (System.Windows.Forms.Control item in this.pl_center_main_bottom_left_main.Controls)
+ {
+ if (item is TableLayoutPanel)
+ {
+ bottomLayoutPanel = (TableLayoutPanel)item;
+ break;
+ }
+ }
+ for (int i = 0; i < topLayoutPanel.RowCount - 1; i++)
+ {
+ try
+ {
+ SimpleControl simpleControl = (SimpleControl)topLayoutPanel.GetControlFromPosition(0, i);
+ if (simpleControl != null)
+ {
+ simpleControl.PicBox.Width = 16;
+ simpleControl.CornerLab.Width = 24;
+ simpleControl.Label.UseCompatibleTextRendering = true;
+ Graphics g = simpleControl.Label.CreateGraphics();
+ SizeF sizeF = g.MeasureString(simpleControl.Label.Text, simpleControl.Label.Font);
+ if (simpleControl.Label.Width < sizeF.Width)
+ {
+ simpleControl.IsNextLine = true;
+ }
+ else
+ {
+ simpleControl.IsNextLine = false;
+ }
+ topLayoutPanel.RowStyles[i].SizeType = SizeType.Absolute;
+ if (simpleControl.IsNextLine)
+ {
+ topLayoutPanel.RowStyles[i].Height = 50;
+ }
+ else
+ {
+ topLayoutPanel.RowStyles[i].Height = 25;
+ }
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+ for (int i = 0; i < bottomLayoutPanel.RowCount - 1; i++)
+ {
+ try
+ {
+ SimpleControl simpleControl = (SimpleControl)bottomLayoutPanel.GetControlFromPosition(0, i);
+ if (simpleControl != null)
+ {
+ simpleControl.PicBox.Width = 16;
+ simpleControl.CornerLab.Width = 24;
+ simpleControl.Label.UseCompatibleTextRendering = true;
+ Graphics g = simpleControl.Label.CreateGraphics();
+ SizeF sizeF = g.MeasureString(simpleControl.Label.Text, simpleControl.Label.Font);
+ if (simpleControl.Label.Width < sizeF.Width)
+ {
+ simpleControl.IsNextLine = true;
+ }
+ else
+ {
+ simpleControl.IsNextLine = false;
+ }
+ bottomLayoutPanel.RowStyles[i].SizeType = SizeType.Absolute;
+ if (simpleControl.IsNextLine)
+ {
+ bottomLayoutPanel.RowStyles[i].Height = 50;
+ }
+ else
+ {
+ bottomLayoutPanel.RowStyles[i].Height = 25;
+ }
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+ }
+ ///
+ /// 判断是不是数值
+ ///
+ ///
+ ///
+ private bool IsNumberic(string oText)
+ {
\ No newline at end of file
diff --git a/插件库/Lskj.Main/Control/ResSelectForm.cs b/插件库/Lskj.Main/Control/ResSelectForm.cs
index 83d7aa6..5d085ad 100644
--- a/插件库/Lskj.Main/Control/ResSelectForm.cs
+++ b/插件库/Lskj.Main/Control/ResSelectForm.cs
@@ -9,6 +9,7 @@ using System.Windows.Forms;
using Lskj.Control;
using Lskj.Business.Impl;
using Lskj.Util;
+using Lskj.Business;
namespace Lskj.Main.Control
{
@@ -58,24 +59,4 @@ namespace Lskj.Main.Control
MessageUtil.Show(Message, ex.Message);
}
}
- private void OnMouseClick(object sender, MouseEventArgs e)
- {
- try
- {
- DevExpress.XtraEditors.SimpleButton btn = (DevExpress.XtraEditors.SimpleButton)sender;
- this.Hide();
- if (MessageUtil.Show("更改分辨率将退回至主界面\r\n是否继续?", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- Lskj.Control.Model.AutoSizeChange.value = Convert.ToDouble(btn.Tag);
- IniHelper.Write(string.Format("DefaultControlScaling_{0}", "Save"), btn.Tag.ToString());
- _clickEvent(this, e);
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
- }
- }
-}
+ private voi
\ No newline at end of file
diff --git a/插件库/Lskj.Main/FrmConfig.cs b/插件库/Lskj.Main/FrmConfig.cs
index 95b5c2e..e303e1b 100644
--- a/插件库/Lskj.Main/FrmConfig.cs
+++ b/插件库/Lskj.Main/FrmConfig.cs
@@ -72,6 +72,7 @@ namespace Lskj.Main
if (DBConfig.Instance.IsInternalNetwork)
{
this.radioWithin.Checked = true;
+ if (DBConfig.Instance.ServerName.Equals(DBConfig.Instance.InternalNetworkAddress)) this.txtServerName.Text = DBConfig.Instance.ExternalNetworkAddress;
}
else
{
diff --git a/插件库/Lskj.Main/FrmLogin.Designer.cs b/插件库/Lskj.Main/FrmLogin.Designer.cs
index 1586880..c4f89b3 100644
--- a/插件库/Lskj.Main/FrmLogin.Designer.cs
+++ b/插件库/Lskj.Main/FrmLogin.Designer.cs
@@ -28,7 +28,6 @@
///
private void InitializeComponent()
{
- this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmLogin));
this.lblCopyright = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
@@ -48,7 +47,7 @@
this.upDateTimeLab = new System.Windows.Forms.Label();
this.language = new DevExpress.XtraEditors.ComboBoxEdit();
this.forgetPwd = new DevExpress.XtraEditors.PictureEdit();
- this.toolTip = new System.Windows.Forms.ToolTip(this.components);
+ this.toolTip = new System.Windows.Forms.ToolTip();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.chkUpdate.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.chkClient.Properties)).BeginInit();
@@ -294,6 +293,7 @@
this.forgetPwd.Size = new System.Drawing.Size(21, 21);
this.forgetPwd.TabIndex = 51;
this.toolTip.SetToolTip(this.forgetPwd, "忘记密码");
+ this.forgetPwd.Visible = false;
this.forgetPwd.Click += new System.EventHandler(this.OnForgetPwdClick);
//
// toolTip
@@ -306,8 +306,7 @@
//
// FrmLogin
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackgroundImage = global::Lskj.Main.Properties.Resources.newlogin;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(664, 451);
diff --git a/插件库/Lskj.Main/FrmLogin.cs b/插件库/Lskj.Main/FrmLogin.cs
index 034e188..fa3d6a1 100644
--- a/插件库/Lskj.Main/FrmLogin.cs
+++ b/插件库/Lskj.Main/FrmLogin.cs
@@ -444,7 +444,7 @@ namespace Lskj.Main
string userName = lueUserName.Text.Trim();
string password = txtPassword.Text.Trim();
string LoginAccount = string.Empty;
- string ErrorLogText= string.Empty;//日志记录信息
+ string ErrorLogText = string.Empty;//日志记录信息
// 设置登录用户信息
bool isConstraint = chkLogin.Checked;
if (string.IsNullOrWhiteSpace(userName))
@@ -678,7 +678,11 @@ namespace Lskj.Main
ERPInfo.Instance.LanguageName = this.language.Text;
LanguageTranslation.GetLanguageComparisonTable();//获取翻译表数据
- if (!string.IsNullOrWhiteSpace(ERPInfo.Instance.LanguageName)&& !ERPInfo.Instance.LanguageName.Equals("中文"))Localizer.Active = new XtraLocalizer();
+ if (!string.IsNullOrWhiteSpace(ERPInfo.Instance.LanguageName) && !ERPInfo.Instance.LanguageName.Equals("中文"))
+ {
+ Localizer.Active = new XtraLocalizer();
+ DevExpress.XtraGrid.Localization.GridLocalizer.Active = new XtraGridLocalizer();
+ }
this.SetDelphiDllParams(); // 设置调用delphi参数
@@ -694,6 +698,9 @@ namespace Lskj.Main
DialogResult result = frmPassword.ShowDialog();
isStartMain = result == DialogResult.OK;
}
+ //清空临时文件
+ PubUtil.ClearFilesInDirectory(PubUtil.ImageDownloadPath);
+
if (isStartMain)
{
// 检查自动升级
diff --git a/插件库/Lskj.Main/FrmMain.Designer.cs b/插件库/Lskj.Main/FrmMain.Designer.cs
index 190ba4d..5738663 100644
--- a/插件库/Lskj.Main/FrmMain.Designer.cs
+++ b/插件库/Lskj.Main/FrmMain.Designer.cs
@@ -28,9 +28,8 @@
///
private void InitializeComponent()
{
- this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
- this.TheMemoryTest = new System.Windows.Forms.Timer(this.components);
+ this.TheMemoryTest = new System.Windows.Forms.Timer();
this.mainPanelControlEx = new Lskj.Main.Control.MainPanelControlEx();
this.SuspendLayout();
//
@@ -43,36 +42,9 @@
//
this.mainPanelControlEx.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainPanelControlEx.Location = new System.Drawing.Point(0, 0);
- this.mainPanelControlEx.Margin = new System.Windows.Forms.Padding(4);
this.mainPanelControlEx.Name = "mainPanelControlEx";
- this.mainPanelControlEx.Size = new System.Drawing.Size(1700, 870);
+ this.mainPanelControlEx.Size = new System.Drawing.Size(1275, 696);
this.mainPanelControlEx.TabIndex = 0;
//
// FrmMain
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1700, 870);
- this.Controls.Add(this.mainPanelControlEx);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.MaximizeBox = false;
- this.Name = "FrmMain";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "用户登录";
- this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
- this.Load += new System.EventHandler(this.FrmMain_Load);
- this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnClickKeyboard);
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- public Control.MainPanelControlEx mainPanelControlEx;
- private System.Windows.Forms.Timer TheMemoryTest;
-
- }
-}
-
+ //
\ No newline at end of file
diff --git a/插件库/Lskj.Main/FrmSubSystem.Designer.cs b/插件库/Lskj.Main/FrmSubSystem.Designer.cs
index 8d47fe2..4867b57 100644
--- a/插件库/Lskj.Main/FrmSubSystem.Designer.cs
+++ b/插件库/Lskj.Main/FrmSubSystem.Designer.cs
@@ -59,6 +59,7 @@
//
this.pl_bg.BackColor = System.Drawing.Color.Transparent;
this.pl_bg.BackgroundImage = global::Lskj.Main.Properties.Resources.sub_backgroud;
+ this.pl_bg.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pl_bg.Controls.Add(this.plSubPages);
this.pl_bg.Controls.Add(this.panelControl4);
this.pl_bg.Controls.Add(this.plTop);
@@ -239,27 +240,4 @@
this.panelControl6.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureEdit1.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.plTop)).EndInit();
- this.plTop.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.plBottom)).EndInit();
- this.plBottom.ResumeLayout(false);
- this.plBottom.PerformLayout();
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.Panel pl_bg;
- private DevExpress.XtraEditors.PanelControl plSubPages;
- private DevExpress.XtraEditors.PanelControl panelControl4;
- private DevExpress.XtraEditors.PanelControl plSubMenus;
- private DevExpress.XtraEditors.PanelControl panelControl6;
- private System.Windows.Forms.RichTextBox rtbTip;
- private DevExpress.XtraEditors.PictureEdit pictureEdit1;
- private DevExpress.XtraEditors.PanelControl plBottom;
- private System.Windows.Forms.Label lblTip;
- private DevExpress.XtraEditors.PanelControl plTop;
- private System.Windows.Forms.Button btnMin;
- private System.Windows.Forms.Button btnColse;
- }
-}
\ No newline at end of file
+
\ No newline at end of file
diff --git a/插件库/Lskj.Main/FrmSubSystem.cs b/插件库/Lskj.Main/FrmSubSystem.cs
index 9f80cbc..5e31a3e 100644
--- a/插件库/Lskj.Main/FrmSubSystem.cs
+++ b/插件库/Lskj.Main/FrmSubSystem.cs
@@ -75,6 +75,16 @@ namespace Lskj.Main
public FrmSubSystem()
{
InitializeComponent();
+
+ //if (this.pl_bg != null && !(this.pl_bg is BackgroundPanel))
+ //{
+ // this.pl_bg = new BackgroundPanel();
+ // this.pl_bg.Dock = DockStyle.Fill;
+ // this.pl_bg.Name = "pl_bg";
+ // this.Controls.Add(this.pl_bg);
+ // // 确保pl_bg在最底层,不遮挡其他控件
+ // this.pl_bg.SendToBack();
+ //}
}
///
/// 说明:窗口加载
@@ -97,6 +107,15 @@ namespace Lskj.Main
this.pictureEdit1.Properties.ContextMenu = new ContextMenu();//把菜单类赋格控件
this.pl_bg.BackgroundImage = BitMapHelper.getBitmap(BitMapEnum.submenubg);//本地拿到自带背景
+
+ //pl_bg.BackgroundImageCustom = BitMapHelper.getBitmap(BitMapEnum.submenubg);
+ //if (this.pl_bg is BackgroundPanel)
+ //{
+ // // 从本地获取背景位图并设置到自定义属性
+ // (pl_bg as BackgroundPanel).BackgroundImageCustom = BitMapHelper.getBitmap(BitMapEnum.submenubg);
+
+ //}
+
this.pictureEdit1.Image = BitMapHelper.getBitmap(BitMapEnum.submenubg_tip);//如果有自定义别的背景,就拿自定义的
if (this.pictureEdit1.Image != Resources.sub_tip_backgound)
{
@@ -670,31 +689,4 @@ namespace Lskj.Main
///
/// 说明:鼠标移动
/// 创建人:龚宇超
- /// 创建日期:2017-08-14
- /// 修改人:
- /// 修改日期:
- /// 修改备注:
- /// 版本:1.0
- ///
- /// The source of the event.
- /// The instance containing the event data.
- private void plTop_MouseMove(object sender, MouseEventArgs e)
- {
- try
- {
- base.OnMouseMove(e);
- if (_isMouseDown && e.Button == MouseButtons.Left)
- {
- this.Location = new Point(Location.X + (e.X - _mousePostion.X), Location.Y + (e.Y - _mousePostion.Y));
- }
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- }
-
- }
- #endregion
- }
-}
\ No newline at end of file
+ ///
/// 默认下载地址
///
@@ -112,13 +113,13 @@ namespace Lskj.Main.Model
if (isStart)
{
// Delphi数据库连接检查
- //if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection(DBConfig.Instance.dephiConnection))) == 0)
- //{
- // MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
- // SplashForm.HideForm();
- // RunConfigForm();
- // return;
- //}
+ if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection(DBConfig.Instance.dephiConnection))) == 0)
+ {
+ MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
+ SplashForm.HideForm();
+ RunConfigForm();
+ return;
+ }
SplashForm.HideForm();
@@ -161,6 +162,7 @@ namespace Lskj.Main.Model
{
WhenConstraintLogin();
LockApplication();
+ if (SystemInfo.Instance.SubscriptRefreshTime > 0 && !SystemInfo.Instance.RefreshNotify)RefreshSubscript();
if (_frmMain != null)
{
if (ERPInfo.Instance.WatermarkForm != null)
@@ -1002,6 +1004,50 @@ namespace Lskj.Main.Model
});
thread.Start();
}
+
+
+
+
+
+
+ ///
+ /// 刷新数量角标
+ ///
+ private static void RefreshSubscript()
+ {
+ Thread thread = new Thread(() =>
+ {
+ while (SystemInfo.Instance.SubscriptRefreshTime > 0)
+ {
+ if (RefreshTime >= SystemInfo.Instance.SubscriptRefreshTime)
+ {
+ RefreshTime = 0;
+ if (_frmMain != null && _frmMain.Visible == true)
+ {
+ XtraTabPage tabPage = _frmMain.mainPanelControlEx.tabMain.SelectedTabPage;
+ if (tabPage.TabIndex == 0)
+ {
+ if (!SystemInfo.Instance.RefreshNotify)
+ {
+ Thread threadnew = new Thread(_frmMain.mainPanelControlEx.RefreshSubscript);
+ threadnew.IsBackground = true;
+ threadnew.Start();
+ }
+ }
+ }
+ }
+ RefreshTime += 1;
+ Thread.Sleep(60000);
+ }
+ });
+ thread.Start();
+ }
+
+
+
+
+
+
///
/// url加密
///
@@ -1045,33 +1091,4 @@ namespace Lskj.Main.Model
{
DateTime dateTime = DateTime.Now.AddDays(1);
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- long timestamp = (dateTime.Ticks - epoch.Ticks) / TimeSpan.TicksPerSecond;
- pms.Add("exp", timestamp);
- }
- return $"{urlParams[0]}?pms={HttpUtility.UrlEncode(hasEn ? Lskj.Web.Core.Util.safety.AESUtil.Encrypt(JSON.Encode(pms), enVal) : Lskj.Web.Core.Util.safety.AESUtil.MobileEncrypt(JSON.Encode(pms)))}&{qpLS.SJoin("&")}";
- }
- return url;
- }
-
-
- ///
- /// 退出主程序,进入登录界面
- ///
- public static void ReLogin()
- {
- if (_frmMain != null)
- {
- if (ERPInfo.Instance.WatermarkForm != null)
- {
- ERPInfo.Instance.WatermarkForm.Close();
- ERPInfo.Instance.WatermarkForm.Dispose();
- }
- _frmMain.Close();
- _frmMain.Dispose();
- _frmMain = null;
- }
- StartForm();
- }
-
- }
-}
\ No newline at end of file
+
\ No newline at end of file