Files
lserp_cs_6.0/插件库/Lskj.Main4/Control/MainPanelControlEx.cs
T
cyf ab56a9bcf7 基线 SVN r240
SVN-Revision: r240
2025-02-06 06:46:06 +00:00

3040 lines
122 KiB
C#

/***********************
* 说明:主窗体界面的构建
* 创建人:龚宇超
* 创建日期:
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
***********************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lskj.Control.Model;
using System.Threading;
using Lskj.Business.Impl;
using Lskj.Control;
using Lskj.Model;
using Lskj.Business;
using Lskj.Main4.Model;
using Lskj.Util;
using System.IO;
using Lskj.Data;
using Lskj.Main4.Properties;
using DevExpress.XtraTab;
using DevExpress.XtraTab.ViewInfo;
using DevExpress.XtraEditors;
using Lskj.Core;
using System.Net;
using DevExpress.LookAndFeel;
namespace Lskj.Main4.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; } }
#endregion
#region 私有属性
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<Menu_Item>> _menus = new Dictionary<string, List<Menu_Item>>();
/// <summary>
/// 缓存菜单
/// </summary>
private List<Menu_Item> _menuItemList = new List<Menu_Item>();
/// <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, CornerLab> _quickPageHeaders = new Dictionary<string, CornerLab>();
/// <summary>
/// 默认模块(右上角)圆角
/// </summary>
private CornerLab defaultModuleRoundedCorners = new 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;
#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();
this.isFlowLayout = SystemInfo.Instance.isFlowLayout;
if (isFlowLayout)
{
//this.splitMainControl.Panel1.Controls.Remove(this.pl_center_main_middle);
//Panel mainPanel = new Panel();
//mainPanel.Name = "pl_center_main_middle";
//mainPanel.Dock = DockStyle.Fill;
//this.splitMainControl.Panel1.Controls.Add(mainPanel);
//this.pl_center_main_middle = new FlowLayoutPanel();
this.pl_center_main_middle_FlowLayout.Visible = true;
this.pl_center_main_middle.Visible = false;
}
this.pl_top_left.Visible = false;
this.menuMain.Visible = false;
this.lblSubTitle.Visible = false;
this.toolStripLabel1.Text = "版本号:" + SystemInfo.Instance.Version;
this.SetDesktop();
this.SetFormObject();
this.SetTopMenus();
InitializeSplitterPosition();
this.SetGallerys();
this.SetDefaultMenu();
this.SetSubItemForm();
this.SetAccounts();
//控件事件订阅
ResSelectForm.MouseClickEventHanlder clickEvent = null;
clickEvent += new ResSelectForm.MouseClickEventHanlder(OnBtnCloseClick);
_resSelectForm.SetClickEvent(clickEvent);
//传统模式
if (SystemInfo.Instance.DefaultMainTag == 2)
{
//非传统模式左部分菜单
this.InitLeftMenu();
}
else
{
this.SetMenus();
this.SetSearchMenus();
this.tv_left.Visible = false;
}
if (!SystemInfo.Instance.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;
splitMainControl.SplitterMoved += new SplitterEventHandler(this.OnSplitterPositionChanged);
OnLayoutSizeChanged();
//StartDogVerifyThread();
}
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;
this.tsmi_userName.Text = "用户名:" + ERPInfo.Instance.UserName;
this.tsmi_account_book.Text = "账套:" + ERPInfo.Instance.AccountBook;
//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 = true;
this.ResetPanelWidth();
}
/// <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;
}
else
{
//添加子系统快捷窗口
_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);
}
/// <summary>
/// <para>说明:设置左侧菜单</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-08-16 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void SetMenus()
{
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);
DataRow[] rows = this._allMenus.AsEnumerable().Where(n => (n["subsysid"] + "").Equals(ERPInfo.Instance.SubSysId) && !string.IsNullOrEmpty(n["menustruct"] + "")).ToArray();
if (rows != null && rows.Length > 0)
{
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; // 内容区域宽度-右侧快捷栏宽度
int centerWidth = pl_center_main_middle.Width; // 内容区域宽度
string defaultParentMenu = string.Empty;
MenuBar.ButtonHoverEventHandler hoverEvent = null;
foreach (DataRow item in rows)
{
string menuStruct = item["menustruct"] + "";
string menuCaption = item["menucaption"] + "";
string menuid = item["menuid"] + "";
// 加载左侧菜单
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);
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;
// 注册事件
hoverEvent += new MenuBar.ButtonHoverEventHandler(OnTriggerMenu);
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<Menu_Item>());
}
}
}
// 加载右侧模块
if (menuStruct.Length == 4)
{
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(menuWidth, menuHeight);
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.Where(o => o.menuRow == menu.menuRow && o.menuNode == menu.menuNode).Count();
menuLeft = count == 0 ? 5 : count * Convert.ToInt32(1.20 * DpiX) + 5;
menuTop = menuHeight * (menu.menuRow - 1);
menu.Location = new Point(menuLeft, menuTop);
}
else
{
menu.Location = new Point(menuLeft, menuTop);
menuLeft += Convert.ToInt32(1.20 * DpiX);
// 换行显示
if (menuLeft + menuWidth > centerWidth)
{
menuLeft = 5;
menuTop += menuHeight;
}
}
// 默认显示
if (defaultParentMenu != menuStruct.Substring(0, 2))
{
menu.Visible = false;
}
if (isFlowLayout)
{
pl_center_main_middle_FlowLayout.Controls.Add(menu);
} else
{
pl_center_main_middle.Controls.Add(menu);
}
List<Menu_Item> controls = new List<Menu_Item>();
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.Add(menuid, countSql);
}
}
}
}
}
/// <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.DataSource = this._allMenus.Select("len(MenuStruct)=4").CopyToDataTable();
}
/// <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();
//DataTable ShortcutDt = MainImpl.GetGallerysByUserIdAndReviewAmount();
int top = 10, height = 30, left = 12;
int width = pl_center_main_bottom_left_main.Width;
int divide = width / 3; // 分为3等分
var baseTable = gallerys.Select("grouptagid=1");
var reportTable = gallerys.Select("grouptagid=2");
this.pl_center_main_bottom_left_main.RowCount = baseTable.Count() + 1;
this.pl_center_main_bottom_left_main.RowStyles.Clear();
//this.pl_center_main_bottom_left_main.SizeChanged += new EventHandler(OnLayoutSizeChanged);
// 显示我的操作通道
for (int i = 0; i < baseTable.Count(); i++)
{
RowStyle rowStyle = new RowStyle();
rowStyle.SizeType = SizeType.Absolute;
rowStyle.Height = 25;
this.pl_center_main_bottom_left_main.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;
pl_center_main_bottom_left_main.Controls.Add(simpleControl, 0, i);
_quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
simpleControl.CornerLab.BringToFront();
}
this.pl_center_main_bottom_right_main.RowCount = reportTable.Count() + 1;
this.pl_center_main_bottom_right_main.RowStyles.Clear();
// this.pl_center_main_bottom_right_main.SizeChanged += new EventHandler(OnLayoutSizeChangednew);
// 显示我的报表通道
for (int i = 0; i < reportTable.Count(); i++)
{
RowStyle rowStyle = new RowStyle();
rowStyle.SizeType = SizeType.Absolute;
rowStyle.Height = 25;
this.pl_center_main_bottom_right_main.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;
pl_center_main_bottom_right_main.Controls.Add(simpleControl, 0, i);
if (!_quickPageHeaders.ContainsKey(simpleControl.Label.Text)) _quickPageHeaders.Add(simpleControl.Label.Text, simpleControl.CornerLab);
simpleControl.CornerLab.BringToFront();
}
}
#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();
tv_left.ParentField = "speciesno";
tv_left.ParentKeyLength = 2;
tv_left.TextField = "speciesname";
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()
{
DataTable subSystems = MainImpl.GetSubSystems();
_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);
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);
menuItem.BackColor = Color.Transparent;
menuItem.ForeColor = Color.White;
menuItem.DropDownClosed += new EventHandler(OnMenuItemDropDownClosed);
menuItem.DropDownOpened += new EventHandler(OnMenuItemDropDownOpened);
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);
// 功能模块
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"] + "" };
childItem.Click += OnItemClick;
subItem.DropDownItems.Add(childItem);
}
menuItem.DropDownItems.Add(subItem);
}
}
catch (Exception ex)
{
MessageUtil.Show(ex);
}
}
if (hasMenu)
{
menuMain.Items.Add(menuItem);
//获取有权限的系统
_subItemMenu.ImportRow(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 (rowItem != null)
{
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;
defaultModuleRoundedCorners.Location = new Point(this.lblMenuTitle.Left + this.lblMenuTitle.Width - 5, this.lblMenuTitle.Top - 8);
defaultModuleRoundedCorners.Height = 20;
defaultModuleRoundedCorners.Width = 20;
defaultModuleRoundedCorners.LabelNum.Location = new Point(2, 4);
defaultModuleRoundedCorners.Visible = false;
this.pl_top_right.Controls.Add(defaultModuleRoundedCorners);
defaultModuleRoundedCorners.BringToFront();
}
else
{
this.lblMenuTitle.Visible = false;
}
}
/// <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 (Menu_Item menu_Item in _menuItemList)
{
menu_Item.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)
{
CornerLab corLab = _quickPageHeaders[key];
corLab.Visible = true;
if (string.IsNullOrWhiteSpace(items["amount"] + ""))
{
corLab.Visible = false;
}
else
{
corLab.SetMenuNum(int.Parse(items["amount"] + ""));
}
}
}
}
foreach (string key in countSqls.Keys)
{
Menu_Item menuItem = this._menuItemList.Cast<Menu_Item>().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))
{
menuItem.SetMenuNum(int.Parse(num));
}
}
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;
Menu_Item menuItem = null;
// 存在menuid则按照menuid来匹配数据,否则按照moduleid来匹配数据
if (!string.IsNullOrWhiteSpace(menuId))
{
menuItem = this._menuItemList.Cast<Menu_Item>().FirstOrDefault(x => x.Name == menuId);
}
else
{
try
{
menuItem = this._menuItemList.Cast<Menu_Item>().FirstOrDefault(x => (x.GetButton().Tag as string[])[1] == moduleId);
}
catch (Exception ex)
{
MessageUtil.Show(ex);
}
}
int markNum = 0;
if (menuItem != null && int.TryParse(num, out markNum))
menuItem.SetMenuNum(markNum);
}
DataRow rowItem = this._allMenus.Rows.OfType<DataRow>().FirstOrDefault(x => SystemInfo.Instance.HeadMenuId == x["menuid"] + "");
if (rowItem == null) return;
string countSql = string.Empty;
string number = string.Empty;
if (rowItem.Table.Columns.Contains("PurviewId"))
{
string DllCoid = rowItem["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(rowItem["MenuId"] + "", ERPInfo.Instance.UserId);
}
defaultModuleRoundedCorners.SetMenuNum_special(!string.IsNullOrWhiteSpace(number) && !number.Equals("0") ? int.Parse(number) : 0);
defaultModuleRoundedCorners.Visible = !string.IsNullOrWhiteSpace(number) && !number.Equals("0") ? true : false;
});
}
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.moduleWebView1.Navigate(ReplaceHelper.ReplaceUserInfo(SystemInfo.Instance.DesktopUrl));
}
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>
/// <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;
Manager.OpenModule(item["LMenuId"] + "", item["DllShowCaption"] + "", item["ObjDll"] + "", item["LinkModeTag"] + "", item["PurviewId"] + "");
}
}
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 as DataRow;
DataRow item_after = after.Tag as DataRow;
if (item_before != null)
{
List<Menu_Item> beforeButtons = new List<Menu_Item>();
List<Menu_Item> afterButtons = new List<Menu_Item>();
if (isFlowLayout)
{
pl_center_main_middle_FlowLayout.Hide();
}
else
{
this.pl_center_main_middle.Hide();
}
// 隐藏控件
if (_menus.TryGetValue(item_before["menustruct"] + "", out beforeButtons))
{
foreach (Menu_Item item in beforeButtons)
{
item.Visible = false;
}
}
// 显示控件
if (_menus.TryGetValue(item_after["menustruct"] + "", out afterButtons))
{
foreach (Menu_Item item in afterButtons)
{
item.Visible = true;
}
}
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
finally
{
if (isFlowLayout)
{
pl_center_main_middle_FlowLayout.Show();
}
else
{
this.pl_center_main_middle.Show();
}
}
}
/// <summary>
/// 功能图标打开模块
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void OnMenuItemClick(object sender, EventArgs e)
{
try
{
Button item = (Button)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-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
{
pl_center_main_middle.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_Item menu = new Menu_Item();
menu.Name = item["menuid"] + "";
menu.Size = new Size(menuWidth, menuHeight);
menu.Location = new Point(menuLeft, menuTop);
menu.SetMenuCaption(item["menuCaption"] + "");
menu.SetRoundRadius = 20;
menu.GetButton().Tag = new string[] { item["DllFileName"] + "", item["PurviewId"] + "", item["MenuId"] + "", item["UrlParams"] + "", item["SubSysId"] + "", item["menucaption"] + "" };
menu.GetButton().Click += OnMenuItemClick;
try
{
menu.SetMenuImg(Image.FromFile(defaultImg));
}
catch (Exception)
{
menu.SetMenuImg(Resources.default_icon);
}
// 116
menuLeft += Convert.ToInt32(1.20 * 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_Item)
// {
// 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 (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;
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();
bool isclose = true;
try
{
//BaseForm baseForm = form as BaseForm;
isclose = m.IsClose;
}
catch (Exception)
{
}
if (isclose)
{
tabMain.TabPages.Remove(tabPage);
Manager.ModuleForms.Remove(m.Tag + "");
}
//审核双击打开界面关闭后回到双击界面
XtraTabPage beforePage = m.BeforePage;
if (beforePage != null)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
{
if (tablepage == beforePage)
{
ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
}
}
}
}
}
}
}
catch (Exception ex)
{
LogHelper.Instance.WriteError(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 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 (!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"] + "";
if (!ToLoginMatching(serverIP, dbName, dataBook, btnSubItem.Text))
{
MessageUtil.Show("切换账套失败");
DataRow dr = dt.Rows[0];
ToLoginMatching(dr["IP"] + "", dr["DBName"] + "", dr["ShowName"] + "", AccountBookOld);
}
//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);
}
}
private bool ToLoginMatching(string serverIP, string dbName, string dataBook, string AccountBook)
{
try
{
DBConfig.Instance.DataBook = dataBook;
DBConfig.Instance.ServerName = serverIP;
DBConfig.Instance.DataBase = dbName;
if (!DBConfig.Instance.CreateConnection())
{
MessageUtil.Show(ResourceKeys.ServerAddressFault);
return false;
}
else
{
if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection())) == 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.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.LoginAccount + "'");//找到所有UserNAme或UserCode为xxx的用户
DataRow drRow = drRows[0];
if (SystemInfo.Instance.SpecialSwitchingCover)
{
drRows = table.Select("UserCode='" + ERPInfo.Instance.LoginAccount + "'");//找到所有UserCode为xxx的用户
drRow = drRows[0];
if (drRow != null)
{
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)
{
ERPInfo.Instance.UserId = drRow["UserId"] + "";
ERPInfo.Instance.UserName = drRow["UserName"] + "";
}
Manager.ReStartMain(!SystemInfo.Instance.IsChangeZTReturnMainForm);
return true;
}
}
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);
}
}
/// <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>
/// 页面刷新角标
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnSelectedPageChanged(object sender, TabPageChangedEventArgs e)
{
try
{
if (!SystemInfo.Instance.RefreshNotify)
{
XtraTabPage tabPage = this.tabMain.SelectedTabPage;
if (tabPage.TabIndex == 0)
{
Thread thread = new Thread(SetNotifys);
thread.IsBackground = true;
thread.Start();
}
}
}
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;
}
}
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 OnLayoutSizeChanged()
{
for (int i = 0; i < pl_center_main_bottom_left_main.RowCount - 1; i++)
{
try
{
SimpleControl simpleControl = (SimpleControl)pl_center_main_bottom_left_main.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;
}
pl_center_main_bottom_left_main.RowStyles[i].SizeType = SizeType.Absolute;
if (simpleControl.IsNextLine)
{
pl_center_main_bottom_left_main.RowStyles[i].Height = 50;
}
else
{
pl_center_main_bottom_left_main.RowStyles[i].Height = 25;
}
}
}
catch (Exception)
{
}
}
for (int i = 0; i < pl_center_main_bottom_right_main.RowCount - 1; i++)
{
try
{
SimpleControl simpleControl = (SimpleControl)pl_center_main_bottom_right_main.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;
}
pl_center_main_bottom_right_main.RowStyles[i].SizeType = SizeType.Absolute;
if (simpleControl.IsNextLine)
{
pl_center_main_bottom_right_main.RowStyles[i].Height = 50;
}
else
{
pl_center_main_bottom_right_main.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;
}
}
}
}