509 lines
19 KiB
C#
509 lines
19 KiB
C#
/******************************
|
|
* 说明:流转类别设置
|
|
* 创建人:龚宇超
|
|
* 创建日期:2019-06-21
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Model;
|
|
using Lskj.BaseWorkflow.Model;
|
|
using Lskj.Control;
|
|
|
|
namespace Lskj.BaseWorkflow.Control
|
|
{
|
|
/// <summary>
|
|
/// 流转类别设置
|
|
/// </summary>
|
|
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 StepItem1 SeletStepItem1Obj;
|
|
/// <summary>
|
|
/// 当前选中的流转步骤对象
|
|
/// </summary>
|
|
public BaseflowModel SelectBaseflowModel;
|
|
/// <summary>
|
|
/// 主页转过来的操作权限
|
|
/// </summary>
|
|
public bool SerpPagePower;
|
|
/// <summary>
|
|
/// 单据流转集合
|
|
/// </summary>
|
|
public List<BaseflowModel> BaseflowModelList = new List<BaseflowModel>();
|
|
|
|
public StepPage1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#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 = WorkFlowBaseImpl.GetBaseFlowData(mMenuCode);
|
|
BaseflowModelList.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];
|
|
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);
|
|
if (this.xtraScrollableControl1.Controls.Count == 0)
|
|
{
|
|
this.InitializeMainField();
|
|
}
|
|
}
|
|
}
|
|
/// <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 (SelectBaseflowModel != null) {
|
|
int rowcount = 7;
|
|
int width = 100, height = 20;
|
|
int left = 0, top = 0;
|
|
|
|
DataTable table = BaseModuleImpl.GetControlLocation(this.moduleModel.FormKey, mMenuCode);
|
|
DataTable editTable = table.Select("visible=0 and edited=0").CopyToDataTable();
|
|
editTable.DefaultView.Sort = "ControlTop,ControlLeft";
|
|
editTable = editTable.DefaultView.ToTable();
|
|
this.xtraScrollableControl1.Controls.Clear();
|
|
for (int i = 0; i < editTable.Rows.Count; i++)
|
|
{
|
|
DataRow rowItem = editTable.Rows[i];
|
|
|
|
if (i % rowcount == 0)
|
|
{
|
|
left = mLocationX[0];
|
|
top = mLocationY[Convert.ToInt32(i / rowcount)];
|
|
}
|
|
else
|
|
{
|
|
left = mLocationX[Convert.ToInt32(i % rowcount)];
|
|
top = mLocationY[Convert.ToInt32(i / rowcount)];
|
|
}
|
|
|
|
LabelCheckEdit checkEdit = new LabelCheckEdit();
|
|
checkEdit.TextEdit.Name = rowItem["fieldname"] + "";
|
|
checkEdit.LabelText = rowItem["username"] + "";
|
|
checkEdit.Size = new Size(width, height);
|
|
checkEdit.Location = new Point(left, top);
|
|
checkEdit.EditText = ("," + this.SelectBaseflowModel.billModifyFields + ",").Contains("," + rowItem["fieldname"] + ",") ? "1" : "0";
|
|
checkEdit.Tag = rowItem;
|
|
this.xtraScrollableControl1.Controls.Add(checkEdit);
|
|
}
|
|
}
|
|
}
|
|
/// <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)
|
|
{
|
|
|
|
this.mMenuCode = menuCode;
|
|
this.moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(menuCode));
|
|
|
|
this.InitializeStepFlow();
|
|
//this.InitializeMainField();
|
|
// 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)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
/// <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();
|
|
|
|
|
|
bool result = WorkFlowBaseImpl.UpdateBaseFlow(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-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 SetMainFieldCheckState(BaseflowModel model)
|
|
{
|
|
foreach (var ctr in xtraScrollableControl1.Controls)
|
|
{
|
|
LabelCheckEdit checkEdit = ctr as LabelCheckEdit;
|
|
if (checkEdit != null)
|
|
{
|
|
DataRow rowItem = checkEdit.Tag as DataRow;
|
|
checkEdit.EditText = ("," + model.billModifyFields + ",").Contains("," + rowItem["fieldname"] + ",") ? "1" : "0";
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <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()
|
|
{
|
|
string fields = string.Empty;
|
|
foreach (var ctr in xtraScrollableControl1.Controls)
|
|
{
|
|
LabelCheckEdit checkEdit = ctr as LabelCheckEdit;
|
|
if (checkEdit != null && "1".Equals(checkEdit.EditText))
|
|
{
|
|
fields += checkEdit.TextEdit.Name + ",";
|
|
}
|
|
}
|
|
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)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <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)
|
|
{
|
|
BaseflowModel model = after.Tag as BaseflowModel;
|
|
|
|
this.SeletStepItem1Obj = after;
|
|
this.SetFlowItem(model);
|
|
this.SetMainFieldCheckState(model);
|
|
}
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:插入流转类别</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InsertFlowItem(string stepGroup, string stepName)
|
|
{
|
|
int Code = 0;
|
|
if (SelectBaseflowModel == null)
|
|
{
|
|
MessageUtil.Show("插入的流转类别不能为空");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
//BillflowModelList
|
|
//选中的步骤号
|
|
int selectedStepCode = SelectBaseflowModel.stepCode;
|
|
//获取比选中步骤小一步的步骤号
|
|
int? maxStepCode = BaseflowModelList
|
|
.Where(m => m.stepCode < selectedStepCode)
|
|
.Select(m => m.stepCode)
|
|
.DefaultIfEmpty() // 避免空集合时抛出异常
|
|
.Max();
|
|
|
|
Code = (int)(maxStepCode + (selectedStepCode - maxStepCode) / 2);
|
|
}
|
|
BaseflowModel model = new BaseflowModel
|
|
{
|
|
stepCode = Convert.ToInt32(Code),
|
|
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);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |