基于WF的意见征集5(浅析)
投票宿主项目,项目名称:toupiao
窗体名称:HFXiangXiXinXi.cs(回复详细信息)
1
using System;2
using System.Collections.Generic;3
using System.ComponentModel;4
using System.Data;5
using System.Drawing;6
using System.Linq;7
using System.Text;8
using System.Windows.Forms;9
using IClass;10
using Maticsoft.DBUtility;11
using FBBLL;12

13
namespace toupiao14


{15
public partial class HFXiangXiXinXi : Form16

{17
HuaTi hh;18
FBBLL.BLHuaTi fbht = new BLHuaTi();19
BLHTHuiFu blhthf = new BLHTHuiFu();20
public HFXiangXiXinXi(int id)21

{22
InitializeComponent();23
this.Height = 363;24
hh = fbht.GetModel(id);25
labHTName.Text = hh.HTName1;26
List<HTHuiFu> lhthf = new List<HTHuiFu>();27
lhthf = blhthf.GetModelList(" HTId="+hh.HTID1);28
for (int i = 0; i < lhthf.Count; i++)29

{30
object[] obj = new object[3];31
obj[0] = lhthf[i].HfId1;32
obj[1] = lhthf[i].FBRenName1;33
obj[2] = lhthf[i].FanKuiNeiRong1;34
dataGridView1.Rows.Add(obj);35
}36
}37

38
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)39

{40
if (e.ColumnIndex<0)41

{42
return;43
}44
else45

{46
int index=e.RowIndex;47
this.Height = 692;48
this.CenterToScreen();49
btnClance.Hide();50
groupBox1.Location = new Point(groupBox1.Location.X, 293);51
txtHTNeiRong.Text = hh.HTNeiRong1;52
HTHuiFu hthf = new HTHuiFu();53
hthf = blhthf.GetModel(Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()));54
txtHuiFuNeiRong.Text = hthf.FanKuiNeiRong1;55
labHuiFuName.Text = hthf.FBRenName1;56
}57
}58

59
private void button2_Click(object sender, EventArgs e)60

{61
this.Close();62
}63

64
private void btnClance_Click(object sender, EventArgs e)65

{66
this.Close();67
}68
}69
}70

窗体名称:HTGuanLi.cs(话题管理)
1
using System;2
using System.Collections.Generic;3
using System.ComponentModel;4
using System.Data;5
using System.Drawing;6
using System.Linq;7
using System.Text;8
using System.Windows.Forms;9
using FBBLL;10
using IClass;11
using Maticsoft.DBUtility;12
using System.Data.SqlClient;13
using System.Workflow.Runtime;14
using System.Workflow.Activities;15
using System.Workflow.Runtime.Hosting;16
using System.Workflow.Runtime.Tracking;17

18
namespace toupiao19


