897 lines
37 KiB
C#
897 lines
37 KiB
C#
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
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.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.ProductBarCode
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
/// <summary>
|
|
/// 左侧树数据
|
|
/// </summary>
|
|
public DataRow LeftRowObj;
|
|
/// <summary>
|
|
/// 主键名
|
|
/// </summary>
|
|
private string _primaryLeftKey;
|
|
/// <summary>
|
|
/// 表格对象
|
|
/// </summary>
|
|
/// <value>The grid view object.</value>
|
|
public GridControlEx GridControlObj { get { return this.moduleGridEx.GridControlObj; } }
|
|
/// <summary>
|
|
/// 必须录入字段
|
|
/// </summary>
|
|
private DataRow[] _nullFields = new DataRow[] { };
|
|
/// <summary>
|
|
/// 基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleObj;
|
|
/// <summary>
|
|
/// 底部基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleBottomObj;
|
|
/// <summary>
|
|
/// 表格明细集合
|
|
/// </summary>
|
|
public List<GridDetailModel> GridDetailModelObjs;
|
|
/// <summary>
|
|
/// 控件源数据
|
|
/// </summary>
|
|
private DataTable _dtFields;
|
|
/// <summary>
|
|
/// 单据信息
|
|
/// </summary>
|
|
private DataRow _drBillInfo;
|
|
/// <summary>
|
|
/// 单据模型
|
|
/// </summary>
|
|
public BillModel BillModelObj;
|
|
public DynamicBarCodeModel SysModel;
|
|
public DynamicModuleModel dmoudelModel;
|
|
/// <summary>
|
|
/// 单表模型
|
|
/// </summary>
|
|
public DynamicModuleModel moudelModel;
|
|
/// <summary>
|
|
/// 控件对象
|
|
/// </summary>
|
|
public MyControl ControlObj { get; private set; }
|
|
/// <summary>
|
|
/// 控件高度
|
|
/// </summary>
|
|
/// <value>The height of the control.</value>
|
|
public int ControlHeight { get; private set; }
|
|
/// <summary>
|
|
/// 控件数据源
|
|
/// </summary>
|
|
private DataTable _controlTable;
|
|
/// <summary>
|
|
/// 单据明细列
|
|
/// </summary>
|
|
private DataTable _detailColumns;
|
|
/// <summary>
|
|
/// 单据关联字段
|
|
/// </summary>
|
|
public string BillRelation;
|
|
|
|
/// <summary>
|
|
/// 单据明细id
|
|
/// </summary>
|
|
public int MxId;
|
|
/// <summary>
|
|
/// 设置红蓝单据
|
|
/// </summary>
|
|
public string BillStatus;
|
|
/// <summary>
|
|
/// 设置是否有操作权限
|
|
/// </summary>
|
|
public bool Ispower = true;
|
|
/// <summary>
|
|
/// 单据名称
|
|
/// </summary>
|
|
public string typename;
|
|
/// <summary>
|
|
/// 左侧表格查询条件
|
|
/// </summary>
|
|
private MyControl _leftGridSearchObj;
|
|
/// <summary>
|
|
/// 是否为初始化创建
|
|
/// </summary>
|
|
private bool _isInitFinish;
|
|
|
|
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//WaitForm.ShowForm();
|
|
//this.SysModel.Privilege = SysModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(SysModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(SysModel.ModuleCode) + "";
|
|
//if (!this.SysModel.HasPrivilege())
|
|
//{
|
|
// MessageUtil.Show(ResourceKeys.UnPurview);
|
|
// this.Close();
|
|
//}
|
|
//else
|
|
//{
|
|
this._isInitFinish = false;
|
|
SetInterfaceState();//设置界面状态
|
|
SetLeftGridView();
|
|
InitializeSetting();
|
|
InitControls();
|
|
SelectSettingsRows();//设置左侧选中行
|
|
//HideControls();
|
|
//}
|
|
this.InitlizeSpiltLocation();
|
|
this.splitRightControl.SplitterMoved += SplitRightControl_SplitterMoved;
|
|
this.splitMainControl.SplitterMoved += SplitMainControl_SplitterMoved;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
WaitForm.HideForm();
|
|
this._isInitFinish = true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化分割条位置
|
|
/// </summary>
|
|
private void InitlizeSpiltLocation()
|
|
{
|
|
string MainPosition = IniHelper.Read(string.Format("ProductBarCode_Main_{0}", this.SysModel.ModuleCode));
|
|
if (!string.IsNullOrEmpty(MainPosition)) this.splitMainControl.SplitterPosition = Convert.ToInt32(MainPosition);
|
|
|
|
string RightPosition = IniHelper.Read(string.Format("ProductBarCode_Right_{0}", this.SysModel.ModuleCode));
|
|
if (!string.IsNullOrEmpty(RightPosition)) this.splitRightControl.SplitterPosition = Convert.ToInt32(RightPosition);
|
|
}
|
|
|
|
private void SplitMainControl_SplitterMoved(object sender, EventArgs e)
|
|
{
|
|
if (this._isInitFinish)// 是否为初始化创建
|
|
{
|
|
IniHelper.Write(string.Format("ProductBarCode_Main_{0}", this.SysModel.ModuleCode), this.splitMainControl.SplitterPosition + "");
|
|
}
|
|
}
|
|
|
|
private void SplitRightControl_SplitterMoved(object sender, EventArgs e)
|
|
{
|
|
if (this._isInitFinish)// 是否为初始化创建
|
|
{
|
|
IniHelper.Write(string.Format("ProductBarCode_Right_{0}", this.SysModel.ModuleCode), this.splitRightControl.SplitterPosition + "");
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:判断是否终审,加载界面是否可以编辑</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetInterfaceState()
|
|
{
|
|
try
|
|
{
|
|
this.BillModelObj = new BillAuditModel(BillImpl.GetBillInfo(this.SysModel.ModuleCode));
|
|
this.BillModelObj.MasterPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.MasterTable);
|
|
this.BillModelObj.DetailPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.DetailTable);
|
|
DataRow rowItem = SqlHelper.ExecuteDataTable(string.Format("SELECT * FROM {2} WHERE {0}='{1}'", this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId, this.BillModelObj.MasterTable)).Rows[0];
|
|
if (("1".Equals(rowItem[this.BillModelObj.MasterPreFix + "stepover"] + "") || "true".Equals((rowItem[this.BillModelObj.MasterPreFix + "stepover"] + "").ToLower())))
|
|
{
|
|
this.but_CreatBarCode.Enabled = false;
|
|
this.Ispower = false;
|
|
}
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置左侧表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetLeftGridView()
|
|
{
|
|
this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(this.SysModel.MoudelId);
|
|
|
|
if (this.LeftRowObj != null)
|
|
{
|
|
DataTable dtTable = BaseModuleImpl.GetBaseLeftGridField(this.SysModel.MoudelId);
|
|
DataTable dtColorTable = BaseModuleImpl.GetBaseGridRowColors(this.LeftRowObj["fieldKey"] + "");
|
|
this.moduleGridEx.ParentKeyField = this.LeftRowObj["fieldsqlid"] + "";
|
|
this.moduleGridEx.ParentUnionField = this.LeftRowObj["fieldname"] + "";
|
|
BillRelation = "{" + this.LeftRowObj["fieldsqlname"] + "}";
|
|
this.gcLeft.GridView.FocusedRowObjectChanged += OnGridViewRowClick;
|
|
this.gcLeft.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnGridViewRowClick);
|
|
this.gcLeft.SetGridRowColors(dtColorTable);
|
|
this.gcLeft.SetReadOnlyColumns(dtTable, GridCustomColumnStruct.BaseLeftGridView + this.SysModel.MoudelId);
|
|
this.gcBottom.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
|
//this.SetLeftGridCondtion();
|
|
|
|
}
|
|
typename = SqlHelper.ExecuteScalar(string.Format("select replace(typename,'单','') as typename from p_systembilltype where typecode='{0}'", this.SysModel.ModuleCode)) + "";
|
|
}
|
|
#region 初始化属性
|
|
/// <summary>
|
|
/// <para>说明:初始化属性设置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeSetting()
|
|
{
|
|
this.GridControlObj.Tag = "IsOldPost";
|
|
this.moudelModel = new DynamicModuleModel(new string[] { "0", ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", this.SysModel.MoudelId + "", "0" });
|
|
this.MoudleObj = new ModuleModel(MainImpl.GetSystemdllTab(this.moudelModel.ModuleCode));
|
|
//初始表头
|
|
this.ControlObj = new MyControl();
|
|
this.ControlObj = new MyControl(this.MoudleObj.MenuSql, null);
|
|
this.ControlObj.OnDataSourceBindCallBack+=OnDataSourceBindCallBack;
|
|
this.GridDetailModelObjs = GetDetailGrids();
|
|
string UnionModule = this.GridDetailModelObjs.Count > 0 ? this.GridDetailModelObjs[0].UnionModule : string.Empty;
|
|
if (!string.IsNullOrEmpty(UnionModule))
|
|
{
|
|
DynamicModuleModel dmoudelModel = new DynamicModuleModel(new string[] { "0", ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", UnionModule + "", "0" });
|
|
this.MoudleBottomObj = new ModuleModel(MainImpl.GetSystemdllTab(dmoudelModel.ModuleCode));
|
|
DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(UnionModule);
|
|
this.gcBottom.Model = dmoudelModel;
|
|
this.gcBottom.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleBottomObj.FormKey);
|
|
if (Ispower)
|
|
{
|
|
this.gcBottom.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(dmoudelModel.ModuleCode), dmoudelModel, OnGridViewRightCallBack, this.ControlObj, null);
|
|
}
|
|
|
|
if (this.MoudleBottomObj.GridObjIsCheck == 1)//主表加载复选框
|
|
{
|
|
GridDragGrid.GridAddCheckBox(this.gcBottom.GridView);
|
|
}
|
|
|
|
}
|
|
this._dtFields = BaseModuleImpl.GetControlLocation(this.MoudleObj.FormKey, this.moudelModel.ModuleCode);
|
|
}
|
|
/// <summary>
|
|
/// 数据绑定完成后触发事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
DataRow rowArray = this.gcLeft.GetViewFocusedDataRow();
|
|
SetCodeHeader(rowArray);
|
|
}
|
|
#endregion
|
|
#region 初始化属性
|
|
/// <summary>
|
|
/// <para>说明:隐藏搜索</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-01-09</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void HideControls()
|
|
{
|
|
foreach (System.Windows.Forms.Control control in this.pl_top_main.Controls)
|
|
{
|
|
if (control is SimpleButton)
|
|
{
|
|
SimpleButton simpleButton = control as SimpleButton;
|
|
simpleButton.Visible = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 获取明细
|
|
/// <summary>
|
|
/// <para>说明:获取报表明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private List<GridDetailModel> GetDetailGrids()
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();
|
|
DataTable moduleDetailBottomTable = BaseModuleImpl.GetBaseDetailPages(this.moudelModel.ModuleCode);
|
|
if (moduleDetailBottomTable.Rows.Count == 0)
|
|
{
|
|
moduleDetailBottomTable = BaseModuleImpl.GetBaseAddTabDetail(this.moudelModel.ModuleCode);
|
|
}
|
|
|
|
foreach (DataRow item in moduleDetailBottomTable.Rows)
|
|
{
|
|
DataTable dtGridColumns = ReportImpl.GetReportDetailColumns(this.moudelModel.ModuleCode, item["id"] + "");
|
|
details.Add(new GridDetailModel(item, dtGridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
return details;
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 创建条码控件
|
|
/// </summary>
|
|
private void InitControls()
|
|
{
|
|
this._drBillInfo = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId);
|
|
BillStatus = _drBillInfo[this.BillModelObj.RtagidKey] + "";
|
|
this._controlTable = BaseModuleImpl.GetControlLocation(this.MoudleObj.FormKey, this.moudelModel.ModuleCode);
|
|
this.ControlObj.InitControl(this._controlTable, this.pl_top_main, BaseModuleImpl.GetAddGroupData(this.MoudleObj.FormKey));
|
|
this.ControlObj.SetReadOnlyAllControl(false);
|
|
this.moduleGridEx.VisibleSearchPanel = false;
|
|
this.gcLeft.Model = this.SysModel;
|
|
this.gcLeft.ParentControl = this.ControlObj;
|
|
|
|
this.moduleGridEx.InitializeControl(this.MoudleObj, moudelModel);
|
|
_detailColumns = BillImpl.GetDetailColumns(this.SysModel.ModuleCode);
|
|
this.moduleGridEx.LeftGridEx = this.gcLeft;
|
|
this.moduleGridEx.ParentGridEx = this.gcLeft; // 方便右侧添加数据自动带出相同字段值
|
|
this.moduleGridEx.AfterDeleteGridCallBack += ModuleGridExAfterDeleteGridCallBack;//点击删除后刷新上下表数据源
|
|
DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(this.moudelModel.ModuleCode);
|
|
this.GridControlObj.SetEditColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleObj.FormKey);
|
|
this.GridControlObj.Model = this.moudelModel;
|
|
|
|
string detailSql = ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql + " " + SysModel.LeftCondition, this.SysModel.BillDocumentId);
|
|
if (this.LeftRowObj != null)
|
|
{
|
|
DataTable table = BaseModuleImpl.GetCustomQueryFields(this.LeftRowObj["fieldKey"] + "");
|
|
string searchSql = detailSql + " ";
|
|
if (table != null && table.Rows.Count > 0)
|
|
{
|
|
// 自定义查询条件
|
|
this._leftGridSearchObj = new MyControl(searchSql, this.gcLeft);
|
|
// this._leftGridSearchObj.OtherParams = Model.OtherParams();
|
|
this.pl_left_top.Height = this._leftGridSearchObj.InitSearchControl(table, this.pl_left_top);
|
|
this._leftGridSearchObj.OnDataSourceBindCallBack += new EventHandler(OnLeftControlObjDataSourceBindCallBack);
|
|
}
|
|
else
|
|
{
|
|
this.pl_left_top.Visible = false;
|
|
this.gcLeft.SetGridViewDataSource(BaseImpl.GetDataTableResult(detailSql));
|
|
|
|
}
|
|
}
|
|
else {
|
|
this.gcLeft.SetGridViewDataSource(BaseImpl.GetDataTableResult(detailSql));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Ispower)
|
|
{
|
|
this.GridControlObj.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.moudelModel.ModuleCode), this.moudelModel, OnGridViewRightCallBack, this.ControlObj, null);
|
|
}
|
|
if (!(this.SysModel.isRedFlag.Equals("1")))
|
|
{
|
|
if ("0".Equals(BillStatus))
|
|
{
|
|
this.splitRightControl.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
else
|
|
{
|
|
this.pl_top_main.Visible = false;
|
|
this.but_CreatBarCode.Visible = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ("1".Equals(BillStatus))
|
|
{
|
|
this.splitRightControl.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
//else
|
|
//{
|
|
// this.pl_top_main.Visible = false;
|
|
// this.but_CreatBarCode.Visible = false;
|
|
//}
|
|
}
|
|
|
|
if (this.SysModel.isVisibelFlag.Equals("1"))
|
|
{
|
|
this.pl_top.Visible = false;
|
|
this.but_CreatBarCode.Visible = false;
|
|
}
|
|
else if (this.SysModel.isVisibelFlag.Equals("2"))
|
|
{
|
|
this.pl_top.Visible = true;
|
|
this.but_CreatBarCode.Visible = true;
|
|
}
|
|
|
|
this.moduleGridEx.GridControlObj.OnParseGridDataCallBack += new GridControlEx.ParseGridDataEventHandler(OnGridViewParseGridDataCallBack);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:粘贴表格后更新树结构关联字段</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="rowItem">The row item.</param>
|
|
protected void OnGridViewParseGridDataCallBack(DataRow rowItem)
|
|
{
|
|
if (rowItem != null && rowItem.Table.Columns.Contains(this.moduleGridEx.ParentKeyField))
|
|
{
|
|
|
|
if (this.gcLeft != null)
|
|
{
|
|
rowItem[this.moduleGridEx.ParentKeyField] = this.gcLeft.GetViewFocusedDataRow()[this.moduleGridEx.ParentKeyField] + "";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (this.gcLeft != null)
|
|
{
|
|
DataTable table = moduleGridEx.GridControlObj.GridView.GridControl.DataSourceTable();
|
|
moduleGridEx.GridControlObj.GridView.SetRowCellValue(this.moduleGridEx.GridControlObj.GridView.GetFocusedDataSourceRowIndex(), this.moduleGridEx.ParentUnionField, this.gcLeft.GetViewFocusedDataRow()[this.moduleGridEx.ParentKeyField] + "");
|
|
//rowItem[this.moduleGridEx.ParentUnionField] = this.gcLeft.GetViewFocusedDataRow()[this.moduleGridEx.ParentKeyField] + "";
|
|
}
|
|
}
|
|
}
|
|
#region 修改表头
|
|
/// <summary>
|
|
/// <para>说明:获取配置条件头属性设置</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-09-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
private void SetCodeHeader(DataRow newRow)
|
|
{
|
|
|
|
StringBuilder updateBuilder = new StringBuilder();
|
|
foreach (ControlModel model in this.ControlObj.ControlModels)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
bool isStart = model.DefaultValue.StartsWith("{");
|
|
string fieldName = model.DefaultValue.Replace("{", "").Replace("}", "");
|
|
if (newRow!=null&&newRow.Table.Columns.Contains(fieldName))
|
|
{
|
|
this.ControlObj.SetControlValue(model.FieldName, newRow[fieldName] + "");
|
|
}
|
|
else
|
|
{
|
|
this.ControlObj.SetControlValue(model.FieldName, isStart ? string.Empty : model.DefaultValue);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// <para>说明:条码点击加载详细条码</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-01-07 </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>
|
|
private void OnGridViewRowClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowArray = this.gcLeft.GetViewFocusedDataRow();
|
|
|
|
if (!string.IsNullOrWhiteSpace(SysModel.DefaultEnabled) && rowArray.Table.Columns.Contains(SysModel.DefaultEnabled))
|
|
{
|
|
string varlue = rowArray[SysModel.DefaultEnabled] + "";
|
|
if (varlue.Equals("0"))
|
|
{
|
|
this.but_CreatBarCode.Enabled = true;
|
|
this.Ispower = true;
|
|
this.gcBottom.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.gcBottom.Model.ModuleCode), this.gcBottom.Model, OnGridViewRightCallBack, this.ControlObj, null);
|
|
this.GridControlObj.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.moudelModel.ModuleCode), this.moudelModel, OnGridViewRightCallBack, this.ControlObj, null);
|
|
}
|
|
else if (varlue.Equals("1"))
|
|
{
|
|
this.but_CreatBarCode.Enabled = false;
|
|
this.Ispower = false;
|
|
this.gcBottom.SetGridRightMenus(new DataTable(), this.gcBottom.Model, OnGridViewRightCallBack, this.ControlObj, null);
|
|
this.GridControlObj.SetGridRightMenus(new DataTable(), this.moudelModel, OnGridViewRightCallBack, this.ControlObj, null);
|
|
}
|
|
|
|
}
|
|
|
|
SetCodeHeader(rowArray);
|
|
string detailSql = ReplaceHelper.ReplaceRowParam(rowArray, this.MoudleObj.MenuSql);
|
|
string BatchBarCodeViewSql = ReplaceHelper.ReplaceRowParam(rowArray, this.MoudleBottomObj.MenuSql);
|
|
BatchBarCodeViewSql = ReplaceHelper.ReplaceRowParam(_drBillInfo, BatchBarCodeViewSql);
|
|
this.GridControlObj.LastSearchSql = detailSql;
|
|
this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql));
|
|
//this.moduleGridEx.OnDelCallBack += OnDelCallBackEven;
|
|
this.gcBottom.LastSearchSql = BatchBarCodeViewSql;
|
|
this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:删除主程序后刷新所有界面</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-01-30 </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 OnDelCallBackEven(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql));
|
|
this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql));
|
|
MessageUtil.Show("刷新成功!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-01-30 </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
|
|
{
|
|
if (this.GridControlObj.LastSearchSql != null)
|
|
{
|
|
this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql));
|
|
this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql));
|
|
if(!this.SysModel.CancelPrompt) MessageUtil.Show("成功!");
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:增加条码后,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-01-30 </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 OnGridAddCallBack(object sender, EventArgs e)
|
|
{
|
|
//if (this.addControl.addbtnSql == null) return;
|
|
//int refreshTypes = SqlHelper.ExecuteNonQuery(this.addControl.addbtnSql);
|
|
//if (refreshTypes == 1)
|
|
//{
|
|
// this.gcMain.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcMain.LastSearchSql));
|
|
// this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql));
|
|
// MessageUtil.Show("成功!");
|
|
//}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:条码点击需要生产的条码</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-01-07 </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>
|
|
private void OnGridViewDoubleClick(object sender, EventArgs e)
|
|
{
|
|
int successQuantity = 0;//执行成功条数
|
|
int AllQuantity = 0;//全部条数
|
|
string mag = string.Empty;
|
|
try
|
|
{
|
|
string msgs = string.Empty;
|
|
//DataRow dr = this.gcBottom.GetViewFocusedDataRow();
|
|
DataRow[] dataRows = this.gcBottom.GetViewFocusedDataRows();
|
|
AllQuantity = dataRows.Length;
|
|
if (this.SysModel.Required.Equals("1") && dataRows.Length == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
foreach (DataRow dr in dataRows)
|
|
{
|
|
|
|
DataRow rowArray = this.gcLeft.GetViewFocusedDataRow();
|
|
string sql = this.ControlObj.ReplaceControlValue(this.SysModel.AddbtnSql);
|
|
sql = ReplaceHelper.ReplaceRowParam(rowArray, sql);
|
|
sql = ReplaceHelper.ReplaceRowParam(dr, sql);
|
|
|
|
string result = SqlHelper.ExecuteScalar(sql) + "";
|
|
if (result == "1")
|
|
{
|
|
successQuantity++;
|
|
}
|
|
else
|
|
{
|
|
mag += result + "\r\n";
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (successQuantity > 0)
|
|
{
|
|
this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql));
|
|
this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql));
|
|
if (AllQuantity == successQuantity && !this.SysModel.CancelPrompt) MessageUtil.Show("成功!");
|
|
}
|
|
if (AllQuantity > successQuantity)
|
|
{
|
|
MessageUtil.Show(mag);
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 生成条码事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void but_CreatBarCode_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowArray = this.gcLeft.GetViewFocusedDataRow();
|
|
string sql = this.ControlObj.ReplaceControlValue(this.SysModel.BillbtnSql);
|
|
sql = ReplaceHelper.ReplaceRowParam(rowArray, sql);
|
|
string result = SqlHelper.ExecuteScalar(sql) + "";
|
|
if (result == "1")
|
|
{
|
|
this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql));
|
|
this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql));
|
|
if (!this.SysModel.CancelPrompt) MessageUtil.Show("成功!");
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(result);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("生成条码事件出错!", ex);
|
|
//MessageUtil.Show("生成条码事件出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:保存表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-09 </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>
|
|
protected void btn_save_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.GridControlObj.GridView.ValidateNullRequired(this._nullFields))
|
|
{
|
|
bool isExec = true;
|
|
try
|
|
{
|
|
if (this.GridControlObj != null && this.GridControlObj.AdapterObj != null)
|
|
{
|
|
int result = this.GridControlObj.AdapterObj.Update(this.GridControlObj.GridControl.DataSource as DataTable);
|
|
if (result > 0)
|
|
{
|
|
isExec = false;
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("基础档案明细保存失败", ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql));
|
|
this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql));
|
|
}
|
|
}
|
|
}
|
|
|
|
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowArray = this.gcLeft.GetViewFocusedDataRow();
|
|
string sql = ReplaceHelper.ReplaceRowParam(rowArray, this.SysModel.ClosebtnSql);
|
|
|
|
string result = SqlHelper.ExecuteScalar(sql) + "";
|
|
if (result == "1")
|
|
{
|
|
e.Cancel = false;//取消关闭事件
|
|
}
|
|
else
|
|
{
|
|
this.DialogResult = MessageUtil.Show(string.Format(result), MessageBoxButtons.YesNo);
|
|
if (this.DialogResult == DialogResult.No)
|
|
{
|
|
e.Cancel = true;//取消关闭事件
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
this.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// moduleGridEx点击删除后刷新上下表
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ModuleGridExAfterDeleteGridCallBack(object sender, EventArgs e)
|
|
{
|
|
if (this.splitRightControl.PanelVisibility == SplitPanelVisibility.Both)
|
|
{
|
|
this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql));
|
|
this.gcBottom.SetGridViewDataSource(MainImpl.GetAdapterResult(this.gcBottom.LastSearchSql));
|
|
}
|
|
else {
|
|
this.GridControlObj.SetGridViewDataSource(MainImpl.GetAdapterResult(this.GridControlObj.LastSearchSql));
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///左侧表格选中设置行
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SelectSettingsRows()
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(this.SysModel.SelectionCriteria))
|
|
{
|
|
DataTable dt = this.gcLeft.gridControl.DataSource as DataTable;
|
|
DataRow[] dataRows = dt.Select(this.SysModel.SelectionCriteria);
|
|
if (dt.Rows.Count > 0 && dataRows.Length > 0)
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
if (dt.Rows[i] == dataRows[0])
|
|
{
|
|
this.gcLeft.GridView.SelectRowHandler(i);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("左侧行选择错误", ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <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>
|
|
protected void OnLeftControlObjDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this._leftGridSearchObj.SearchGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |