ca14852308
SVN-Revision: r1108
1385 lines
58 KiB
C#
1385 lines
58 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Control;
|
|
using Lskj.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Data;
|
|
using Lskj.Business.Impl;
|
|
using DevExpress.XtraEditors;
|
|
using Lskj.Util;
|
|
using Lskj.ProductPlatform.Properties;
|
|
using System.IO;
|
|
using Lskj.Core;
|
|
using Lskj.Business;
|
|
using DevExpress.XtraGrid.Views.Base;
|
|
using System.Drawing.Imaging;
|
|
using System.Diagnostics;
|
|
using DevExpress.XtraBars;
|
|
using System.Threading;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Lskj.ProductPlatform
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
public ToolButton mBottomButton, mRightButton;
|
|
public string mMenuCode;
|
|
public bool isInit = true;
|
|
public int mPage = 1, mMaxPage = 1, mPageSize = 10;
|
|
public Font mColumnFont = new Font("微软雅黑", 12);
|
|
public Font mRowFont = new Font("微软雅黑", 12);
|
|
|
|
/// <summary>
|
|
/// 系统模块实体对象
|
|
/// </summary>
|
|
/// <value>The system model.</value>
|
|
public ModuleModel ModelObj;
|
|
/// <summary>
|
|
/// 查询条件
|
|
/// </summary>
|
|
public MyControl SearchObj;
|
|
public DynamicModel DyncModel;
|
|
/// <summary>
|
|
/// 根据天数分组
|
|
/// </summary>
|
|
public DataTable groups = new DataTable();
|
|
public DataTable mSourceTable = new DataTable();
|
|
public List<Button> mButtons = new List<Button>();
|
|
public List<Image> mButtonImage = new List<Image>();
|
|
public List<Image> mButtonGrayImage = new List<Image>();
|
|
public List<string> Timegroup = new List<string>();
|
|
|
|
public MachineSwitching machineSwitching = new MachineSwitching();
|
|
|
|
/// <summary>
|
|
/// 是否鼠标按下
|
|
/// </summary>
|
|
private bool _isMouseDown;
|
|
/// <summary>
|
|
/// 记录窗口位置
|
|
/// </summary>
|
|
private Point _mousePostion;
|
|
/// <summary>
|
|
/// 机台信息
|
|
/// </summary>
|
|
private DataTable MachineInformation = new DataTable();
|
|
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.gcMain.GridView.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(OnRowCellClick);
|
|
//this.dpbTools.ShowDropDownControl += new ShowDropDownControlEventHandler(OnDpbTools_ShowDropDownControl);
|
|
|
|
this.panelControl6.MouseDown += OnPanelMouseDown;
|
|
this.panelControl6.MouseMove += OnPanelMouseMove;
|
|
this.panelControl6.MouseUp += OnPanelMouseUp;
|
|
this.panelControl6.MouseDoubleClick += OnPanelMouseDoubleClick;
|
|
this.noticeContent.MouseDown += OnPanelMouseDown;
|
|
this.noticeContent.MouseMove += OnPanelMouseMove;
|
|
this.noticeContent.MouseUp += OnPanelMouseUp;
|
|
this.noticeContent.MouseDoubleClick += OnPanelMouseDoubleClick;
|
|
this.panelControl7.MouseDown += OnPanelMouseDown;
|
|
this.panelControl7.MouseMove += OnPanelMouseMove;
|
|
this.panelControl7.MouseUp += OnPanelMouseUp;
|
|
this.panelControl7.MouseDoubleClick += OnPanelMouseDoubleClick;
|
|
|
|
//让窗口可以捕获子控件的键盘按下事件
|
|
this.KeyPreview = true;
|
|
this.KeyDown += FrmMain_KeyDown;
|
|
}
|
|
|
|
|
|
#region 方法
|
|
/// <summary>
|
|
/// <para>说明:初始化车间切换功能</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-11-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeTeam()
|
|
{
|
|
DataRow MesTeamTable = MainImpl.MesGetTeam();
|
|
if (MesTeamTable != null)
|
|
{
|
|
this.noticeContent.Text = MesTeamTable["noticeContent"] + "";
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化车间切换功能</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-05-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeOper()
|
|
{
|
|
if (!SystemInfo.Instance.MesDepartment)
|
|
{
|
|
this.butMachineSwitch.Visible = true;
|
|
DataTable mWorkTable = MainImpl.MesGetCJ();
|
|
DataRow[] rows = mWorkTable.Select(string.Format("mc = '{0}'", ERPInfo.Instance.WorkCJ));
|
|
DataTable table = MainImpl.MesGetJT(rows[0]["dm"] + "");
|
|
MachineInformation = table.Copy();
|
|
// 车间列表
|
|
//foreach (DataRow item in table.Rows)
|
|
//{
|
|
// BarButtonItem itemCommon = new BarButtonItem();
|
|
// itemCommon.Caption = item["mc"] + "";
|
|
// itemCommon.Tag = item;
|
|
// itemCommon.ItemClick += new ItemClickEventHandler(OnCommonItemClick);
|
|
// //itemCommon.OwnFont = new Font(itemCommon.Font, (FontStyle)12);
|
|
// pMenu.AddItem(itemCommon);
|
|
|
|
//}
|
|
machineSwitching.Addmachine(table);
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-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="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SearchObj.SearchLastGrid();
|
|
this.mSourceTable = this.gcMain.GridControl.DataSourceTable();
|
|
if (mSourceTable.Rows.Count == 0) return;
|
|
if (SystemInfo.Instance.MesMainType == 1)
|
|
{
|
|
this.groups = this.mSourceTable.AsEnumerable().GroupBy(r => new { Col1 = r["Planstdt"] }).Select(g => g.OrderBy(r => r["Planstdt"]).First()).CopyToDataTable();
|
|
this.Timegroup.Clear();
|
|
foreach (DataRow item in groups.Rows)
|
|
{
|
|
Timegroup.Add(item["Planstdt"] + "");
|
|
}
|
|
this.mMaxPage = Timegroup.Count;
|
|
}
|
|
this.InitControl();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitializeControl()
|
|
{
|
|
this.lblDayName.Text = ERPInfo.Instance.WorkCJ + " " + ERPInfo.Instance.WorkJT + " " + ERPInfo.Instance.WorkBZ + " ";
|
|
string tableName = "P_SystemTab", colName = "PPMenuCode", colType = "VARCHAR(50)";
|
|
BaseImpl.HasExistsColumn(tableName, colName, colType);
|
|
BaseImpl.HasExistsColumn(tableName, "PPGridRowSize", "INT");
|
|
BaseImpl.HasExistsColumn(tableName, "PPTitle", "VARCHAR(100)");
|
|
|
|
this.mMenuCode = string.IsNullOrEmpty(ERPInfo.Instance.WorkModid) ? BaseImpl.GetResult("select PPMenuCode from P_SystemTab") + "" : ERPInfo.Instance.WorkModid;
|
|
//如果机台配置了对应的模块号,就以机台的配置为准
|
|
if (MachineInformation.Rows.Count > 0&& MachineInformation.Columns.Contains("modid"))
|
|
{
|
|
DataRow dr = MachineInformation.Select("mc='" + ERPInfo.Instance.WorkJT + "'")[0];
|
|
if (dr != null&&!string.IsNullOrWhiteSpace(dr["modid"] + "")) this.mMenuCode = dr["modid"] + "";
|
|
}
|
|
|
|
|
|
this.lblTitle.Text = BaseImpl.GetResult("select PPTitle from P_SystemTab") + "";
|
|
string pageSize = BaseImpl.GetResult("select PPGridRowSize from P_SystemTab") + "";
|
|
|
|
if (!string.IsNullOrEmpty(pageSize))
|
|
{
|
|
this.mPageSize = Convert.ToInt32(pageSize);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.mMenuCode))
|
|
{
|
|
this.ModelObj = new ModuleModel(MainImpl.GetSystemdllTab(this.mMenuCode));
|
|
if (this.ModelObj != null && !string.IsNullOrEmpty(this.ModelObj.FormKey))
|
|
{
|
|
this.ModelObj.ParmaryKey = BaseImpl.GetBasePrimaryKey(this.mMenuCode);
|
|
this.DyncModel = new DynamicModel(new string[] { this.ModelObj.MenuName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", this.mMenuCode });
|
|
// Step 0. 设置字体大小
|
|
this.gcMain.GridView.Appearance.Row.Font = mRowFont;
|
|
this.gcDetail.GridView.Appearance.Row.Font = mRowFont;
|
|
this.gcAttach.GridView.Appearance.Row.Font = mRowFont;
|
|
this.gcRight.GridView.Appearance.Row.Font = mRowFont;
|
|
|
|
this.gcMain.GridView.RowHeight = this.gcDetail.GridView.RowHeight = this.gcAttach.GridView.RowHeight = this.gcRight.GridView.RowHeight = this.ModelObj.RowHeight > 0 ? this.ModelObj.RowHeight : 40;
|
|
this.gcMain.GridView.ColumnPanelRowHeight = this.gcDetail.GridView.ColumnPanelRowHeight = this.gcAttach.GridView.ColumnPanelRowHeight = this.gcRight.GridView.ColumnPanelRowHeight = 40;
|
|
|
|
if (this.ModelObj.GridObjIsCheck == 1)//主表加载复选框
|
|
{
|
|
GridDragGrid.GridAddCheckBox(this.gcMain.GridView);
|
|
}
|
|
|
|
// Step 1. 获取模块配置信息
|
|
this.InitializeModule();
|
|
// Step 2. 获取附加配置信息
|
|
this.InitializeAttach();
|
|
// Step 3. 获取右键菜单、明细配置信息
|
|
this.InitializeToolBar();
|
|
|
|
|
|
this.splitContainer1.SplitterWidth = this.splitContainer2.SplitterWidth = 15;
|
|
this.splitContainer1.Panel2Collapsed = this.splitContainer2.Panel2Collapsed = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("检测到P_SystemTab表中PPMenuCode未设置模块编号,请先设置后在运行系统.");
|
|
this.Close();
|
|
}
|
|
|
|
//设置主页面语言
|
|
this.SetInterfaceLanguage();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取模块配置信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitializeModule()
|
|
{
|
|
DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.ModelObj.CondKey);
|
|
DataTable columns = BaseModuleImpl.GetBaseGridColumns(this.mMenuCode);
|
|
|
|
if (queryTable == null || queryTable.Rows.Count == 0)
|
|
{
|
|
panelControl14.Visible = false;
|
|
}
|
|
this.SearchObj = new MyControl(this.ModelObj.MenuSql, gcMain, null, null, null);
|
|
|
|
this.panel2.Height = this.SearchObj.InitSearchControl(queryTable, this.panelControl14);
|
|
this.SearchObj.OnSearchAfterCallBack += new EventHandler(OnSearchAfterCallBack);// 查询条件执行前
|
|
this.SearchObj.OnDataSourceBindCallBack += new EventHandler(ControlObj_OnDataSourceBindCallBack);
|
|
|
|
if (this.ModelObj.GridObjIsCheck == 1)//主表加载复选框,搜索后不记住上一次选中行
|
|
{
|
|
this.SearchObj.RememberRow = false;
|
|
}
|
|
|
|
this.gcMain.SetReadOnlyColumns(columns, GridCustomColumnStruct.BaseMainGridView + this.ModelObj.FormKey, mColumnFont, DevExpress.Utils.DefaultBoolean.False);
|
|
this.gcMain.GridView.OptionsView.RowAutoHeight = true;
|
|
this.gcMain.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(this.mMenuCode));
|
|
this.gcMain.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.mMenuCode, ModuleType.MESGRIDRIGHT), this.DyncModel, OnGridViewRightCallBack);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:搜索之后</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-05-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnSearchAfterCallBack(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.ModelObj.AfterStored))
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
this.SearchLastGrid();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:数据源绑定完成后执行</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </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>
|
|
void ControlObj_OnDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SearchLastGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
public void SearchLastGrid()
|
|
{
|
|
try
|
|
{
|
|
int rowHandle = this.gcMain.GridView.FocusedRowHandle;
|
|
|
|
this.SearchObj.SearchGrid();
|
|
this.mSourceTable = this.gcMain.GridControl.DataSourceTable();
|
|
if (mSourceTable.Rows.Count == 0) return;
|
|
if (SystemInfo.Instance.MesMainType == 1)
|
|
{
|
|
this.groups = this.mSourceTable.AsEnumerable().GroupBy(r => new { Col1 = r["Planstdt"] }).Select(g => g.OrderBy(r => r["Planstdt"]).First()).CopyToDataTable();
|
|
this.Timegroup.Clear();
|
|
foreach (DataRow item in groups.Rows)
|
|
{
|
|
Timegroup.Add(item["Planstdt"] + "");
|
|
}
|
|
this.mMaxPage = Timegroup.Count;
|
|
}
|
|
this.InitControl();
|
|
|
|
this.gcMain.GridView.SelectRowHandler(rowHandle);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取明细配置信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitializeToolBar()
|
|
{
|
|
int padding = 3, left = 0, width = 90, height = 90, Top = 2;
|
|
string bgImage = string.Empty;
|
|
this.panel1.Controls.Clear();
|
|
DataTable rightTable = BaseModuleImpl.GetBaseGridRightMenus(this.mMenuCode, ModuleType.MESTOOL);
|
|
DataTable detailTable = BaseModuleImpl.GetBaseDetailPages(this.mMenuCode);
|
|
|
|
int count = rightTable.Rows.Count + detailTable.Rows.Count;
|
|
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
left = left == 0 ? padding : left + width + padding;
|
|
if (left + width + padding > this.panel1.Width)
|
|
{
|
|
left = padding;
|
|
Top = Top + height + 6;
|
|
int panlheight = Top + height + 6;
|
|
this.panelControl2.Height = panlheight;
|
|
}
|
|
if (i < rightTable.Rows.Count)
|
|
{
|
|
DataRow item = rightTable.Rows[i];
|
|
GridRightMenuModel menuModel = new GridRightMenuModel(item);
|
|
if (rightTable.Columns.Contains("DefailtImage"))
|
|
bgImage = PubUtil.MesItemImage + item["DefailtImage"] + "";
|
|
ToolButton toolButton = new ToolButton();
|
|
toolButton.Name = menuModel.MenuId + "";
|
|
toolButton.SetTitle(menuModel.MenuName);
|
|
toolButton.SetImage(File.Exists(bgImage) ? Image.FromFile(bgImage) : Resources.机台设置);
|
|
toolButton.Size = new Size(width, height);
|
|
toolButton.Location = new Point(left, Top);
|
|
toolButton.Tag = menuModel;
|
|
toolButton.OnClick += new EventHandler(OnModuleClick);
|
|
mButtonImage.Add(File.Exists(bgImage) ? Image.FromFile(bgImage) : Resources.机台设置);
|
|
mButtonGrayImage.Add(GrayImage(File.Exists(bgImage) ? Image.FromFile(bgImage) : Resources.机台设置));
|
|
this.panel1.Controls.Add(toolButton);
|
|
}
|
|
else
|
|
{
|
|
DataRow item = detailTable.Rows[i - rightTable.Rows.Count];
|
|
GridDetailModel detailModel = new GridDetailModel(item);
|
|
if (detailTable.Columns.Contains("DefailtImage"))
|
|
bgImage = PubUtil.MesItemImage + item["DefailtImage"] + "";
|
|
ToolButton toolButton = new ToolButton();
|
|
toolButton.Name = detailModel.Id + "";
|
|
toolButton.SetTitle(detailModel.DetailName);
|
|
toolButton.SetImage(File.Exists(bgImage) ? Image.FromFile(bgImage) : Resources.机台设置);
|
|
toolButton.Size = new Size(width, height);
|
|
toolButton.Location = new Point(left, Top);
|
|
toolButton.Tag = detailModel;
|
|
toolButton.OnClick += new EventHandler(OnModuleClick);
|
|
mButtonImage.Add(File.Exists(bgImage) ? Image.FromFile(bgImage) : Resources.机台设置);
|
|
mButtonGrayImage.Add(GrayImage(File.Exists(bgImage) ? Image.FromFile(bgImage) : Resources.机台设置));
|
|
this.panel1.Controls.Add(toolButton);
|
|
}
|
|
|
|
}
|
|
if (count == 0)
|
|
{
|
|
this.panel1.Height = 0;
|
|
this.panelControl2.Hide();
|
|
}
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取附加配置信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitializeAttach()
|
|
{
|
|
int width = 80, height = 120, paddingTop = 1;
|
|
this.panelControl4.Controls.Clear();
|
|
|
|
DataTable table = BaseModuleImpl.GetBaseAttach(this.mMenuCode);
|
|
|
|
if (table.Rows.Count > 0)
|
|
{
|
|
panelControl4.Visible = true;
|
|
// 加载默认模块
|
|
Button defaultButton = new Button();
|
|
defaultButton.Name = this.mMenuCode;
|
|
defaultButton.Text = HorTextToVer(this.ModelObj.MenuText);
|
|
defaultButton.Size = new Size(width, height);
|
|
defaultButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
|
defaultButton.FlatAppearance.BorderColor = System.Drawing.Color.White;
|
|
defaultButton.FlatAppearance.BorderSize = 0;
|
|
defaultButton.BackgroundImage = Resources.right_bg;
|
|
defaultButton.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold);
|
|
defaultButton.BackgroundImageLayout = ImageLayout.Stretch;
|
|
defaultButton.Click += new EventHandler(OnAttachClick);
|
|
|
|
this.panelControl4.Controls.Add(defaultButton);
|
|
this.mButtons.Add(defaultButton);
|
|
|
|
|
|
for (int i = 0; i < table.Rows.Count; i++)
|
|
{
|
|
DataRow item = table.Rows[i];
|
|
|
|
Button button = new Button();
|
|
button.Name = item["id"] + "";
|
|
button.Text = HorTextToVer(item["AttachName"] + "");
|
|
button.Size = new Size(width, height);
|
|
button.FlatAppearance.BorderColor = System.Drawing.Color.White;
|
|
button.FlatAppearance.BorderSize = 0;
|
|
button.BackColor = Color.White;
|
|
button.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
|
button.BackgroundImageLayout = ImageLayout.Stretch;
|
|
button.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold);
|
|
button.Location = new Point(0, i == 0 ? height + paddingTop : i * (height + paddingTop) + height + paddingTop);
|
|
button.Click += new EventHandler(OnAttachClick);
|
|
button.Tag = item;
|
|
|
|
this.panelControl4.Controls.Add(button);
|
|
this.mButtons.Add(button);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
panelControl4.Visible = false;
|
|
}
|
|
}
|
|
|
|
public void InitControl()
|
|
{
|
|
try
|
|
{
|
|
if (this.mSourceTable == null || this.mSourceTable.Rows.Count == 0)
|
|
return;
|
|
if (SystemInfo.Instance.MesMainType == 1)
|
|
{
|
|
this.gcMain.GridControl.DataSource = this.mSourceTable.Select(string.Format("Planstdt='{0}'", Timegroup[mPage - 1])).CopyToDataTable();
|
|
this.label1.Text = "第" + mPage + "天,共" + mMaxPage + "天";
|
|
this.button2.Text = "上一天";
|
|
this.button3.Text = "下一天";
|
|
if (ERPInfo.Instance.LanguageName.Equals("Việt nam"))
|
|
{
|
|
this.label1.Text = string.Format("Ngày {0},của {1}", mPage, mMaxPage);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.GridControl.DataSource = this.mSourceTable.Rows.Cast<DataRow>().Skip((mPage - 1) * mPageSize).Take(mPageSize).CopyToDataTable();
|
|
this.mMaxPage = Convert.ToInt32(this.mSourceTable.Rows.Count / mPageSize) + (this.mSourceTable.Rows.Count % mPageSize > 0 ? 1 : 0);
|
|
this.label1.Text = "第" + mPage + "页,共" + mMaxPage + "页";
|
|
if (ERPInfo.Instance.LanguageName.Equals("Việt nam"))
|
|
{
|
|
this.label1.Text = string.Format("Trang {0},của {1}", mPage, mMaxPage);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
|
|
|
|
}
|
|
public void SetButtonBackImage(Button button)
|
|
{
|
|
foreach (Button item in mButtons)
|
|
{
|
|
if (item.Name == button.Name)
|
|
{
|
|
item.BackgroundImage = Resources.right_bg;
|
|
item.BackgroundImageLayout = ImageLayout.Stretch;
|
|
item.BackColor = Color.Transparent;
|
|
}
|
|
else
|
|
{
|
|
item.BackgroundImage = null;
|
|
item.BackColor = Color.White;
|
|
}
|
|
}
|
|
}
|
|
public string HorTextToVer(string text)
|
|
{
|
|
string str = string.Empty;
|
|
for (int i = 0; i < text.Length; i++)
|
|
{
|
|
str += text.Substring(i, 1) + "\r\n";
|
|
}
|
|
return str;
|
|
}
|
|
#endregion
|
|
|
|
#region 事件
|
|
/// <summary>
|
|
/// <para>说明:切换车间点击</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-05-25 </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="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnCommonItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowItem = e.Item.Tag as DataRow;
|
|
ERPInfo.Instance.WorkJT = rowItem["mc"] + "";
|
|
Program.ReStartMain(true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:窗口加载</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </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>
|
|
void OnLoad(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
|
|
// 设置基础信息
|
|
this.lblDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
|
|
this.lblUserName.Text = ERPInfo.Instance.UserName;
|
|
this.lblDayName.Text = "白班";
|
|
this.label2.Text = SystemInfo.Instance.ClientName;
|
|
//初始化班组展示信息
|
|
InitializeTeam();
|
|
//初始化切换车间模块
|
|
InitializeOper();
|
|
// 获取配置信息
|
|
this.InitializeControl();
|
|
if (SystemInfo.Instance.IntervalEnable)
|
|
{
|
|
timer1.Interval = 1000 * 60 * (SystemInfo.Instance.Interval > 0 ? SystemInfo.Instance.Interval : 5);
|
|
timer1.Start();
|
|
}
|
|
if (SystemInfo.Instance.HideHelpDocument)
|
|
{
|
|
this.button8.Visible = false;
|
|
}
|
|
|
|
|
|
this.gcMain.GridView.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(OnRowFocusedRowChanged);
|
|
|
|
//this.gcMain.GridView.OptionsView.ShowFooter = false;
|
|
//this.gcDetail.GridView.OptionsView.ShowFooter = false;
|
|
|
|
this.gcMain.Controls.Remove(this.gcMain.plbuttomObj);
|
|
this.gcDetail.Controls.Remove(this.gcDetail.plbuttomObj);
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:模块点击</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </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>
|
|
void OnModuleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
PubModuleClick(sender);
|
|
//Thread thread = new Thread(new ParameterizedThreadStart(PubModuleClick));
|
|
//thread.IsBackground = true;
|
|
//thread.Start(sender);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:模块点击多线程方法</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </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>
|
|
public void PubModuleClick(Object sender)
|
|
{
|
|
//this.Invoke(new EventHandler(delegate
|
|
//{
|
|
this.isInit = false;
|
|
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
|
//if (rowItem == null)
|
|
//{
|
|
// MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
// return;
|
|
//}
|
|
|
|
try
|
|
{
|
|
//WaitForm.ShowForm();
|
|
ToolButton button = sender as ToolButton;
|
|
if (button != null)
|
|
{
|
|
if (button.Tag is GridRightMenuModel)
|
|
{
|
|
GridRightMenuModel model = button.Tag as GridRightMenuModel;
|
|
//DataRow focusedRow = this.gcMain.GridView.GetFocusedDataRow();
|
|
//if (rowItem == null && !model.isStartRun)
|
|
//{
|
|
// MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
// return;
|
|
//}
|
|
DataRow[] rowArray = gcMain.GetViewFocusedDataRows();
|
|
if (rowArray.Length==0 && !model.isStartRun)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
return;
|
|
}
|
|
BaseRightMenu menu = new BaseRightMenu();
|
|
menu.Model = this.DyncModel;
|
|
if (menu.ExecRightMenu(model, rowArray) && model.Refresh)
|
|
{
|
|
this.SearchLastGrid();
|
|
}
|
|
//if (menu.ExecRightMenu(model, new DataRow[] { focusedRow }) && model.Refresh)
|
|
//{
|
|
// this.SearchLastGrid();
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
if (rowItem == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
return;
|
|
}
|
|
GridDetailModel model = button.Tag as GridDetailModel;
|
|
this.Invoke(new EventHandler(delegate
|
|
{
|
|
if (model.IsRightVisible)
|
|
{
|
|
if (this.mRightButton != button)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.UnionModule))
|
|
{
|
|
ModuleModel unionModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
|
DataTable columns = BaseModuleImpl.GetBaseGridColumns(model.UnionModule);
|
|
|
|
this.gcRight.GridView.Columns.Clear();
|
|
this.gcRight.SetReadOnlyColumns(columns, "", mColumnFont, DevExpress.Utils.DefaultBoolean.False);
|
|
this.gcRight.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.UnionModule, ModuleType.MESGRIDRIGHT), this.DyncModel);
|
|
this.gcRight.GridControl.DataSource = BaseModuleImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(unionModel.MenuSql) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[this.ModelObj.ParmaryKey]));
|
|
|
|
this.splitContainer1.Panel2Collapsed = false;
|
|
this.mRightButton = button;
|
|
|
|
string width = IniHelper.Read("mes123456_width");
|
|
if (!string.IsNullOrEmpty(width))
|
|
{
|
|
this.splitContainer1.SplitterDistance = Convert.ToInt32(width);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.splitContainer1.Panel2Collapsed = true;
|
|
this.mRightButton = null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.mBottomButton != button)
|
|
{
|
|
this.gcDetail.GridView.Columns.Clear();
|
|
if (!string.IsNullOrEmpty(model.UnionModule))
|
|
{
|
|
ModuleModel unionModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
|
DataTable columns = BaseModuleImpl.GetBaseGridColumns(model.UnionModule);
|
|
|
|
this.gcDetail.SetReadOnlyColumns(columns, "", mColumnFont, DevExpress.Utils.DefaultBoolean.False);
|
|
this.gcDetail.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.UnionModule, ModuleType.MESGRIDRIGHT), this.DyncModel);
|
|
this.gcDetail.GridControl.DataSource = BaseModuleImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(unionModel.MenuSql) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[this.ModelObj.ParmaryKey]));
|
|
}
|
|
else
|
|
{
|
|
DataTable columns = ReportImpl.GetReportDetailColumns(this.mMenuCode, model.Id + "");
|
|
|
|
this.gcDetail.SetReadOnlyColumns(columns, GridCustomColumnStruct.BaseMainGridView + this.ModelObj.FormKey, mColumnFont, DevExpress.Utils.DefaultBoolean.False);
|
|
//this.gcDetail.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.ModelObj.FormKey, ModuleType.MESGRIDRIGHT), this.DyncModel);
|
|
this.gcDetail.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.DyncModel);
|
|
this.gcDetail.GridControl.DataSource = BaseModuleImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceWhereCond(model.DetailSql)));
|
|
}
|
|
this.splitContainer2.Panel2Collapsed = false;
|
|
this.mBottomButton = button;
|
|
|
|
string height = IniHelper.Read("mes123456_height");
|
|
if (!string.IsNullOrEmpty(height))
|
|
{
|
|
this.splitContainer2.SplitterDistance = Convert.ToInt32(height);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.splitContainer2.Panel2Collapsed = true;
|
|
this.mBottomButton = null;
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
GridViewClick();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
//WaitForm.HideForm();
|
|
}
|
|
//}));
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:附加模块点击</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </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>
|
|
void OnAttachClick(object sender, EventArgs e)
|
|
{
|
|
this.isInit = false;
|
|
Button button = sender as Button;
|
|
if (button != null)
|
|
{
|
|
SetButtonBackImage(button);
|
|
if (button.Name == this.mMenuCode)
|
|
{
|
|
this.panelControl12.Visible = true;
|
|
this.panelControl11.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
|
|
DataRow rowItem = button.Tag as DataRow;
|
|
|
|
string unionModel = (rowItem["unionModule"] + "").Replace("{", "").Replace("}", "");
|
|
string unionValue = (rowItem["unionValue"] + "").Replace("{", "").Replace("}", ""); ;
|
|
|
|
if (string.IsNullOrEmpty(unionModel.Trim()))
|
|
{
|
|
MessageUtil.Show("关联模块未配置.");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(unionValue.Trim()))
|
|
{
|
|
MessageUtil.Show("关联值未配置.");
|
|
return;
|
|
}
|
|
|
|
ModuleModel attachModel = new ModuleModel(MainImpl.GetSystemdllTab(unionModel));
|
|
|
|
this.gcAttach.SetReadOnlyColumns(BaseModuleImpl.GetBaseGridColumns(unionModel), "", mColumnFont, DevExpress.Utils.DefaultBoolean.False);
|
|
this.gcAttach.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(unionModel, ModuleType.MESGRIDRIGHT), this.DyncModel);
|
|
this.gcAttach.GridControl.DataSource = BaseModuleImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(attachModel.MenuSql));
|
|
|
|
this.panelControl11.Visible = true;
|
|
this.panelControl12.Visible = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//图片进行灰度处理
|
|
//originalImage为原图像 返回灰度图像
|
|
private Bitmap GrayImage(Image originalImage)
|
|
{
|
|
ImageAttributes imageAttributes = new ImageAttributes();
|
|
float[][] matrix = { new float[] {0.299f, 0.299f, 0.299f, 0, 0},
|
|
new float[] {0.587f, 0.587f, 0.587f, 0, 0},
|
|
new float[] {0.114f, 0.114f, 0.114f, 0, 0},
|
|
new float[] {0, 0, 0, 1, 0},
|
|
new float[] {0, 0, 0, 0, 1}
|
|
};
|
|
ColorMatrix colorMatrix = new ColorMatrix(matrix);
|
|
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
|
|
|
Bitmap grayHead = new Bitmap(originalImage.Width, originalImage.Height);
|
|
using (Graphics g = Graphics.FromImage(grayHead))
|
|
{
|
|
g.DrawImage(originalImage, new Rectangle(0, 0, originalImage.Width, originalImage.Height), 0, 0, originalImage.Width, originalImage.Height, GraphicsUnit.Pixel, imageAttributes);
|
|
}
|
|
return grayHead;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:行焦点改变事件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-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="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
void OnRowFocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridViewClick();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:主表格点击加载数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
void OnRowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridViewClick();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// <para>说明:表格选中点击共用函数</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-14</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void GridViewClick()
|
|
{
|
|
try
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
|
int i = 0;
|
|
// 判断右键菜单是否可用
|
|
foreach (ToolButton toolButton in panel1.Controls)
|
|
{
|
|
GridRightMenuModel model = toolButton.Tag as GridRightMenuModel;
|
|
if (model == null) continue;
|
|
if (model.PrivilegeOper.Length > 1 && !model.PrivilegeOper.Contains(ERPInfo.Instance.UserName + ","))
|
|
{
|
|
toolButton.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
|
{
|
|
try
|
|
{
|
|
string cond = ReplaceHelper.ReplaceRowParam(rowItem, model.MenuCond);
|
|
toolButton.Enabled = ReplaceHelper.EvalCond(cond);
|
|
toolButton.SetImage(toolButton.Enabled ? mButtonImage[i] : mButtonGrayImage[i]);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
if (mRightButton != null)
|
|
{
|
|
GridDetailModel model = mRightButton.Tag as GridDetailModel;
|
|
if (!string.IsNullOrEmpty(model.UnionModule))
|
|
{
|
|
ModuleModel unionModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
|
DataTable columns = BaseModuleImpl.GetBaseGridColumns(model.UnionModule);
|
|
|
|
this.gcRight.GridView.Columns.Clear();
|
|
this.gcRight.SetReadOnlyColumns(columns, "", mColumnFont, DevExpress.Utils.DefaultBoolean.False);
|
|
this.gcRight.GridControl.DataSource = BaseModuleImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(unionModel.MenuSql) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[this.ModelObj.ParmaryKey]));
|
|
}
|
|
}
|
|
if (mBottomButton != null)
|
|
{
|
|
GridDetailModel model = mBottomButton.Tag as GridDetailModel;
|
|
this.gcDetail.GridView.Columns.Clear();
|
|
if (!string.IsNullOrEmpty(model.UnionModule))
|
|
{
|
|
ModuleModel unionModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
|
DataTable columns = BaseModuleImpl.GetBaseGridColumns(model.UnionModule);
|
|
|
|
this.gcDetail.SetReadOnlyColumns(columns, "", mColumnFont, DevExpress.Utils.DefaultBoolean.False);
|
|
this.gcDetail.GridControl.DataSource = BaseModuleImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(unionModel.MenuSql) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[this.ModelObj.ParmaryKey]));
|
|
}
|
|
else
|
|
{
|
|
DataTable columns = ReportImpl.GetReportDetailColumns(this.mMenuCode, model.Id + "");
|
|
|
|
this.gcDetail.SetReadOnlyColumns(columns, GridCustomColumnStruct.BaseMainGridView + this.ModelObj.FormKey, mColumnFont, DevExpress.Utils.DefaultBoolean.False);
|
|
this.gcDetail.GridControl.DataSource = BaseModuleImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceWhereCond(model.DetailSql)));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
private void simpleButton22_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.mPage == 1) return;
|
|
this.mPage = 1;
|
|
this.InitControl();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void simpleButton23_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.mPage > 1)
|
|
{
|
|
this.mPage -= 1;
|
|
this.InitControl();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void simpleButton24_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.mPage < this.mMaxPage)
|
|
{
|
|
this.mPage += 1;
|
|
this.InitControl();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
private void simpleButton25_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.mPage == this.mMaxPage) return;
|
|
this.mPage = this.mMaxPage;
|
|
this.InitControl();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SearchLastGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void simpleButton3_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void splitContainer2_SplitterMoved(object sender, SplitterEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!isInit && this.splitContainer2.SplitterDistance != 271) IniHelper.Write("mes123456_height", this.splitContainer2.SplitterDistance + "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void splitContainer1_SizeChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!isInit) IniHelper.Write("mes123456_width", this.splitContainer1.SplitterDistance + "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void butMachineSwitch_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (machineSwitching.Parent == null)
|
|
{
|
|
this.Controls.Add(machineSwitching);
|
|
machineSwitching.BringToFront();
|
|
// machineSwitching.Location = new Point(this.butMachineSwitch.Left, this.panelControl13.Top + this.butMachineSwitch.Top - machineSwitching.Height);
|
|
Point point = this.FindForm().PointToClient(butMachineSwitch.PointToScreen(new Point(0, 0)));
|
|
if(machineSwitching.Height> this.Height / 2) machineSwitching.Height = this.Height / 2;
|
|
|
|
machineSwitching.Location = new Point(point.X, point.Y - machineSwitching.Height);
|
|
|
|
machineSwitching.Width = this.butMachineSwitch.Width;
|
|
machineSwitching.Show();
|
|
|
|
}
|
|
else
|
|
{
|
|
if (machineSwitching.Visible)
|
|
{
|
|
machineSwitching.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
machineSwitching.Visible = true;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Application.DoEvents();
|
|
this.SearchLastGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void button8_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WebBrowserUtil.StartWebBrowser(this.DyncModel.ModuleCode, this.ModelObj.MenuText);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void btnZX_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Process.Start("Ls_MES.exe");
|
|
this.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
private void OnDpbTools_ShowDropDownControl(object sender, ShowDropDownControlEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DropDownButton dropDownButton = (DropDownButton)sender;
|
|
PopupMenu popupMenu = (PopupMenu)e.DropDownControl;
|
|
int popupMenuHeight = 0;
|
|
foreach (BarButtonItemLink ItemLink in popupMenu.ItemLinks)
|
|
{
|
|
popupMenuHeight += ItemLink.Item.Font.Height;
|
|
}
|
|
Point screenPoint = dropDownButton.PointToScreen(new Point(0, 0));
|
|
Point point = new Point(screenPoint.X, screenPoint.Y - popupMenuHeight);
|
|
popupMenu.ShowPopup(point);
|
|
e.Allow = false;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 鼠标按下
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnPanelMouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
base.OnMouseDown(e);
|
|
System.Windows.Forms.Control control = (System.Windows.Forms.Control)sender;
|
|
Point mousePoint = control.PointToClient(System.Windows.Forms.Control.MousePosition);
|
|
_mousePostion = new Point(mousePoint.X, mousePoint.Y);
|
|
_isMouseDown = true;
|
|
}
|
|
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 OnPanelMouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
base.OnMouseMove(e);
|
|
if (_isMouseDown && e.Button == MouseButtons.Left)
|
|
{
|
|
this.Location = new Point(Location.X + (e.X - _mousePostion.X), Location.Y + (e.Y - _mousePostion.Y));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 鼠标放开
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnPanelMouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
base.OnMouseUp(e);
|
|
_isMouseDown = false;
|
|
//this.Focus();
|
|
}
|
|
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 OnPanelMouseDoubleClick(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.WindowState == FormWindowState.Maximized)
|
|
{
|
|
this.WindowState = FormWindowState.Normal;
|
|
}
|
|
else if (this.WindowState == FormWindowState.Normal)
|
|
{
|
|
this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
[DllImport("User32.dll")]
|
|
public static extern IntPtr GetForegroundWindow(); //获取活动窗口句柄
|
|
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
|
public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID); //获取线程ID
|
|
|
|
/// <summary>
|
|
/// 获取句柄
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void FrmMain_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.F3)
|
|
{
|
|
IntPtr hWnd = GetForegroundWindow(); //获取活动窗口句柄
|
|
int calcID = 0; //进程ID pid
|
|
int calcTD = 0; //线程ID
|
|
calcTD = GetWindowThreadProcessId(hWnd, out calcID);
|
|
Clipboard.SetData(DataFormats.Text, (Object)calcID);
|
|
MessageUtil.Show("程序PID码:" + calcID + "已复制到粘贴板上!");
|
|
}
|
|
}
|
|
|
|
|
|
private void SetInterfaceLanguage()
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(ERPInfo.Instance.LanguageName))
|
|
{
|
|
//翻译按钮固定文本
|
|
this.TranslationFixedButton(this.panelC |