{20
public partial class HTGuanLi : Form,IClass.InterFaces21

{22
HuaTi hh;23
FBBLL.BLHuaTi blht = new BLHuaTi();24
WorkflowRuntime wr = new WorkflowRuntime();25
WorkflowInstance wfi;26
ExternalDataExchangeService edes = new ExternalDataExchangeService();27
BLHTHuiFu blhthf = new BLHTHuiFu();28
HuaTi hhh;29
public HTGuanLi()30

{31
InitializeComponent();32
wr.AddService(edes);33
edes.AddService(this);34
// wr.AddService(new SqlTrackingService("Initial Catalog=Tracking;Data Source=192.168.1.5;uid=sa;pwd=sa"));35

36
WorkflowPersistenceService persistenceService =37
new SqlWorkflowPersistenceService(38
"Initial Catalog=SqlPersistenceService;Data Source=192.168.1.5;uid=sa;pwd=sa");39
wr.AddService(persistenceService);40
41
wr.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(wr_WorkflowCompleted);42
wr.WorkflowIdled += new EventHandler<WorkflowEventArgs>(wr_WorkflowIdled);43
wr.StartRuntime();44

45

46
this.Height = 315;47
List<HuaTi> ht = new List<HuaTi>();48
ht = blht.GetModelList("");49
object[] obj = new object[2];50
for (int i = 0; i < ht.Count; i++)51

{52
obj[0] = ht[i].HTID1;53
obj[1] = ht[i].HTName1;54
dgv1.Rows.Add(obj);55
}56
}57

58
void wr_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)59

{60

61
MessageBox.Show("已经完成此次表决!");62
}63

64
void wr_WorkflowIdled(object sender, WorkflowEventArgs e)65

{66
e.WorkflowInstance.TryUnload();67
}68

69
private void dgv1_CellClick(object sender, DataGridViewCellEventArgs e)70

{71
if (e.ColumnIndex < 0)72

{73
return;74
}75
else76

{77
hh=blht.GetModel(Convert.ToInt32(dgv1.Rows[e.RowIndex].Cells[0].Value.ToString()));78
int index = e.RowIndex;79
btnClance1.Hide();80
this.Height = 670;81
groupBox1.Location = new Point(21, 249);82
this.CenterToScreen();83
this.labName.Text = dgv1.Rows[e.RowIndex].Cells[1].Value.ToString();84
this.txtNeiRong.Text =hh.HTNeiRong1;85
DataSet ds=DbHelperSQL.Query("select count(*) from HTHuiFu where HTId="+dgv1.Rows[e.RowIndex].Cells[0].Value.ToString());86
string str = ds.Tables[0].Rows[0][0].ToString();87
if (hh.State1==0)88

{89
labMessage.Text="表决正在进行中
.";90
labMessage.Text+="已经有"+str+"人表决完毕";91
button3.Enabled = true;92
}93
else94

{95
labMessage.Text = "表决已经完成..所有人已经完成表决
";96
button3.Enabled = false;97
}98

99
}100
}101

102
private void btnClance1_Click(object sender, EventArgs e)103

{104
this.Close();105
}106

107
private void button2_Click(object sender, EventArgs e)108

{109
this.Close();110
}111

112
private void button1_Click(object sender, EventArgs e)113

{114
HFXiangXiXinXi hfxx = new HFXiangXiXinXi(hh.HTID1);115
hfxx.Show();116
}117

118
private void button3_Click(object sender, EventArgs e)119

{120
this.Height = 315;121
groupBox1.Location = new Point(21, 249+46);122
btnClance1.Show();123
IClass.Master mm = new IClass.Master();124
List<IClass.Master> lm = new List<IClass.Master>();125
FBBLL.Master blm = new FBBLL.Master();126
lm = blm.GetModelList(" flage=" + hh.HTID1);127
mm = lm[0];128
wfi = wr.GetWorkflow(new Guid(mm.Id));129
eve1(null, new pargme(new Guid(mm.Id), hh.HTID1, true));130
hh.State1 = 1;131
blht.Update(hh);132
}133

134

InterFaces 成员#region InterFaces 成员135

136
public event EventHandler<ExternalDataEventArgs> eve1;137

138
public void callroupiao(object flage)139

{140
MessageBox.Show("已经完成话题为"+flage.ToString()+"的表决!");141
}142

143
#endregion144
}145
}146

窗体名称:Main.cs(发布话题)
1
using System;2
using System.Collections.Generic;3
using System.ComponentModel;4
using System.Data;5
using System.Drawing;6
using System.Linq;7
using System.Text;8
using System.Windows.Forms;9
using FBBLL;10
using IClass;11
using System.Workflow.Activities;12
using System.Workflow.Runtime;13
using System.Workflow.Runtime.Hosting;14
using Maticsoft.DBUtility;15
using System.Workflow.Runtime.Tracking;16

17
namespace toupiao18


