2419 lines
109 KiB
C#
2419 lines
109 KiB
C#
using DevExpress.Utils;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraTab;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Core;
|
|
using Lskj.Data;
|
|
using Lskj.Model;
|
|
using Lskj.SweepCode.Control;
|
|
using Lskj.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Threading;
|
|
using System.Speech.Synthesis;
|
|
|
|
namespace Lskj.SweepCode
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
/// <summary>
|
|
/// <para>说明:初始化后构造方法</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public FrmMain()
|
|
{
|
|
this.DoubleBuffered = true;
|
|
//SetStyle(ControlStyles.UserPaint, true);
|
|
//SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
|
|
//SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
|
|
InitializeComponent();
|
|
}
|
|
#region 公共变量
|
|
/// <summary>
|
|
/// 下拉框的数据源的实际值
|
|
/// </summary>
|
|
public string ComValueMember;
|
|
/// <summary>
|
|
/// 下拉框的数据源的显示值
|
|
/// </summary>
|
|
public string ComDisplayMember;
|
|
/// <summary>
|
|
/// 下拉框的数据源
|
|
/// </summary>
|
|
public DataTable ComBoxSource = new DataTable();
|
|
/// <summary>
|
|
/// 搜索之前执行的存储过程
|
|
/// </summary>
|
|
public string BeforeStored = "";
|
|
/// <summary>
|
|
/// 搜索之后执行的存储过程
|
|
/// </summary>
|
|
public string AfterStored = "";
|
|
/// <summary>
|
|
/// 下拉框筛选后触发存储过程
|
|
/// </summary>
|
|
public string ScreenStored = "";
|
|
/// <summary>
|
|
/// 界面关闭触发存储过程
|
|
/// </summary>
|
|
public string FrmCloseStored = "";
|
|
/// <summary>
|
|
/// 主搜索框回车不跳转扫码区域
|
|
/// </summary>
|
|
public string IsGotoFirstCtr = "isAtuoGotoFirstSweepControl";
|
|
/// <summary>
|
|
/// 主搜索框搜索后改变开工状态
|
|
/// </summary>
|
|
public string IsSweepTipStata = "SweepTipStata";
|
|
/// <summary>
|
|
/// 入口模型
|
|
/// </summary>
|
|
public DynamicProductionModel SysModel;
|
|
/// <summary>
|
|
/// 扫码提示表
|
|
/// </summary>
|
|
public DataTable tips;
|
|
/// <summary>
|
|
///查询条件控件
|
|
/// </summary>
|
|
public MyControl SearchObj;
|
|
/// <summary>
|
|
/// 主控件集
|
|
/// </summary>
|
|
public MyControl ControlObj;
|
|
/// <summary>
|
|
/// 基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleObj;
|
|
/// <summary>
|
|
/// 明细初始集合
|
|
/// </summary>
|
|
public List<GridDetailModel> GridInitDetailModel;
|
|
/// <summary>
|
|
/// 表格明细集合
|
|
/// </summary>
|
|
public List<GridDetailModel> GridDetailModelObjs;
|
|
/// <summary>
|
|
/// 明细衍生到下侧数据
|
|
/// </summary>
|
|
public List<GridDetailModel> GridDetailAddObj;
|
|
/// <summary>
|
|
/// 明细衍生到右侧数据
|
|
/// </summary>
|
|
public List<GridDetailModel> GridDetailRightObj;
|
|
/// <summary>
|
|
/// 右侧按钮数据字典
|
|
/// </summary>
|
|
public Dictionary<double, SweepButton> sweepDic = new Dictionary<double, SweepButton>();
|
|
/// <summary>
|
|
/// 中间输入控件数据字典
|
|
/// </summary>
|
|
public Dictionary<int, System.Windows.Forms.Control> sweepMidControl = new Dictionary<int, System.Windows.Forms.Control>();
|
|
/// <summary>
|
|
/// 提示消息框
|
|
/// </summary>
|
|
public LevitationPanel levitationPanel;
|
|
/// <summary>
|
|
/// 上一次工单拼接键
|
|
/// </summary>
|
|
public string afterRshKey = "";
|
|
/// <summary>
|
|
/// 上一次工单值
|
|
/// </summary>
|
|
public string aftertxtFixKey = "";
|
|
/// <summary>
|
|
/// 查询是否刷新
|
|
/// </summary>
|
|
public bool isSearchRefresh = true;
|
|
/// <summary>
|
|
/// 是否是加载第一次弹出框
|
|
/// </summary>
|
|
public bool isFristSearch = false;
|
|
/// <summary>
|
|
/// 是否执行了加载储存过程
|
|
/// </summary>
|
|
public bool ProcessExists = false;
|
|
|
|
#endregion
|
|
#region 私有变量
|
|
List<Color> colorlist = new List<Color>() { ColorTranslator.FromHtml("#CBEAEC"), ColorTranslator.FromHtml("#D0E3F3"), ColorTranslator.FromHtml("#FDE7CC"), ColorTranslator.FromHtml("#FCD5CF") };
|
|
/// <summary>
|
|
/// 子系统默认背景色
|
|
/// </summary>
|
|
private string[] _defaultColors = { "#0198A3", "#1C76C8", "#F88906", "#EA5C46" };
|
|
/// <summary>
|
|
/// 数据索引
|
|
/// </summary>
|
|
private int _dataIndex;
|
|
/// <summary>
|
|
/// 初始化完成标记
|
|
/// </summary>
|
|
private bool _isInitFinish;
|
|
/// <summary>
|
|
/// 附件部分显隐
|
|
/// </summary>
|
|
private bool _isFilePanelVisble;
|
|
/// <summary>
|
|
/// 附件源sql
|
|
/// </summary>
|
|
private string _fileSql;
|
|
/// <summary>
|
|
/// 主键值
|
|
/// </summary>
|
|
private string _keyValue;
|
|
/// <summary>
|
|
/// 主键名
|
|
/// </summary>
|
|
private string _primaryKey;
|
|
/// <summary>
|
|
/// 附件地址
|
|
/// </summary>
|
|
private string _filePath;
|
|
/// <summary>
|
|
/// 选项卡刷新页签
|
|
/// </summary>
|
|
private string[] _pageIndex;
|
|
/// <summary>
|
|
/// 当前数据内容
|
|
/// </summary>
|
|
private DataRow _rowItem;
|
|
/// <summary>
|
|
/// 界面上一次刷新sql
|
|
/// </summary>
|
|
private string LastRefreshSql;
|
|
/// <summary>
|
|
/// 界面上一次刷新sql,未配置第二个sql的情况
|
|
/// </summary>
|
|
private string AnotherLastRefreshSql;
|
|
/// <summary>
|
|
/// 控件源数据
|
|
/// </summary>
|
|
private DataTable _dtFields;
|
|
/// <summary>
|
|
/// 扫码控件源数据
|
|
/// </summary>
|
|
private DataTable _codeFields;
|
|
/// <summary>
|
|
/// 动态加载右侧按钮
|
|
/// </summary>
|
|
private DataTable _RightFields;
|
|
/// <summary>
|
|
/// 主表数据
|
|
/// </summary>
|
|
private DataTable _dtMainTable;
|
|
/// <summary>
|
|
/// pdf附件资源
|
|
/// </summary>
|
|
private DataTable _dtFiles;
|
|
/// <summary>
|
|
/// 搜索字段
|
|
/// </summary>
|
|
private string _searchFile;
|
|
/// <summary>
|
|
/// 搜索字段条件
|
|
/// </summary>
|
|
private string _searchCode;
|
|
/// <summary>
|
|
/// 搜索第二个字段
|
|
/// </summary>
|
|
private string _searchSecondFile;
|
|
/// <summary>
|
|
/// 搜索第二个字段条件
|
|
/// </summary>
|
|
private string _searchSecondCode;
|
|
/// <summary>
|
|
/// 附件下拉菜单
|
|
/// </summary>
|
|
private LabelComboxEdit _fileComboBox;
|
|
/// <summary>
|
|
/// 查看附件
|
|
/// </summary>
|
|
private ModuleWebView _moduleWebView;
|
|
/// <summary>
|
|
/// 选项卡排序Sql
|
|
/// </summary>
|
|
private Dictionary<string, string> _dicOrder = new Dictionary<string, string>();
|
|
/// <summary>
|
|
///默认窗口长度
|
|
/// </summary>
|
|
private int _windowWidth;
|
|
/// <summary>
|
|
/// 分割条横坐标
|
|
/// </summary>
|
|
private int _splitLocation;
|
|
/// <summary>
|
|
/// 设置的字体大小
|
|
/// </summary>
|
|
private int _fontSize;
|
|
/// <summary>
|
|
/// 分辨率改变时界面的比例大小(高)
|
|
/// </summary>
|
|
private double _FormHeight;
|
|
/// <summary>
|
|
/// 分辨率改变时界面的比例大小(宽)
|
|
/// </summary>
|
|
private double _FormWidth;
|
|
|
|
/// <summary>
|
|
/// 是否是放大模式
|
|
/// </summary>
|
|
private bool isAmplification;
|
|
/// <summary>
|
|
/// 放大模式下,下方明细字体
|
|
/// </summary>
|
|
private int detailFontSize;
|
|
/// <summary>
|
|
/// 语音播报
|
|
/// </summary>
|
|
private SpeechSynthesizer speech = new SpeechSynthesizer();
|
|
/// <summary>
|
|
///模式3打开,上一次点击的时间
|
|
/// </summary>
|
|
private DateTime LastScanCodeTime;
|
|
|
|
|
|
|
|
#endregion
|
|
#region 事件
|
|
#region 窗体加载时
|
|
/// <summary>
|
|
/// <para>说明:窗体加载时</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
this.txtFixKey.ImeMode = System.Windows.Forms.ImeMode.Disable;//扫码框设置输入时不会弹出输入法框
|
|
this.ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload);
|
|
//SweepTipStata.Hide();
|
|
this.SweepTipStata.Text = "";
|
|
this.labelTips.MouseMove += OnTips_MouseMove;
|
|
this.labelTips.MouseLeave += OnTips_MouseLeave;
|
|
//splitMain.SetPanelCollapsed(true);//初始折叠
|
|
this.Width = 1150;
|
|
//_splitLocation = this.splitMain.SplitterPosition;
|
|
_windowWidth = this.Width;
|
|
//this.splitMain.SplitGroupPanelCollapsed += new SplitGroupPanelCollapsedEventHandler(OnClickSplitBar);
|
|
if (this.SysModel.Privilege.Equals("3")) this.panelMain.Height = 800;
|
|
SysModel.Privilege = this.SysModel.Privilege.Equals("3") ? "1" : SysModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(SysModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(SysModel.ModuleCode) + "";
|
|
this._isInitFinish = false;
|
|
if (!this.SysModel.HasPrivilege())
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnPurview);
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
|
|
this.InitializeSetting();//初始化属性设置
|
|
this.ResizeControl();//根据分辨率重绘界面大小
|
|
this.InitializeControl();//设置control初始化
|
|
this.InitializeDetailGrid();//初始化扫码功能模块的明细数据
|
|
this.InitSpliterPosition();//初始化分割条位置
|
|
this.SweepIsUsable();//扫码完成后判断右键是否可点击
|
|
this.txtEditClass.SelectedIndexChanged += new EventHandler(chooseToChange);
|
|
// this.TabRight.TabControlObj.SizeChanged += TabControlObj_SizeChanged;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
this._isInitFinish = true;
|
|
}
|
|
WaitForm.HideForm();
|
|
}
|
|
|
|
private void TabControlObj_SizeChanged(object sender, EventArgs e)
|
|
{
|
|
foreach (XtraTabPage tabPage in TabRight.TabControlObj.TabPages)
|
|
{
|
|
if (tabPage.Tag is FrmWebBrowser)
|
|
{
|
|
//网页改变大小
|
|
FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser;
|
|
if (webView.cefBrowserSettings != null)
|
|
{
|
|
var handle = webView.cefBrowserSettings.GetHost().GetWindowHandle();
|
|
webView.ResizeWindow(handle, this.Width, this.Height);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 工单选中索引改变事件
|
|
/// <summary>
|
|
/// <para>说明:工单选中改变</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-10-8 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void chooseToChange(object sender, EventArgs e)
|
|
{
|
|
DataRow rowItem = ComBoxSource != null && ComBoxSource.Rows.Count > 0 ? ComBoxSource.Select("1=1").FirstOrDefault(x => txtEditClass.Text == x[ComDisplayMember] + "") : null;
|
|
if (rowItem != null)
|
|
{
|
|
this.txtFixKey.Focus();
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 点击分割条展开右边明细
|
|
/// <summary>
|
|
/// <para>说明:点击分割条展开右边明细</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnClickSplitBar(object sender, SplitGroupPanelCollapsedEventArgs e)
|
|
{
|
|
if (this.Size.Width <= _windowWidth)
|
|
{
|
|
this.Size = new Size(_windowWidth + 200, this.Size.Height);
|
|
}
|
|
else
|
|
{
|
|
this.Size = new Size(_windowWidth, this.Size.Height);
|
|
}
|
|
Rectangle r = new Rectangle(_splitLocation, 0, 200, this.Size.Height);
|
|
splitMain.Panel2.RectangleToClient(r);
|
|
}
|
|
#endregion
|
|
#region 点击加载的右键事件
|
|
/// <summary>
|
|
/// <para>说明:点击加载的右键事件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnModuleClick(object sender, EventArgs e)
|
|
{
|
|
//if (!string.IsNullOrEmpty(_searchCode))
|
|
//{
|
|
// string SearchCode = ReplaceHelper.ReplaceParamToValue(_searchCode, txtFixKey.Text); // 未替换的参数所有替换搜索值
|
|
// _rowItem = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql + " " + SearchCode)).Rows[0];
|
|
//}
|
|
//else
|
|
//{
|
|
// _rowItem = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql + "and" + _primaryKey + "=" + txtFixKey.Text)).Rows[0];
|
|
//}
|
|
|
|
if (_rowItem == null)
|
|
{
|
|
MessageUtil.Show("请查询工单号!");
|
|
return;
|
|
}
|
|
SweepIsUsable();
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
SweepButton button = sender as SweepButton;
|
|
if (button != null)
|
|
{
|
|
if (button.Tag is GridRightMenuModel)
|
|
{
|
|
GridRightMenuModel model = button.Tag as GridRightMenuModel;
|
|
if (!button.isEnable) return;
|
|
BaseRightMenu menu = new BaseRightMenu();
|
|
menu.Model = this.SysModel;
|
|
if (model.DllName == "Lskj.FrmCompletion.dll")
|
|
{
|
|
// 保存流转步骤
|
|
FrmCompletion frmCompletion = new FrmCompletion();
|
|
List<string> paramList = new List<string>();
|
|
paramList = this.HandleRightMenuParams(model.ParamList, _rowItem);
|
|
frmCompletion.finishWork(this.SysModel.ModuleCode, _rowItem, SysModel, paramList, LastRefreshSql);
|
|
if (frmCompletion.ShowDialog() == DialogResult.OK)
|
|
{
|
|
#region 执行成功调用Api接口
|
|
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleContextMenu, SysModel.ModuleCode, model.Id))
|
|
{
|
|
ApiHelper apiHelper = new ApiHelper(SysModel.ModuleCode, model.Id, _rowItem);
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleContextMenu, Interface.Api.ActionType.None);
|
|
if (!string.IsNullOrEmpty(apiHelper.apiResutMsg))
|
|
MessageUtil.Show(apiHelper.apiResutMsg);
|
|
}
|
|
#endregion
|
|
if (!string.IsNullOrWhiteSpace(LastRefreshSql))
|
|
{
|
|
_rowItem = BaseImpl.GetDataRowResult(LastRefreshSql);
|
|
IniAllControl(_rowItem, false);
|
|
}
|
|
else
|
|
{
|
|
Refresh(null, true);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SystemInfo.Instance.Reload = string.Empty;
|
|
SystemInfo.Instance.Reloadcond = string.Empty;
|
|
//menu.ControlObj.refreshThePage += new MyControl.RefreshThePage(refreshThePage);
|
|
if (menu.ExecRightMenu(model, new DataRow[] { _rowItem }) && model.Refresh)
|
|
{
|
|
|
|
if (!string.IsNullOrWhiteSpace(LastRefreshSql))
|
|
{
|
|
_rowItem = BaseImpl.GetDataRowResult(LastRefreshSql);
|
|
IniAllControl(_rowItem, false);
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.Reload))
|
|
{
|
|
AnotherLastRefreshSql = ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql) + " " + SystemInfo.Instance.Reload;
|
|
_rowItem = BaseImpl.GetDataRowResult(AnotherLastRefreshSql);
|
|
IniAllControl(_rowItem, false);
|
|
AutomaticSweepRheYard();
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.Reloadcond) && !string.IsNullOrEmpty(_searchCode))
|
|
{
|
|
|
|
string[] Reloadconds = SystemInfo.Instance.Reloadcond.Split(';');
|
|
string SearchCode = ReplaceHelper.ReplaceParamToValue(_searchCode, Reloadconds[0]);
|
|
DataRow rowItem = ComBoxSource != null && ComBoxSource.Rows.Count > 0 ? ComBoxSource.Select("1=1").FirstOrDefault(x => txtEditClass.Text == x[ComDisplayMember] + "") : null;
|
|
if (rowItem != null && Reloadconds.Length > 1)
|
|
{
|
|
SearchCode += " " + ReplaceHelper.ReplaceParamToValue(_searchSecondCode, Reloadconds[1] + ""); // 未替换的参数所有替换搜索值
|
|
}
|
|
AnotherLastRefreshSql = ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql) + " " + SearchCode;
|
|
_rowItem = BaseImpl.GetDataRowResult(AnotherLastRefreshSql);
|
|
IniAllControl(_rowItem, false);
|
|
AutomaticSweepRheYard();
|
|
}
|
|
else
|
|
{
|
|
|
|
_rowItem = BaseImpl.GetDataRowResult(AnotherLastRefreshSql);
|
|
IniAllControl(_rowItem, false);
|
|
//Refresh(null, true);
|
|
}
|
|
|
|
}
|
|
//执行完右键后,默认点击指定页签的搜索按钮
|
|
if (!string.IsNullOrWhiteSpace(model.AutomaticSearchId))
|
|
{
|
|
DefaultSearch(detailTab, model.AutomaticSearchId);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
#region 处理右键菜单10个扩展参数
|
|
/// <summary>
|
|
/// <para>说明:处理右键菜单10个扩展参数</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2017-10-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="paramList">The parameter list.</param>
|
|
protected virtual List<string> HandleRightMenuParams(List<string> paramList, DataRow rowData, DataRow[] rowDatas = null)
|
|
{
|
|
List<string> handleParamList = new List<string>();
|
|
|
|
foreach (string item in paramList)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(item))
|
|
{
|
|
string fieldValue = ReplaceHelper.ReplaceUserInfo(item);
|
|
|
|
string firstChar = fieldValue.Length > 0 ? fieldValue.Substring(0, 1) : "";
|
|
switch (firstChar)
|
|
{
|
|
case "@": // sql处理
|
|
{
|
|
string value = MainImpl.GetResult(ReplaceHelper.ReplaceRowParam(rowData, fieldValue.Replace("@", ""))) + "";
|
|
handleParamList.Add(value);
|
|
}
|
|
break;
|
|
case "#": // 需要传入的sql语句
|
|
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowData, fieldValue.Replace("#", "")) + "");
|
|
break;
|
|
case "[": //[FormTitle_格式数据
|
|
if (fieldValue.StartsWith("[FormTitle_"))
|
|
{
|
|
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowData, fieldValue.Replace("[FormTitle_", "")) + "");
|
|
}
|
|
else
|
|
{
|
|
if (rowDatas != null)
|
|
{
|
|
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowDatas, fieldValue, "'", "'") + "");
|
|
}
|
|
else
|
|
{
|
|
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowData, fieldValue) + "");
|
|
}
|
|
}
|
|
break;
|
|
case "$": //传入参数不需要任何处理
|
|
handleParamList.Add(fieldValue.Replace("$", "") + "");
|
|
break;
|
|
default:
|
|
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowData, fieldValue) + "");
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
handleParamList.Add(item);
|
|
}
|
|
}
|
|
|
|
return handleParamList;
|
|
}
|
|
#endregion
|
|
#region 主搜索控件回车事件
|
|
/// <summary>
|
|
/// <para>说明:主搜索控件回车事件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
ERPInfo.Instance.IsExecute = true;
|
|
SweepControl sweepControl = null;
|
|
if (sender is SweepControl)
|
|
{
|
|
sweepControl = sender as SweepControl;
|
|
//再次扫码的时间小于设置时间,就不执行
|
|
//if (sweepControl.WaitingTime > 0)
|
|
//{
|
|
// DateTime now = DateTime.Now;
|
|
// TimeSpan timeSinceLastClick = now - LastScanCodeTime;
|
|
// if (timeSinceLastClick.TotalMilliseconds < sweepControl.WaitingTime*1000) return;
|
|
//}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(MoudleObj.BeforeStored))
|
|
{
|
|
try
|
|
{
|
|
string sql = ReplaceHelper.ReplaceUserInfo(MoudleObj.BeforeStored);
|
|
if(_rowItem != null)sql = ReplaceHelper.ReplaceRowParam(_rowItem, sql);
|
|
string result = SqlHelper.ExecuteScalar(sql) + "";
|
|
if (!string.IsNullOrEmpty(result)) MessageUtil.Show(result);
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
}
|
|
try
|
|
{
|
|
WaitForm.ShowForm(ResourceKeys.Handing);
|
|
if (sweepControl != null && !string.IsNullOrEmpty(this._keyValue))
|
|
{
|
|
if (this.MoudleObj.Broadcast)
|
|
{
|
|
Thread thread = new Thread(() =>
|
|
{
|
|
try
|
|
{
|
|
speech.Rate = 1; //语速
|
|
speech.Volume = 100; //音量
|
|
speech.Speak("扫码成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
}
|
|
});
|
|
thread.IsBackground = true;
|
|
thread.Start();
|
|
}
|
|
|
|
|
|
DataRow item = sweepControl.Tag as DataRow;
|
|
string SweepControlText = sweepControl.ObjSweepControlText;
|
|
string msgs = string.Empty, refreshPages = string.Empty, reRightButton = string.Empty;
|
|
bool isScanningCheckCard = false;
|
|
int returnValue = 0;
|
|
Thread checkThread = new Thread(() =>
|
|
{
|
|
try
|
|
{
|
|
returnValue = ScanningCheckCard(this.SysModel.ModuleCode, SweepControlText, this._keyValue, this.SysModel.UserId, this.SysModel.UserName, 0, item["fieldname"] + "", out msgs, out refreshPages, out reRightButton);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
isScanningCheckCard = true;
|
|
});
|
|
checkThread.Start();
|
|
while (!isScanningCheckCard)
|
|
{
|
|
Application.DoEvents();
|
|
}
|
|
string[] resultMsgs = msgs.ToLower().Split('&');
|
|
string[] _positionIndex = refreshPages.Split(';');
|
|
//returnValue = 1;
|
|
if (returnValue != 1)
|
|
{
|
|
if (this.MoudleObj.Broadcast)
|
|
{
|
|
Thread thread = new Thread(() =>
|
|
{
|
|
try
|
|
{
|
|
speech.Rate = 1; //语速
|
|
speech.Volume = 100; //音量
|
|
speech.Speak(resultMsgs[0]);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
}
|
|
});
|
|
thread.IsBackground = true;
|
|
thread.Start();
|
|
}
|
|
MessageUtil.Show(resultMsgs[0]);
|
|
}
|
|
else
|
|
{
|
|
string positionIndex = string.Empty;
|
|
_pageIndex = _positionIndex[0].Split(',');
|
|
if (_positionIndex.Count() > 1) positionIndex = _positionIndex[1];
|
|
if (resultMsgs.Length >= 2)
|
|
{
|
|
GetMsgParamters(resultMsgs);
|
|
}
|
|
else
|
|
{
|
|
if (_pageIndex != null) Refresh(_pageIndex, false, positionIndex);
|
|
}
|
|
if (!string.IsNullOrEmpty(reRightButton))
|
|
{
|
|
(sweepDic[double.Parse(reRightButton)] as SweepButton).OnClickCallBack();
|
|
}
|
|
|
|
if (sweepControl.RefreshMain)
|
|
{
|
|
RefreshMasterTable();
|
|
}
|
|
|
|
System.Windows.Forms.Control FocusControl = this.ActiveControl;
|
|
//扫码后工具配置,把焦点移入下一扫码框
|
|
for (int i = 0; i < sweepMidControl.Count - 1; i++)
|
|
{
|
|
if (sweepMidControl[i] == FocusControl)
|
|
{
|
|
if ((sweepMidControl[i + 1] as SweepControl).isGainFocus)
|
|
{
|
|
sweepMidControl[i + 1].Focus();
|
|
}
|
|
else
|
|
{
|
|
for (int j = i + 1; j <= sweepMidControl.Count - 1; j++)
|
|
{
|
|
if ((sweepMidControl[j] as SweepControl).isGainFocus)
|
|
{
|
|
sweepMidControl[j].Focus();
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
}
|
|
//扫码成功后计时
|
|
//if (sweepControl != null && sweepControl.WaitingTime > 0)
|
|
//{
|
|
// DateTime now = DateTime.Now;
|
|
// LastScanCodeTime = now;
|
|
//}
|
|
if (this.MoudleObj.Broadcast)
|
|
{
|
|
Thread thread = new Thread(() =>
|
|
{
|
|
try
|
|
{
|
|
speech.Rate = 1; //语速
|
|
speech.Volume = 100; //音量
|
|
speech.Speak("保存成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
}
|
|
});
|
|
thread.IsBackground = true;
|
|
thread.Start();
|
|
}
|
|
}
|
|
if (!SystemInfo.Instance.isRemberText && sweepControl.isEmptyData)
|
|
{
|
|
sweepControl.ObjButtonEdit.Text = "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
isSearchRefresh = true;
|
|
if (MoudleObj.isRihgtRefresh == 1)
|
|
{
|
|
isSearchRefresh = false;
|
|
aftertxtFixKey = this.txtFixKey.Text;
|
|
string[] txtArgs = aftertxtFixKey.Split('-');
|
|
//ComboBoxModel model = this.txtEditClass.SelectedItem as ComboBoxModel;
|
|
//if (model != null && !(model.RowItem[model.ValueMember] + txtArgs[0]).Equals(afterRshKey))
|
|
//{
|
|
// afterRshKey = model.RowItem[model.ValueMember] + txtArgs[0];
|
|
// isSearchRefresh = true;
|
|
//}
|
|
DataRow rowItem = ComBoxSource != null && ComBoxSource.Rows.Count > 0 ? ComBoxSource.Select("1=1").FirstOrDefault(x => txtEditClass.Text == x[ComDisplayMember] + "") : null;
|
|
if (rowItem != null && !(rowItem[ComValueMember] + txtArgs[0]).Equals(afterRshKey))
|
|
{
|
|
afterRshKey = rowItem[ComValueMember] + txtArgs[0];
|
|
isSearchRefresh = true;
|
|
}
|
|
}
|
|
SearchMainGrid(true);
|
|
if (!string.IsNullOrEmpty(MoudleObj.AfterStored) && _rowItem != null)
|
|
{
|
|
try
|
|
{
|
|
|
|
string sql = this.ControlObj.ReplaceControlValue(MoudleObj.AfterStored);
|
|
sql = ReplaceHelper.ReplaceRowParam(_rowItem, sql);
|
|
string result = SqlHelper.ExecuteScalar(sql) + "";
|
|
if (!string.IsNullOrEmpty(result) && isFristSearch) MessageUtil.Show(result);
|
|
_rowItem = BaseImpl.GetDataRowResult(LastRefreshSql);
|
|
IniAllControl(_rowItem, false);
|
|
isFristSearch = true;
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
|
|
}
|
|
finally
|
|
{
|
|
ERPInfo.Instance.IsExecute = false;
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 下拉框控件获取数据后自动执行回车事件
|
|
/// <summary>
|
|
/// <para>说明:下拉框控件获取数据后自动执行回车事件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnEnterAfterCell(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(this._keyValue))
|
|
{
|
|
SweepAutoEdit sweepAutoEdit = sender as SweepAutoEdit;
|
|
DataRow item = sweepAutoEdit.Tag as DataRow;
|
|
string SweepControlText = sweepAutoEdit.EditValue;
|
|
string msgs = string.Empty, refreshPages = string.Empty, reRightButton = string.Empty;
|
|
int returnValue = ScanningCheckCard(this.SysModel.ModuleCode, SweepControlText, this._keyValue, this.SysModel.UserId, this.SysModel.UserName, 0, item["fieldname"] + "", out msgs, out refreshPages, out reRightButton);
|
|
string[] resultMsgs = msgs.ToLower().Split('&');
|
|
if (returnValue != 1)
|
|
{
|
|
MessageUtil.Show(resultMsgs[0]);
|
|
}
|
|
else
|
|
{
|
|
_pageIndex = refreshPages.Split(',');
|
|
if (resultMsgs.Length >= 2)
|
|
{
|
|
GetMsgParamters(resultMsgs);
|
|
}
|
|
else
|
|
{
|
|
if (_pageIndex != null) Refresh(_pageIndex);
|
|
}
|
|
if (!string.IsNullOrEmpty(reRightButton))
|
|
{
|
|
(sweepDic[double.Parse(reRightButton)] as SweepButton).OnClickCallBack();
|
|
}
|
|
System.Windows.Forms.Control FocusControl = this.ActiveControl;
|
|
for (int i = 0; i < sweepMidControl.Count - 1; i++)
|
|
{
|
|
if (sweepMidControl[i] == FocusControl)
|
|
{
|
|
if ((sweepMidControl[i + 1] as SweepAutoEdit).isGainFocus)
|
|
{
|
|
sweepMidControl[i + 1].Focus();
|
|
}
|
|
else
|
|
{
|
|
for (int j = i + 1; j <= sweepMidControl.Count - 1; j++)
|
|
{
|
|
if ((sweepMidControl[j] as SweepAutoEdit).isGainFocus)
|
|
{
|
|
sweepMidControl[j].Focus();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
#region 鼠标划过事件
|
|
private void OnMouseMove(object sender, EventArgs e)
|
|
{
|
|
SweepButton sweepButton = (SweepButton)sender;
|
|
if (sweepButton.isEnable)
|
|
{
|
|
sweepButton.BackColor = Color.FromArgb(255, 111, 0);// ColorTranslator.FromHtml("#eac205");
|
|
}
|
|
}
|
|
#endregion
|
|
#region 鼠标滑过提示信息事件
|
|
private void OnTips_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (labelTips.Text != "")
|
|
{
|
|
levitationPanel.Location = new Point(this.panelMain.PointToClient(MousePosition).X + 15, this.panelMain.PointToClient(MousePosition).Y + 15);
|
|
levitationPanel.labelLev.Text = labelTips.Text;
|
|
levitationPanel.Show();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 鼠标提示信息事件
|
|
|
|
private void OnTips_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
levitationPanel.Hide();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 鼠标离开事件
|
|
private void OnMouseLeave(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SweepButton sweepButton = (SweepButton)sender;
|
|
if (sweepButton.isEnable)
|
|
{
|
|
sweepButton.BackColor = sweepButton.emptyColor;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 优化加载速度
|
|
/// <summary>
|
|
/// 优化加载速度
|
|
/// </summary>
|
|
//protected override CreateParams CreateParams
|
|
//{
|
|
// get
|
|
// {
|
|
// CreateParams cp = base.CreateParams;
|
|
// cp.ExStyle |= 0x02000000;
|
|
// return cp;
|
|
// }
|
|
//}
|
|
#endregion
|
|
#region 下拉框选择刷新触发的存储过程
|
|
/// <summary>
|
|
/// 下拉框选择刷新触发的存储过程
|
|
/// </summary>
|
|
private void OnSelectedValueChanged(object sender, EventArgs e)
|
|
{
|
|
OnPubComChange();
|
|
}
|
|
#endregion
|
|
#region 下拉扫码框回车触发绑定功能
|
|
/// <summary>
|
|
/// <para>说明:下拉扫码框回车触发绑定功能</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-09-23</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnSelectedKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
if (ComBoxSource != null && ComBoxSource.Rows.Count > 0)
|
|
{
|
|
DataRow rowItem = ComBoxSource.Select("1=1").FirstOrDefault(x => txtEditClass.Text == x[ComDisplayMember] + "");
|
|
DataRow ValuerowItem = ComBoxSource.Select("1=1").FirstOrDefault(x => txtEditClass.Text == x[ComValueMember] + "");
|
|
if (rowItem != null)
|
|
{
|
|
this.txtEditClass.Text = rowItem[ComDisplayMember] + "";
|
|
}
|
|
if (ValuerowItem != null)
|
|
{
|
|
this.txtEditClass.Text = ValuerowItem[ComDisplayMember] + "";
|
|
}
|
|
}
|
|
OnPubComChange();
|
|
this.txtFixKey.Focus();
|
|
}
|
|
}
|
|
#endregion
|
|
#region 下拉扫码框回车触发绑定功能
|
|
/// <summary>
|
|
/// <para>说明:下拉框改变公共功能</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-09-23</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnPubComChange()
|
|
{
|
|
if (!string.IsNullOrEmpty(MoudleObj.ScreenStored) && _rowItem != null)
|
|
{
|
|
if (MoudleObj.isRihgtRefresh == 1)
|
|
{
|
|
isSearchRefresh = false;
|
|
string[] txtArgs = aftertxtFixKey.Split('-');
|
|
if (!string.IsNullOrEmpty(txtArgs[0]))
|
|
{
|
|
//ComboBoxModel model = this.txtEditClass.SelectedItem as ComboBoxModel;
|
|
DataRow rowItem = ComBoxSource != null && ComBoxSource.Rows.Count > 0 ? ComBoxSource.Select("1=1").FirstOrDefault(x => txtEditClass.Text == x[ComDisplayMember] + "") : null;
|
|
|
|
if (rowItem != null && !(rowItem[ComValueMember] + txtArgs[0]).Equals(afterRshKey))
|
|
{
|
|
afterRshKey = rowItem[ComValueMember] + txtArgs[0];
|
|
isSearchRefresh = true;
|
|
}
|
|
}
|
|
}
|
|
string sql = this.ControlObj.ReplaceControlValue(MoudleObj.ScreenStored);
|
|
sql = ReplaceHelper.ReplaceRowParam(_rowItem, sql);
|
|
string result = SqlHelper.ExecuteScalar(sql) + "";
|
|
_rowItem = BaseImpl.GetDataRowResult(LastRefreshSql);
|
|
this.ControlObj.ResetControlValue();
|
|
string codeSql = "Select";
|
|
bool isDoubleCode = false;//是否有多个条件
|
|
if (!string.IsNullOrEmpty(_searchCode))
|
|
{
|
|
string SearchCode = ReplaceHelper.ReplaceParamToValue(_searchCode, aftertxtFixKey); // 未替换的参数所有替换搜索值
|
|
codeSql += string.Format(" '{0}' as {1}", aftertxtFixKey, _searchFile);
|
|
DataRow rowItem = ComBoxSource != null && ComBoxSource.Rows.Count > 0 ? ComBoxSource.Select("1=1").FirstOrDefault(x => txtEditClass.Text == x[ComDisplayMember] + "") : null;
|
|
if (rowItem != null)
|
|
{
|
|
isDoubleCode = true;
|
|
SearchCode += " " + ReplaceHelper.ReplaceParamToValue(_searchSecondCode, rowItem[ComValueMember] + ""); // 未替换的参数所有替换搜索值
|
|
codeSql += string.Format(",'{0}' as {1}", rowItem[ComValueMember] + "", _searchSecondFile);
|
|
}
|
|
LastRefreshSql = isDoubleCode ? ReplaceHelper.ReplaceRowParam(BaseImpl.GetDataRowResult(codeSql), this.MoudleObj.RefreshSql) : ReplaceHelper.ReplaceParamToValue(this.MoudleObj.RefreshSql, aftertxtFixKey);
|
|
_rowItem = BaseImpl.GetDataRowResult(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql) + " " + SearchCode);
|
|
}
|
|
else
|
|
{
|
|
_rowItem = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql + "and" + _primaryKey + "=" + aftertxtFixKey)).Rows[0];
|
|
}
|
|
|
|
IniAllControl(_rowItem, false);
|
|
if (!string.IsNullOrEmpty(result)) MessageUtil.Show(result);
|
|
}
|
|
// this.txtFixKey.Focus();
|
|
}
|
|
#endregion
|
|
#region 扫码模块关闭时触发
|
|
/// <summary>
|
|
/// 扫码模块关闭时触发
|
|
/// </summary>
|
|
private void OnFormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(MoudleObj.FrmCloseStored))
|
|
{
|
|
string sql = this.ControlObj.ReplaceControlValue(MoudleObj.FrmCloseStored);
|
|
sql = ReplaceHelper.ReplaceRowParam(_rowItem, sql);
|
|
string result = SqlHelper.ExecuteScalar(sql) + "";
|
|
if (!string.IsNullOrEmpty(result)) MessageUtil.Show(result);
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 方法
|
|
|
|
#region 初始化分割条位置
|
|
/// <summary>
|
|
/// <para>说明:自动扫码(只有在msg有返回值时才会执行)</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2022-9-16</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void AutomaticSweepRheYard()
|
|
{
|
|
foreach (System.Windows.Forms.Control item in sweepMidControl.Values)
|
|
{
|
|
if (item is SweepControl && !string.IsNullOrEmpty(this._keyValue))
|
|
{
|
|
SweepControl sweepControl = item as SweepControl;
|
|
if (!string.IsNullOrWhiteSpace(sweepControl.ObjSweepControlText))
|
|
{
|
|
sweepControl.Focus();
|
|
KeyEventArgs e = new KeyEventArgs(Keys.Enter);
|
|
OnKeyDown(sweepControl, e);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 初始化分割条位置
|
|
/// <summary>
|
|
/// <para>说明:初始化分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-15</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitSpliterPosition()
|
|
{
|
|
string spliterPosition = IniHelper.Read(string.Format("Step_spliterPositionMain_{0}", this.SysModel.ModuleCode));
|
|
if (!string.IsNullOrEmpty(spliterPosition)) this.splitMain.SplitterPosition = Convert.ToInt32(spliterPosition);
|
|
|
|
string newwidth = IniHelper.Read(string.Format("Step_splitLeftSide_{0}", this.SysModel.ModuleCode));
|
|
if (!string.IsNullOrEmpty(newwidth)) this.splitLeftSide.SplitterPosition = Convert.ToInt32(newwidth);
|
|
this.splitLeftSide.SplitterMoved += new System.EventHandler(this.OnDetailsSplitterMoved);
|
|
}
|
|
#endregion
|
|
#region 刷新
|
|
/// <summary>
|
|
/// <para>说明:刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void Refresh(string[] pageIndexs, bool isRefresh = false, string positionIndex = "")
|
|
{
|
|
int selectdetailTabIndex = !string.IsNullOrEmpty(positionIndex) ? int.Parse(positionIndex) : this.detailTab.TabControlObj.SelectedTabPageIndex;
|
|
foreach (GridDetailModel gridmodel in GridDetailModelObjs)
|
|
{
|
|
string sqlValue = this.GetSearchSql(gridmodel, _rowItem);
|
|
if (isRefresh || pageIndexs.Contains<string>(gridmodel.Orderid + ""))
|
|
{
|
|
this.detailTab.TabControlObj.SelectedTabPage = this.detailTab.TabControlObj.TabPages.Where(o => o.Text.Contains(gridmodel.DetailName)).FirstOrDefault();
|
|
if (this.detailTab.TabControlObj.SelectedTabPage == null)
|
|
this.detailTab.TabControlObj.SelectedTabPage = this.detailTab.TabControlObj.TabPages[0];
|
|
this.detailTab.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue));
|
|
}
|
|
|
|
}
|
|
foreach (GridDetailModel gridmodel in GridDetailAddObj)
|
|
{
|
|
string sqlValue = this.GetSearchSql(gridmodel, _rowItem);
|
|
if (isRefresh || pageIndexs.Contains<string>(gridmodel.Orderid + ""))
|
|
{
|
|
|
|
this.TabBottom.TabControlObj.SelectedTabPage = this.TabBottom.TabControlObj.TabPages.Where(o => o.Text == gridmodel.DetailName).FirstOrDefault();
|
|
if (this.TabBottom.TabControlObj.SelectedTabPage == null)
|
|
this.TabBottom.TabControlObj.SelectedTabPage = this.TabBottom.TabControlObj.TabPages[0];
|
|
this.TabBottom.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue));
|
|
|
|
}
|
|
|
|
}
|
|
foreach (GridDetailModel gridmodel in GridDetailRightObj)
|
|
{
|
|
string sqlValue = this.GetSearchSql(gridmodel, _rowItem);
|
|
if (isRefresh || pageIndexs.Contains<string>(gridmodel.Orderid + ""))
|
|
{
|
|
this.TabRight.TabControlObj.SelectedTabPage = this.TabRight.TabControlObj.TabPages.Where(o => o.Text == gridmodel.DetailName).FirstOrDefault();
|
|
if (this.TabRight.TabControlObj.SelectedTabPage == null)
|
|
this.TabRight.TabControlObj.SelectedTabPage = this.detailTab.TabControlObj.TabPages[0];
|
|
this.TabRight.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue));
|
|
|
|
}
|
|
}
|
|
this.detailTab.TabControlObj.SelectedTabPageIndex = selectdetailTabIndex;
|
|
}
|
|
#endregion
|
|
#region 获取验证返回操作参数
|
|
/// <summary>
|
|
/// <para>说明:获取验证返回操作参数</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnSplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
IniHelper.Write(string.Format("Step_spliterPositionMain_{0}", this.SysModel.ModuleCode), this.splitMain.SplitterPosition + "");
|
|
}
|
|
#endregion
|
|
#region 扫码调用dll
|
|
/// <summary>
|
|
/// <para>说明:获取验证返回操作参数</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void GetMsgParamters(string[] msgs)
|
|
{
|
|
if (msgs[1].Contains("module="))
|
|
{
|
|
string[] paramters = msgs[1].Split('=');
|
|
if (paramters.Length != 2)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ProcNameSettingFault);
|
|
return;
|
|
}
|
|
string[] defaultParams = paramters[1].Split('^');
|
|
if (defaultParams.Length < 4)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ExcuteMoudleFail);
|
|
return;
|
|
}
|
|
string dllName = defaultParams[1];
|
|
string moduleTitle = defaultParams[2];
|
|
string saveState = defaultParams[3];
|
|
if ("lskj.pubadd3.dll".Equals(dllName) || "lskj.pubadd2.dll".Equals(dllName))
|
|
dllName = "Lskj.PubAdd.dll";
|
|
|
|
List<string> paramList = new List<string>();
|
|
for (int i = 4; i < 14; i++)
|
|
{
|
|
paramList.Add(defaultParams.Length > i ? defaultParams[i] : "");
|
|
}
|
|
//执行dll
|
|
string[] str = {
|
|
this.SysModel.FormText,
|
|
ERPInfo.Instance.UserId,
|
|
ERPInfo.Instance.UserName,
|
|
this.SysModel.Privilege,
|
|
this.SysModel.ModuleCode,
|
|
paramList[0],
|
|
paramList[1],
|
|
paramList[2],
|
|
paramList[3],
|
|
paramList[4],
|
|
paramList[5],
|
|
paramList[6],
|
|
paramList[7],
|
|
paramList[8],
|
|
paramList[9],
|
|
"",
|
|
"",
|
|
saveState
|
|
};
|
|
IForm form = FormHelper.LoadDllForm(dllName, str);
|
|
if (form == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DyncmicDllNotFount);
|
|
return;
|
|
}
|
|
if (form.SubForm == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DyncmicDllInitFault);
|
|
return;
|
|
}
|
|
form.SubForm.WindowState = FormWindowState.Normal;
|
|
form.SubForm.StartPosition = FormStartPosition.CenterScreen;
|
|
form.SubForm.Text = moduleTitle;
|
|
DialogResult dr = form.SubForm.ShowDialog();
|
|
if (_pageIndex != null) Refresh(_pageIndex);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 初始化属性
|
|
/// <summary>
|
|
/// <para>说明:初始化属性设置</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeSetting()
|
|
{
|
|
//string key=BaseImpl.GetBasePrimaryKey(this.SysModel.ModuleCode);
|
|
this._primaryKey = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetBasePrimaryKey() : BaseImpl.GetBasePrimaryKey(this.SysModel.ModuleCode);
|
|
DataTable dataRows = BaseModuleImpl.GetBaseGridColumns(SysModel.ModuleCode);
|
|
//DataRow dgxx = MainImpl.GetSystemdllTab(this.SysModel.ModuleCode);
|
|
DataRow dgxx = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetSystemdllTab() : MainImpl.GetSystemdllTab(this.SysModel.ModuleCode);
|
|
this.MoudleObj = new ModuleModel(dgxx);
|
|
DataRow menuCondRow = null;
|
|
|
|
if (dgxx.Table.Columns.Contains("isAmplification") && "1".Equals(dgxx["isAmplification"] + "")) isAmplification = true;
|
|
if (dgxx.Table.Columns.Contains("detailFontSize") && !string.IsNullOrWhiteSpace(dgxx["detailFontSize"] + "")) detailFontSize = int.Parse(dgxx["detailFontSize"] + "");
|
|
|
|
menuCondRow = BaseImpl.GetMenuConfigTab(this.SysModel.ModuleId); //获取菜单其他配置
|
|
if (menuCondRow != null)
|
|
{
|
|
if (menuCondRow["DllFileName"].Equals("Lskj.SweepCodeSearch.dll")) SysModel.IsDetailSearch = true;// 是否是配置查询明细
|
|
}
|
|
this._fontSize = 14;//获取扫码控件字体大小
|
|
int H = Screen.PrimaryScreen.Bounds.Height;
|
|
int W = Screen.PrimaryScreen.Bounds.Width;
|
|
this._fontSize = H * W >= 1920 * 1080 ? _fontSize : Convert.ToInt32(_fontSize * H * W / 1920 / 1080 * 1.3);
|
|
|
|
//和上方获取主键名重复了(存储过程中还没有删除这步)
|
|
//this.MoudleObj.ParmaryKey = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetBasePrimaryKey() : BaseImpl.GetBasePrimaryKey(this.SysModel.ModuleCode);
|
|
this.MoudleObj.ParmaryKey = this._primaryKey;
|
|
|
|
DataTable queryTable = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields() : BaseModuleImpl.GetCustomQueryFields(this.MoudleObj.CondKey);
|
|
|
|
if (queryTable != null && queryTable.Rows.Count > 0)
|
|
{
|
|
if (queryTable.Rows.Count == 1)
|
|
{
|
|
this.searchClass.Visible = false;
|
|
}
|
|
int searchNamewidth = 0; int searchClassWidth = 0;
|
|
foreach (DataRow queryItem in queryTable.Rows)
|
|
{
|
|
int FieldType = int.Parse(queryItem["fieldTypeId"] + "");
|
|
if (FieldType == ControlType.LabSacn)
|
|
{
|
|
_searchFile = queryItem["fieldName"] + "";
|
|
_searchCode = queryItem["checkCond"] + "";
|
|
this.lab_searchName.Text = queryItem["userName"] + "";
|
|
searchNamewidth = int.Parse(queryItem["controlWidth"] + "");
|
|
}
|
|
else
|
|
{
|
|
_searchSecondFile = queryItem["fieldName"] + "";
|
|
_searchSecondCode = queryItem["checkCond"] + "";
|
|
this.lab_searchClass.Text = queryItem["userName"] + "";
|
|
string ValueMember = ControlType.LabComboxValue == FieldType || ControlType.LabAutoCompleteValueParam == FieldType ? queryItem["lookupKeyField"] + "" : queryItem["lookupResult"] + "";
|
|
//string ValueMember = ControlType.LabComboxValue == FieldType || ControlType.LabAutoCompleteValueParam == FieldType ? model.ValueMember : model.TextMember;
|
|
//comboxEdit.ValueField = model.ValueMember;
|
|
//comboxEdit.TextField = model.TextMember;
|
|
ComBoxSource = MainImpl.GetDataTableResult(queryItem["lookupSql"] + "");
|
|
this.SetDataSource(ComBoxSource, ValueMember, queryItem["lookupResult"] + "");
|
|
//this.lab_searchClass.Width = searchClassWidth = int.Parse(queryItem["controlWidth"] + "");
|
|
this.searchClass.Width = searchClassWidth = int.Parse(queryItem["controlWidth"] + "");
|
|
|
|
}
|
|
}
|
|
this.pl_search.Width = searchNamewidth + searchClassWidth;
|
|
}
|
|
|
|
this.GridInitDetailModel = GetDetailGrids();
|
|
this.GridDetailModelObjs = GridInitDetailModel.Where(o => o.displayMode != 1 && o.rightVisible != 1 && o.Orderid != 100).ToList();
|
|
this.GridDetailAddObj = GridInitDetailModel.Where(o => o.displayMode == 1).ToList();
|
|
this.GridDetailRightObj = GridInitDetailModel.Where(o => o.rightVisible == 1).ToList();
|
|
|
|
this._dtFields = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields() : BaseModuleImpl.GetControlLocation(this.MoudleObj.FormKey, this.SysModel.ModuleCode);
|
|
|
|
this._codeFields = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields() : BaseImpl.GetSweepCode(this.SysModel.ModuleCode);
|
|
|
|
tips = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields() : BaseImpl.GetSweepCodeTips(this.SysModel.ModuleCode);//获取提示信息
|
|
|
|
this._RightFields = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields() : BaseModuleImpl.GetBaseGridRightMenus(this.SysModel.ModuleCode);
|
|
|
|
this.TabRight.Model = this.TabBottom.Model = this.detailTab.Model = this.SysModel;
|
|
if (!string.IsNullOrEmpty(this.SysModel.ParmaryValue))
|
|
{
|
|
this.txtFixKey.Text = this._keyValue = this.SysModel.ParmaryValue;
|
|
}
|
|
}
|
|
#region 初始化第二条件下拉框的值
|
|
#region 下拉框通用类
|
|
/// <summary>
|
|
/// <para>说明:下拉框通用类</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
class ComboBoxModel
|
|
{
|
|
public string ValueMember;
|
|
public string DisplayMember;
|
|
public DataRow RowItem;
|
|
|
|
public override string ToString()
|
|
{
|
|
return this.RowItem[DisplayMember] + "";
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// <para>说明:设置数据源</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2017-08-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="dataSource">数据源</param>
|
|
public void SetDataSource(DataTable dataSource, string ValueField, string TextField)
|
|
{
|
|
try
|
|
{
|
|
ComValueMember = ValueField;
|
|
ComDisplayMember = TextField;
|
|
foreach (DataRow item in dataSource.Rows)
|
|
{
|
|
ComboBoxModel model = new ComboBoxModel
|
|
{
|
|
ValueMember = ValueField,
|
|
DisplayMember = TextField,
|
|
RowItem = item
|
|
};
|
|
this.txtEditClass.Properties.Items.Add(model);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 通过字体内容提升长度
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected int GetCharWidth()
|
|
{
|
|
int CharWidth = 22;
|
|
float DefaultFontSize = 12;
|
|
return Convert.ToInt32(CharWidth + (lab_searchName.Font.Size > DefaultFontSize ? lab_searchName.Font.Size - DefaultFontSize : 0));
|
|
}
|
|
#endregion
|
|
#region 获取明细
|
|
/// <summary>
|
|
/// <para>说明:获取报表明细</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private List<GridDetailModel> GetDetailGrids()
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();
|
|
|
|
DataTable moduleDetailBottomTable = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields() : BaseModuleImpl.GetBaseDetailPages(this.SysModel.ModuleCode);
|
|
|
|
|
|
if (moduleDetailBottomTable.Rows.Count == 0)
|
|
{
|
|
moduleDetailBottomTable = BaseModuleImpl.GetBaseAddTabDetail(this.SysModel.ModuleCode);
|
|
}
|
|
|
|
foreach (DataRow item in moduleDetailBottomTable.Rows)
|
|
{
|
|
DataTable dtGridColumns = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields() : ReportImpl.GetReportDetailColumns(this.SysModel.ModuleCode, item["id"] + "");
|
|
details.Add(new GridDetailModel(item, dtGridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
return details;
|
|
}
|
|
#endregion
|
|
#region 初始化控件
|
|
/// <summary>
|
|
/// <para>说明:初始化控件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeControl()
|
|
{
|
|
levitationPanel = new LevitationPanel();
|
|
this.Controls.Add(levitationPanel);
|
|
levitationPanel.BringToFront();
|
|
levitationPanel.Hide();
|
|
this.panel1.Left = this.pl_search.Location.X + this.pl_search.Width + 10;
|
|
this.labelTips.Location = new Point(this.panel1.Location.X + this.panel1.Width + 10, (this.pl_search.Height - this.labelTips.Height) / 2);
|
|
this.ControlObj = new MyControl();
|
|
this.ControlObj.InitControl(_dtFields, this.pl_Main_Center, false);
|
|
int sweepControlWidth = 0;
|
|
int top = 0; int left = 0;
|
|
this.pl_Main.Height = Convert.ToInt32(pl_Main.Height * _FormHeight);
|
|
|
|
|
|
if (_codeFields.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < _codeFields.Rows.Count; i++)
|
|
{
|
|
top += Convert.ToInt32((17 * _FormHeight));
|
|
DataRow item = _codeFields.Rows[i];
|
|
if (!string.IsNullOrEmpty(item["fieldsql"] + ""))
|
|
{
|
|
SweepAutoEdit sweepControl = new SweepAutoEdit();
|
|
sweepControl.orderId = i + "";
|
|
sweepControl.Parent = detailplControl;
|
|
sweepControl.TitleLabelObj.Text = item["username1"] + "";
|
|
sweepControl.ValueMember = sweepControl.ValueField = item["fieldsqlid"] + ""; ;
|
|
sweepControl.TextMember = item["fieldsqlname"] + ""; ;
|
|
sweepControl.SourceSQL = item["fieldsql"] + "";
|
|
sweepControl.DataSource = MainImpl.GetDataTableResult(item["fieldsql"] + "");
|
|
sweepControl.Top = top;
|
|
sweepControl.Left = -30;
|
|
sweepControl.Tag = item;
|
|
sweepControl.OnEnterAfterback += OnEnterAfterCell;
|
|
sweepControl.Name = item["fieldname"] + "";
|
|
sweepControl.ControlObj = this.ControlObj;
|
|
sweepControl.TextEdit.ImeMode = System.Windows.Forms.ImeMode.Disable;//扫码框设置输入时不会弹出输入法框
|
|
|
|
if (_codeFields.Columns.Contains("isGainFocus"))
|
|
{
|
|
// 是否扫码后获取焦点(默认获取,配置为1就不获取)
|
|
sweepControl.isGainFocus = !string.IsNullOrEmpty(item["isGainFocus"] + "") ? !"1".Equals(item["isGainFocus"] + "") : true;
|
|
}
|
|
if (_codeFields.Columns.Contains("RefreshMain"))
|
|
{
|
|
//扫码后刷新主表
|
|
sweepControl.RefreshMain = !string.IsNullOrEmpty(item["RefreshMain"] + "") ? "1".Equals(item["RefreshMain"] + "") : false;
|
|
}
|
|
|
|
|
|
if (_fontSize > 0)
|
|
{
|
|
sweepControl.Width = Convert.ToInt32(sweepControl.Width * _FormWidth);
|
|
sweepControlWidth = sweepControl.Width;
|
|
sweepControl.Height = Convert.ToInt32(sweepControl.Height * _FormHeight) + 5;
|
|
sweepControl.FontSize = _fontSize;
|
|
|
|
if (isAmplification)
|
|
{
|
|
//设置了大小的情况
|
|
sweepControl.TitleLabelObj.AutoSize = true;
|
|
sweepControl.Left = 0;
|
|
sweepControl.FontSize = int.Parse(item["FontSize"] + "");
|
|
sweepControl.TextEdit.Width = sweepControl.Width - sweepControl.TitleLabelObj.Width;
|
|
Image image = sweepControl.TextEdit.Properties.Buttons[0].Image;
|
|
Size size = new Size(Convert.ToInt32(sweepControl.TextEdit.Properties.Buttons[0].Image.Width * _FormWidth), sweepControl.Height);
|
|
sweepControl.TextEdit.Properties.Buttons[0].Image = resizeImage(image, size);
|
|
}
|
|
else
|
|
{
|
|
Image image = sweepControl.TextEdit.Properties.Buttons[0].Image;
|
|
Size size = new Size(Convert.ToInt32(sweepControl.TextEdit.Properties.Buttons[0].Image.Width * _FormWidth), Convert.ToInt32(sweepControl.TextEdit.Properties.Buttons[0].Image.Height * _FormHeight));
|
|
sweepControl.TextEdit.Properties.Buttons[0].Image = resizeImage(image, size);
|
|
}
|
|
|
|
|
|
sweepControl.Popup.Width = Convert.ToInt32(sweepControl.Popup.Width * _FormWidth);
|
|
sweepControl.Popup.Height = Convert.ToInt32(sweepControl.Popup.Height * _FormHeight);
|
|
sweepControl.Popup.GridViewObj.Appearance.Row.Font = new System.Drawing.Font("Microsoft YaHei UI", _fontSize);
|
|
sweepControl.Popup.GridViewObj.Appearance.Row.Font = new System.Drawing.Font("Microsoft YaHei UI", _fontSize);
|
|
}
|
|
top += sweepControl.Height;
|
|
sweepMidControl.Add(i, sweepControl);
|
|
}
|
|
else
|
|
{
|
|
SweepControl sweepControl = new SweepControl();
|
|
sweepControlWidth = sweepControl.Width;
|
|
sweepControl.orderId = i + "";
|
|
sweepControl.Parent = detailplControl;
|
|
sweepControl.TitleLabelObj.Text = item["username1"] + "";
|
|
sweepControl.Top = top;
|
|
sweepControl.Left = -30;
|
|
sweepControl.Tag = item;
|
|
sweepControl.KeyDown += OnKeyDown;
|
|
sweepControl.Name = item["fieldname"] + "";
|
|
sweepControl.ObjButtonEdit.ImeMode = System.Windows.Forms.ImeMode.Disable;//扫码框设置输入时不会弹出输入法框
|
|
|
|
if (_codeFields.Columns.Contains("isEmptyData"))
|
|
{
|
|
// 是否清空数据(默认清空,配置为1就不清空)
|
|
sweepControl.isEmptyData = !string.IsNullOrEmpty(item["isEmptyData"] + "") ? !"1".Equals(item["isEmptyData"] + "") : true;
|
|
}
|
|
if (_codeFields.Columns.Contains("isGainFocus"))
|
|
{
|
|
// 是否扫码后获取焦点(默认获取,配置为1就不获取)
|
|
sweepControl.isGainFocus = !string.IsNullOrEmpty(item["isGainFocus"] + "") ? !"1".Equals(item["isGainFocus"] + "") : true;
|
|
}
|
|
if (_codeFields.Columns.Contains("RefreshMain"))
|
|
{
|
|
//扫码后刷新主表
|
|
sweepControl.RefreshMain = !string.IsNullOrEmpty(item["RefreshMain"] + "") ? "1".Equals(item["RefreshMain"] + "") : false;
|
|
}
|
|
if (_codeFields.Columns.Contains("ScanInterval"))
|
|
{
|
|
//扫码后成功后等待的时间(秒) 此参数不在使用
|
|
sweepControl.WaitingTime = !string.IsNullOrEmpty(item["ScanInterval"] + "") ? int.Parse(item["ScanInterval"] + "") : 0;
|
|
}
|
|
|
|
if (_fontSize > 0)
|
|
{
|
|
sweepControl.Width = Convert.ToInt32(sweepControl.Width * _FormWidth);
|
|
sweepControl.Height = Convert.ToInt32(sweepControl.Height * _FormHeight) + 5;
|
|
sweepControl.FontSize = _fontSize;//_fontSize
|
|
|
|
if (isAmplification)
|
|
{
|
|
//codeFields.Columns.Contains("FontSize")&& !string.IsNullOrWhiteSpace(item["FontSize"]+"")&&int.Parse(item["FontSize"]+"")>14
|
|
//设置了大小的情况
|
|
sweepControl.TitleLabelObj.AutoSize = true;
|
|
sweepControl.Left = 0;
|
|
sweepControl.FontSize = int.Parse(item["FontSize"] + "");
|
|
sweepControl.ObjButtonEdit.Width = sweepControl.Width - sweepControl.TitleLabelObj.Width;
|
|
Image image = sweepControl.ObjButtonEdit.Properties.Buttons[0].Image;
|
|
Size size = new Size(Convert.ToInt32(sweepControl.ObjButtonEdit.Properties.Buttons[0].Image.Width * _FormWidth), sweepControl.Height);
|
|
sweepControl.ObjButtonEdit.Properties.Buttons[0].Image = resizeImage(image, size);
|
|
}
|
|
else
|
|
{
|
|
Image image = sweepControl.ObjButtonEdit.Properties.Buttons[0].Image;
|
|
Size size = new Size(Convert.ToInt32(sweepControl.ObjButtonEdit.Properties.Buttons[0].Image.Width * _FormWidth), Convert.ToInt32(sweepControl.ObjButtonEdit.Properties.Buttons[0].Image.Height * _FormHeight));
|
|
sweepControl.ObjButtonEdit.Properties.Buttons[0].Image = resizeImage(image, size);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
top += sweepControl.Height;
|
|
sweepMidControl.Add(i, sweepControl);
|
|
}
|
|
}
|
|
}
|
|
this.detailpl_Left.Width = sweepControlWidth;
|
|
detailplControl.EndInit();
|
|
this.detailContorl.Height = top + Convert.ToInt32(15 * _FormHeight);
|
|
if (_RightFields.Rows.Count > 0)
|
|
{
|
|
top = 25;
|
|
left = 10;
|
|
|
|
|
|
|
|
for (int i = 0; i < _RightFields.Rows.Count; i++)
|
|
{
|
|
SweepButton sweepButton = new SweepButton();
|
|
DataRow item = _RightFields.Rows[i];
|
|
GridRightMenuModel menuModel = new GridRightMenuModel(item);
|
|
sweepButton.Parent = detailControl_Right;
|
|
sweepButton.TitleLabelObj.Text = menuModel.MenuName;
|
|
sweepButton.Tag = menuModel;
|
|
//sweepButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
sweepButton.OnClick += new EventHandler(OnModuleClick);
|
|
sweepButton.OnHover += new EventHandler(OnMouseMove);
|
|
sweepButton.OnLeave += new EventHandler(OnMouseLeave);
|
|
sweepButton.BackColor = Color.FromArgb(65, 115, 188); //ColorTranslator.FromHtml(_defaultColors[i % 4]);//背景颜色
|
|
sweepButton.emptyColor = Color.FromArgb(65, 115, 188);// ColorTranslator.FromHtml(_defaultColors[i % 4]);
|
|
sweepButton.BorderStyle = BorderStyle.None;
|
|
sweepButton.TitleLabelObj.Font = new Font("宋体", 9, FontStyle.Regular);
|
|
|
|
|
|
|
|
if (_fontSize > 0)
|
|
{
|
|
sweepButton.Width = Convert.ToInt32(sweepButton.Width * _FormWidth * 0.7);
|
|
sweepButton.Height = Convert.ToInt32(sweepButton.Height * _FormHeight);
|
|
sweepButton.FontSize = _fontSize;
|
|
if (isAmplification)
|
|
{
|
|
if (item.Table.Columns.Contains("FontSize") && !string.IsNullOrWhiteSpace(item["FontSize"] + ""))
|
|
{
|
|
sweepButton.FontSize = int.Parse(item["FontSize"] + "");
|
|
}
|
|
else
|
|
{
|
|
sweepButton.FontSize = _fontSize + 4;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
sweepButton.FontSize = _fontSize;
|
|
}
|
|
}
|
|
|
|
if (this.MoudleObj.ButtonFlat)
|
|
{
|
|
top = (detailControl_Right.Height - sweepButton.Height) / 2;
|
|
if (i != 0)
|
|
{
|
|
left += Convert.ToInt32(34 * _FormWidth) + sweepButton.Width;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (i % 2 == 0)
|
|
{
|
|
if (i != 0)
|
|
{
|
|
left += Convert.ToInt32(34 * _FormWidth) + sweepButton.Width;
|
|
top -= (sweepButton.Height + Convert.ToInt32(22 * _FormHeight));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
top += sweepButton.Height + Convert.ToInt32(22 * _FormHeight);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
sweepButton.Top = top;
|
|
sweepButton.Left = left;
|
|
sweepDic.Add(menuModel.OrderId, sweepButton);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
#region 初始化扫码功能模块的明细数据
|
|
/// <summary>
|
|
/// <para>说明:初始化扫码功能模块的明细数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeDetailGrid()
|
|
{
|
|
|
|
if (_fontSize != 0)
|
|
{
|
|
decimal result = Math.Round((decimal)_fontSize / (decimal)12, 2);//缩放比
|
|
this.pl_Bottom.Height = Convert.ToInt32(this.pl_Bottom.Height * result);
|
|
}
|
|
if (GridDetailAddObj.Count > 0)
|
|
{
|
|
this.TabBottom.InitTabPages(GridDetailAddObj);
|
|
}
|
|
else
|
|
{
|
|
pl_Bottom.Visible = false;
|
|
}
|
|
this.detailTab.ParentControlEx = this.ControlObj;
|
|
this.detailTab.InitTabPages(GridDetailModelObjs, isAmplification ? detailFontSize > 0 ? detailFontSize : 14 : 0);
|
|
|
|
|
|
if (GridDetailRightObj.Count > 0)
|
|
{
|
|
this.TabRight.InitTabPages(GridDetailRightObj);//InitTabPages(GridDetailRightObj)
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(this._keyValue))
|
|
{
|
|
SearchMainGrid();
|
|
}
|
|
SetTabPageStyle();
|
|
this.splitMain.PanelVisibility = SplitPanelVisibility.Panel1;//初始化时默认隐藏
|
|
//SweepIsUsable();
|
|
}
|
|
#endregion
|
|
#region 设置动态TabPage的样式
|
|
/// <summary>
|
|
/// <para>说明:设置动态的TabPage的样式隐藏页签标题</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetTabPageStyle()
|
|
{
|
|
detailTab.TabControlObj.ShowTabHeader = detailTab.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
TabBottom.TabControlObj.ShowTabHeader = TabBottom.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
TabRight.TabControlObj.ShowTabHeader = TabRight.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
}
|
|
#endregion
|
|
#region 加载新数据源
|
|
/// <summary>
|
|
/// <para>说明:加载新的数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="Index">数据索引</param>
|
|
private void LoadNewForm(DataRow dataRowItem)
|
|
{
|
|
//三部分明细数据源更新
|
|
setTabPageGridData(detailTab, dataRowItem);
|
|
setTabPageGridData(TabBottom, dataRowItem);
|
|
|
|
if (isSearchRefresh || !SystemInfo.Instance.isRemberText) setTabPageGridData(TabRight, dataRowItem, true);
|
|
this.ControlObj.SetAllControlValue(dataRowItem);
|
|
this._keyValue = dataRowItem == null ? string.Empty : dataRowItem[this._primaryKey] + "";
|
|
}
|
|
#endregion
|
|
#region 设置选项卡数据源
|
|
/// <summary>
|
|
/// <para>说明:设置选项卡数据源</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void setTabPageGridData(TabControlEx tabDetail, DataRow rowItem, bool isRigh = false)
|
|
{
|
|
int DisplayQuantity = 0;//右侧显示的数量
|
|
|
|
foreach (XtraTabPage tabPage in tabDetail.TabControlObj.TabPages)
|
|
{
|
|
GridDetailModel model = tabDetail.GetGridDetailModel(tabPage);
|
|
if (model.ProhibitRefresh) continue;//设置后不刷新数据
|
|
if (tabPage.Tag is FrmWebBrowser)
|
|
{
|
|
|
|
// 加载网页
|
|
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
|
|
|
if (isRigh)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(url))
|
|
{
|
|
tabPage.PageVisible = false;
|
|
}
|
|
else
|
|
{
|
|
tabPage.PageVisible = true;
|
|
//tabDetail.TabControlObj.SelectedTabPage = tabPage;//先选中页签,避免出现除第一个外的页签中网页都很小的问题
|
|
DisplayQuantity++;
|
|
}
|
|
}
|
|
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
|
if (isRigh)
|
|
{
|
|
if (TabRight.TabControlObj.TabPages.Count > 0 && DisplayQuantity > 0)
|
|
{
|
|
this.splitMain.PanelVisibility = SplitPanelVisibility.Both;
|
|
}
|
|
else
|
|
{
|
|
this.splitMain.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
}
|
|
|
|
FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser;
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.LoadUrl(url);
|
|
webView.Tag = model;
|
|
}
|
|
else
|
|
{
|
|
GridControlEx gridControl = tabPage.Tag as GridControlEx;
|
|
gridControl.LastSearchSql = this.GetSearchSql(model, rowItem);
|
|
tabDetail.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(gridControl.LastSearchSql));
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
#region 获取查询条件
|
|
/// <summary>
|
|
/// <para>说明:获取查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2021-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <returns>System.String.</returns>
|
|
protected string GetSearchSql(GridDetailModel model, DataRow rowItem)
|
|
{
|
|
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) ? model.UnionParentField : this.MoudleObj.ParmaryKey;
|
|
string sqlValue = model.IsReadOnly ? model.DetailSql : model.SystemModel.MenuSql;
|
|
string orderCond = _dicOrder.FirstOrDefault(o => o.Key == model.UnionModule).Value;
|
|
if (rowItem == null) return ReplaceHelper.ReplaceWhereCond(sqlValue) + " and 1<>1";
|
|
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[fieldName] + "");
|
|
}
|
|
else
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
}
|
|
return sqlValue + orderCond;
|
|
}
|
|
#endregion
|
|
#region 公用刷新主表程序
|
|
/// <summary>
|
|
/// <para>说明:主程序刷新方法</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <returns>System.String.</returns>
|
|
public void SearchMainGrid(bool isFocus = false)
|
|
{
|
|
try
|
|
{
|
|
labelTips.Text = "";
|
|
//lab_TipsText = "";
|
|
string codeSql = "select";
|
|
bool isDoubleCode = false;//是否有多个条件
|
|
this.panel1.BackgroundImage = global::Lskj.SweepCode.Properties.Resources.message;
|
|
panel1.BackColor = Color.FromArgb(65, 115, 188);
|
|
if (!string.IsNullOrEmpty(_searchCode))
|
|
{
|
|
string SearchCode = ReplaceHelper.ReplaceParamToValue(_searchCode, txtFixKey.Text); // 未替换的参数所有替换搜索值
|
|
codeSql += string.Format(" '{0}' as {1}", txtFixKey.Text, _searchFile);
|
|
DataRow rowItem = ComBoxSource != null && ComBoxSource.Rows.Count > 0 ? ComBoxSource.Select("1=1").FirstOrDefault(x => txtEditClass.Text == x[ComDisplayMember] + "") : null;
|
|
if (rowItem != null)
|
|
{
|
|
isDoubleCode = true;
|
|
SearchCode += " " + ReplaceHelper.ReplaceParamToValue(_searchSecondCode, rowItem[ComValueMember] + ""); // 未替换的参数所有替换搜索值
|
|
codeSql += string.Format(",'{0}' as {1}", rowItem[ComValueMember] + "", _searchSecondFile);
|
|
}
|
|
LastRefreshSql = isDoubleCode ? ReplaceHelper.ReplaceRowParam(BaseImpl.GetDataRowResult(codeSql), this.MoudleObj.RefreshSql) : ReplaceHelper.ReplaceParamToValue(this.MoudleObj.RefreshSql, txtFixKey.Text);
|
|
AnotherLastRefreshSql = ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql) + " " + SearchCode;
|
|
//_rowItem = BaseImpl.GetDataRowResult(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql) + " " + SearchCode);
|
|
_rowItem = BaseImpl.GetDataRowResult(AnotherLastRefreshSql);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
_rowItem = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql + "and" + _primaryKey + "=" + txtFixKey.Text)).Rows[0];
|
|
}
|
|
|
|
if (isFocus && _rowItem != null && this.MoudleObj.Broadcast)
|
|
{
|
|
|
|
Thread thread = new Thread(() =>
|
|
{
|
|
try
|
|
{
|
|
speech.Rate = 1; //语速
|
|
speech.Volume = 100; //音量
|
|
speech.Speak("扫码成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
}
|
|
|
|
});
|
|
thread.IsBackground = true;
|
|
thread.Start();
|
|
|
|
}
|
|
|
|
//页签中设置主表行(页签里可以设置主表行中的值为默认值)
|
|
if (_rowItem != null)
|
|
{
|
|
this.detailTab.SetMainRow(_rowItem);
|
|
}
|
|
|
|
IniAllControl(_rowItem, isFocus);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
#region 刷新所有界面数据
|
|
/// <summary>
|
|
/// <para>说明:刷新所有界面数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-04</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void IniAllControl(DataRow rowItem, bool isFocus)
|
|
{
|
|
if (rowItem != null)
|
|
{
|
|
|
|
if (tips != null && tips.Rows.Count > 0)
|
|
{
|
|
labelTips.Text = rowItem[tips.Rows[0]["fieldname"] + ""] + "";
|
|
if (rowItem.Table.Columns.Contains(IsSweepTipStata)) SweepTipStata.Text = rowItem[IsSweepTipStata] + "";
|
|
//lab_TipsText = rowItem[tips.Rows[0]["fieldname"] + ""] + "";
|
|
}
|
|
|
|
for (int i = 0; i < sweepMidControl.Count; i++)
|
|
{
|
|
if (sweepMidControl[i] is SweepControl)
|
|
{
|
|
SweepControl sweepControl = (sweepMidControl[i] as SweepControl);
|
|
DataRow item = sweepControl.Tag as DataRow;
|
|
string cond = ReplaceHelper.ReplaceRowParam(_rowItem, item["disableCond"] + "");
|
|
bool isEnabled = string.IsNullOrEmpty(item["disableCond"] + "") ? true : ReplaceHelper.EvalCond(cond);
|
|
sweepControl.Enabled = isEnabled;
|
|
}
|
|
if (sweepMidControl[i] is SweepAutoEdit)
|
|
{
|
|
SweepAutoEdit sweepAutoEdit = (sweepMidControl[i] as SweepAutoEdit);
|
|
DataRow item = sweepAutoEdit.Tag as DataRow;
|
|
string cond = ReplaceHelper.ReplaceRowParam(_rowItem, item["disableCond"] + "");
|
|
bool isEnabled = string.IsNullOrEmpty(item["disableCond"] + "") ? true : ReplaceHelper.EvalCond(cond);
|
|
sweepAutoEdit.Enabled = isEnabled;
|
|
}
|
|
}
|
|
|
|
//foreach (System.Windows.Forms.Control control in detailplControl.Controls)
|
|
//{
|
|
// if (control is SweepControl)
|
|
// {
|
|
// SweepControl sweepControl = (control as SweepControl);
|
|
// sweepControl.ObjButtonEdit.Text = rowItem[sweepControl.Name] + "";
|
|
// }
|
|
// if (control is SweepAutoEdit)
|
|
// {
|
|
// SweepAutoEdit sweepAutoEdit = (control as SweepAutoEdit);
|
|
// sweepAutoEdit.EditValue = rowItem[sweepAutoEdit.Name] + "";
|
|
// }
|
|
//}
|
|
LoadNewForm(rowItem);
|
|
this.ControlObj.SetAllControlValue(rowItem);
|
|
if (!(rowItem.Table.Columns.Contains(IsGotoFirstCtr) && rowItem[IsGotoFirstCtr].Equals("1")) && isFocus)
|
|
{
|
|
SweepControl sweepControl = this.detailplControl.Controls.Cast<SweepControl>().FirstOrDefault(x => x.orderId == "0");
|
|
if (sweepControl != null) sweepControl.ObjButtonEdit.Focus();
|
|
|
|
}
|
|
if (!SystemInfo.Instance.isRemberText)
|
|
{
|
|
this.txtFixKey.Text = string.Empty;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_rowItem = null;
|
|
this.ControlObj.ResetControlValue();
|
|
LoadNewForm(_rowItem);
|
|
this.txtFixKey.Text = string.Empty;
|
|
aftertxtFixKey = string.Empty;
|
|
labelTips.Text = "该工单不存在!";
|
|
//lab_TipsText = "该工单不存在!";
|
|
this.panel1.BackgroundImage = global::Lskj.SweepCode.Properties.Resources.红喇叭;
|
|
}
|
|
SweepIsUsable();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 扫码框执行的存储过程
|
|
/// <summary>
|
|
/// <para>说明:生产过程随工单扫码验证</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">模块编号.</param>
|
|
/// <param name="scanCode">扫码信息.</param>
|
|
/// <param name="parmaryValue">主键值.</param>
|
|
/// <param name="operatorId">用户Id.</param>
|
|
/// <param name="operatorName">用户名</param>
|
|
/// <param name="flag">确认标记.</param>
|
|
/// <param name="msgs">返回消息</param>
|
|
/// <param name="pageRefrsh">刷新页签</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int ScanningCheckCard(string menuCode, string scanCode, string parmaryValue, string operatorId, string operatorName, int flag, string scanField, out string msgs, out string refreshPages, out string reRightButton)
|
|
{
|
|
SqlParameter msg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
msg.Direction = ParameterDirection.Output;
|
|
SqlParameter pageindex = new SqlParameter("@pageindex", SqlDbType.VarChar, 50);
|
|
pageindex.Direction = ParameterDirection.Output;
|
|
SqlParameter rightIndex = new SqlParameter("@actionIndex", SqlDbType.VarChar, 50);
|
|
rightIndex.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return_value", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@modid",SqlDbType.VarChar,10),
|
|
new SqlParameter("@scanCode",SqlDbType.VarChar,50),
|
|
new SqlParameter("@keyvalue",SqlDbType.VarChar,40),
|
|
new SqlParameter("@operatorId",SqlDbType.Int,4),
|
|
new SqlParameter("@operatorName",SqlDbType.VarChar,20),
|
|
new SqlParameter("@comfirmFlag",SqlDbType.VarChar,500),
|
|
new SqlParameter("@scanField",SqlDbType.VarChar,40),
|
|
pageindex,
|
|
rightIndex,
|
|
msg,
|
|
returnValue
|
|
};
|
|
param[0].Value = menuCode;
|
|
param[1].Value = scanCode;
|
|
param[2].Value = parmaryValue;
|
|
param[3].Value = operatorId;
|
|
param[4].Value = operatorName;
|
|
param[5].Value = flag;
|
|
param[6].Value = scanField;
|
|
SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_mrp_ProcessScanning", "temp", param);
|
|
msgs = msg.Value + "";
|
|
refreshPages = pageindex.Value + "";
|
|
reRightButton = rightIndex.Value + "";
|
|
return Convert.ToInt32(returnValue.Value);
|
|
}
|
|
|
|
#endregion
|
|
#region 根据字体缩放大小
|
|
/// <summary>
|
|
/// <para>说明:根据字体缩放大小</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-07-04</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void ResizeControl()
|
|
{
|
|
_FormHeight = (double)(Screen.PrimaryScreen.Bounds.Height) / (double)1080;
|
|
_FormWidth = (double)(Screen.PrimaryScreen.Bounds.Width) / (double)1920;
|
|
if (_fontSize == 0) return;
|
|
double result = Math.Round((double)_fontSize / (double)txtFixKey.Font.Size, 2);//缩放比
|
|
Font originalAttributes = this.lab_searchName.Font;
|
|
this.lab_searchName.Font = new Font(originalAttributes.Name, _fontSize, FontStyle.Bold);//_fontSize;
|
|
pl_search.Width = Convert.ToInt32(Math.Round((double)pl_search.Width * _FormWidth));
|
|
pl_search.Height = Convert.ToInt32((double)pl_search.Height * _FormHeight);
|
|
pl_search.Top = Convert.ToInt32((double)pl_search.Top * _FormHeight);
|
|
originalAttributes = this.txtFixKey.Font;
|
|
txtFixKey.Font = new Font(originalAttributes.Name, _fontSize);
|
|
detailpl_Left.Width = Convert.ToInt32((double)detailpl_Left.Width * _FormWidth);
|
|
//pl_TopSearch.Width = Convert.ToInt32(pl_TopSearch.Width * result);
|
|
pl_TopSearch.Height = Convert.ToInt32((double)pl_TopSearch.Height * _FormHeight);
|
|
panel1.Width = Convert.ToInt32((double)panel1.Width * _FormWidth);
|
|
panel1.Height = Convert.ToInt32((double)panel1.Height * _FormHeight);
|
|
panel1.Top = Convert.ToInt32((double)panel1.Top * _FormHeight);
|
|
//lab_searchName.Top = Convert.ToInt32(lab_searchName.Top * result);
|
|
|
|
pl_MainState.Height = Convert.ToInt32((double)pl_MainState.Height * _FormHeight);
|
|
originalAttributes = this.labelControl5.Font;
|
|
labelControl5.Font = new Font(originalAttributes.Name, _fontSize, FontStyle.Bold);
|
|
labelControl5.Top = Convert.ToInt32((double)labelControl5.Top * _FormHeight);
|
|
originalAttributes = this.SweepTipStata.Font;
|
|
SweepTipStata.Font = new Font(originalAttributes.Name, _fontSize, FontStyle.Bold);
|
|
SweepTipStata.Top = Convert.ToInt32((double)SweepTipStata.Top * _FormHeight);
|
|
|
|
detailTab_Title.Height = Convert.ToInt32((double)detailTab_Title.Height * _FormHeight);
|
|
originalAttributes = this.lbTitle.Font;
|
|
lbTitle.Font = new Font(originalAttributes.Name, _fontSize, FontStyle.Bold);
|
|
|
|
pl_Bottom_Title.Height = Convert.ToInt32((double)pl_Bottom_Title.Height * _FormHeight);
|
|
originalAttributes = this.label1.Font;
|
|
label1.Font = new Font(originalAttributes.Name, _fontSize, FontStyle.Bold);
|
|
|
|
Image image = txtFixKey.Properties.Buttons[0].Image;
|
|
Size size = new Size(Convert.ToInt32((double)txtFixKey.Properties.Buttons[0].Image.Width * _FormWidth), Convert.ToInt32((double)txtFixKey.Properties.Buttons[0].Image.Height * _FormHeight));
|
|
txtFixKey.Properties.Buttons[0].Image = resizeImage(image, size);
|
|
this.lab_searchName.Width = this.lab_searchName.Text.Length * GetCharWidth();
|
|
this.lab_searchClass.Width = this.lab_searchClass.Text.Length * GetCharWidth();
|
|
this.lab_searchName.Location = new Point(0, this.txtFixKey.Location.Y);
|
|
this.detailpl_Left.Width = Convert.ToInt32(this.Size.Width / 3.5);
|
|
this.lab_searchClass.Font = new Font(originalAttributes.Name, _fontSize, FontStyle.Bold);//_fontSize;
|
|
this.txtEditClass.Font = new Font(originalAttributes.Name, _fontSize);
|
|
}
|
|
#endregion
|
|
#region 改变图片大小
|
|
/// <summary>
|
|
/// <para>说明:改变图片大小</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-07-04</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private static System.Drawing.Image resizeImage(System.Drawing.Image imgToResize, Size size)
|
|
{
|
|
//获取图片宽度
|
|
int sourceWidth = imgToResize.Width;
|
|
//获取图片高度
|
|
int sourceHeight = imgToResize.Height;
|
|
|
|
float nPercent = 0;
|
|
float nPercentW = 0;
|
|
float nPercentH = 0;
|
|
//计算宽度的缩放比例
|
|
nPercentW = ((float)size.Width / (float)sourceWidth);
|
|
//计算高度的缩放比例
|
|
nPercentH = ((float)size.Height / (float)sourceHeight);
|
|
|
|
if (nPercentH < nPercentW)
|
|
nPercent = nPercentH;
|
|
else
|
|
nPercent = nPercentW;
|
|
//期望的宽度
|
|
int destWidth = (int)(sourceWidth * nPercent);
|
|
//期望的高度
|
|
int destHeight = (int)(sourceHeight * nPercent);
|
|
|
|
Bitmap b = new Bitmap(destWidth, destHeight);
|
|
Graphics g = Graphics.FromImage((System.Drawing.Image)b);
|
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
|
//绘制图像
|
|
g.DrawImage(imgToResize, 0, 0, destWidth, destHeight);
|
|
g.Dispose();
|
|
return (System.Drawing.Image)b;
|
|
}
|
|
#endregion
|
|
#region 扫码完成后判断右键是否可点击
|
|
/// <summary>
|
|
/// <para>说明:扫码完成后判断右键是否可点击</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-25</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SweepIsUsable()
|
|
{
|
|
int i = 0;
|
|
// 判断右键菜单是否可用
|
|
foreach (SweepButton sweepButton in detailControl_Right.Controls)
|
|
{
|
|
GridRightMenuModel model = sweepButton.Tag as GridRightMenuModel;
|
|
if (_rowItem == null)
|
|
{
|
|
//sweepButton.Enabled = false;
|
|
sweepButton.isEnable = false;
|
|
sweepButton.BackColor = Color.FromArgb(104, 104, 104); //colorlist[i % 4];//背景颜色
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(model.MenuCond))
|
|
{
|
|
try
|
|
{
|
|
string cond = ReplaceHelper.ReplaceRowParam(_rowItem, model.MenuCond);
|
|
//sweepButton.Enabled = ReplaceHelper.EvalCond(cond);
|
|
sweepButton.isEnable = ReplaceHelper.EvalCond(cond);
|
|
sweepButton.BackColor = sweepButton.isEnable ? Color.FromArgb(65, 115, 188) : Color.FromArgb(104, 104, 104);//sweepButton.isEnable ? ColorTranslator.FromHtml(_defaultColors[i % 4]) : colorlist[i % 4];
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sweepButton.isEnable = false;
|
|
sweepButton.BackColor = Color.FromArgb(104, 104, 104);// colorlist[i % 4];
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 刷新主表
|
|
public void RefreshMasterTable()
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(_searchCode))
|
|
{
|
|
|
|
_rowItem = BaseImpl.GetDataRowResult(AnotherLastRefreshSql);
|
|
|
|
}
|
|
else
|
|
{
|
|
_rowItem = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql + "and" + _primaryKey + "=" + txtFixKey.Text)).Rows[0];
|
|
}
|
|
|
|
if (_rowItem != null)
|
|
{
|
|
this.ControlObj.SetAllControlValue(_rowItem);
|
|
SweepIsUsable();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 右键后默认执行搜索
|
|
private void DefaultSearch(TabControlEx tabDetail, string id)
|
|
{
|
|
|
|
foreach (XtraTabPage tabPage in tabDetail.TabControlObj.TabPages)
|
|
{
|
|
GridDetailModel model = tabDetail.GetGridDetailModel(tabPage);
|
|
if (id.Split(',').Contains(model.Id + "") && tabPage.Tag is GridControlEx)
|
|
{
|
|
GridControlEx gridControl = tabPage.Tag as GridControlEx;
|
|
if (!string.IsNullOrWhiteSpace(gridControl.LastSearchButtonhSql))
|
|
{
|
|
tabDetail.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(gridControl.LastSearchButtonhSql));
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:明细分割条移动保存位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnDetailsSplitterMoved(object sender, EventArgs e)
|
|
{
|
|
if (this._isInitFinish)
|
|
{
|
|
SplitContainerControl splitContainerControl = sender as SplitContainerControl;
|
|
IniHelper.Write(string.Format("Step_splitLeftSide_{0}", this.SysModel.ModuleCode), splitContainerControl.SplitterPosition + "");
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|