/***********************
* 说明:主窗体界面的构建
* 创建人:龚宇超
* 创建日期:
* 修改人:
* 修改日期:
* 修改备注:
* 版本: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.Main3.Model;
using Lskj.Util;
using System.IO;
using Lskj.Data;
using DevExpress.XtraTab;
using DevExpress.XtraTab.ViewInfo;
using DevExpress.XtraEditors;
using Lskj.Core;
using System.Net;
using DevExpress.LookAndFeel;
using Lskj.Main3.Properties;
namespace Lskj.Main3.Control
{
public partial class MainPanelControlEx : UserControl
{
#region 公有属性
///
/// 屏幕dpix、dpiy
///
public float DpiX, DpiY;
public int plTopHeight
{
get { return plTop.Height; }
}
///
/// 最大化回调
///
public event EventHandler OnMaxButtonCallBack;
///
/// 最小化回调
///
public event EventHandler OnMinButtonCallBack;
///
/// 关闭回调
///
public event EventHandler OnCloseButtonCallBack;
///
/// 顶部双击回调
///
public event EventHandler OnTopPanelMouseDoubleClickCallBack;
///
/// Occurs when [on top mouse down callback].
///
public event MouseEventHandler OnTopMouseDownCallback;
///
/// Occurs when [on top mouse up call back].
///
public event MouseEventHandler OnTopMouseUpCallBack;
///
/// Occurs when [on top mouse move call back].
///
public event MouseEventHandler OnTopMouseMoveCallBack;
///
/// 窗口状态
///
public FormWindowState State;
#endregion
#region 私有属性
private bool _firstSubItemFocus;
private bool _firstAccountsFocus;
///
/// 模块sql
///
private string _menuSql;
///
/// 权限条件
///
private string _purviewCond = string.Empty;
///
/// 上次点击的按钮
///
private Button _lastMenuButton;
///
/// 当前配置的模块
///
private DataTable _allMenus = new DataTable();
///
/// 子系统菜单
///
private DataTable _subItemMenu;
///
/// 缓存菜单控件
///
private Dictionary> _menus = new Dictionary>();
///
/// 缓存菜单
///
private List _menuItemList = new List();
///
/// 第一个menuItem
///
private ToolStripMenuItem _firstMenuItem;
///
/// 上次点击的菜单
///
private ToolStripMenuItem _lastMenuItem;
///
/// 子系统小窗口
///
private SubItemForm _subItemForm;
///
/// 套账小窗口
///
private SubItemForm _accountsItemForm;
///
/// 判断消息框是否加载完成
///
private bool _isFinish = true;
///
/// 分辨率选择小窗口
///
private ResSelectForm _resSelectForm = new ResSelectForm();
private Dictionary _quickPageHeaders = new Dictionary();
#endregion
#region 初始加载
public MainPanelControlEx()
{
InitializeComponent();
}
///
/// 说明:初始加载时
/// 创建人 龚宇超
/// 创建日期:2018-04-24
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
public void OnLoad()
{
try
{
WaitForm.ShowForm();
this.toolStripLabel1.Text = "版本号:" + SystemInfo.Instance.Version;
this.SetDesktop();
this.SetFormObject();
this.SetTopMenus();
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;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
finally
{
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
////移动实现模块位置到中间
//int remainingWidth = this.Width - this.lueUserName.Width - this.pic_search.Width;
//this.lueUserName.Left = this.Width / 2 - ((this.lueUserName.Width + this.pic_search.Width) / 2);
//this.pic_search.Left = this.lueUserName.Left + this.lueUserName.Width;
WaitForm.HideForm();
Manager.frmHeight = Screen.PrimaryScreen.WorkingArea.Height - this.plTopHeight;
//this.Information_timer.Start();
}
}
///
/// 说明:加载速度优化
/// 创建人:唐德馨
/// 创建日期:2021-09-03
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
///
///
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
if (Lskj.Control.Model.AutoSizeChange.value != 1)
{
cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
else
return cp;
}
}
///
/// 刷新上一次切换的页面
///
//private void SetLastFormObject()
//{
// try
// {
// if (Manager.LastModuleForm != null)
// {
// int num = Manager.LastModuleForm.Count;
// if (num > 0)
// {
// DllModule model = Manager.LastModuleForm[num - 1];
// DataRow[] rowItems = this._allMenus.Select("MenuId=" + model.Id);
// Manager.ModuleForms.Clear();
// Manager.LastModuleForm.Clear();
// if (rowItems != null && rowItems.Length > 0)
// {
// DataRow rowItem = rowItems[0];
// Manager.TabMain = this.tabMain;
// Manager.OpenModule(rowItem["menuId"] + "", rowItem["MenuCaption"] + "", rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["UrlParams"] + "");
// }
// }
// }
// }
// catch (Exception)
// {
// throw;
// }
//}
///
/// 说明:设置主界面控件值
/// 创建人:龚宇超
/// 创建日期:2017-08-15
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void SetFormObject()
{
this.lbUserName.Text = ERPInfo.Instance.UserName;
this.tsmi_userName.Text = "用户名:" + 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 = SystemInfo.Instance.ClientName;
this.pl_top_left.BackgroundImage = BitMapHelper.getBitmap(BitMapEnum.logobg);
this.ResetPanelWidth();
}
///
/// 说明:子系统快捷窗口
/// 创建人:龚宇超
/// 创建日期:2018-08-09
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void SetSubItemForm()
{
//添加子系统快捷窗口
_subItemForm = new SubItemForm();
_subItemForm.Location = new Point(180, 40);
this.Controls.Add(_subItemForm);
_subItemForm.BringToFront();
_subItemForm.OnbtnSubItemClick += new EventHandler(OnSubItemClick);
_subItemForm.LostFocus += new EventHandler(OnSubFormLostFocus);
_subItemForm.SetDataSource(GetSubItem());
}
///
/// 说明:切换账套快捷窗口
/// 创建人:王一帆
/// 创建日期:2019-12-09
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void SetAccounts()
{
string condition = string.Format("where ShowName !='{0}'", ERPInfo.Instance.AccountBook);
//获取套账表格
DataTable dt = MainImpl.GetLedgerList(condition);
if (dt.Rows.Count == 0)
{
this.button4.Visible = false;
this.label1.Visible = false;
}
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);
}
}
///
/// 说明:初始化窗口大小
/// 创建人:龚宇超
/// 创建日期:2018-03-05/para>
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void FrmMain_Resize(object sender, EventArgs e)
{
try
{
this.CalcPopupLocation();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:计算弹出账套控件位置
/// 创建人:龚宇超
/// 创建日期:2018-03-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void CalcPopupLocation()
{
this._accountsItemForm.Parent = this.GetParent(this.Parent);
Form form = this._accountsItemForm.Parent as Form;
if (form != null)
{
int iTop = this.label1.Top + this.label1.Height;
int iLeft = this.label1.Left;
System.Windows.Forms.Control ctr = this.Parent;
while (ctr != form)
{
iTop += ctr.Top;
iLeft += ctr.Left;
ctr = ctr.Parent;
}
if (ctr.Height > 100)
{
if (iTop + this.label1.Height + this._accountsItemForm.Height > ctr.Height)
{
if (iTop - this.label1.Height > ctr.Height - iTop)
{
if (this._accountsItemForm.Height > iTop - this.label1.Height)
{
this._accountsItemForm.Height = iTop - this.label1.Height;
iTop = 0;
}
else
{
iTop = iTop - this.label1.Height - this._accountsItemForm.Height;
}
}
else
{
this._accountsItemForm.Height = ctr.Height - iTop - 30;
}
}
if (iLeft + this._accountsItemForm.Width > ctr.Width)
{
if (iLeft + this.label1.Width > ctr.Width - iLeft)
{
if (this._accountsItemForm.Width > iLeft + this.label1.Width)
{
this._accountsItemForm.Width = iLeft + this.label1.Width;
iLeft = 0;
}
else
iLeft = iLeft + this.label1.Width - this._accountsItemForm.Width;
}
else
this._accountsItemForm.Width = ctr.Width - iLeft - 30;
}
this._accountsItemForm.Left = (iLeft + (this.Width - this.pl_top_right.Width) + this.label1.Width / 2) - _accountsItemForm.Width / 2;
this._accountsItemForm.Top = iTop;
}
this._accountsItemForm.BringToFront();
}
}
///
/// 说明:获取顶层窗口
/// 创建人:龚宇超
/// 创建日期:2018-03-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// Control.
private Form GetParent(System.Windows.Forms.Control ctr)
{
if (ctr == null) return null;
return ctr is Form ? ctr as Form : GetParent(ctr.Parent);
}
///
/// 说明:设置左侧菜单
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void SetMenus()
{
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);
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; // 内容区域宽度-右侧快捷栏宽度
string defaultParentMenu = string.Empty;
NewMenuBar.PanelHoverEventHandler 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().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);
NewMenuBar button = new NewMenuBar();
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.GetNewMenuBar().labelTitle.Text = item["menucaption"] + "";
button.GetNewMenuBar().Tag = item;
// 注册事件
hoverEvent += new NewMenuBar.PanelHoverEventHandler(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());
}
}
}
// 加载右侧模块
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;
}
pl_center_main.Controls.Add(menu);
List controls = new List();
if (_menus.TryGetValue(menuStruct.Substring(0, 2), out controls))
{
controls.Add(menu);
}
this._menuItemList.Add(menu);
}
}
}
}
///
/// 说明:设置筛选模块
/// 创建人:龚宇超
/// 创建日期:2017-11-20
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void SetSearchMenus()
{
lueUserName.ValueMember = lueUserName.ValueField = "MenuId";
lueUserName.TextMember = "SearchMenuCaption";
lueUserName.SourceSQL = this._menuSql;
lueUserName.DataSource = this._allMenus.Select("len(MenuStruct)=4").CopyToDataTable();
}
///
/// 说明:设置快捷通道
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
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");
// 显示我的操作通道
for (int i = 0; i < baseTable.Count(); i++)
{
DataRow item = baseTable[i];
if (i > 0)
{
top += height;
}
height = 30;
// 前方箭头
PictureBox pic = new PictureBox();
pic.BackgroundImage = Resources.arrows;
pic.Size = new Size(16, 16);
pic.Location = new Point(left, top);
Label label = new Label();
label.Location = new Point(left + 20, top - 3);
label.Text = item["DllShowCaption"] + "";
label.Font = new Font("微软雅黑", 10);
label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
label.Tag = item;
label.MouseMove += OnLabelMouseMove;
label.MouseLeave += OnLabelMouseLeave;
label.MouseClick += OnLabelMouseClick;
label.MaximumSize = new Size(100, 0);
label.AutoSize = true;
CornerLab corneLab = new CornerLab();
corneLab.Location = new Point(left - 5, top - 5);
corneLab.Visible = false;
if (label.PreferredHeight > height)
{
height = label.PreferredHeight + 10;
}
pl_center_main_bottom_left_main.Controls.Add(pic);
pl_center_main_bottom_left_main.Controls.Add(label);
pl_center_main_bottom_left_main.Controls.Add(corneLab);
_quickPageHeaders.Add(label.Text, corneLab);
corneLab.BringToFront();
}
top = 10; height = 30;
// 显示我的报表通道
for (int i = 0; i < reportTable.Count(); i++)
{
DataRow item = reportTable[i];
if (i > 0)
{
top += height;
}
height = 30;
// 前方箭头
PictureBox pic = new PictureBox();
pic.BackgroundImage = Resources.arrows;
pic.Size = new Size(16, 16);
pic.Location = new Point(left, top);
Label label = new Label();
label.Location = new Point(left + 20, top - 3);
label.Text = item["DllShowCaption"] + "";
label.Font = new Font("微软雅黑", 10);
label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
label.Tag = item;
label.MouseMove += OnLabelMouseMove;
label.MouseLeave += OnLabelMouseLeave;
label.MouseClick += OnLabelMouseClick;
label.MaximumSize = new Size(100, 0);
label.AutoSize = true;
CornerLab corneLab = new CornerLab();
corneLab.Location = new Point(left - 5, top - 5);
corneLab.Visible = false;
if (label.PreferredHeight > height)
{
height = label.PreferredHeight + 10;
}
pl_center_main_bottom_right_main.Controls.Add(pic);
pl_center_main_bottom_right_main.Controls.Add(label);
pl_center_main_bottom_right_main.Controls.Add(corneLab);
if (!_quickPageHeaders.ContainsKey(label.Text)) _quickPageHeaders.Add(label.Text, corneLab);
corneLab.BringToFront();
}
}
#region
///
/// 说明:重绘圆角
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void MenuItem_Paint(object sender, PaintEventArgs e)
{
try
{
System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
int x = 0;
int y = 0;
int thisWidth = this.Width;
int thisHeight = this.Height;
int angle = 20;
if (angle > 0)
{
System.Drawing.Graphics g = CreateGraphics();
oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角
oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角
oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角
oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角
oPath.CloseAllFigures();
Region = new System.Drawing.Region(oPath);
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
///
/// 说明:获取子系统小窗口内容
/// 创建人:龚宇超
/// 创建日期:2018-08-02
/// 修改人:`
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private DataRow[] GetSubItem()
{
DataRow[] rows = _subItemMenu.Select(string.Format("SubSysId <>'{0}'", ERPInfo.Instance.SubSysId));
return rows;
}
///
/// 说明:左菜单初始化(左边为树)
/// 创建人:龚宇超
/// 创建日期:2018-04-24
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void InitLeftMenu()
{
DataTable dtLvTree = MainImpl.GetLeftTreeView();
tv_left.ParentField = "speciesno";
tv_left.ParentKeyLength = 2;
tv_left.TextField = "speciesname";
tv_left.OnButtonClickEvent += new TreeViewCustom.ButtonClickEventHandler(OnMenuButtonClick);
tv_left.SetDataSource(dtLvTree);
}
///
/// 说明:加载顶部菜单
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void SetTopMenus()
{
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);
ToolStripMenuItem mainItem = new ToolStripMenuItem();
//mainItem.Text = "切换系统";
mainItem.Text = ERPInfo.Instance.SubSysName;
//menuItem.Tag = subSysId;
mainItem.Font = new Font("微软雅黑", 12);
mainItem.BackColor = Color.Transparent;
mainItem.ForeColor = Color.White;
mainItem.DropDownClosed += new EventHandler(OnMenuItemDropDownClosed);
mainItem.DropDownOpened += new EventHandler(OnMenuItemDropDownOpened);
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);
menuItem.Click += new EventHandler(OnToolStripMenuItemClick);
DataTable subTable = new DataTable();
try
{
subTable = _allMenus.Rows.Cast().Where(x => x["subsysid"] + "" == subSysId && (x["MenuStruct"] + "").Length == 2).CopyToDataTable();
}
catch (Exception)
{
}
if (subTable != null && subTable.Rows.Count > 0)
{
foreach (DataRow row in subTable.Rows)
{
string menuStruct = row["MenuStruct"] + "";
string menuCaption = row["MenuCaption"] + "";
ToolStripMenuItem subItem = new ToolStripMenuItem(menuCaption);
subItem.Font = new Font("微软雅黑", 10);
// 功能模块
try
{
DataTable childs = new DataTable();
try
{
childs = _allMenus.Rows.Cast().Where(x => x["subsysid"] + "" == subSysId && (x["MenuStruct"] + "").Length == 4 && (x["MenuStruct"] + "").Substring(0, 2) == menuStruct).CopyToDataTable();
}
catch (Exception)
{
}
if (childs != null && childs.Rows.Count > 0)
{
hasMenu = true;
foreach (DataRow child in childs.Rows)
{
ToolStripMenuItem childItem = new ToolStripMenuItem();
childItem.Text = child["MenuCaption"] + "";
childItem.Font = new Font("微软雅黑", 10);
childItem.Tag = new string[] { child["DllFileName"] + "", child["PurviewId"] + "", child["MenuId"] + "", child["UrlParams"] + "", subSysId + "", child["MenuCaption"] + "" };
childItem.Click += OnItemClick;
subItem.DropDownItems.Add(childItem);
}
menuItem.DropDownItems.Add(subItem);
}
}
catch (Exception ex)
{
MessageUtil.Show(ex);
}
}
if (hasMenu)
{
//menuMain.Items.Add(menuItem);
mainItem.DropDownItems.Add(menuItem);
//获取有权限的系统
_subItemMenu.ImportRow(item);
}
}
}
menuMain.Items.Add(mainItem);
}
}
private void OnToolStripMenuItemClick(object sender, EventArgs e)
{
if (sender != null)
{
ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
//修改最外层名字
menuItem.OwnerItem.Text = menuItem.Text;
//切换左侧模块
ERPInfo.Instance.SubSysName = menuItem.Text;
ERPInfo.Instance.SubSysId = menuItem.Tag as string;
Manager.ReStartMain(true);
}
}
///
/// 说明:加载默认模块
/// 创建人:龚宇超
/// 创建日期:2018-03-22
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void SetDefaultMenu()
{
// 加载默认模块
DataRow rowItem = this._allMenus.Rows.OfType().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;
}
else
{
this.lblMenuTitle.Visible = false;
}
}
///
/// 说明:获取通知表数据
/// 创建人:龚宇超
/// 创建日期:2018-04-17
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The subsysid.
private void SetNotifys()
{
try
{
this.Invoke((EventHandler)delegate
{
if (this._menuItemList == null || this._menuItemList.Count == 0) return;
DataTable notifys = MainImpl.GetNotifys(ERPInfo.Instance.SubSysId, ERPInfo.Instance.UserId);
DataTable ShortcutDt = MainImpl.GetGallerysByUserIdAndReviewAmount();
foreach (Menu_Item menu_Item in _menuItemList)
{
menu_Item.SetMenuNum(0);
}
if (ShortcutDt != null)
{
foreach (string key in _quickPageHeaders.Keys)
{
DataRow items = ShortcutDt.Rows.Cast().FirstOrDefault(x => x["DllShowCaption"].ToString() == key);
if (items != null)
{
CornerLab corLab = _quickPageHeaders[key];
corLab.Visible = true;
if (string.IsNullOrWhiteSpace(items["amount"] + ""))
{
corLab.Visible = false;
}
else
{
corLab.SetMenuNum(int.Parse(items["amount"] + ""));
}
}
}
}
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().FirstOrDefault(x => x.Name == menuId);
}
else
{
try
{
menuItem = this._menuItemList.Cast().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);
}
});
}
catch (Exception)
{
throw;
}
}
///
/// 解析DNS
///
private void SetHostEntry()
{
try
{
this.InitHostEntryField();
string sqlValue = "select DnsHostEntry from p_systemtab";
DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue);
if (dtTable != null && dtTable.Rows.Count > 0)
{
string dnsHostEntry = dtTable.Rows[0]["DnsHostEntry"] + "";
string startHost = dnsHostEntry.Substring(0, dnsHostEntry.IndexOf("."));
int startNumber = 0;
if (!string.IsNullOrWhiteSpace(dnsHostEntry) && !Int32.TryParse(startHost, out startNumber))
{
string ipAddress = Dns.GetHostEntry(dnsHostEntry).AddressList[0] + "";
sqlValue = string.Format("update p_systemtab set InternetIP = '{0}'", ipAddress);
int result = SqlHelper.ExecuteNonQuery(sqlValue);
}
}
}
catch (Exception)
{
}
}
///
/// 说明:设置我的桌面
/// 创建人:龚宇超
/// 创建日期:
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void SetDesktop()
{
if (!string.IsNullOrEmpty(SystemInfo.Instance.DesktopUrl))
{
this.xtpDesktop.PageVisible = true;
this.moduleWebView1.Navigate(ReplaceHelper.ReplaceUserInfo(SystemInfo.Instance.DesktopUrl));
}
else
{
this.xtpDesktop.PageVisible = false;
}
}
///
/// 初始化系统DNS字段
///
private void InitHostEntryField()
{
try
{
// 创建DNS字段
string sqlValue = "alter table p_systemtab add DnsHostEntry varchar(50)";
int result = SqlHelper.ExecuteNonQuery(sqlValue);
sqlValue = "update p_systemtab set DnsHostEntry = InternetIP";
result = SqlHelper.ExecuteNonQuery(sqlValue);
}
catch (Exception)
{
}
}
#endregion
#region 顶部菜单相关
///
/// 说明:菜单展开后
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnMenuItemDropDownOpened(object sender, EventArgs e)
{
try
{
ToolStripMenuItem menuItem = (sender as ToolStripMenuItem);
if (menuItem != null)
{
menuItem.ForeColor = Color.Black;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:菜单关闭后
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnMenuItemDropDownClosed(object sender, EventArgs e)
{
try
{
ToolStripMenuItem menuItem = (sender as ToolStripMenuItem);
if (menuItem != null)
{
menuItem.ForeColor = Color.White;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:顶部菜单打开模块
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnItemClick(object sender, EventArgs e)
{
try
{
ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
string[] arr = (string[])menuItem.Tag;
Manager.TabMain = this.tabMain;
Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
Manager.OpenModule(arr[2], arr[5], arr[0], arr[1], arr[3]);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 快捷通道相关
///
/// 说明:快捷通道功能鼠标离开时
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
public void OnLabelMouseLeave(object sender, EventArgs e)
{
try
{
Label label = sender as Label;
label.Font = new Font("微软雅黑", label.Font.SizeInPoints);
label.ForeColor = ColorTranslator.FromHtml("#0a57a7");
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:快速通道鼠标移动时
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
public void OnLabelMouseMove(object sender, MouseEventArgs e)
{
try
{
Label label = sender as Label;
label.Font = new Font("微软雅黑", label.Font.SizeInPoints, FontStyle.Bold | FontStyle.Underline);
label.ForeColor = ColorTranslator.FromHtml("#1ba109");
this.Cursor = Cursors.Hand;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:快捷通道打开模块
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
public void OnLabelMouseClick(object sender, MouseEventArgs e)
{
try
{
Label label = sender as Label;
DataRow item = label.Tag as DataRow;
if (item != null)
{
Manager.TabMain = this.tabMain;
Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
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 功能菜单相关
///
/// 说明:切换模块
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The before.
/// The after.
public void OnTriggerMenu(NewMenuBar before, NewMenuBar after)
{
try
{
if (before != null)
{
DataRow item_before = before.Tag as DataRow;
DataRow item_after = after.Tag as DataRow;
if (item_before != null)
{
List beforeButtons = new List();
List afterButtons = new List();
// 隐藏控件
if (_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);
}
}
///
/// 功能图标打开模块
///
///
///
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);
}
}
///
/// 说明:打开模块
/// 创建人:龚宇超
/// 创建日期:2018-01-27
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnMenuTitleClick(object sender, EventArgs e)
{
try
{
Label item = (Label)sender;
string[] arr = (string[])item.Tag;
Manager.TabMain = this.tabMain;
Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
Manager.OpenModule(arr[2], arr[5], arr[0], arr[1], arr[3]);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:左菜单树点击事件
/// 创建人:龚宇超
/// 创建日期:2018-04-25
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void OnMenuButtonClick(Button button)
{
try
{
if (this._lastMenuButton != button && tabMain.TabPages.Count > 2)
{
if (MessageUtil.Show(ResourceKeys.ChangeMenu, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
int count = tabMain.TabPages.Count;
for (int i = count; i > 0; i--)
{
XtraTabPage item = tabMain.TabPages[i - 1];
string guid = item.Tag + "";
if (Manager.ModuleForms.ContainsKey(guid))
{
DllModule m = Manager.ModuleForms[guid];
tabMain.TabPages.Remove(item);
Manager.ModuleForms.Remove(m.Id);
}
}
}
else
{
return;
}
}
this.lblSubTitle.Text = SystemInfo.Instance.ClientName + "-" + button.Text;
this.pl_top_left.Width = this.lblSubTitle.Width + 50;
this._lastMenuButton = button;
ERPInfo.Instance.GroupId = (_lastMenuButton.Tag as DataRow)["smid"] + "";
OnMenuTopItemClick(_firstMenuItem, null);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:上菜单按钮点击事件
/// 创建人:龚宇超
/// 创建日期:2018-04-24
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void OnMenuTopItemClick(object sender, EventArgs e)
{
try
{
ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
if (menuItem == null || _lastMenuButton == null || _lastMenuItem == menuItem) return;
this._lastMenuItem = menuItem;
DataRow row = menuItem.Tag as DataRow;
DataTable dtChilds = MainImpl.GetChildsMenu(row["subsysid"] + "", row["MenuStruct"] + "", _purviewCond);
//位置设置
int buttonTop = Convert.ToInt32(0.05 * DpiY); // 按钮上边距
int menuLeft = Convert.ToInt32(0.05 * DpiY), menuTop = Convert.ToInt32(0.05 * DpiY); // 模块距离左边距,模块距离顶部边距
int menuWidth = Convert.ToInt32(1.14 * DpiX), menuHeight = Convert.ToInt32(1.32 * DpiY); // 模块宽度,模块高度
int centerWidth = pl_center_main.Width - pl_center_main_right.Width; // 内容区域宽度-右侧快捷栏宽度
pl_center_main.Controls.Clear();
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);
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 重置界面宽度高度
///
/// 说明:计算快速通道宽度
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void ResetPanelWidth()
{
pl_center_main_bottom_left.Height = pl_center_main_bottom_right.Height = pl_center_main_right.Height / 2;
}
///
/// 说明:重新计算菜单显示位置
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void ResetMenuLocation()
{
//int menuLeft = 5, menuTop = 5; // 模块距离左边距,模块距离顶部边距
//int menuWidth = 110, menuHeight = 127; // 模块宽度,模块高度
//int centerWidth = pl_center_main.Width - pl_center_main_right.Width; // 内容区域宽度-右侧快捷栏宽度
//string defaultParentMenu = string.Empty;
//foreach (DataRow item in dtSubMenus.Rows)
//{
// defaultParentMenu = dtSubMenus.Rows[0]["menustruct"] + "";
// string menuStruct = item["menustruct"] + "";
// string menuCaption = item["menucaption"] + "";
// string menuid = item["menuid"] + "";
// if (menuStruct.Length == 2)
// {
// menuLeft = 5; menuTop = 5;
// }
// 加载右侧模块
// if (menuStruct.Length == 4)
// {
// Control[] ctrs = pl_center_main.Controls.Find(menuid, true);
// if (ctrs != null && ctrs.Length > 0)
// {
// if (ctrs[0] is Menu_Item)
// {
// ctrs[0].Location = new Point(menuLeft, menuTop);
// menuLeft += 116;
// 换行显示
// if (menuLeft + menuWidth > centerWidth)
// {
// menuLeft = 5;
// menuTop += menuHeight;
// }
// }
// }
// }
//}
}
#endregion
#region 窗口拖动行为
///
/// 说明:鼠标双击最大化、还原
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnTopMouseDoubleClick(object sender, MouseEventArgs e)
{
try
{
if (OnTopPanelMouseDoubleClickCallBack != null)
{
OnTopPanelMouseDoubleClickCallBack(null, null);
btnMax.BackgroundImage = this.State == FormWindowState.Normal ? Resources.max_default : Resources.window_default;
this.ResetPanelWidth();
this.ResetMenuLocation();
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:鼠标按下
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnTopMouseDown(object sender, MouseEventArgs e)
{
try
{
if (this.OnTopMouseDownCallback != null)
this.OnTopMouseDownCallback(sender, e);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:鼠标放开
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnTopMouseUp(object sender, MouseEventArgs e)
{
try
{
if (this.OnTopMouseUpCallBack != null)
this.OnTopMouseUpCallBack(sender, e);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:鼠标移动
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnTopMouseMove(object sender, MouseEventArgs e)
{
try
{
if (this.OnTopMouseMoveCallBack != null)
this.OnTopMouseMoveCallBack(sender, e);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 最小化相关
///
/// 说明:最小化按钮点击
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnMinClick(object sender, EventArgs e)
{
try
{
if (OnMinButtonCallBack != null)
{
OnMinButtonCallBack(null, null);
}
this.ResetPanelWidth();
this.ResetMenuLocation();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:最小化鼠标离开时
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnMinMouseLeave(object sender, EventArgs e)
{
try
{
btnMin.BackgroundImage = Resources.smail_default;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:最小化鼠标移动时
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnMinMouseMove(object sender, MouseEventArgs e)
{
try
{
btnMin.BackgroundImage = Resources.smail_select;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 最大化相关
///
/// 说明:最大化点击
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnMaxClick(object sender, EventArgs e)
{
try
{
if (OnMaxButtonCallBack != null)
{
OnMaxButtonCallBack(null, null);
btnMax.BackgroundImage = this.State == FormWindowState.Normal ? Resources.max_default : Resources.window_default;
this.ResetPanelWidth();
this.ResetMenuLocation();
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:最大化鼠标离开时
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnMaxMouseLeave(object sender, EventArgs e)
{
try
{
if (this.State == FormWindowState.Normal)
{
btnMax.BackgroundImage = Resources.max_default;
}
else
{
btnMax.BackgroundImage = Resources.window_default;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:最大化鼠标移动时
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnMaxMouseMove(object sender, MouseEventArgs e)
{
try
{
if (this.State == FormWindowState.Normal)
{
btnMax.BackgroundImage = Resources.max_select;
}
else
{
btnMax.BackgroundImage = Resources.window_select;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 关闭相关
///
/// 说明:关闭事件
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnCloseClick(object sender, EventArgs e)
{
try
{
if (ERPInfo.Instance.SubMenuCount == 1)
{
if (MessageUtil.Show(ResourceKeys.IsExit, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
OnCloseButtonCallBack(null, null);
}
}
else
{
OnCloseButtonCallBack(null, null);
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:关闭按钮离开时
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnCloseMouseLeave(object sender, EventArgs e)
{
try
{
btnClose.BackgroundImage = Resources.close_default;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:关闭按钮移动时
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnBtnCloseMouseMove(object sender, MouseEventArgs e)
{
try
{
btnClose.BackgroundImage = Resources.close_select;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:关闭tabpage窗口
/// 创建人:龚宇超
/// 创建日期:2017-09-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnTabMainClick(object sender, EventArgs e)
{
try
{
Point pt = MousePosition;
XtraTabHitInfo info = this.tabMain.CalcHitInfo(tabMain.PointToClient(pt));
if (info.HitTest == XtraTabHitTest.PageHeader && info.Page.TabIndex != 0)
{
XtraTabPage tabPage = this.tabMain.SelectedTabPage;
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();
tabMain.TabPages.Remove(tabPage);
Manager.ModuleForms.Remove(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;
}
}
}
}
}
}
}
catch (Exception ex)
{
LogHelper.Instance.WriteError(ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 用户相关
///
/// 说明:切换用户
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnSwapUserClick(object sender, EventArgs e)
{
try
{
FrmSwap frmSwap = new FrmSwap();
frmSwap.ShowDialog();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:修改密码
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnUserNameClick(object sender, EventArgs e)
{
try
{
FrmUpdatePassword frmPass = new FrmUpdatePassword();
frmPass.ShowDialog();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 换肤
///
/// 说明:打开换肤界面
/// 创建人:龚宇超
/// 创建日期:2017-09-13
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnSettingClick(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.Hand;
FrmSkins skins = new FrmSkins();
skins.ShowDialog();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:
/// 创建人:龚宇超
/// 创建日期:2017-09-13
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnSettingMouseLeave(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.Default;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 模块搜索
///
/// 说明:打开界面
/// 创建人:龚宇超
/// 创建日期:2017-12-06
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnUserNamePopupClosed(object sender, EventArgs e)
{
try
{
this.OnOpenSearchModule();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:模块搜索
/// 创建人:龚宇超
/// 创建日期:2018-04-23
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnSearchClick(object sender, EventArgs e)
{
try
{
this.OnOpenSearchModule();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:打开搜索模块
/// 创建人:龚宇超
/// 创建日期:2018-04-23
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void OnOpenSearchModule()
{
try
{
string menuId = lueUserName.EditValue;
if (!string.IsNullOrEmpty(menuId))
{
DataRow[] rowItems = this._allMenus.Select("MenuId=" + menuId);
if (rowItems != null && rowItems.Length > 0)
{
DialogResult result = MessageUtil.Show(string.Format(ResourceKeys.OpenMenuConfirm, lueUserName.Text), MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
DataRow rowItem = rowItems[0];
Manager.TabMain = this.tabMain;
Manager.MinusTheHeight = this.pl_top_center.Height + this.toolStrip1.Height;
Manager.OpenModule(menuId, rowItem["MenuCaption"] + "", rowItem["DllFileName"] + "", rowItem["PurviewId"] + "", rowItem["UrlParams"] + "");
}
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 更新角标
///
/// 说明:每隔5s取一次通知数据
/// 创建人:龚宇超
/// 创建日期:2018-04-17
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnMarkTimerTick(object sender, EventArgs e)
{
//SetNotifys();
}
#endregion
#region 子系统小窗口相关
///
/// 说明:快捷窗口中子系统点击
/// 创建人:龚宇超
/// 创建日期:2018-08-03
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
private void OnSubItemClick(object sender, EventArgs e)
{
try
{
if (sender != null)
{
SimpleButton btnSubItem = sender as SimpleButton;
ERPInfo.Instance.SubSysName = btnSubItem.Text;
ERPInfo.Instance.SubSysId = btnSubItem.Tag as string;
// Manager.LastModuleForm.Clear();
Manager.ReStartMain(true);
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:快捷窗口中子系统点击
/// 创建人:龚宇超
/// 创建日期:2018-08-03
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
private void OnAccountsClick(object sender, EventArgs e)
{
try
{
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"] + "";
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];
//DataRow drRow = table.Rows.Cast().FirstOrDefault(x => userName.Equals(x["UserName"] + ""));
if (drRow != null)
{
ERPInfo.Instance.UserId = drRow["UserId"] + "";
ERPInfo.Instance.UserName = drRow["UserName"] + "";
}
Manager.ReStartMain(true);
}
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:设置delphi参数
/// 创建人:龚宇超
/// 创建日期:2018-03-12
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
void SetDelphiDllParams()
{
try
{
StringBuilder sb1 = new StringBuilder();
sb1.Append(ERPInfo.Instance.UserName);
StringBuilder sb2 = new StringBuilder();
sb2.Append(ERPInfo.Instance.WindowName);
StringBuilder sb3 = new StringBuilder();
sb3.Append(ERPInfo.Instance.SkinName);
//给delphi库设置参数(用户id、子系统id、操作员名称、计算机名称)
DelphiHelper.Delphi_SetParams(Convert.ToInt32(ERPInfo.Instance.UserId), Convert.ToInt32(ERPInfo.Instance.SubSysId), sb1, sb2, sb3);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
LogHelper.Instance.WriteError(ex);
}
}
///
/// 说明:子系统面板弹出事件
/// 创建人:龚宇超
/// 创建日期:2018-08-02
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
private void OnTabMouseClick(object sender, MouseEventArgs e)
{
}
///
/// 说明:子系统失去焦点
/// 创建人:龚宇超
/// 创建日期:2018-08-03
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
private void OnSubFormLostFocus(object sender, EventArgs e)
{
try
{
if (!_firstSubItemFocus)
{
_subItemForm.Hide();
_subItemForm._isFocus = false;
}
_firstSubItemFocus = false;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:切换账套失去焦点
/// 创建人:王一帆
/// 创建日期:2019-12-10
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
private void OnAccountLostFocus(object sender, EventArgs e)
{
try
{
if (!_firstAccountsFocus)
{
_accountsItemForm.Hide();
_accountsItemForm._isFocus = false;
}
_firstAccountsFocus = false;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 快捷通道双击操作
///
/// 说明:快捷通道双击操作
/// 创建人:龚宇超
/// 创建日期:2018-08-13
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
private void OnShortCutDoubleClick(object sender, EventArgs e)
{
try
{
if (!string.IsNullOrEmpty(SystemInfo.Instance.ShortCutDll))
{
DelphiHelper.LoadDelphiDll(SystemInfo.Instance.ShortCutDll);
}
else
{
DelphiHelper.LoadDelphiDll("P_Lsplanes.lsp");
}
}
catch (Exception)
{
MessageUtil.Show(ResourceKeys.OpenShortCutError);
}
}
///
/// 选中切换套账
///
///
///
private void label1_Click(object sender, EventArgs e)
{
try
{
if (label1.Visible)
{
CalcPopupLocation();
_accountsItemForm.Show();
this.label1.Focus();
}
//if (!_accountsItemForm._isFocus)
//{
// _firstAccountsFocus = true;
// _accountsItemForm.Focus();
// _accountsItemForm._isFocus = true;
//}
//else
//{
// _accountsItemForm.Hide();
// _accountsItemForm._isFocus = false;
// _firstAccountsFocus = false;
//}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 隐藏账套控件
///
///
///
private void label1_LostFocus(object sender, EventArgs e)
{
try
{
_accountsItemForm.Hide();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
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);
}
}
///
/// 页面刷新角标
///
///
///
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);
}
}
}
}