{19
public partial class Main : Form,IClass.InterFaces20

{21
FBBLL.BLHuaTi blht = new BLHuaTi();22
WorkflowRuntime wr;23
WorkflowInstance wfi;24
ExternalDataExchangeService edes=new ExternalDataExchangeService();25

26

27

28

29
public Main()30

{31
InitializeComponent();32

33
wr = new WorkflowRuntime();34
wr.AddService(edes);35
edes.AddService(this);36
wr.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(wr_WorkflowCompleted);37
wr.WorkflowIdled += new EventHandler<WorkflowEventArgs>(wr_WorkflowIdled);38
//wr.AddService(new SqlTrackingService("Initial Catalog=Tracking;Data Source=192.168.1.5;uid=sa;pwd=sa"));39
WorkflowPersistenceService persistenceService =40
new SqlWorkflowPersistenceService(41
"Initial Catalog=SqlPersistenceService;Data Source=192.168.1.5;uid=sa;pwd=sa");42
43
wr.AddService(persistenceService);44
wr.StartRuntime();45
}46

47
void wr_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)48

{49
MessageBox.Show("表决完成");50
}51

52
void wr_WorkflowIdled(object sender, WorkflowEventArgs e)53

{54
e.WorkflowInstance.TryUnload();55
}56

57
private void button1_Click(object sender, EventArgs e)58

{59
FBBLL.Master mm = new FBBLL.Master();60

61

62
wfi = wr.CreateWorkflow(typeof(zhuangtaiji.Workflow1));63
wfi.Start();64

65

66

67
HuaTi ht = new HuaTi();68
ht.HTName1 = txtHTName.Text.ToString();69
ht.HTNeiRong1 = txtHTNeiRong.Text.ToString();70
ht.State1 = 0;71
ht.Dt = DateTime.Now;72
blht.Add(ht);73
List<HuaTi> h1 = new List<HuaTi>();74
h1 = blht.GetModelList(" HTName='" + ht.HTName1 + "' and State=0");75
IClass.Master m = new IClass.Master(wfi.InstanceId.ToString(), false, h1[0].HTID1);76
mm.Add(m);77
// eve1(null,new ExternalDataEventArgs(wfi.InstanceId));78
MessageBox.Show("发布话题成功!");79
//eve1(null, new ExternalDataEventArgs(wfi.InstanceId));80
wfi.TryUnload();81
}82

83
private void button2_Click(object sender, EventArgs e)84

{85
HTGuanLi htgl = new HTGuanLi();86
htgl.Show();87
}88

89
private void txtNumber_KeyPress(object sender, KeyPressEventArgs e)90

{91
if (e.KeyChar>='0' &&e.KeyChar<='9')92

{93
e.Handled = false;94
}95
else if (e.KeyChar==8)96

{97
e.Handled = false;98
}99
else100

{101
e.Handled = true;102
}103
}104

105
private void Main_FormClosing(object sender, FormClosingEventArgs e)106

{107

108
}109

110

InterFaces 成员#region InterFaces 成员111

112
public event EventHandler<ExternalDataEventArgs> eve1;113

114
public void callroupiao(object flage)115

{116
throw new NotImplementedException();117
}118

119
#endregion120
}121
}122

配置文件:App.config
1
<?xml version="1.0" encoding="utf-8" ?>
2
<configuration>
3
<appSettings>
4
<add key="SQL2000" value="server=192.168.1.3;database=asd;uid=sa" />
5
</appSettings>
6
</configuration>
<?xml version="1.0" encoding="utf-8" ?>2
<configuration>3
<appSettings>4
<add key="SQL2000" value="server=192.168.1.3;database=asd;uid=sa" />5
</appSettings>6
</configuration>
投票用户宿主项目,项目名称:User
配置文件:App.config
1
<?xml version="1.0" encoding="utf-8" ?>
2
<configuration>
3
<appSettings>
4
<add key="SQL2000" value="server=192.168.1.3;database=asd;uid=sa" />
5
</appSettings>
6
</configuration>
<?xml version="1.0" encoding="utf-8" ?>2
<configuration>3
<appSettings>4
<add key="SQL2000" value="server=192.168.1.3;database=asd;uid=sa" />5
</appSettings>6
</configuration>
窗体名称:UserMain.cs(用户投票窗体)
1
using System;2
using System.Collections.Generic;3
using System.ComponentModel;4
using System.Data;5
using System.Drawing;6
using System.Linq;7
using System.Text;8
using System.Windows.Forms;9
using Maticsoft.DBUtility;10
using IClass;11
using FBBLL;12
using System.Workflow.Activities;13
using System.Workflow.Runtime;14
using System.Workflow.Runtime.Hosting;15
using System.Workflow.Runtime.Tracking;16

17
namespace User18


{19
public partial class UserMain : Form,IClass.InterFaces20

{21

#region 22
WorkflowRuntime wr = new WorkflowRuntime();23
WorkflowInstance wfi;24
ExternalDataExchangeService edes = new ExternalDataExchangeService();25
BLHuaTi blht = new BLHuaTi();26
BLHTHuiFu blhthf = new BLHTHuiFu();27
HuaTi hhh;28
public UserMain()29

{30
InitializeComponent();31
wr.AddService(edes);32
edes.AddService(this);33
WorkflowPersistenceService persistenceService =34
new SqlWorkflowPersistenceService(35
"Initial Catalog=SqlPersistenceService;Data Source=192.168.1.5;uid=sa;pwd=sa");36
wr.AddService(persistenceService);37
//wr.AddService(new SqlTrackingService("Initial Catalog=Tracking;Data Source=192.168.1.5;uid=sa;pwd=sa"));38
wr.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(wr_WorkflowCompleted);39
wr.WorkflowIdled += new EventHandler<WorkflowEventArgs>(wr_WorkflowIdled);40
wr.StartRuntime();41

42
this.Height = 343;43
List<HuaTi> lht = new List<HuaTi>();44
lht = blht.GetModelList("");45
for (int i = 0; i < lht.Count; i++)46

{47
if (lht[i].State1==0)48

{49
object[] obj = new object[2];50
obj[0] = lht[i].HTID1;51
obj[1] = lht[i].HTName1;52
dgv1.Rows.Add(obj);53
} 54
}55
}56

57
void wr_WorkflowIdled(object sender, WorkflowEventArgs e)58

{59
e.WorkflowInstance.TryUnload();60
}61

62
void wr_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)63

{64
MessageBox.Show("此次投票已经完成");65
}66

67
private void dgv1_CellContentClick(object sender, DataGridViewCellEventArgs e)68

{69
if (e.RowIndex<0)70

{71
return;72
}73
else74

{75
76
this.Height = 732 - 46;77
groupBox1.Location = new Point(groupBox1.Location.X, 265);78
hhh=blht.GetModel(Convert.ToInt32(dgv1.Rows[e.RowIndex].Cells[0].Value.ToString()));79
labHTName.Text = hhh.HTID1.ToString();80
txtHuTiNeiRong.Text = hhh.HTNeiRong1;81
}82
}83

84
private void button1_Click(object sender, EventArgs e)85

{86
Application.Exit();87
}88
#endregion89
private void button2_Click(object sender, EventArgs e)90

{91
IClass.Master mm = new IClass.Master();92
List<IClass.Master> lm = new List<IClass.Master>();93
FBBLL.Master blm = new FBBLL.Master();94
lm = blm.GetModelList(" flage="+hhh.HTID1);95
mm = lm[0];96
wfi = wr.GetWorkflow(new Guid(mm.Id));97
98
HTHuiFu hthf = new HTHuiFu();99
if (cbx1.Checked)100

{101
hthf.FBRenName1 = "匿名";102
}103
else104

{105
hthf.FBRenName1 = txtName.Text.ToString();106
}107
hthf.HTId1 = hhh.HTID1;108
hthf.FanKuiNeiRong1 = textBox1.Text.ToString();109
blhthf.Add(hthf);110
eve1(null, new pargme(new Guid(mm.Id), hhh.HTID1,false));111

112
}113

114
private void button3_Click(object sender, EventArgs e)115

{116
Application.Exit();117
}118

119
private void cbx1_CheckedChanged(object sender, EventArgs e)120

{121
if (cbx1.Checked)122

{123
txtName.Text = "";124
txtName.ReadOnly = true;125
}126
else127

{128
txtName.Text = "";129
txtName.ReadOnly = false;130
}131
}132

133

InterFaces 成员#region InterFaces 成员134

135
public event EventHandler<ExternalDataEventArgs> eve1;136

137
public void callroupiao(object flage)138

{139
HuaTi h = hhh;140
h.HTID1 = Convert.ToInt32(flage);141
h.State1 = 1;142
FBBLL.BLHuaTi blht = new BLHuaTi();143
blht.Update(h);144
}145

146
#endregion147
}148
149
}150

基于WF的意见征集1(浅析)
基于WF的意见征集2(浅析)
基于WF的意见征集3(浅析)
基于WF的意见征集4(浅析)
基于WF的意见征集6(浅析)
基于WF的意见征集7(浅析)
浙公网安备 33010602011771号