5055 lines
236 KiB
C#
5055 lines
236 KiB
C#
/***********************
|
||
* 说明:主窗体界面的构建
|
||
* 创建人:龚宇超
|
||
* 创建日期:
|
||
* 修改人:
|
||
* 修改日期:
|
||
* 修改备注:
|
||
* 版本: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.Web;
|
||
using System.Windows.Forms;
|
||
|
||
namespace Lskj.Main.Control
|
||
{
|
||
public partial class MainPanelControlEx : UserControl
|
||
{
|
||
#region 公有属性
|
||
/// <summary>
|
||
/// 屏幕dpix、dpiy
|
||
/// </summary>
|
||
public float DpiX, DpiY;
|
||
public int plTopHeight
|
||
{
|
||
get { return plTop.Height; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 最大化回调
|
||
/// </summary>
|
||
public event EventHandler OnMaxButtonCallBack;
|
||
/// <summary>
|
||
/// 最小化回调
|
||
/// </summary>
|
||
public event EventHandler OnMinButtonCallBack;
|
||
/// <summary>
|
||
/// 关闭回调
|
||
/// </summary>
|
||
public event EventHandler OnCloseButtonCallBack;
|
||
/// <summary>
|
||
/// 顶部双击回调
|
||
/// </summary>
|
||
public event EventHandler OnTopPanelMouseDoubleClickCallBack;
|
||
/// <summary>
|
||
/// Occurs when [on top mouse down callback].
|
||
/// </summary>
|
||
public event MouseEventHandler OnTopMouseDownCallback;
|
||
/// <summary>
|
||
/// Occurs when [on top mouse up call back].
|
||
/// </summary>
|
||
public event MouseEventHandler OnTopMouseUpCallBack;
|
||
/// <summary>
|
||
/// Occurs when [on top mouse move call back].
|
||
/// </summary>
|
||
public event MouseEventHandler OnTopMouseMoveCallBack;
|
||
/// <summary>
|
||
/// 窗口状态
|
||
/// </summary>
|
||
public FormWindowState State;
|
||
/// <summary>
|
||
/// 界面主页签
|
||
/// </summary>
|
||
public XtraTabControl TabMain { get { return this.tabMain; } }
|
||
/// <summary>
|
||
/// 主Panel
|
||
/// </summary>
|
||
public Panel MainPanel { get { return this.plMain; } }
|
||
/// <summary>
|
||
/// 锁屏窗口
|
||
/// </summary>
|
||
public AwaitScreenControl AwaitControl { get { return this.awaitScreenControl; } }
|
||
#endregion
|
||
|
||
#region 私有属性
|
||
private MenuBar _firstMenuBar;
|
||
private bool _firstSubItemFocus;
|
||
private bool _firstAccountsFocus;
|
||
/// <summary>
|
||
/// 模块sql
|
||
/// </summary>
|
||
private string _menuSql;
|
||
/// <summary>
|
||
/// 权限条件
|
||
/// </summary>
|
||
private string _purviewCond = string.Empty;
|
||
/// <summary>
|
||
/// 上次点击的按钮
|
||
/// </summary>
|
||
private Button _lastMenuButton;
|
||
/// <summary>
|
||
/// 当前配置的模块
|
||
/// </summary>
|
||
private DataTable _allMenus = new DataTable();
|
||
/// <summary>
|
||
/// 子系统菜单
|
||
/// </summary>
|
||
private DataTable _subItemMenu;
|
||
/// <summary>
|
||
/// 缓存菜单控件
|
||
/// </summary>
|
||
private Dictionary<string, List<UserControl>> _menus = new Dictionary<string, List<UserControl>>();
|
||
/// <summary>
|
||
/// 缓存分组控件
|
||
/// </summary>
|
||
private Dictionary<string, Panel> _groupItems = new Dictionary<string, Panel>();
|
||
private TreeView _leftGroupTreeView;
|
||
private ImageList _leftGroupTreeIcons;
|
||
private Panel _leftGroupSeparator;
|
||
private const string LeftGroupTreeNodeTypeMenu = "menu";
|
||
private const string LeftGroupTreeNodeTypeGroup = "group";
|
||
private const int GroupControlTopPadding = 8;
|
||
/// <summary>
|
||
/// 缓存右上菜单控件
|
||
/// </summary>
|
||
private Dictionary<string, TableLayoutPanel> topLayoutPanelDic = new Dictionary<string, TableLayoutPanel>();
|
||
/// <summary>
|
||
/// 缓存右下菜单控件
|
||
/// </summary>
|
||
private Dictionary<string, TableLayoutPanel> botLayoutPanelDic = new Dictionary<string, TableLayoutPanel>();
|
||
/// <summary>
|
||
/// 缓存菜单
|
||
/// </summary>
|
||
private List<UserControl> _menuItemList = new List<UserControl>();
|
||
/// <summary>
|
||
/// 第一个menuItem
|
||
/// </summary>
|
||
private ToolStripMenuItem _firstMenuItem;
|
||
/// <summary>
|
||
/// 上次点击的菜单
|
||
/// </summary>
|
||
private ToolStripMenuItem _lastMenuItem;
|
||
/// <summary>
|
||
/// 子系统小窗口
|
||
/// </summary>
|
||
private SubItemForm _subItemForm;
|
||
/// <summary>
|
||
/// 套账小窗口
|
||
/// </summary>
|
||
private SubItemForm _accountsItemForm;
|
||
/// <summary>
|
||
/// 判断消息框是否加载完成
|
||
/// </summary>
|
||
private bool _isFinish = true;
|
||
/// <summary>
|
||
/// 分辨率选择小窗口
|
||
/// </summary>
|
||
private ResSelectForm _resSelectForm = new ResSelectForm();
|
||
/// <summary>
|
||
/// 快捷窗口圆角
|
||
/// </summary>
|
||
private Dictionary<string, Lskj.Control.CircleButton> _quickPageHeaders = new Dictionary<string, Lskj.Control.CircleButton>();
|
||
/// <summary>
|
||
/// 默认模块(右上角)圆角
|
||
/// </summary>
|
||
private List<CornerLab> defaultModuleRoundedCornerss = new List<CornerLab>();
|
||
|
||
/// <summary>
|
||
/// 当前所有配置了countSql的模块和对于的模块号
|
||
/// </summary>
|
||
private Dictionary<string, string> countSqls = new Dictionary<string, string>();
|
||
/// <summary>
|
||
/// 初始化完成
|
||
/// </summary>
|
||
private bool _isInitFinish = false;
|
||
/// <summary>
|
||
///是否为流布局
|
||
/// </summary>
|
||
private bool isFlowLayout = false;
|
||
/// <summary>
|
||
///分组时快捷菜单是否显示在内部
|
||
/// </summary>
|
||
private bool isShowGrallyInTop = false;
|
||
/// <summary>
|
||
///模式3打开,上一次点击的时间
|
||
/// </summary>
|
||
public DateTime lastClickTime;
|
||
/// <summary>
|
||
///子目录是否已经存在 更多 选项
|
||
/// </summary>
|
||
public bool isMore;
|
||
/// <summary>
|
||
/// 更多
|
||
/// </summary>
|
||
public ToolStripMenuItem more = new ToolStripMenuItem();
|
||
/// <summary>
|
||
/// 主页面默认模块数据
|
||
/// </summary>
|
||
public List<DataRow> DefaultModules = new List<DataRow>();
|
||
|
||
/// <summary>
|
||
/// 隐藏账套
|
||
/// </summary>
|
||
public bool HiddenAccountSet = false;
|
||
|
||
/// <summary>
|
||
/// 上一次选中的页签
|
||
/// </summary>
|
||
public XtraTabPage PreviousTab = null;
|
||
/// <summary>
|
||
/// 鼠标点击状态
|
||
/// </summary>
|
||
private MouseButtons mouseButtons;
|
||
|
||
#endregion
|
||
|
||
#region 初始加载
|
||
public MainPanelControlEx()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:初始加载时</para>
|
||
/// <para>创建人 龚宇超</para>
|
||
/// <para>创建日期:2018-04-24 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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;
|
||
this.lblMenuTitle.Location = new Point(this.button3.Left, this.lblMenuTitle.Top);
|
||
}
|
||
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();
|
||
if (!this._allMenus.Columns.Contains("groupcaption") || isFlowLayout)
|
||
{
|
||
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;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:加载速度优化</para>
|
||
/// <para>创建人:唐德馨</para>
|
||
/// <para>创建日期:2021-09-03 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
//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;
|
||
// }
|
||
//}
|
||
|
||
/// <summary>
|
||
/// 刷新上一次切换的页面
|
||
/// </summary>
|
||
//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;
|
||
// }
|
||
|
||
//}
|
||
/// <summary>
|
||
/// <para>说明:设置主界面控件值</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-15 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void SetFormObject()
|
||
{
|
||
this.lbUserName.Text = ERPInfo.Instance.UserName;
|
||
|
||
if (this.lbUserName.Width+ this.lbUserName.Left-2> button6.Left)
|
||
{
|
||
//右上角用户名特殊处理
|
||
this.lbUserName.Text = this.lbUserName.Text.Substring(0, 2) + "...";
|
||
ToolTip toolTip = new ToolTip
|
||
{
|
||
InitialDelay = 100, // 鼠标悬浮后延迟显示时间(毫秒)
|
||
ReshowDelay = 500, // 连续悬浮不同控件时的延迟
|
||
ShowAlways = true, // 始终显示提示
|
||
UseAnimation = true, // 显示动画效果
|
||
UseFading = true, // 淡入淡出效果
|
||
AutoPopDelay = 1000000 // 提示框自动消失时间(毫秒)
|
||
};
|
||
toolTip.SetToolTip(this.lbUserName, 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;
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:子系统快捷窗口</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-08-09 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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());
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:切换账套快捷窗口</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2019-12-09 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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);
|
||
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:初始化窗口大小</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-05/para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void FrmMain_Resize(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
this.CalcPopupLocation();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:计算弹出账套控件位置</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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();
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:获取顶层窗口</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <returns>Control.</returns>
|
||
private Form GetParent(System.Windows.Forms.Control ctr)
|
||
{
|
||
if (ctr == null) return null;
|
||
|
||
return ctr is Form ? ctr as Form : GetParent(ctr.Parent);
|
||
}
|
||
|
||
private DataTable CreateLeftGroupTreeTable()
|
||
{
|
||
DataTable table = new DataTable();
|
||
table.Columns.Add("nodekey");
|
||
table.Columns.Add("parentkey");
|
||
table.Columns.Add("nodetext");
|
||
table.Columns.Add("nodetype");
|
||
table.Columns.Add("menustruct");
|
||
table.Columns.Add("groupkey");
|
||
table.Columns.Add("sortno", typeof(int));
|
||
table.Columns.Add("iconindex", typeof(int));
|
||
return table;
|
||
}
|
||
|
||
private void AddLeftGroupTreeNode(DataTable table, string nodeKey, string nodeText, string nodeType, string menuStruct, string groupKey)
|
||
{
|
||
if (table == null || string.IsNullOrWhiteSpace(nodeKey)) return;
|
||
if (table.Rows.Cast<DataRow>().Any(n => (n["nodekey"] + "").Equals(nodeKey))) return;
|
||
|
||
DataRow row = table.NewRow();
|
||
row["nodekey"] = nodeKey;
|
||
row["parentkey"] = nodeType.Equals(LeftGroupTreeNodeTypeGroup) ? menuStruct : string.Empty;
|
||
row["nodetext"] = nodeText;
|
||
row["nodetype"] = nodeType;
|
||
row["menustruct"] = menuStruct;
|
||
row["groupkey"] = groupKey;
|
||
row["sortno"] = table.Rows.Count + 1;
|
||
row["iconindex"] = table.Rows.Count;
|
||
table.Rows.Add(row);
|
||
}
|
||
|
||
private string GetGroupTreeKey(string menuStruct, int groupIndex)
|
||
{
|
||
return string.Format("{0}|{1:00}", menuStruct, groupIndex);
|
||
}
|
||
|
||
private string GetLeftGroupTreeDefaultNode(DataTable treeTable, string defaultParentMenu)
|
||
{
|
||
if (treeTable == null || treeTable.Rows.Count == 0) return string.Empty;
|
||
|
||
DataRow defaultParentRow = treeTable.Rows.Cast<DataRow>()
|
||
.FirstOrDefault(n => (n["nodetype"] + "").Equals(LeftGroupTreeNodeTypeMenu) && (n["menustruct"] + "").Equals(defaultParentMenu));
|
||
if (defaultParentRow != null)
|
||
{
|
||
return defaultParentRow["nodekey"] + "";
|
||
}
|
||
|
||
DataRow firstParentRow = treeTable.Rows.Cast<DataRow>()
|
||
.FirstOrDefault(n => (n["nodetype"] + "").Equals(LeftGroupTreeNodeTypeMenu));
|
||
if (firstParentRow != null) return firstParentRow["nodekey"] + "";
|
||
|
||
return treeTable.Rows[0]["nodekey"] + "";
|
||
}
|
||
|
||
private string GetGroupCaptionText(string groupCaption)
|
||
{
|
||
if (string.IsNullOrWhiteSpace(groupCaption)) return string.Empty;
|
||
return groupCaption.Length > 2 ? groupCaption.Remove(0, 2) : groupCaption;
|
||
}
|
||
|
||
private TreeView GetLeftGroupTreeView()
|
||
{
|
||
if (_leftGroupTreeView != null) return _leftGroupTreeView;
|
||
|
||
_leftGroupTreeView = new TreeView
|
||
{
|
||
Dock = DockStyle.Fill,
|
||
BorderStyle = BorderStyle.None,
|
||
BackColor = Color.FromArgb(250, 253, 255),
|
||
DrawMode = TreeViewDrawMode.Normal,
|
||
Font = new Font("微软雅黑", 10F),
|
||
ForeColor = Color.FromArgb(38, 73, 98),
|
||
HideSelection = false,
|
||
Indent = 20,
|
||
ImageList = GetLeftGroupTreeIcons(),
|
||
ItemHeight = 29,
|
||
LineColor = Color.FromArgb(198, 214, 226),
|
||
ShowLines = false,
|
||
ShowPlusMinus = false,
|
||
ShowRootLines = false
|
||
};
|
||
_leftGroupTreeView.NodeMouseClick += OnLeftGroupTreeViewNodeMouseClick;
|
||
|
||
return _leftGroupTreeView;
|
||
}
|
||
|
||
private Panel GetLeftGroupSeparator()
|
||
{
|
||
if (_leftGroupSeparator != null) return _leftGroupSeparator;
|
||
|
||
_leftGroupSeparator = new Panel
|
||
{
|
||
Dock = DockStyle.Left,
|
||
Width = 2,
|
||
BackColor = Color.FromArgb(198, 214, 226),
|
||
Margin = Padding.Empty
|
||
};
|
||
return _leftGroupSeparator;
|
||
}
|
||
|
||
private void SetLeftGroupSeparatorVisible(bool visible)
|
||
{
|
||
Panel separator = GetLeftGroupSeparator();
|
||
this.FirstMain.SuspendLayout();
|
||
try
|
||
{
|
||
if (!this.FirstMain.Controls.Contains(separator))
|
||
{
|
||
this.FirstMain.Controls.Add(separator);
|
||
}
|
||
|
||
this.FirstMain.Controls.SetChildIndex(this.pl_center_main, 0);
|
||
this.FirstMain.Controls.SetChildIndex(separator, 1);
|
||
this.FirstMain.Controls.SetChildIndex(this.pl_center_left, 2);
|
||
separator.Visible = visible;
|
||
}
|
||
finally
|
||
{
|
||
this.FirstMain.ResumeLayout();
|
||
}
|
||
}
|
||
|
||
private ImageList GetLeftGroupTreeIcons()
|
||
{
|
||
if (_leftGroupTreeIcons != null) return _leftGroupTreeIcons;
|
||
|
||
_leftGroupTreeIcons = new ImageList();
|
||
_leftGroupTreeIcons.ColorDepth = ColorDepth.Depth32Bit;
|
||
_leftGroupTreeIcons.ImageSize = new Size(18, 18);
|
||
|
||
string iconPath = PubUtil.MainTreeviewImagePath;
|
||
if (Directory.Exists(iconPath))
|
||
{
|
||
string[] files = Directory.GetFiles(iconPath, "*.png").OrderBy(n => n).ToArray();
|
||
foreach (string file in files)
|
||
{
|
||
using (Image image = ImageHelper.ReadImage(file))
|
||
{
|
||
if (image != null)
|
||
{
|
||
_leftGroupTreeIcons.Images.Add(new Bitmap(image));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (_leftGroupTreeIcons.Images.Count == 0)
|
||
{
|
||
_leftGroupTreeIcons.Images.Add(new Bitmap(18, 18));
|
||
}
|
||
return _leftGroupTreeIcons;
|
||
}
|
||
private void BindLeftGroupTreeView(DataTable treeTable, string defaultNode)
|
||
{
|
||
TreeView treeView = GetLeftGroupTreeView();
|
||
treeView.BeginUpdate();
|
||
treeView.Nodes.Clear();
|
||
|
||
Dictionary<string, TreeNode> nodeMap = new Dictionary<string, TreeNode>();
|
||
List<DataRow> rows = treeTable.Rows.Cast<DataRow>()
|
||
.OrderBy(n => Convert.ToInt32(n["sortno"]))
|
||
.ToList();
|
||
int iconCount = GetLeftGroupTreeIcons().Images.Count;
|
||
|
||
foreach (DataRow row in rows)
|
||
{
|
||
TreeNode node = new TreeNode(row["nodetext"] + "");
|
||
int iconIndex = 0;
|
||
int.TryParse(row["iconindex"] + "", out iconIndex);
|
||
iconIndex = Math.Abs(iconIndex) % iconCount;
|
||
node.ImageIndex = iconIndex;
|
||
node.SelectedImageIndex = iconIndex;
|
||
node.Name = row["nodekey"] + "";
|
||
node.Tag = row;
|
||
nodeMap[node.Name] = node;
|
||
}
|
||
|
||
foreach (DataRow row in rows)
|
||
{
|
||
string nodeKey = row["nodekey"] + "";
|
||
string parentKey = row["parentkey"] + "";
|
||
TreeNode node = nodeMap[nodeKey];
|
||
|
||
if (!string.IsNullOrEmpty(parentKey) && nodeMap.ContainsKey(parentKey))
|
||
{
|
||
nodeMap[parentKey].Nodes.Add(node);
|
||
}
|
||
else
|
||
{
|
||
treeView.Nodes.Add(node);
|
||
}
|
||
}
|
||
|
||
treeView.CollapseAll();
|
||
FocusLeftGroupTreeNode(defaultNode);
|
||
treeView.EndUpdate();
|
||
}
|
||
|
||
private void FocusLeftGroupTreeNode(string nodeKey)
|
||
{
|
||
if (_leftGroupTreeView == null || string.IsNullOrEmpty(nodeKey)) return;
|
||
|
||
TreeNode node = FindLeftGroupTreeNode(_leftGroupTreeView.Nodes, nodeKey);
|
||
if (node == null) return;
|
||
|
||
_leftGroupTreeView.SelectedNode = node;
|
||
}
|
||
|
||
private TreeNode FindLeftGroupTreeNode(TreeNodeCollection nodes, string nodeKey)
|
||
{
|
||
foreach (TreeNode node in nodes)
|
||
{
|
||
if (node.Name.Equals(nodeKey)) return node;
|
||
|
||
TreeNode childNode = FindLeftGroupTreeNode(node.Nodes, nodeKey);
|
||
if (childNode != null) return childNode;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
private void OnLeftGroupTreeViewNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
TreeView treeView = sender as TreeView;
|
||
if (treeView == null || e.Node == null || e.Button != MouseButtons.Left) return;
|
||
|
||
treeView.SelectedNode = e.Node;
|
||
if (e.Node.Nodes.Count > 0)
|
||
{
|
||
e.Node.Toggle();
|
||
}
|
||
|
||
OnLeftGroupTreeRowClick(e.Node.Tag as DataRow);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
}
|
||
|
||
private void BindLeftGroupTreeMenu(DataTable treeTable, string defaultParentMenu)
|
||
{
|
||
if (treeTable == null || treeTable.Rows.Count == 0) return;
|
||
|
||
string expandNode = GetLeftGroupTreeDefaultNode(treeTable, defaultParentMenu);
|
||
this.pl_center_left.Controls.Clear();
|
||
this.pl_center_left.Padding = Padding.Empty;
|
||
this.pl_center_left.BackColor = Color.FromArgb(250, 253, 255);
|
||
this.pl_center_main.Padding = Padding.Empty;
|
||
this.pl_center_main.BackColor = Color.FromArgb(240, 240, 240);
|
||
SetLeftGroupSeparatorVisible(true);
|
||
TreeView treeView = GetLeftGroupTreeView();
|
||
this.pl_center_left.Controls.Add(treeView);
|
||
BindLeftGroupTreeView(treeTable, expandNode);
|
||
|
||
if (!string.IsNullOrEmpty(expandNode))
|
||
{
|
||
DataRow expandRow = treeTable.Rows.Cast<DataRow>().FirstOrDefault(n => (n["nodekey"] + "").Equals(expandNode));
|
||
if (expandRow != null)
|
||
{
|
||
OnLeftGroupTreeRowClick(expandRow);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void ShowGroupMenuPanel(string menuStruct, string groupKey)
|
||
{
|
||
if (!_groupItems.ContainsKey(menuStruct)) return;
|
||
|
||
Panel groupPanel = _groupItems[menuStruct];
|
||
groupPanel.SuspendLayout();
|
||
foreach (System.Windows.Forms.Control control in groupPanel.Controls)
|
||
{
|
||
GroupControl groupControl = control as GroupControl;
|
||
if (groupControl == null) continue;
|
||
groupControl.Visible = string.IsNullOrEmpty(groupKey) || (groupControl.Name + "").Equals(groupKey);
|
||
}
|
||
NormalizeGroupPanelSpacing(groupPanel);
|
||
groupPanel.ResumeLayout(true);
|
||
groupPanel.AutoScrollPosition = Point.Empty;
|
||
|
||
this.allMenuPanel.Controls.Clear();
|
||
this.allMenuPanel.Controls.Add(groupPanel);
|
||
groupPanel.Visible = true;
|
||
}
|
||
|
||
private void NormalizeGroupPanelSpacing(Panel groupPanel)
|
||
{
|
||
if (groupPanel == null) return;
|
||
|
||
List<GroupControl> groupControls = groupPanel.Controls.OfType<GroupControl>().ToList();
|
||
int topPadding = groupControls.Count > 1 ? GroupControlTopPadding : 0;
|
||
foreach (GroupControl groupControl in groupControls)
|
||
{
|
||
groupControl.Padding = new Padding(0, topPadding, 0, 0);
|
||
}
|
||
}
|
||
|
||
private void ShowShortcutPanels(string menuStruct)
|
||
{
|
||
if (!this._allMenus.Columns.Contains("menuposition") || (!SystemInfo.Instance.IsOpenWork && !SystemInfo.Instance.ShowGallerysFromMenu) || SystemInfo.Instance.HideGallerys)
|
||
{
|
||
return;
|
||
}
|
||
|
||
this.pl_center_main_bottom_right_main.Controls.Clear();
|
||
this.pl_center_main_bottom_left_main.Controls.Clear();
|
||
if (this.topLayoutPanelDic.ContainsKey(menuStruct))
|
||
{
|
||
TableLayoutPanel tableLayoutPanel = this.topLayoutPanelDic[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(menuStruct))
|
||
{
|
||
TableLayoutPanel tableLayoutPanel = this.botLayoutPanelDic[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 + "";
|
||
}
|
||
}
|
||
|
||
private void OnLeftGroupTreeMenuClick(Button button)
|
||
{
|
||
try
|
||
{
|
||
DataRow row = button == null ? null : button.Tag as DataRow;
|
||
if (row == null) return;
|
||
|
||
OnLeftGroupTreeRowClick(row);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
}
|
||
|
||
private void OnLeftGroupTreeRowClick(DataRow row)
|
||
{
|
||
if (row == null) return;
|
||
|
||
string menuStruct = row["menustruct"] + "";
|
||
string nodeType = row["nodetype"] + "";
|
||
string groupKey = nodeType.Equals(LeftGroupTreeNodeTypeGroup) ? row["groupkey"] + "" : string.Empty;
|
||
ShowGroupMenuPanel(menuStruct, groupKey);
|
||
ShowShortcutPanels(menuStruct);
|
||
|
||
if (SystemInfo.Instance.DesktopFormat && this.tabMain.SelectedTabPage == this.xtpDesktop)
|
||
{
|
||
this.webBrowser.Hide();
|
||
this.webBrowser.SendToBack();
|
||
this.tabMain.SelectedTabPage = this.xtpFirst;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:设置左侧菜单</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void SetMenus()
|
||
{
|
||
this._menus.Clear();
|
||
this._firstMenuBar = null;
|
||
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<DataRow> rows = this._allMenus.AsEnumerable().Where(n => (n["subsysid"] + "").Equals(ERPInfo.Instance.SubSysId) && !string.IsNullOrEmpty(n["menustruct"] + "")).ToList();
|
||
if (rows != null && rows.Count > 0)
|
||
{
|
||
bool useLeftGroupTreeMenu = this._allMenus.Columns.Contains("groupcaption") && !isFlowLayout;
|
||
DataTable leftGroupTreeTable = useLeftGroupTreeMenu ? CreateLeftGroupTreeTable() : null;
|
||
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<DataRow>().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);
|
||
if (useLeftGroupTreeMenu)
|
||
{
|
||
AddLeftGroupTreeNode(leftGroupTreeTable, menuStruct, item["menucaption"] + "", LeftGroupTreeNodeTypeMenu, menuStruct, string.Empty);
|
||
}
|
||
else
|
||
{
|
||
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<UserControl>());
|
||
}
|
||
#region 添加右侧菜单模块
|
||
if (this._allMenus.Columns.Contains("menuposition") && (SystemInfo.Instance.IsOpenWork || SystemInfo.Instance.ShowGallerysFromMenu) && !SystemInfo.Instance.HideGallerys)
|
||
{
|
||
List<DataRow> 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<DataRow> 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<DataRow> groupDataRows = new List<DataRow>();
|
||
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<IGrouping<int, DataRow>> groupByDataRows = groupDataRows.GroupBy(n => Convert.ToInt32((n["groupcaption"] + "").Substring(0, 2))).OrderByDescending(n => n.Key);
|
||
int groupByDataRowCount = groupByDataRows.Count();
|
||
Panel groupPanel = new Panel();
|
||
groupPanel.AutoScroll = true;
|
||
groupPanel.Dock = DockStyle.Fill;
|
||
int groupControlIndex = 0;
|
||
foreach (IGrouping<int, DataRow> groupByDataRow in groupByDataRows)
|
||
{
|
||
string groupTreeKey = GetGroupTreeKey(menuStruct, groupByDataRow.Key);
|
||
string groupTreeCaption = GetGroupCaptionText(groupByDataRow.First()["groupcaption"] + "");
|
||
if (string.IsNullOrWhiteSpace(groupTreeCaption) || (groupByDataRowCount == 1 && groupTreeCaption.Equals("默认分组")))
|
||
{
|
||
groupTreeCaption = item["menucaption"] + "";
|
||
}
|
||
if (useLeftGroupTreeMenu && groupByDataRowCount > 1)
|
||
{
|
||
string leftGroupTreeGroupKey = menuStruct + groupByDataRow.Key.ToString("00");
|
||
AddLeftGroupTreeNode(leftGroupTreeTable, leftGroupTreeGroupKey, groupTreeCaption, LeftGroupTreeNodeTypeGroup, menuStruct, groupTreeKey);
|
||
}
|
||
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.Name = groupTreeKey;
|
||
groupControl.Tag = groupTreeCaption;
|
||
groupControl.TipsLabel.ForeColor = Color.DimGray;
|
||
groupControl.Dock = DockStyle.Top;
|
||
groupControl.Padding = new Padding(0, GroupControlTopPadding, 0, 0);
|
||
groupPanel.Controls.Add(groupControl);
|
||
List<DataRow> 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<UserControl> controls = new List<UserControl>();
|
||
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 + GroupControlTopPadding);
|
||
}
|
||
if (groupPanel.Controls.Count == 1)
|
||
{
|
||
(groupPanel.Controls[0] as GroupControl).TipsVisable = false;
|
||
}
|
||
NormalizeGroupPanelSpacing(groupPanel);
|
||
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<Menu_Item>().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<UserControl> controls = new List<UserControl>();
|
||
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);
|
||
//}
|
||
}
|
||
}
|
||
}
|
||
if (useLeftGroupTreeMenu)
|
||
{
|
||
BindLeftGroupTreeMenu(leftGroupTreeTable, defaultParentMenu);
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:设置筛选模块</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-20 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:设置快捷通道</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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
|
||
/// <summary>
|
||
/// <para>说明:重绘圆角</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
|
||
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
|
||
/// <summary>
|
||
/// <para>说明:获取子系统小窗口内容</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-08-02 </para>
|
||
/// <para>修改人:</parya>`
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private DataRow[] GetSubItem()
|
||
{
|
||
DataRow[] rows = _subItemMenu.Select(string.Format("SubSysId <>'{0}'", ERPInfo.Instance.SubSysId));
|
||
return rows;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:左菜单初始化(左边为树)</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-24 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void InitLeftMenu()
|
||
{
|
||
DataTable dtLvTree = MainImpl.GetLeftTreeView();
|
||
if (!pl_center_left.Controls.Contains(tv_left))
|
||
{
|
||
pl_center_left.Controls.Clear();
|
||
pl_center_left.Padding = new Padding(4);
|
||
pl_center_left.BackColor = Color.FromArgb(10, 87, 167);
|
||
pl_center_main.Padding = Padding.Empty;
|
||
pl_center_main.BackColor = Color.FromArgb(240, 240, 240);
|
||
SetLeftGroupSeparatorVisible(false);
|
||
pl_center_left.Controls.Add(tv_left);
|
||
}
|
||
tv_left.Dock = DockStyle.Fill;
|
||
tv_left.Visible = true;
|
||
tv_left.ParentField = "speciesno";
|
||
tv_left.ParentKeyLength = 2;
|
||
tv_left.TextField = "speciesname";
|
||
tv_left.RaiseClickEventOnAllNodes = false;
|
||
tv_left.ExpandAllNodes = false;
|
||
tv_left.AllowNodeCollapse = true;
|
||
tv_left.SwitchOnMouseMove = false;
|
||
tv_left.UseMenuBarTextStyle = false;
|
||
tv_left.UseGroupTreeImageStyle = false;
|
||
tv_left.OnButtonClickEvent += new TreeViewCustom.ButtonClickEventHandler(OnMenuButtonClick);
|
||
tv_left.SetDataSource(dtLvTree);
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:加载顶部菜单</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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<DataRow>().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<DataRow>().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);
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:加载默认模块</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-22 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void SetDefaultMenu()
|
||
{
|
||
// 加载默认模块
|
||
//DataRow rowItem = this._allMenus.Rows.OfType<DataRow>().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++;
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:获取通知表数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-17 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="subsysid">The subsysid.</param>
|
||
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<DataRow>().FirstOrDefault(x => x["DllShowCaption"].ToString() == key);
|
||
if (items != null)
|
||
{
|
||
string groupMenuId = items["LMenuId"] + "";
|
||
UserControl menuItem = this._menuItemList.Cast<UserControl>().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<UserControl>().FirstOrDefault(x => x.Name == menuId);
|
||
}
|
||
else
|
||
{
|
||
try
|
||
{
|
||
menuItem = this._menuItemList.Cast<UserControl>().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<UserControl>().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;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 解析DNS
|
||
/// </summary>
|
||
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)
|
||
{
|
||
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:设置我的桌面</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期: </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化系统DNS字段
|
||
/// </summary>
|
||
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 顶部菜单相关
|
||
|
||
|
||
/// <summary>
|
||
/// 点击上方子系统,切换系统
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 存入更多中的子目录,点击切换
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// <para>说明:菜单展开后</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:菜单关闭后</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:顶部菜单打开模块</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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 快捷通道相关
|
||
/// <summary>
|
||
/// <para>说明:快捷通道功能鼠标离开时</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:快速通道鼠标移动时</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:快捷通道打开模块</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
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 功能菜单相关
|
||
|
||
/// <summary>
|
||
/// <para>说明:切换模块</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="before">The before.</param>
|
||
/// <param name="after">The after.</param>
|
||
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<UserControl> beforeButtons = new List<UserControl>();
|
||
List<UserControl> afterButtons = new List<UserControl>();
|
||
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"] + ""];
|
||
foreach (System.Windows.Forms.Control control in groupPanel.Controls)
|
||
{
|
||
GroupControl groupControl = control as GroupControl;
|
||
if (groupControl != null) groupControl.Visible = true;
|
||
}
|
||
NormalizeGroupPanelSpacing(groupPanel);
|
||
groupPanel.AutoScrollPosition = Point.Empty;
|
||
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;
|
||
}
|
||
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 功能图标打开模块
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 快捷图标点击
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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();
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:打开模块</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-01-27 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:左菜单树点击事件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-25 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:上菜单按钮点击事件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-24 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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 重置界面宽度高度
|
||
/// <summary>
|
||
/// <para>说明:计算快速通道宽度</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void ResetPanelWidth()
|
||
{
|
||
pl_center_main_bottom_left.Height = pl_center_main_bottom_right.Height = pl_center_main_right.Height / 2;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:重新计算菜单显示位置</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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 窗口拖动行为
|
||
/// <summary>
|
||
/// <para>说明:鼠标双击最大化、还原</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:鼠标按下</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:鼠标放开</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:鼠标移动</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
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 最小化相关
|
||
/// <summary>
|
||
/// <para>说明:最小化按钮点击</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:最小化鼠标离开时</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:最小化鼠标移动时</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
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 最大化相关
|
||
/// <summary>
|
||
/// <para>说明:最大化点击</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:最大化鼠标离开时</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:最大化鼠标移动时</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
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 关闭相关
|
||
/// <summary>
|
||
/// <para>说明:关闭事件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:关闭按钮离开时</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:关闭按钮移动时</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:关闭tabpage窗口</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-09-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 惨淡打开时
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 右键关闭页签
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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<XtraTabPage> removeList = new List<XtraTabPage>();
|
||
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 用户相关
|
||
/// <summary>
|
||
/// <para>说明:切换用户</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:修改密码</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-08-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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 换肤
|
||
/// <summary>
|
||
/// <para>说明:打开换肤界面</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-09-13 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-09-13 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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 模块搜索
|
||
/// <summary>
|
||
/// <para>说明:打开界面</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-06 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
private void OnUserNamePopupClosed(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
this.OnOpenSearchModule();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:模块搜索</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-23 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
private void OnSearchClick(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
this.OnOpenSearchModule();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:打开搜索模块</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-23 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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 更新角标
|
||
/// <summary>
|
||
/// <para>说明:每隔5s取一次通知数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-17 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
private void OnMarkTimerTick(object sender, EventArgs e)
|
||
{
|
||
//SetNotifys();
|
||
}
|
||
#endregion
|
||
|
||
#region 子系统小窗口相关
|
||
/// <summary>
|
||
/// <para>说明:快捷窗口中子系统点击</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-08-03 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:快捷窗口中子系统点击</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-08-03 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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<DataRow>().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);
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// <para>说明:切换账号后重新登录</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-08-03 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="serverIP">ip</param>
|
||
/// <param name="dbName">数据库名</param>
|
||
/// <param name="dataBook">当前账套名</param>
|
||
/// <param name="AccountBook">登录帐套</param>
|
||
/// <param name="Reset">是否为重新登录初始账套</param>
|
||
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<string, string> readKeysValues = new Dictionary<string, string>();
|
||
// 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<DataRow>().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<string, string> readKeysValues = new Dictionary<string, string>();
|
||
// 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;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:设置delphi参数</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-12 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:子系统面板弹出事件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-08-02 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||
private void OnTabMouseClick(object sender, MouseEventArgs e)
|
||
{
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:子系统失去焦点</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-08-03 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:切换账套失去焦点</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2019-12-10 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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 快捷通道双击操作
|
||
/// <summary>
|
||
/// <para>说明:快捷通道双击操作</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-08-13 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
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();
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 选中切换套账
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 隐藏账套控件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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 自检功能操作
|
||
/// <summary>
|
||
/// <para>说明:程序自检功能</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2022-07-14 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// PageHead点击时
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void OnPageHeadMouseDown(object sender, MouseEventArgs e)
|
||
{
|
||
mouseButtons = e.Button;
|
||
}
|
||
/// <summary>
|
||
/// 页签切换时判断
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 页面刷新角标
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:初始化分割条位置</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-01-24</para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:并行分割条位置变化事件</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2020-08-24</para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
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)
|
||
{
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 判断是不是数值
|
||
/// </summary>
|
||
/// <param name="oText"></param>
|
||
/// <returns></returns>
|
||
private bool IsNumberic(string oText)
|
||
{
|
||
try
|
||
{
|
||
int var1 = Convert.ToInt32(oText);
|
||
return true;
|
||
}
|
||
catch
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
#region 加密狗验证
|
||
/// <summary>
|
||
/// 加密狗验证
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private void DogVerify()
|
||
{
|
||
int[] keyHandles = ERPInfo.Instance.keyHandles = new int[8];
|
||
int[] keyNumber = ERPInfo.Instance.keyNumber = new int[8];
|
||
int rtn = SmartX1Api.SmartX1Find("Ls_ERP", keyHandles, keyNumber);
|
||
}
|
||
#endregion
|
||
|
||
public void RefreshSubscript()
|
||
{
|
||
try
|
||
{
|
||
Thread thread = new Thread(SetNotifys);
|
||
thread.IsBackground = true;
|
||
thread.Start();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
}
|