ab56a9bcf7
SVN-Revision: r240
458 lines
18 KiB
C#
458 lines
18 KiB
C#
using DevExpress.XtraEditors;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Core;
|
|
using Lskj.Model;
|
|
using Lskj.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.ProductBarCode2
|
|
{
|
|
public partial class FrmMainModule : UserControl
|
|
{
|
|
/// <summary>
|
|
/// 上方主表
|
|
/// </summary>
|
|
/// <value>The grid view object.</value>
|
|
public ModuleGridEx ModuleGridEx { get { return this.moduleGridEx; } }
|
|
/// <summary>
|
|
/// 下方明细
|
|
/// </summary>
|
|
/// <value>The grid view object.</value>
|
|
public GridControlEx GcBottom { get { return this.gcBottom; } }
|
|
|
|
|
|
/// <summary>
|
|
/// 表格对象
|
|
/// </summary>
|
|
/// <value>The grid view object.</value>
|
|
public GridControlEx GridControlObj { get { return this.moduleGridEx.GridControlObj; } }
|
|
/// <summary>
|
|
/// 基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleObj;
|
|
/// <summary>
|
|
/// 底部基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleBottomObj;
|
|
/// <summary>
|
|
/// 表格明细集合
|
|
/// </summary>
|
|
public List<GridDetailModel> GridDetailModelObjs;
|
|
/// <summary>
|
|
/// 单据信息
|
|
/// </summary>
|
|
public 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>
|
|
public string BillStatus;
|
|
/// <summary>
|
|
/// 设置是否有操作权限
|
|
/// </summary>
|
|
public bool Ispower = true;
|
|
/// <summary>
|
|
/// 左侧表格查询条件
|
|
/// </summary>
|
|
private MyControl _leftGridSearchObj;
|
|
/// <summary>
|
|
/// 左侧表格
|
|
/// </summary>
|
|
public GridControlEx gridLeft;
|
|
|
|
|
|
|
|
public FrmMainModule()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void initial()
|
|
{
|
|
SetInterfaceState();
|
|
InitializeSetting();
|
|
InitControls();
|
|
|
|
}
|
|
|
|
/// <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
|
|
{
|
|
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>
|
|
/// 重新设置生成条码按钮状态和权限
|
|
/// </summary>
|
|
/// <param name="Authority"></param>
|
|
public void SetPermissions(bool Authority)
|
|
{
|
|
if (Authority)
|
|
{
|
|
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 {
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <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>
|
|
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.gridLeft;
|
|
this.moduleGridEx.ParentGridEx = this.gridLeft; // 方便右侧添加数据自动带出相同字段值
|
|
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;
|
|
|
|
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;
|
|
}
|
|
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.gridLeft != null)
|
|
{
|
|
rowItem[this.moduleGridEx.ParentKeyField] = this.gridLeft.GetViewFocusedDataRow()[this.moduleGridEx.ParentKeyField] + "";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (this.gridLeft != null)
|
|
{
|
|
DataTable table = moduleGridEx.GridControlObj.GridView.GridControl.DataSourceTable();
|
|
moduleGridEx.GridControlObj.GridView.SetRowCellValue(this.moduleGridEx.GridControlObj.GridView.GetFocusedDataSourceRowIndex(), this.moduleGridEx.ParentUnionField, this.gridLeft.GetViewFocusedDataRow()[this.moduleGridEx.ParentKeyField] + "");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <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 OnDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
DataRow rowArray = this.gridLeft.GetViewFocusedDataRow();
|
|
SetCodeHeader(rowArray);
|
|
}
|
|
|
|
#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
|
|
|
|
#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-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>
|
|
/// 生成条码事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void but_CreatBarCode_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowArray = this.gridLeft.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);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|