using DevExpress.XtraTab;
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.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Lskj.PubUserTomodule.AuditPermissionControls
{
public partial class FrmWork : UserControl
{
///
/// 上一次选中标签
///
public StepEnum mPrevStepPage;
///
/// 当前选中标签
///
public StepEnum mCurrentStepPage;
///
/// 模块编号
///
public string MenuCode = string.Empty;
///
/// 基础对象
///
public ModuleModel ModuleModel;
///
/// 单据
///
public BillModel BillModel;
///
/// 判断是否有权力
///
public bool powerflag;
///
/// 选择步骤的panel
///
public DevExpress.XtraEditors.PanelControl choosePanel { get { return this.panelControl1; } }
///
/// 是基础模块true 还是单据
///
public bool isBasis;
public FrmWork()
{
InitializeComponent();
this.but_increase.Visible = false;
this.but_delete.Visible = false;
this.but_increase.Enabled = false;
this.but_delete.Enabled = false;
this.stepPage41.Sp4XtraTabControl.SelectedPageChanged += new DevExpress.XtraTab.TabPageChangedEventHandler(Sp4XtraTabControl_SelectedPageChanged);
this.but_increase.Click += new EventHandler(onBut_increase);
this.but_delete.Click += new EventHandler(onBut_delete);
}
#region 方法相关
///
/// 说明:切换
/// 创建人:龚宇超
/// 创建日期:2019-06-21
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The step enum.
public void SetStepPage(StepEnum stepEnum)
{
this.mCurrentStepPage = stepEnum;
this.btnAdd.Visible = this.btnInsert.Visible= true;
this.but_increase.Visible = false;
this.but_delete.Visible = false;
switch (stepEnum)
{
case StepEnum.StepPage1:
default:
this.btnReset.Visible = false;
this.stepPage11.Visible = true;
this.stepPage21.Visible = false;
this.stepPage31.Visible = false;
this.stepPage41.Visible = false;
this.pllzbzsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_xllzsz_2x;
this.plxlsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_xlsz_gray_2x;
this.plxllzsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_lzbzsz_gray_2x;
this.plzsht.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_lzbzsz_gray_2x;
this.btnAdd.Text = "新增(&A)";
break;
case StepEnum.StepPage2:
this.btnReset.Visible = false;
this.btnInsert.Visible = false;
this.stepPage11.Visible = false;
this.stepPage21.Visible = true;
this.stepPage31.Visible = false;
this.stepPage41.Visible = false;
this.pllzbzsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_xllzsz_gray_2x;
this.plxlsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_xlsz_2x;
this.plxllzsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_lzbzsz_gray_2x;
this.plzsht.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_lzbzsz_gray_2x;
this.btnAdd.Text = "新增(&A)";
break;
case StepEnum.StepPage3:
this.btnReset.Visible = true;
this.btnInsert.Visible = false;
this.stepPage11.Visible = false;
this.stepPage21.Visible = false;
this.stepPage31.Visible = true;
this.stepPage41.Visible = false;
this.pllzbzsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_xllzsz_gray_2x;
this.plxlsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_xlsz_gray_2x;
this.plxllzsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_lzbzsz_2x;
this.plzsht.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_lzbzsz_gray_2x;
this.btnAdd.Text = "生成(&A)";
break;
case StepEnum.StepPage4:
this.btnReset.Visible = this.btnInsert.Visible = false;
this.stepPage11.Visible = false;
this.stepPage21.Visible = false;
this.stepPage31.Visible = false;
this.stepPage41.Visible = true;
this.but_increase.Visible = true;
this.but_delete.Visible = true;
this.pllzbzsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_xllzsz_gray_2x;
this.plxlsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_xlsz_gray_2x;
this.plxllzsz.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_lzbzsz_gray_2x;
this.plzsht.BackgroundImage = Lskj.PubUserTomodule.Properties.Resources.icon_lzbzsz_2x;
//this.btnAdd.Visible = false;
this.btnAdd.Text = "生成Sql(&A)";
break;
}
}
#endregion
#region 事件相关
///
/// 说明:窗口加载
/// 创建人:龚宇超
/// 创建日期:2019-06-21
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnWorkLoad(object sender, EventArgs e)
{
}
public void InitializeControl(string menuCode, bool Basis)
{
this.MenuCode = menuCode;
this.isBasis = Basis;
try
{
if (isBasis)
{
this.ModuleModel = new BaseAuditModel(MainImpl.GetSystemdllTab(this.MenuCode));
if (this.ModuleModel == null || string.IsNullOrEmpty(this.ModuleModel.FormKey))
{
MessageUtil.Show("无效的模块编号->" + MenuCode);
//this.Close();
}
this.Text = this.Text + "->" + this.ModuleModel.MenuName;
DataTable table = WorkFlowBaseImpl.GetPowerTable();
string[] Purview = table.Rows[0]["DllFlowPurview"].ToString().Trim().TrimEnd(',').Split(',');
if (Purview.Contains(ERPInfo.Instance.UserName))
{
powerflag = true;
}
}
else
{
this.BillModel = new BillModel(BillImpl.GetBillInfo(this.MenuCode));
if (this.BillModel == null || string.IsNullOrEmpty(this.BillModel.FormKey))
{
MessageUtil.Show("无效的模块编号->" + MenuCode);
//this.Close();
}
this.Text = this.Text + "->" + this.BillModel.TypeName;
DataTable table = WorkFlowBillImpl.GetPowerTable();
string[] Purview = table.Rows[0]["BillFlowPurview"].ToString().Trim().TrimEnd(',').Split(',');
if (Purview.Contains(ERPInfo.Instance.UserName))
{
powerflag = true;
}
}
if (!powerflag)
{
this.btnAdd.Enabled = this.btnReset.Enabled =this.btnInsert.Enabled = false;
stepPage11.SerpPagePower = true;
stepPage21.SerpPage2Power = true;
stepPage31.SerpPage3Power = true;
}
// 设置默认显示第一个界面
this.SetStepPage(StepEnum.StepPage1);
//this.stepPage11 = new StepPage1();
//this.stepPage21 = new StepPage2();
//this.stepPage31 = new StepPage3();
//this.stepPage41 = new StepPage4();
this.stepPage11.InitializeControl(this.MenuCode, isBasis);
this.stepPage21.InitializeControl(this.MenuCode, isBasis);
this.stepPage31.InitializeControl(this.MenuCode, isBasis);
this.stepPage41.InitializeControl(this.MenuCode, isBasis);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
//private void InitializeColumns()
//{
// this.moduleControl.GridView.Columns.AddVisible("PurviewId", "模块编号");
// this.moduleControl.GridView.Columns.AddVisible("MenuCaption", "模块名");
// this.moduleControl.GridView.Columns.AddVisible("DllFileName", "dll名");
// string sql = @"select PurviewId,MenuCaption,DllFileName from
// (SELECT Word_Checkid,MenuId,SubSysId, MenuStruct,'01'+case when SubSysId>9 then cast(SubSysId as varchar(10)) else '0'+cast(SubSysId as varchar(10)) end+MenuStruct as speciesno,
// MenuCaption,MouseOutImg,DllFileName,UrlParams,PurviewId,ParentMenuId,DllInfo,PurviewId as DllCode
// FROM P_FormMenuConfigTab where 1=1 and len(MenuStruct)=4 and useFlag=1
// ) a where 1=1 and dllfilename in ( 'Lskj.PubModuleDetail.dll','Lskj.PubModule.dll','Lskj.PubBill.dll') ";
// DataTable dataTable = SqlHelper.ExecuteDataTable(sql);
// this.moduleControl.gridControl.DataSource = dataTable;
// this.moduleControl.GridView.Click += new EventHandler(OnGridViewClick);
//}
//private void OnGridViewClick(object sender, EventArgs e)
//{
// DataRow mSelectRow = this.moduleControl.GridView.GetFocusedDataRow();
// if (mSelectRow != null)
// {
// string PurviewId = mSelectRow["PurviewId"] + "";
// string DllFileName= mSelectRow["DllFileName"] + "";
// bool Basis = !DllFileName.Equals("Lskj.PubBill.dll", StringComparison.CurrentCultureIgnoreCase);
// InitializeControl(PurviewId, Basis);
// }
//}
///
/// 说明:添加模块
/// 创建人:龚宇超
/// 创建日期:2019-06-24
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnAddClick(object sender, EventArgs e)
{
try
{
switch (mCurrentStepPage)
{
case StepEnum.StepPage1:
{
// 保存流转步骤
FrmAddStep frmAddStep = new FrmAddStep();
frmAddStep.LabelObj.Text = "请输入审批步骤:";
if (frmAddStep.ShowDialog() == DialogResult.OK)
{
string stepName = frmAddStep.StepName;
string stepGroup = frmAddStep.StepName;
this.stepPage11.AddFlowItem(stepGroup, stepGroup);
}
}
break;
case StepEnum.StepPage2:
{
// 保存小类设置
FrmAddStep frmAddStep = new FrmAddStep();
frmAddStep.LabelObj.Text = "请输入审批方案:";
if (frmAddStep.ShowDialog() == DialogResult.OK)
{
string typeName = frmAddStep.StepName;
this.stepPage21.AddFlowTypeItem(typeName);
}
}
break;
case StepEnum.StepPage3:
{
// 生成小类流转步骤设置
this.stepPage31.CreateFlowTypeStep();
}
break;
case StepEnum.StepPage4:
{
// 生成终审sql
this.stepPage41.GenerateFinalSqlStatement();
}
break;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
//MessageUtil.Show(ex.Message);
//LogUtil.WriteError("单据审批添加模块", ex);
}
}
private void btnInsert_Click(object sender, EventArgs e)
{
try
{
switch (mCurrentStepPage)
{
case StepEnum.StepPage1:
{
// 保存流转步骤
FrmAddStep frmAddStep = new FrmAddStep();
frmAddStep.LabelObj.Text = "请输入审批步骤:";
if (frmAddStep.ShowDialog() == DialogResult.OK)
{
string stepName = frmAddStep.StepName;
string stepGroup = frmAddStep.StepName;
// this.stepPage11.InsertStep(stepGroup, stepGroup);
this.stepPage11.InsertFlowItem(stepGroup, stepGroup);
}
}
break;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 一键保存所有图像
///
///
///
void OnBtnSaveAllFlow(object sender, EventArgs e)
{
this.stepPage31.InitAllStepTypeFlow();
}
public void OnBtnToword(object sender, EventArgs e)
{
try
{
//FrmMain fm = new FrmMain();
//fm.modelCound = this.MenuCode;
//fm.modelName = this.BillModel.TypeName;
//fm.StartPosition = FormStartPosition.CenterScreen;
//fm.ShowDialog();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
//LogUtil.WriteError("转word流程设计出错!", ex);
//MessageUtil.Show("转word流程设计出错!" + ex);
}
}
///
/// 说明:保存
/// 创建人:龚宇超
/// 创建日期:2019-06-25
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnBtnSaveClick(object sender, EventArgs e)
{
try
{
switch (mCurrentStepPage)
{
case StepEnum.StepPage1:
// 保存流转步骤
if (isBasis)
{
this.stepPage11.UpdateBaseFlow();
}
else
{
this.stepPage11.UpdateBillFlow();
}
break;
case StepEnum.StepPage2:
// 保存小类设置
if (isBasis)
{
this.stepPage21.UpdateBaseFlowType();
}
else
{
this.stepPage21.UpdateBillFlowType();
}
break;
case StepEnum.StepPage3:
// 保存小类流转设置
if (isBasis)
{
this.stepPage31.UpdateBaseFlowTypeStep();
}
else
{
this.stepPage31.UpdateBillFlowTypeStep();
}
break;
case StepEnum.StepPage4:
// 保存终审回退权限信息
this.stepPage41.UpdateFinalReturnSettings();
break;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
//MessageUtil.Show("数据保存失败:" + ex.Message);
//LogUtil.WriteError("数据保存失败!", ex);
}
}
///
/// 说明:流转步骤设置点击
/// 创建人:龚宇超
/// 创建日期:2019-06-24
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnlzbzszClick(object sender, EventArgs e)
{
try
{
this.SetStepPage(StepEnum.StepPage1);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:小类设置点击
/// 创建人:龚宇超
/// 创建日期:2019-06-24
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnxlszClick(object sender, EventArgs e)
{
try
{
this.SetStepPage(StepEnum.StepPage2);
this.stepPage21.InitializeStepFlow();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:小类流转步骤设置
/// 创建人:龚宇超
/// 创建日期:2019-06-24
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnxllzszClick(object sender, EventArgs e)
{
try
{
this.SetStepPage(StepEnum.StepPage3);
this.stepPage31.InitializeStepType();
this.stepPage31.InitializeStepTypeFlow();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:终审回退设置
/// 创建人:曹屹峰
/// 创建日期:2022-06-08
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnzshtClick(object sender, EventArgs e)
{
try
{
this.SetStepPage(StepEnum.StepPage4);
this.stepPage41.initialLoad();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:重置权限
/// 创建人:龚宇超
/// 创建日期:2019-06-28
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnBtnResetClick(object sender, EventArgs e)
{
try
{
this.stepPage31.ResetPurview();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:初始化权限
/// 创建人:龚宇超
/// 创建日期:2019-06-28
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The sender.
/// The instance containing the event data.
void OnBtnInitClick(object sender, EventArgs e)
{
try
{
this.stepPage31.InitPurview();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
private void Sp4XtraTabControl_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
{
if (this.stepPage41.Sp4XtraTabControl.SelectedTabPage.Name == "xtraTabPage1")//进行tabpage位置判断
{
this.but_increase.Enabled = false;
this.but_delete.Enabled = false