ab56a9bcf7
SVN-Revision: r240
1148 lines
42 KiB
C#
1148 lines
42 KiB
C#
using DevExpress.XtraEditors.Repository;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Core;
|
|
using Lskj.Model;
|
|
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.PubUserTomodule.AuditPermissionControls
|
|
{
|
|
//审批步骤
|
|
public partial class StepPage1 : UserControl
|
|
{
|
|
/// <summary>
|
|
/// 控件摆放固定X轴位置
|
|
/// </summary>
|
|
private int[] mLocationX = { 10, 120, 230, 340, 450, 560, 670 };
|
|
/// <summary>
|
|
/// 控件摆放固定Y轴位置
|
|
/// </summary>
|
|
private int[] mLocationY = { 10, 40, 70, 100, 130, 160, 190, 220, 250, 280, 310, 340, 370 };
|
|
/// <summary>
|
|
/// 模块编号
|
|
/// </summary>
|
|
public string mMenuCode;
|
|
/// <summary>
|
|
/// 基础对象
|
|
/// </summary>
|
|
public ModuleModel moduleModel;
|
|
/// <summary>
|
|
/// 单据对象
|
|
/// </summary>
|
|
public BillModel mBillModel;
|
|
/// <summary>
|
|
/// 选中的流转步骤
|
|
/// </summary>
|
|
public StepItem1 SeletStepItem1Obj;
|
|
/// <summary>
|
|
/// 当前选中的流转步骤对象 基础
|
|
/// </summary>
|
|
public BaseflowModel SelectBaseflowModel;
|
|
/// <summary>
|
|
/// 当前选中的流转步骤对象 单据
|
|
/// </summary>
|
|
public BillflowModel SelectBillflowModel;
|
|
/// <summary>
|
|
/// 主页转过来的操作权限
|
|
/// </summary>
|
|
public bool SerpPagePower;
|
|
/// <summary>
|
|
/// 基础流转集合
|
|
/// </summary>
|
|
public List<BaseflowModel> BaseflowModelList = new List<BaseflowModel>();
|
|
/// <summary>
|
|
/// 单据流转集合
|
|
/// </summary>
|
|
public List<BillflowModel> BillflowModelList = new List<BillflowModel>();
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 是基础模块true 还是单据
|
|
/// </summary>
|
|
public bool isBasis;
|
|
|
|
|
|
public StepPage1()
|
|
{
|
|
InitializeComponent();
|
|
CreateMainTableColumns();
|
|
CreateDetailTableColumns();
|
|
}
|
|
|
|
private void CreateMainTableColumns()
|
|
{
|
|
GridColumn fieldnameColumn = new GridColumn();
|
|
fieldnameColumn.Caption = "字段名称";
|
|
fieldnameColumn.FieldName = "fieldName";
|
|
fieldnameColumn.Visible = true;
|
|
fieldnameColumn.VisibleIndex = 1;
|
|
fieldnameColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
GridColumn usernameColumn = new GridColumn();
|
|
usernameColumn.Caption = "用户名称";
|
|
usernameColumn.FieldName = "userName";
|
|
usernameColumn.Visible = true;
|
|
usernameColumn.VisibleIndex = 2;
|
|
usernameColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
RepositoryItemCheckEdit checkEdit = new RepositoryItemCheckEdit();
|
|
checkEdit.ValueChecked = 1;
|
|
checkEdit.ValueUnchecked = 0;
|
|
checkEdit.ValueGrayed = 3;
|
|
//checkEdit.CheckedChanged += new EventHandler(CheckedChanged);
|
|
|
|
|
|
|
|
GridColumn modifyColumn = new GridColumn();
|
|
modifyColumn.Caption = "可修改";
|
|
modifyColumn.FieldName = "modify";
|
|
modifyColumn.Visible = true;
|
|
modifyColumn.VisibleIndex = 3;
|
|
modifyColumn.ColumnEdit = checkEdit;
|
|
|
|
GridColumn nullableColumn = new GridColumn();
|
|
nullableColumn.Caption = "必填";
|
|
nullableColumn.FieldName = "mandatory";
|
|
nullableColumn.Visible = true;
|
|
nullableColumn.VisibleIndex = 4;
|
|
nullableColumn.ColumnEdit = checkEdit;
|
|
|
|
this.headerControlEx.GridView.Columns.AddRange(new GridColumn[] {
|
|
fieldnameColumn,
|
|
usernameColumn,
|
|
modifyColumn,
|
|
nullableColumn,
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
private void CreateDetailTableColumns()
|
|
{
|
|
GridColumn fieldnameColumn = new GridColumn();
|
|
fieldnameColumn.Caption = "字段名称";
|
|
fieldnameColumn.FieldName = "fieldName";
|
|
fieldnameColumn.Visible = true;
|
|
fieldnameColumn.VisibleIndex = 1;
|
|
fieldnameColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
GridColumn usernameColumn = new GridColumn();
|
|
usernameColumn.Caption = "用户名称";
|
|
usernameColumn.FieldName = "username";
|
|
usernameColumn.Visible = true;
|
|
usernameColumn.VisibleIndex = 2;
|
|
usernameColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
RepositoryItemCheckEdit checkEdit = new RepositoryItemCheckEdit();
|
|
checkEdit.ValueChecked = 1;
|
|
checkEdit.ValueUnchecked = 0;
|
|
checkEdit.ValueGrayed = 3;
|
|
//checkEdit.CheckedChanged += new EventHandler(CheckedChanged);
|
|
|
|
|
|
|
|
GridColumn modifyColumn = new GridColumn();
|
|
modifyColumn.Caption = "可修改";
|
|
modifyColumn.FieldName = "modify";
|
|
modifyColumn.Visible = true;
|
|
modifyColumn.VisibleIndex = 3;
|
|
modifyColumn.ColumnEdit = checkEdit;
|
|
|
|
GridColumn nullableColumn = new GridColumn();
|
|
nullableColumn.Caption = "必填";
|
|
nullableColumn.FieldName = "mandatory";
|
|
nullableColumn.Visible = true;
|
|
nullableColumn.VisibleIndex = 4;
|
|
nullableColumn.ColumnEdit = checkEdit;
|
|
|
|
this.detailControlEx.GridView.Columns.AddRange(new GridColumn[] {
|
|
fieldnameColumn,
|
|
usernameColumn,
|
|
modifyColumn,
|
|
nullableColumn,
|
|
});
|
|
}
|
|
|
|
|
|
|
|
#region 私有方法
|
|
/// <summary>
|
|
/// <para>说明:初始化流转步骤</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeStepFlow()
|
|
{
|
|
this.PlStep1Container.Controls.Clear();
|
|
DataTable table = isBasis ? WorkFlowBaseImpl.GetBaseFlowData(mMenuCode) : WorkFlowBillImpl.GetBillFlowData(mMenuCode);
|
|
BillflowModelList.Clear();
|
|
BillflowModelList.Clear();
|
|
if (table.Rows.Count == 0)
|
|
{
|
|
this.panelControl1.Visible = false;
|
|
return;
|
|
}
|
|
this.panelControl1.Visible = true;
|
|
for (int i = table.Rows.Count; i > 0; i--)
|
|
{
|
|
|
|
DataRow rowItem = table.Rows[i - 1];
|
|
if (isBasis)
|
|
{
|
|
BaseflowModel model = new BaseflowModel(rowItem);
|
|
// 设置面板值
|
|
if (i == 1)
|
|
{
|
|
this.SelectBaseflowModel = model;
|
|
this.SetFlowItem(model);
|
|
}
|
|
this.PlStep1Container.Controls.Add(this.InitStepFlowItem(model, i));
|
|
this.BaseflowModelList.Add(model);
|
|
|
|
}
|
|
else
|
|
{
|
|
BillflowModel model = new BillflowModel(rowItem);
|
|
// 设置面板值
|
|
if (i == 1)
|
|
{
|
|
this.SelectBillflowModel = model;
|
|
this.SetFlowItem(model);
|
|
}
|
|
this.PlStep1Container.Controls.Add(this.InitStepFlowItem(model, i));
|
|
this.BillflowModelList.Add(model);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化主表字段</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeMainField()
|
|
{
|
|
if (isBasis)
|
|
{
|
|
if (SelectBaseflowModel != null)
|
|
{
|
|
int rowcount = 7;
|
|
int width = 100, height = 20;
|
|
int left = 0, top = 0;
|
|
|
|
DataTable table = BaseModuleImpl.GetControlLocation(this.moduleModel.FormKey, mMenuCode);
|
|
if (table == null || table.Rows.Count == 0)
|
|
{
|
|
this.headerControlEx.gridControl.DataSource = table;
|
|
return;
|
|
}
|
|
DataTable editTable = table.Select("visible=0 and edited=0").CopyToDataTable();
|
|
editTable.DefaultView.Sort = "ControlTop,ControlLeft";
|
|
editTable = editTable.DefaultView.ToTable();
|
|
DataTable newdt = ConversionDataSource(editTable);
|
|
this.headerControlEx.gridControl.DataSource = newdt;
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (SelectBillflowModel != null)
|
|
{
|
|
int rowcount = 7;
|
|
int width = 100, height = 20;
|
|
int left = 0, top = 0;
|
|
|
|
DataTable table = BaseModuleImpl.GetControlLocation(this.mBillModel.FormKey, mMenuCode);
|
|
if (table == null || table.Rows.Count == 0)
|
|
{
|
|
this.headerControlEx.gridControl.DataSource = table;
|
|
return;
|
|
}
|
|
DataTable editTable = table.Select("visible=0 and edited=0").CopyToDataTable();
|
|
editTable.DefaultView.Sort = "ControlTop,ControlLeft";
|
|
editTable = editTable.DefaultView.ToTable();
|
|
|
|
DataTable newdt = ConversionDataSource(editTable);
|
|
this.headerControlEx.gridControl.DataSource = newdt;
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化明细表字段</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeDetailField()
|
|
{
|
|
if (SelectBillflowModel != null)
|
|
{
|
|
int rowcount = 7;
|
|
int width = 100, height = 20;
|
|
int left = 0, top = 0;
|
|
|
|
DataTable table = BillImpl.GetDetailColumns(mMenuCode);
|
|
if (table == null || table.Rows.Count == 0)
|
|
{
|
|
this.detailControlEx.gridControl.DataSource = table;
|
|
return;
|
|
}
|
|
DataTable editTable = table.Select("isVisible=False and edit=0").CopyToDataTable();
|
|
DataTable newdt = newConversionDataSource(editTable);
|
|
this.detailControlEx.gridControl.DataSource = newdt;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据行内容,判断是否打勾 表头
|
|
/// </summary>
|
|
/// <param name="dataTable"></param>
|
|
/// <returns></returns>
|
|
private DataTable ConversionDataSource(DataTable dataTable)
|
|
{
|
|
DataTable newdt = dataTable.Copy();
|
|
newdt.Columns.Add("modify", typeof(int));
|
|
newdt.Columns.Add("mandatory", typeof(int));
|
|
|
|
|
|
foreach (DataRow dr in newdt.Rows)
|
|
{
|
|
int modify = 0;
|
|
int mandatory = 0;
|
|
|
|
|
|
if (isBasis)
|
|
{
|
|
modify = ("," + this.SelectBaseflowModel.billModifyFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
mandatory = ("," + this.SelectBaseflowModel.requiredFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
}
|
|
else
|
|
{
|
|
modify = ("," + this.SelectBillflowModel.billModifyFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
mandatory = ("," + this.SelectBillflowModel.requiredFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
}
|
|
|
|
dr["modify"] = modify;
|
|
dr["mandatory"] = mandatory;
|
|
}
|
|
return newdt;
|
|
}
|
|
|
|
private DataTable newConversionDataSource(DataTable dataTable)
|
|
{
|
|
DataTable newdt = dataTable.Clone();
|
|
newdt.Columns.Add("modify", typeof(int));
|
|
newdt.Columns.Add("mandatory", typeof(int));
|
|
|
|
foreach (DataRow dr in dataTable.Rows)
|
|
{
|
|
DataRow newdr = newdt.NewRow();
|
|
|
|
newdr["fieldName"] = dr["fieldName"];
|
|
newdr["username"] = dr["username"];
|
|
|
|
int modify = ("," + this.SelectBillflowModel.detailModifyFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
newdr["modify"] = modify;
|
|
|
|
int mandatory = ("," + this.SelectBillflowModel.requiredDetailFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
newdr["mandatory"] = mandatory;
|
|
|
|
newdt.Rows.Add(newdr);
|
|
}
|
|
return newdt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="flowName">Name of the flow.</param>
|
|
private StepItem1 InitStepFlowItem(BillflowModel model, int pos)
|
|
{
|
|
StepItem1 item = new StepItem1();
|
|
item.TitleLabelObj.Text = pos + "、" + model.stepName;
|
|
if (SerpPagePower)
|
|
{
|
|
item.DeletePabelObj.Enabled = false;
|
|
}
|
|
item.DeletePabelObj.Click += new EventHandler(OnDeletePabelObjClick);
|
|
item.Dock = DockStyle.Top;
|
|
item.Tag = item.TitleLabelObj.Tag = item.DeletePabelObj.Tag = model;
|
|
item.SetHoverEvent(OnTitleLabelObjClick);
|
|
item.TabIndex = pos;
|
|
if (pos == 1)
|
|
{
|
|
SeletStepItem1Obj = item;
|
|
item.SetDefaultSelectItem(item);
|
|
}
|
|
return item;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="flowName">Name of the flow.</param>
|
|
private StepItem1 InitStepFlowItem(BaseflowModel model, int pos)
|
|
{
|
|
StepItem1 item = new StepItem1();
|
|
item.TitleLabelObj.Text = pos + "、" + model.stepName;
|
|
if (SerpPagePower)
|
|
{
|
|
item.DeletePabelObj.Enabled = false;
|
|
}
|
|
item.DeletePabelObj.Click += new EventHandler(OnDeletePabelObjClick);
|
|
item.Dock = DockStyle.Top;
|
|
item.Tag = item.TitleLabelObj.Tag = item.DeletePabelObj.Tag = model;
|
|
item.SetHoverEvent(OnTitleLabelObjClick);
|
|
item.TabIndex = pos;
|
|
if (pos == 1)
|
|
{
|
|
SeletStepItem1Obj = item;
|
|
item.SetDefaultSelectItem(item);
|
|
}
|
|
return item;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:验证数据合法性</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public bool VerifyNull()
|
|
{
|
|
foreach (System.Windows.Forms.Control item in panelControl6.Controls)
|
|
{
|
|
if (item is LabelTextEdit)
|
|
{
|
|
LabelTextEdit textEdit = item as LabelTextEdit;
|
|
if (string.IsNullOrEmpty(textEdit.EditText) && textEdit.Required)
|
|
{
|
|
textEdit.Focus();
|
|
MessageUtil.Show(textEdit.LabelText + "不能为空!");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 公共方法
|
|
/// <summary>
|
|
/// <para>说明:初始化流转类别控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitializeControl(string menuCode, bool Basis)
|
|
{
|
|
this.isBasis = Basis;
|
|
this.mMenuCode = menuCode;
|
|
if (isBasis)
|
|
{
|
|
this.ltepStepCode.Hide();
|
|
this.lcetm_Test.Hide();
|
|
this.lcestepDivide.Hide();
|
|
this.groupBox3.Hide();
|
|
this.groupBox2.Height = this.panelControl1.Height - this.groupBox1.Height;
|
|
this.moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(menuCode));
|
|
}
|
|
else
|
|
{
|
|
this.ltepStepCode.Show();
|
|
this.lcetm_Test.Show();
|
|
this.lcestepDivide.Show();
|
|
this.groupBox3.Show();
|
|
this.groupBox2.Height = this.groupBox3.Height = (this.panelControl1.Height - this.groupBox1.Height) / 2;
|
|
this.mBillModel = new BillModel(BillImpl.GetBillInfo(mMenuCode));
|
|
}
|
|
|
|
this.headerControlEx.GridView.BestFitColumns();//设置根据内容填充列宽
|
|
this.detailControlEx.GridView.BestFitColumns();//设置根据内容填充列宽
|
|
|
|
this.InitializeStepFlow();
|
|
this.InitializeMainField();
|
|
if (!isBasis) this.InitializeDetailField();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:添加流转类别</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void AddFlowItem(string stepGroup, string stepName)
|
|
{
|
|
if (isBasis)
|
|
{
|
|
BaseflowModel model = new BaseflowModel
|
|
{
|
|
stepCode = Convert.ToInt32((BaseflowModelList.Count + 1) + "00"),
|
|
typeCode = mMenuCode,
|
|
stepGroup = stepGroup,
|
|
stepName = stepName,
|
|
stepApplyText = "审核(&Y)",
|
|
stepApplyContent = "同意",
|
|
stepBackText = "反退(&N)",
|
|
stepBackContent = "不同意",
|
|
};
|
|
try
|
|
{
|
|
// 保存
|
|
if (WorkFlowBaseImpl.SaveBaseFlow(model))
|
|
{
|
|
// 重排列表
|
|
InitializeStepFlow();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show("保存失败!" + ex.Message);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
BillflowModel model = new BillflowModel
|
|
{
|
|
stepCode = Convert.ToInt32((BillflowModelList.Count + 1) + "00"),
|
|
typeCode = mMenuCode,
|
|
stepGroup = stepGroup,
|
|
stepName = stepName,
|
|
stepApplyText = "审核(&Y)",
|
|
stepApplyContent = "同意",
|
|
stepBackText = "反退(&N)",
|
|
stepBackContent = "不同意"
|
|
};
|
|
|
|
try
|
|
{
|
|
// 保存
|
|
if (WorkFlowBillImpl.SaveBillFlow(model))
|
|
{
|
|
// 重排列表
|
|
InitializeStepFlow();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw;
|
|
//MessageUtil.Show("保存失败!" + ex.Message);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:更新流转步骤数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void UpdateBaseFlow()
|
|
{
|
|
if (this.VerifyNull())
|
|
{
|
|
// 获取基本数据
|
|
BaseflowModel model = this.SelectBaseflowModel;
|
|
model.stepGroup = this.ltestepGroup.EditText;
|
|
model.stepName = this.ltestepName.EditText;
|
|
model.stepApplyText = this.ltestepApplyText.EditText;
|
|
model.stepApplyContent = this.ltestepApplyContent.EditText;
|
|
model.stepBackText = this.ltestepBackText.EditText;
|
|
model.stepBackContent = this.ltestepBackContent.EditText;
|
|
model.stepCloseText = this.ltestepCloseText.EditText;
|
|
model.stepCloseContent = this.ltestepCloseContent.EditText;
|
|
|
|
|
|
|
|
// 获取单据主表可修改字段
|
|
model.billModifyFields = GetMainFieldCheckState(true);
|
|
// 获取单据主表必填字段
|
|
model.requiredFields = GetMainFieldCheckState(false);
|
|
|
|
|
|
bool result = WorkFlowBaseImpl.newUpdateBaseFlow(model);
|
|
if (result)
|
|
{
|
|
this.SeletStepItem1Obj.TitleLabelObj.Text = this.SeletStepItem1Obj.TabIndex + "、" + model.stepName;
|
|
this.SelectBaseflowModel = model;
|
|
}
|
|
MessageUtil.Show(result ? "保存成功!" : "保存失败!");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:更新流转步骤数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void UpdateBillFlow()
|
|
{
|
|
if (this.VerifyNull())
|
|
{
|
|
// 获取基本数据
|
|
BillflowModel model = this.SelectBillflowModel;
|
|
model.stepGroup = this.ltestepGroup.EditText;
|
|
model.stepName = this.ltestepName.EditText;
|
|
model.stepApplyText = this.ltestepApplyText.EditText;
|
|
model.stepApplyContent = this.ltestepApplyContent.EditText;
|
|
model.stepBackText = this.ltestepBackText.EditText;
|
|
model.stepBackContent = this.ltestepBackContent.EditText;
|
|
model.stepCloseText = this.ltestepCloseText.EditText;
|
|
model.stepCloseContent = this.ltestepCloseContent.EditText;
|
|
model.pStepCode = this.ltepStepCode.EditText;
|
|
model.tm_Test = this.lcetm_Test.EditText;
|
|
model.stepDivide = this.lcestepDivide.EditText;
|
|
|
|
// 获取单据主表可修改字段
|
|
model.billModifyFields = GetMainFieldCheckState(true);
|
|
// 获取单据主表必填字段
|
|
model.requiredFields = GetMainFieldCheckState(false);
|
|
|
|
// 获取单据明细表可修改字段
|
|
model.detailModifyFields = GetDetailFieldCheckState(true);
|
|
// 获取单据明细表必填字段
|
|
model.requiredDetailFields = GetDetailFieldCheckState(false);
|
|
|
|
|
|
bool result = WorkFlowBillImpl.newUpdateBillFlow(model);
|
|
if (result)
|
|
{
|
|
this.SeletStepItem1Obj.TitleLabelObj.Text = this.SeletStepItem1Obj.TabIndex + "、" + model.stepName;
|
|
this.SelectBillflowModel = model;
|
|
}
|
|
MessageUtil.Show(result ? "保存成功!" : "保存失败!");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置面板值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
public void SetFlowItem(BaseflowModel model)
|
|
{
|
|
if (model != null)
|
|
{
|
|
ltestepCode.EditText = model.stepCode + "";
|
|
ltestepGroup.EditText = model.stepGroup;
|
|
ltestepName.EditText = model.stepName;
|
|
ltestepApplyText.EditText = model.stepApplyText;
|
|
ltestepApplyContent.EditText = model.stepApplyContent;
|
|
ltestepBackText.EditText = model.stepBackText;
|
|
ltestepBackContent.EditText = model.stepBackContent;
|
|
ltestepCloseText.EditText = model.stepCloseText;
|
|
ltestepCloseContent.EditText = model.stepCloseContent;
|
|
|
|
|
|
this.SelectBaseflowModel = model;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置面板值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
public void SetFlowItem(BillflowModel model)
|
|
{
|
|
if (model != null)
|
|
{
|
|
ltestepCode.EditText = model.stepCode + "";
|
|
ltestepGroup.EditText = model.stepGroup;
|
|
ltestepName.EditText = model.stepName;
|
|
ltestepApplyText.EditText = model.stepApplyText;
|
|
ltestepApplyContent.EditText = model.stepApplyContent;
|
|
ltestepBackText.EditText = model.stepBackText;
|
|
ltestepBackContent.EditText = model.stepBackContent;
|
|
ltestepCloseText.EditText = model.stepCloseText;
|
|
ltestepCloseContent.EditText = model.stepCloseContent;
|
|
ltepStepCode.EditText = model.pStepCode + "";
|
|
|
|
this.SelectBillflowModel = model;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置主表字段选中状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
public void SetMainFieldCheckState(BaseflowModel model)
|
|
{
|
|
|
|
DataTable dataTable = this.headerControlEx.gridControl.DataSource as DataTable;
|
|
foreach (DataRow dr in dataTable.Rows)
|
|
{
|
|
int modify = 0;
|
|
int mandatory = 0;
|
|
modify = ("," + model.billModifyFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
mandatory = ("," + model.requiredFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
dr["modify"] = modify;
|
|
dr["mandatory"] = mandatory;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置主表字段选中状态 (表头)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
public void SetMainFieldCheckState(BillflowModel model)
|
|
{
|
|
DataTable dataTable = this.headerControlEx.gridControl.DataSource as DataTable;
|
|
foreach (DataRow dr in dataTable.Rows)
|
|
{
|
|
int modify = 0;
|
|
int mandatory = 0;
|
|
modify = ("," + model.billModifyFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
mandatory = ("," + model.requiredFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
dr["modify"] = modify;
|
|
dr["mandatory"] = mandatory;
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置主表字段选中状态 (明细)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
public void SetDetailFieldCheckState(BillflowModel model)
|
|
{
|
|
|
|
DataTable dataTable = this.detailControlEx.gridControl.DataSource as DataTable;
|
|
foreach (DataRow dr in dataTable.Rows)
|
|
{
|
|
|
|
int modify = ("," + this.SelectBillflowModel.detailModifyFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
dr["modify"] = modify;
|
|
|
|
int mandatory = ("," + this.SelectBillflowModel.requiredDetailFields + ",").Contains("," + dr["fieldname"] + ",") ? 1 : 0;
|
|
dr["mandatory"] = mandatory;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取主表选中字段</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public string GetMainFieldCheckState(bool isUpdate)
|
|
{
|
|
string fields = string.Empty;
|
|
DataTable dataTable = this.headerControlEx.gridControl.DataSource as DataTable;
|
|
|
|
foreach (DataRow dr in dataTable.Rows)
|
|
{
|
|
if (isUpdate)
|
|
{
|
|
if (dr["modify"] + "" == "1")
|
|
{
|
|
fields += dr["fieldname"] + ",";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (dr["mandatory"] + "" == "1")
|
|
{
|
|
fields += dr["fieldname"] + ",";
|
|
}
|
|
}
|
|
}
|
|
return fields.TrimEnd(',');
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取明细表选中字段</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public string GetDetailFieldCheckState(bool isUpdate)
|
|
{
|
|
string fields = string.Empty;
|
|
DataTable dataTable = this.detailControlEx.gridControl.DataSource as DataTable;
|
|
|
|
foreach (DataRow dr in dataTable.Rows)
|
|
{
|
|
if (isUpdate)
|
|
{
|
|
if (dr["modify"] + "" == "1")
|
|
{
|
|
fields += dr["fieldname"] + ",";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (dr["mandatory"] + "" == "1")
|
|
{
|
|
fields += dr["fieldname"] + ",";
|
|
}
|
|
}
|
|
}
|
|
return fields.TrimEnd(',');
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 事件相关
|
|
/// <summary>
|
|
/// <para>说明:删除流转分类</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
void OnDeletePabelObjClick(object sender, EventArgs e)
|
|
{
|
|
if (isBasis)
|
|
{
|
|
Panel deletePanel = sender as Panel;
|
|
if (deletePanel != null && deletePanel.Tag != null)
|
|
{
|
|
BaseflowModel model = deletePanel.Tag as BaseflowModel;
|
|
if (MessageUtil.Show("删除审批步骤将同步删除方案步骤相关数据\r\n是否删除?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
try
|
|
{
|
|
// 验证删除存储过程
|
|
string tipMsg = string.Empty;
|
|
if (BaseImpl.deleteFlow(0, mMenuCode, model.stepCode.ToString(), model.id, out tipMsg) == 1)
|
|
{
|
|
MessageUtil.Show("删除成功!");
|
|
// 重排列表
|
|
InitializeStepFlow();
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(tipMsg);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show("删除失败:\r\n" + ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
Panel deletePanel = sender as Panel;
|
|
if (deletePanel != null && deletePanel.Tag != null)
|
|
{
|
|
BillflowModel model = deletePanel.Tag as BillflowModel;
|
|
if (MessageUtil.Show("删除审批步骤将同步删除方案步骤相关数据\r\n是否删除?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
try
|
|
{
|
|
// 验证删除存储过程
|
|
string tipMsg = string.Empty;
|
|
if (BaseImpl.deleteFlow(1, mMenuCode, model.stepCode.ToString(), model.id, out tipMsg) == 1)
|
|
{
|
|
MessageUtil.Show("删除成功!");
|
|
// 重排列表
|
|
InitializeStepFlow();
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(tipMsg);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw;
|
|
//MessageUtil.Show("删除失败:\r\n" + ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:点击流转步骤加载数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </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>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
void OnTitleLabelObjClick(StepItem1 before, StepItem1 after)
|
|
{
|
|
if (isBasis)
|
|
{
|
|
BaseflowModel model = after.Tag as BaseflowModel;
|
|
|
|
this.SeletStepItem1Obj = after;
|
|
this.SetFlowItem(model);
|
|
this.SetMainFieldCheckState(model);
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
BillflowModel model = after.Tag as BillflowModel;
|
|
|
|
this.SeletStepItem1Obj = after;
|
|
this.SetFlowItem(model);
|
|
this.SetMainFieldCheckState(model);
|
|
this.SetDetailFieldCheckState(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
public void InsertStep(string stepGroup, string stepName)
|
|
{
|
|
SqlTransaction myTrans = SqlHelper._connection.BeginTransaction();
|
|
////为事务创建一个命令
|
|
|
|
try
|
|
{
|
|
|
|
if (isBasis)
|
|
{
|
|
//基础模块
|
|
//当前选中序号
|
|
int SelectStepCode = this.SelectBaseflowModel.stepCode;
|
|
//循环全部数据,大于选中序号的先删除
|
|
foreach (BaseflowModel item in BaseflowModelList)
|
|
{
|
|
if (item.stepCode > SelectStepCode)
|
|
{
|
|
// 验证删除存储过程
|
|
string tipMsg = string.Empty;
|
|
if (BaseImpl.deleteFlow(1, mMenuCode, item.stepCode.ToString(), item.id, out tipMsg, myTrans) != 1)
|
|
{
|
|
MessageUtil.Show(tipMsg);
|
|
}
|
|
}
|
|
}
|
|
|
|
//新增
|
|
BaseflowModel model = new BaseflowModel
|
|
{
|
|
stepCode = Convert.ToInt32(SelectStepCode + 100),
|
|
typeCode = mMenuCode,
|
|
stepGroup = stepGroup,
|
|
stepName = stepName,
|
|
stepApplyText = "审核(&Y)",
|
|
stepApplyContent = "同意",
|
|
stepBackText = "反退(&N)",
|
|
stepBackContent = "不同意"
|
|
};
|
|
WorkFlowBaseImpl.SaveBaseFlow(model, myTrans);
|
|
|
|
//把之前删除的重新新增
|
|
foreach (BaseflowModel item in BaseflowModelList)
|
|
{
|
|
if (item.stepCode > SelectStepCode)
|
|
{
|
|
// 验证删除存储过程
|
|
string tipMsg = string.Empty;
|
|
item.stepCode = item.stepCode + 100;
|
|
item.stepSql = item.stepSql.Replace("'", "''");
|
|
WorkFlowBaseImpl.SaveBaseFlow(item, myTrans);
|
|
}
|
|
}
|
|
myTrans.Commit(); //事务提交
|
|
}
|
|
else
|
|
{
|
|
//单据
|
|
//当前选中序号
|
|
int SelectStepCode = this.SelectBillflowModel.stepCode;
|
|
//循环全部数据,大于选中序号的先删除
|
|
foreach (BillflowModel item in BillflowModelList)
|
|
{
|
|
if (item.stepCode > SelectStepCode)
|
|
{
|
|
// 验证删除存储过程
|
|
string tipMsg = string.Empty;
|
|
if (BaseImpl.deleteFlow(1, mMenuCode, item.stepCode.ToString(), item.id, out tipMsg, myTrans) != 1)
|
|
{
|
|
MessageUtil.Show(tipMsg);
|
|
}
|
|
}
|
|
}
|
|
|
|
//新增
|
|
BillflowModel model = new BillflowModel
|
|
{
|
|
stepCode = Convert.ToInt32(SelectStepCode + 100),
|
|
typeCode = mMenuCode,
|
|
stepGroup = stepGroup,
|
|
stepName = stepName,
|
|
stepApplyText = "审核(&Y)",
|
|
stepApplyContent = "同意",
|
|
stepBackText = "反退(&N)",
|
|
stepBackContent = "不同意"
|
|
};
|
|
WorkFlowBillImpl.SaveBillFlow(model, myTrans);
|
|
|
|
//把之前删除的重新新增
|
|
foreach (BillflowModel item in BillflowModelList)
|
|
{
|
|
if (item.stepCode > SelectStepCode)
|
|
{
|
|
// 验证删除存储过程
|
|
string tipMsg = string.Empty;
|
|
item.stepCode = item.stepCode + 100;
|
|
item.stepSql = item.stepSql.Replace("'", "''");
|
|
WorkFlowBillImpl.SaveBillFlow(item, myTrans);
|
|
}
|
|
}
|
|
myTrans.Commit(); //事务提交
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
myTrans.Rollback(); //回滚
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
// 重排列表
|
|
InitializeStepFlow();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|