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

📄 queryflow.cs

📁 工作流引擎
💻 CS
📖 第 1 页 / 共 2 页
字号:
		#endregion

		private void setProjectStep()
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
			
				string select = " select autoid, userid, name, depid, depcode from t_user where status = 1";
				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
						while(reader.Read())
						{
						
						}
					}
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return;
			}
			finally
			{
				sconn.Close();
			}
		}

		private void groupBox3_Enter(object sender, System.EventArgs e)
		{
		
		}

		private void FlowStepFinished_Load(object sender, System.EventArgs e)
		{
//			try
//			{
//				if(conn==null)
//					conn = MainForm.getConnection();
//
//				
//			}
//			catch(Exception ex)
//			{
//				MessageBox.Show(ex.ToString());
//				return;
//			}
		}

		private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
							
				string select = " select distinct title from t_flow,t_flowstep "+
					"where t_flow.AUTOID=t_flowstep.PROJECTID "+
					"and t_flow.STATUS="+this.comboBox1.SelectedIndex+
					" and t_flowstep.OPERATORID="+MainForm.getUserAutoID();
				Console.WriteLine(select);
				this.comboBox2.Items.Clear();
				this.listBox1.Items.Clear();
				this.comboBox2.Items.Add("请选择");
				this.comboBox2.SelectedIndex=0;
				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
						while(reader.Read())
						{
							object item=reader.GetString(0);
							this.comboBox2.Items.Add(item);
						}
						
					}
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return;
			}
			finally
			{
				sconn.Close();
			}
		}

		private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
							
				string select = " select distinct t_flowstepmodeldef.name,t_flowstepmodeldef.seq,t_flow.autoid from t_flowstepmodeldef,t_flow where t_flow.flowid=t_flowstepmodeldef.flowid "+
					" and t_flow.title='"+this.comboBox2.SelectedItem.ToString()+"' order by t_flowstepmodeldef.seq";
				Console.WriteLine(select);
				this.listBox1.Items.Clear();
				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
						while(reader.Read())
						{
							object item=reader.GetString(0);
							int step=reader.GetInt32(1);
							int cansee=this.getMaxStepUserCanSeee();							
							this.projectid=reader.GetInt32(2);
							this.listBox1.Items.Add(item);
							if(step==cansee)
								break;
						}
						
					}
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return;
			}
			finally
			{
				sconn.Close();
			}
		}

		private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
							
				string select =  "select t_flowstepmodeldef.NEEDRELATE,t_flow.BEGINDATE,t_flow.ENDDATE,t_flowstep.OPERATORID,t_flowstep.MODIFYDATE,t_flowstep.SEQ,t_flowstep.content,t_flowstep.status "+
					" 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+
					" and t_flowstepmodeldef.NAME='"+this.listBox1.SelectedItem.ToString()+"'";
				Console.WriteLine(select);
				//
				//                this.label3.Text="";
				//				this.label4.Text="";
				this.textBox1.Text="";
				
				

				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
						if(reader.Read())
						{
							int isneedrelation=reader.GetInt32(0);
							string begindate=reader.GetDateTime(1).ToString();
							string enddate=reader.IsDBNull(2)?"":reader.GetDateTime(2).ToString();
							int operid=reader.IsDBNull(3)?0:reader.GetInt32(3);
							string modifydate=reader.IsDBNull(4)?"":reader.GetDateTime(4).ToString();
							int seq=reader.GetInt32(5);
							string content=reader.IsDBNull(6)?"待完成":reader.GetString(6);
							int status=reader.GetInt32(7);

							this.nextseq=seq+1;//下一步操作

							this.textBox2.Text=this.getRealName(operid);
							this.textBox3.Text=modifydate;
							this.textBox1.Text=content;
							
						}
						
					}
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return;
			}
			finally
			{
				sconn.Close();
			}
		}
		public string getRealName(int autoid)
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
							
				string select =  "select name from t_user where autoid="+autoid;
				Console.WriteLine(select);
				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
						if(reader.Read())
						{
							return reader.GetString(0);							
						}
						
					}
				}
				return null;
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return null;
			}
			finally
			{
				sconn.Close();
			}
		}
		private int getMaxStepUserCanSeee()
		{
			SqlConnection sconn=MainForm.getConnection();
			try
			{
							
				string select = " select distinct t_flowstepmodeldef.seq "+
					" from t_flowstepmodeldef,t_flow,t_flowstep "+
					" where t_flow.flowid=t_flowstepmodeldef.flowid  "+
					" and t_flow.AUTOID=t_flowstep.PROJECTID "+
					" and t_flowstep.OPERATORID="+MainForm.getUserAutoID()+
					" and t_flowstepmodeldef.SEQ=t_flowstep.SEQ "+
					" and t_flow.title='"+this.comboBox2.SelectedItem.ToString()+"' order by t_flowstepmodeldef.seq ";
				Console.WriteLine(select);
				using(SqlCommand cmd = sconn.CreateCommand())
				{
					cmd.CommandText = select;
					using(SqlDataReader reader = cmd.ExecuteReader())
					{
							int maxstep=0;
						while(reader.Read())
						{    
							maxstep=reader.GetInt32(0);
							if(maxstep==1)
								return 999;
							
						}
						return maxstep;
						
					}
				}
				return 0;
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return 0;
			}
			finally
			{
				sconn.Close();
			}
		}
	}
}

⌨️ 快捷键说明

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