基于WF的报销单流转审批业务5(浅析)
项目名:ShenPBXXT(审批申请报销)
窗体名:Form1
Form1
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;
using BLL;
using System.Workflow.Activities;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace ShenPBXXT
{
public partial class Form1 : Form, InterFaces.IClass
{
WorkflowRuntime wr;
WorkflowInstance wfi;
ExternalDataExchangeService edes;
Model.BXDan bxd;
BLL.BLBXDan blbx = new BLBXDan();
List<Model.BXDan> lbx = new List<Model.BXDan>();
public Form1()
{
InitializeComponent();
wr = new WorkflowRuntime();
edes = new ExternalDataExchangeService();
wr.AddService(edes);
edes.AddService(this);
wr.WorkflowIdled += new EventHandler<WorkflowEventArgs>(wr_WorkflowIdled);
wr.AddService(new SqlWorkflowPersistenceService("Initial Catalog=SqlPersistenceService;Data Source=192.168.1.5;uid=sa;pwd=sa"));
wr.StartRuntime();
this.Height = 403;
lbx = blbx.GetModelList("");
for (int i = 0; i < lbx.Count; i++)
{
object[] obj = new object[3];
obj[0] = lbx[i].BXID;
obj[1] = lbx[i].BXName;
switch (lbx[i].stated)
{
case 0:
obj[2] = "被打回需要补充!";
break;
case 1:
obj[2] = "财务在核审中!";
break;
case 2:
obj[2] = "经理正在核审中!";
break;
case 3:
obj[2] = "出纳正在准备报销款!";
break;
case 9:
obj[2] = "没有通过审批不提供报销!";
break;
default:
obj[2] = "款项已经准备完成请去出纳处取款!";
break;
}
dgv1.Rows.Add(obj);
}
}
void wr_WorkflowIdled(object sender, WorkflowEventArgs e)
{
e.WorkflowInstance.TryUnload();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
{
return;
}
else
{
this.Height = 748 - 46;
this.dbx1.Location = new Point(dbx1.Location.X, 377 - 46);
this.button1.Enabled = false;
this.CenterToScreen();
bxd = new Model.BXDan();
bxd = blbx.GetModel(Convert.ToInt32(dgv1.Rows[e.RowIndex].Cells[0].Value.ToString()));
txtName.Text = bxd.BXName;
txtBaoXiaoNR.Text = bxd.BXNeiRong;
txtBaoXiao.Text = bxd.BXJin;
labState.Text = dgv1.Rows[e.RowIndex].Cells[2].Value.ToString();
txtName.Enabled = false;
if (bxd.stated != 0)
{
txtBaoXiao.Enabled = false;
txtBaoXiaoNR.Enabled = false;
btnShangBao.Enabled = false;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnShangBao_Click(object sender, EventArgs e)
{
Model.BXDan bb = bxd;
wfi = wr.GetWorkflow(new Guid(bb.BXGID));
bb.BXJin = txtBaoXiao.Text.Trim().ToString();
bb.BXName = txtName.Text.Trim().ToString();
bb.BXNeiRong = txtBaoXiaoNR.Text.Trim().ToString();
if (Convert.ToInt32(txtBaoXiao.Text.Trim().ToString()) >= 1000)
{
bb.stated = 2;
}
else
{
bb.stated = 1;
}
blbx.Update(bb);
ShenQing(null, new InterFaces.ShenQingBaoXiao(wfi.InstanceId, Convert.ToDouble(txtBaoXiao.Text.Trim().ToString())));
this.Close();
}
private void txtBaoXiao_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= '0' && e.KeyChar <= '9')
{
e.Handled = false;
}
else if (e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
#region IClass 成员
public event EventHandler<ExternalDataEventArgs> ShenQing;
public event EventHandler<ExternalDataEventArgs> CaiWuShenPi;
public event EventHandler<ExternalDataEventArgs> JingLiShenPi;
public event EventHandler<ExternalDataEventArgs> ChuNaShenPi;
public void quqian()
{
throw new NotImplementedException();
}
#endregion
}
}
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;
using BLL;
using System.Workflow.Activities;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace ShenPBXXT
{
public partial class Form1 : Form, InterFaces.IClass
{
WorkflowRuntime wr;
WorkflowInstance wfi;
ExternalDataExchangeService edes;
Model.BXDan bxd;
BLL.BLBXDan blbx = new BLBXDan();
List<Model.BXDan> lbx = new List<Model.BXDan>();
public Form1()
{
InitializeComponent();
wr = new WorkflowRuntime();
edes = new ExternalDataExchangeService();
wr.AddService(edes);
edes.AddService(this);
wr.WorkflowIdled += new EventHandler<WorkflowEventArgs>(wr_WorkflowIdled);
wr.AddService(new SqlWorkflowPersistenceService("Initial Catalog=SqlPersistenceService;Data Source=192.168.1.5;uid=sa;pwd=sa"));
wr.StartRuntime();
this.Height = 403;
lbx = blbx.GetModelList("");
for (int i = 0; i < lbx.Count; i++)
{
object[] obj = new object[3];
obj[0] = lbx[i].BXID;
obj[1] = lbx[i].BXName;
switch (lbx[i].stated)
{
case 0:
obj[2] = "被打回需要补充!";
break;
case 1:
obj[2] = "财务在核审中!";
break;
case 2:
obj[2] = "经理正在核审中!";
break;
case 3:
obj[2] = "出纳正在准备报销款!";
break;
case 9:
obj[2] = "没有通过审批不提供报销!";
break;
default:
obj[2] = "款项已经准备完成请去出纳处取款!";
break;
}
dgv1.Rows.Add(obj);
}
}
void wr_WorkflowIdled(object sender, WorkflowEventArgs e)
{
e.WorkflowInstance.TryUnload();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
{
return;
}
else
{
this.Height = 748 - 46;
this.dbx1.Location = new Point(dbx1.Location.X, 377 - 46);
this.button1.Enabled = false;
this.CenterToScreen();
bxd = new Model.BXDan();
bxd = blbx.GetModel(Convert.ToInt32(dgv1.Rows[e.RowIndex].Cells[0].Value.ToString()));
txtName.Text = bxd.BXName;
txtBaoXiaoNR.Text = bxd.BXNeiRong;
txtBaoXiao.Text = bxd.BXJin;
labState.Text = dgv1.Rows[e.RowIndex].Cells[2].Value.ToString();
txtName.Enabled = false;
if (bxd.stated != 0)
{
txtBaoXiao.Enabled = false;
txtBaoXiaoNR.Enabled = false;
btnShangBao.Enabled = false;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnShangBao_Click(object sender, EventArgs e)
{
Model.BXDan bb = bxd;
wfi = wr.GetWorkflow(new Guid(bb.BXGID));
bb.BXJin = txtBaoXiao.Text.Trim().ToString();
bb.BXName = txtName.Text.Trim().ToString();
bb.BXNeiRong = txtBaoXiaoNR.Text.Trim().ToString();
if (Convert.ToInt32(txtBaoXiao.Text.Trim().ToString()) >= 1000)
{
bb.stated = 2;
}
else
{
bb.stated = 1;
}
blbx.Update(bb);
ShenQing(null, new InterFaces.ShenQingBaoXiao(wfi.InstanceId, Convert.ToDouble(txtBaoXiao.Text.Trim().ToString())));
this.Close();
}
private void txtBaoXiao_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= '0' && e.KeyChar <= '9')
{
e.Handled = false;
}
else if (e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
#region IClass 成员
public event EventHandler<ExternalDataEventArgs> ShenQing;
public event EventHandler<ExternalDataEventArgs> CaiWuShenPi;
public event EventHandler<ExternalDataEventArgs> JingLiShenPi;
public event EventHandler<ExternalDataEventArgs> ChuNaShenPi;
public void quqian()
{
throw new NotImplementedException();
}
#endregion
}
}
窗体名:FrmMain
FrmMain
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;
using System.Workflow.Activities;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace ShenPBXXT
{
public partial class FrmMain : Form, InterFaces.IClass
{
WorkflowRuntime wr;
WorkflowInstance wfi;
ExternalDataExchangeService edes;
BLL.BLBXDan blbxd = new BLL.BLBXDan();
public FrmMain()
{
InitializeComponent();
wr = new WorkflowRuntime();
edes = new ExternalDataExchangeService();
wr.AddService(edes);
wr.WorkflowIdled += new EventHandler<WorkflowEventArgs>(wr_WorkflowIdled);
edes.AddService(this);
wr.AddService(new SqlWorkflowPersistenceService("Initial Catalog=SqlPersistenceService;Data Source=192.168.1.5;uid=sa;pwd=sa"));
wr.StartRuntime();
}
void wr_WorkflowIdled(object sender, WorkflowEventArgs e)
{
e.WorkflowInstance.TryUnload();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
wfi = wr.CreateWorkflow(typeof(BaoXiaoShenPin.ShenQing));
wfi.Start();
Model.BXDan bxd = new Model.BXDan();
if ((Convert.ToInt32(txtBaoXiaoJin.Text.Trim().ToString())) >= 1000)
{
bxd.stated = 2;
}
else
{
bxd.stated = 1;
}
bxd.BXName = txtName.Text.Trim().ToString();
bxd.BXNeiRong = txtNeiRong.Text.Trim().ToString();
bxd.BXJin = txtBaoXiaoJin.Text.Trim().ToString();
bxd.BXGID = wfi.InstanceId.ToString();
blbxd.Add(bxd);
ShenQing(null, new InterFaces.ShenQingBaoXiao(wfi.InstanceId, Convert.ToDouble(txtBaoXiaoJin.Text.Trim().ToString())));
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= '0' && e.KeyChar <= '9')
{
e.Handled = false;
}
else if (e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
#region IClass 成员
public event EventHandler<ExternalDataEventArgs> ShenQing;
public event EventHandler<ExternalDataEventArgs> CaiWuShenPi;
public event EventHandler<ExternalDataEventArgs> JingLiShenPi;
public event EventHandler<ExternalDataEventArgs> ChuNaShenPi;
public void quqian()
{
throw new NotImplementedException();
}
#endregion
private void button3_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1.Show();
}
}
}
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;
using System.Workflow.Activities;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace ShenPBXXT
{
public partial class FrmMain : Form, InterFaces.IClass
{
WorkflowRuntime wr;
WorkflowInstance wfi;
ExternalDataExchangeService edes;
BLL.BLBXDan blbxd = new BLL.BLBXDan();
public FrmMain()
{
InitializeComponent();
wr = new WorkflowRuntime();
edes = new ExternalDataExchangeService();
wr.AddService(edes);
wr.WorkflowIdled += new EventHandler<WorkflowEventArgs>(wr_WorkflowIdled);
edes.AddService(this);
wr.AddService(new SqlWorkflowPersistenceService("Initial Catalog=SqlPersistenceService;Data Source=192.168.1.5;uid=sa;pwd=sa"));
wr.StartRuntime();
}
void wr_WorkflowIdled(object sender, WorkflowEventArgs e)
{
e.WorkflowInstance.TryUnload();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
wfi = wr.CreateWorkflow(typeof(BaoXiaoShenPin.ShenQing));
wfi.Start();
Model.BXDan bxd = new Model.BXDan();
if ((Convert.ToInt32(txtBaoXiaoJin.Text.Trim().ToString())) >= 1000)
{
bxd.stated = 2;
}
else
{
bxd.stated = 1;
}
bxd.BXName = txtName.Text.Trim().ToString();
bxd.BXNeiRong = txtNeiRong.Text.Trim().ToString();
bxd.BXJin = txtBaoXiaoJin.Text.Trim().ToString();
bxd.BXGID = wfi.InstanceId.ToString();
blbxd.Add(bxd);
ShenQing(null, new InterFaces.ShenQingBaoXiao(wfi.InstanceId, Convert.ToDouble(txtBaoXiaoJin.Text.Trim().ToString())));
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= '0' && e.KeyChar <= '9')
{
e.Handled = false;
}
else if (e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
#region IClass 成员
public event EventHandler<ExternalDataEventArgs> ShenQing;
public event EventHandler<ExternalDataEventArgs> CaiWuShenPi;
public event EventHandler<ExternalDataEventArgs> JingLiShenPi;
public event EventHandler<ExternalDataEventArgs> ChuNaShenPi;
public void quqian()
{
throw new NotImplementedException();
}
#endregion
private void button3_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1.Show();
}
}
}
配置文件:App.config
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SQL2000" value="server=192.168.1.3;database=Shenp;uid=sa" />
</appSettings>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SQL2000" value="server=192.168.1.3;database=Shenp;uid=sa" />
</appSettings>
</configuration>
基于WF的报销单流转审批业务1(浅析)
基于WF的报销单流转审批业务2(浅析)
基于WF的报销单流转审批业务3(浅析)
基于WF的报销单流转审批业务4(浅析)
基于WF的报销单流转审批业务6(浅析)