⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flowstepfinish.cs

📁 工作流引擎
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using WorkFlow.user;
using WorkFlow.util;

namespace WorkFlow.flow
{
	/// <summary>
	/// FlowStepFinish 的摘要说明。
	/// </summary>
	public class FlowStepFinish : System.Windows.Forms.Form
	{
		private System.Windows.Forms.RichTextBox richTextBox1;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.Button button1;
		private int projectid=1;
		private int nextseq=0;
		private string nextstepname="";
		private string currentname="";
		private int nextoper=0;
		private SqlConnection  conn=null;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private FinishFlow ff=null;
		private string flowname="";
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public FlowStepFinish(int projectid,string flowname,FinishFlow ff)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			this.projectid=projectid;
			this.ff=ff;
            this.flowname=flowname;

			setFinishedStep();
			this.textBox1.Focus();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.richTextBox1 = new System.Windows.Forms.RichTextBox();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.button1 = new System.Windows.Forms.Button();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// richTextBox1
			// 
			this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.richTextBox1.BackColor = System.Drawing.SystemColors.InactiveBorder;
			this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.richTextBox1.Location = new System.Drawing.Point(8, 32);
			this.richTextBox1.Name = "richTextBox1";
			this.richTextBox1.ReadOnly = true;
			this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedHorizontal;
			this.richTextBox1.Size = new System.Drawing.Size(528, 232);
			this.richTextBox1.TabIndex = 0;
			this.richTextBox1.Text = "";
			// 
			// textBox1
			// 
			this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.textBox1.Location = new System.Drawing.Point(8, 304);
			this.textBox1.Multiline = true;
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(528, 168);
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(128, 16);
			this.label1.TabIndex = 2;
			this.label1.Text = "该流程已经完成步骤:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 280);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(512, 16);
			this.label2.TabIndex = 3;
			// 
			// comboBox1
			// 
			this.comboBox1.Location = new System.Drawing.Point(232, 488);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(121, 20);
			this.comboBox1.TabIndex = 4;
			this.comboBox1.Text = "请选择";
			this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
			// 
			// button1
			// 
			this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.button1.Location = new System.Drawing.Point(456, 488);
			this.button1.Name = "button1";
			this.button1.TabIndex = 5;
			this.button1.Text = "提交";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(32, 488);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(192, 24);
			this.label3.TabIndex = 6;
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(360, 488);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(64, 23);
			this.label4.TabIndex = 7;
			this.label4.Text = "完成";
			// 
			// FlowStepFinish
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.AliceBlue;
			this.ClientSize = new System.Drawing.Size(544, 517);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.richTextBox1);
			this.Name = "FlowStepFinish";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "填写流程步骤";
			this.ResumeLayout(false);

		}
		#endregion


		public int getMaxStep()
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
							
				string select =  "select max(seq) from t_flowstep where projectid="+this.projectid;
				Console.WriteLine(select);
				//conn=this.getConnection();
				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
						if(reader.Read())
						{
							return reader.GetInt32(0);							
						}
						reader.Close();
						
					}
				}
				return 0;
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return 0;
			}
			finally
			{
				sconn.Close();
			}

		}
		public string getNextRealName()
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
							
				string select =  "select distinct t_flowstepmodeldef.NAME "+
					" from t_flow,t_flowstep,t_flowstepmodeldef "+
					" where t_flow.FLOWID=t_flowstepmodeldef.FLOWID "+
					" and t_flowstep.PROJECTID=t_flow.AUTOID "+
					" and t_flowstep.seq=t_flowstepmodeldef.seq "+
					" and t_flow.AUTOID="+this.projectid +
					" and t_flowstep.SEQ="+(this.nextseq);

				Console.WriteLine(select);
				//conn=this.getConnection();
				
				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
						if(reader.Read())
						{
							return reader.GetString(0);							
						}
						reader.Close();
					}
				}
				return "";
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return "";
			}
			finally
			{
				sconn.Close();
			}
		}
		public void setFinishedStep()
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
							
				string select =  "select t_flowstep.*,t_flowstepmodeldef.NAME "+
					" from t_flowstepmodeldef,t_flow,t_flowstep "+
					" where t_flow.AUTOID=t_flowstep.PROJECTID  "+
					" and t_flow.FLOWID=t_flowstepmodeldef.FLOWID  "+ 
					" and t_flowstepmodeldef.seq=t_flowstep.seq  "+
					" and t_flow.AUTOID="+this.projectid+" order by t_flowstep.seq ";
				//从数据库取出前面已经完成的步骤和每步完成的内容
				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
						while(reader.Read())
						{
							int seq=reader.GetInt32(1);
							int operatorid=reader.IsDBNull(2)?-1:reader.GetInt32(2);
							string realname=this.getRealName(operatorid);
							string content=reader.IsDBNull(3)?"":reader.GetString(3);
							int status=reader.IsDBNull(4)?0:reader.GetInt32(4);
							string mddate=reader.IsDBNull(5)?"":reader.GetDateTime(5).ToString();
							string stepname=reader.GetString(6);						    
							if(status==1)
							{
								this.richTextBox1.AppendText("第"+seq+"步:"+stepname+"\n" );								
								this.richTextBox1.AppendText("操作者:"+realname+"\n" );
								this.richTextBox1.AppendText("填写日期:"+mddate+"\n" );
								this.richTextBox1.AppendText(content+"\n");
								this.richTextBox1.AppendText("\n");							
							}
							else
							{
								this.nextseq=seq+1;
								this.nextstepname=stepname;
								this.label2.Text="你需要完成该流程第【"+(nextseq-1)+"】步:【"+stepname+"】";
								this.currentname=stepname;
								this.label3.Text="指定下一步操作【"+getNextRealName()+"】由";
								break;
							}
							
						}
						reader.Close();
					}
				}

				Hashtable hs=this.getNextOper();
				//调用getNextOper()方法取得下步的操作者,如果有多个讲得到一个列表
				//可以从列表里面选择一个
				if(hs!=null&&hs.Keys.Count>0)
				{
					foreach(string key in hs.Keys)
					{
						object item=(object)key;
						this.comboBox1.Items.Add(item);
					}					
					this.comboBox1.SelectedIndex=0;
				}               
				if(this.getMaxStep()<this.nextseq)
				{
					this.comboBox1.Enabled=false;
				}
			
			}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -