📄 finishflow.cs
字号:
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>
/// FinishFlow 的摘要说明。
/// </summary>
public class FinishFlow : System.Windows.Forms.Form
{
private SqlConnection conn=null;
private int nextseq=0;
private int projectid=0;
private System.Windows.Forms.GroupBox groupBox1;
public System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn3;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn4;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn5;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public FinishFlow()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
setUserMustDo();
//
// 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.groupBox1 = new System.Windows.Forms.GroupBox();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.dataGrid1);
this.groupBox1.Location = new System.Drawing.Point(8, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(768, 320);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "当前您需要处理的流程";
//
// dataGrid1
//
this.dataGrid1.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText;
this.dataGrid1.CaptionVisible = false;
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 16);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(752, 296);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
this.dataGrid1.CurrentCellChanged += new System.EventHandler(this.dataGrid1_CurrentCellChanged);
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
this.dataGridTextBoxColumn1,
this.dataGridTextBoxColumn2,
this.dataGridTextBoxColumn5,
this.dataGridTextBoxColumn3,
this.dataGridTextBoxColumn4});
this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "mustdo";
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "流程编号";
this.dataGridTextBoxColumn1.MappingName = "autoid";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// dataGridTextBoxColumn2
//
this.dataGridTextBoxColumn2.Format = "";
this.dataGridTextBoxColumn2.FormatInfo = null;
this.dataGridTextBoxColumn2.HeaderText = "流程名称";
this.dataGridTextBoxColumn2.MappingName = "title";
this.dataGridTextBoxColumn2.ReadOnly = true;
this.dataGridTextBoxColumn2.Width = 200;
//
// dataGridTextBoxColumn5
//
this.dataGridTextBoxColumn5.Format = "";
this.dataGridTextBoxColumn5.FormatInfo = null;
this.dataGridTextBoxColumn5.HeaderText = "需处理步骤";
this.dataGridTextBoxColumn5.MappingName = "name";
this.dataGridTextBoxColumn5.Width = 150;
//
// dataGridTextBoxColumn3
//
this.dataGridTextBoxColumn3.Format = "";
this.dataGridTextBoxColumn3.FormatInfo = null;
this.dataGridTextBoxColumn3.HeaderText = "开始日期";
this.dataGridTextBoxColumn3.MappingName = "begindate";
this.dataGridTextBoxColumn3.Width = 75;
//
// dataGridTextBoxColumn4
//
this.dataGridTextBoxColumn4.Format = "";
this.dataGridTextBoxColumn4.FormatInfo = null;
this.dataGridTextBoxColumn4.HeaderText = "结束日期";
this.dataGridTextBoxColumn4.MappingName = "enddate";
this.dataGridTextBoxColumn4.Width = 75;
//
// FinishFlow
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.AliceBlue;
this.ClientSize = new System.Drawing.Size(784, 325);
this.Controls.Add(this.groupBox1);
this.Name = "FinishFlow";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "当前待处理流程";
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
public void setUserMustDo()
{
try
{
conn=MainForm.getConnection();
string select=" select distinct t_flow.autoid,t_flow.title,t_flowstepmodeldef.NAME, t_flow.begindate,t_flow.enddate from t_flow,t_flowstep,t_flowstepmodeldef "+
" where t_flow.AUTOID=t_flowstep.PROJECTID "+
" and t_flowstep.STATUS=0 "+
" and t_flow.STATUS=0 "+
" and t_flow.FLOWID=t_flowstepmodeldef.FLOWID "+
" and t_flowstep.SEQ=t_flowstepmodeldef.SEQ "+
" and t_flowstep.OPERATORID="+MainForm.getUserAutoID();
//从数据库取出当前登录用户需要处理的全部流程,显示在dataGrid1中
DataSet ds=new System.Data.DataSet();
Database.Fill(ds,"mustdo",conn,select);
this.dataGrid1.SetDataBinding(ds,"mustdo");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return;
}
}
public SqlConnection getConnection()
{
try
{
if(conn==null)
conn = MainForm.getConnection();
return conn;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return null;
}
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
// if(this.toolBarButton1)
// {
// CreatProject cp=new CreatProject();
// cp.ShowDialog();
// }
}
// private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
// {
// //if(!this.treeView1.SelectedNode.Text.StartsWith("项目"))
// {
// try
// {
//
// //string name=this.treeView1.SelectedNode.Parent.Text;
// name=name.Substring(4,name.Length-4);
// 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.title= '"+name+"'";
// // " and t_flowstepmodeldef.NAME='"+this.treeView1.SelectedNode.Text+"'";
// Console.WriteLine(select);
//
// this.label3.Text="";
// this.label4.Text="";
// this.textBox1.Text="";
//
//
// using(SqlCommand cmd = conn.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.GetDateTime(2).ToString();
// int operid=reader.GetInt32(3);
// string modifydate=reader.GetDateTime(4).ToString();
// int seq=reader.GetInt32(5);
// string content=reader.GetString(6);
// int status=reader.GetInt32(7);
//
// this.nextseq=seq+1;//下一步操作
//
// this.label3.Text="本项目从【"+begindate+"】到【"+enddate+"】为止";
// string label4text="本步骤是该项目第【"+seq+"】步";
// if(status==0)
// {
// label4text+=",本步骤应该由【"+this.getRealName(operid)+"】完成,目前尚未完成。";
// }
// else
// {
// label4text+=",本步骤由【"+this.getRealName(operid)+"】在【"+modifydate+"】完成。";
// }
// this.label4.Text=label4text;
// this.textBox1.Text=content;
//
//// if(status==1||operid!=MainForm.getUserAutoID())
//// this.button1.Enabled=false;
//// Hashtable hs=this.getNextOper(isneedrelation);
////
//// if(hs!=null)
//// {
//// foreach(string key in hs.Keys)
//// {
//// object item=(object)key;
//// this.comboBox3.Items.Add(item);
//// }
//// }
//
//
//
//
//
// }
//
// }
// }
// }
// catch(Exception ex)
// {
// MessageBox.Show(ex.ToString());
// return;
// }
//
//
// }
// }
public string getRealName(int autoid)
{
try
{
string select = "select name from t_user where autoid="+autoid;
Console.WriteLine(select);
conn=MainForm.getConnection();
using(SqlCommand cmd = conn.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;
}
}
public Hashtable getNextOper(int isneedrelate)
{
try
{
Hashtable hs=new Hashtable();
if(isneedrelate==1)
{
return null;
}
else
{
string select = "select OPERATORID from t_flowstep where projectid="+this.projectid +" and seq="+this.nextseq;
Console.WriteLine(select);
conn=MainForm.getConnection();
using(SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = select;
using(SqlDataReader reader = cmd.ExecuteReader())
{
if(reader.Read())
{
if(reader.GetInt32(0)!=0)
{
hs.Add(this.getRealName(reader.GetInt32(0)),"s");
return hs;
}
}
}
}
select="select userid from t_flowstepmodeldef,t_flow,t_flowstep where t_flowstep.projectid=t_flow.autoid "+
" and t_flow.flowid=t_flowstepmodeldef.flowid "+
" and t_flow.autoid="+this.projectid+
" and t_flowstepmodeldef.seq="+this.nextseq;
Console.WriteLine(select);
conn=MainForm.getConnection();
using(SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = select;
using(SqlDataReader reader = cmd.ExecuteReader())
{
if(reader.Read())
{
string opuser=reader.GetString(0);
if(opuser!=null)
{
string []users=opuser.Split(',');
foreach(string user in users)
{
if(user!=null&&!user.Equals(""))
hs.Add(this.getRealName(int.Parse(user)),"s");
}
}
}
return hs;
}
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return null;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
StartFlow cp=new StartFlow();
cp.ShowDialog();
}
private void button3_Click(object sender, System.EventArgs e)
{
QueryFlow qf=new QueryFlow();
qf.ShowDialog();
}
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
int projectid=int.Parse(this.dataGrid1[this.dataGrid1.CurrentCell.RowNumber,0].ToString());
string flowname=this.dataGrid1[this.dataGrid1.CurrentCell.RowNumber,1].ToString();
FlowStepFinish fs=new FlowStepFinish(projectid,flowname,this);
fs.ShowDialog();
}
private void button1_Click(object sender, System.EventArgs e)
{
this.dataGrid1.DataBindings.Clear();
this.setUserMustDo();
}
private void button1_Click_1(object sender, System.EventArgs e)
{
button1_Click(sender,e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -