📄 endflow.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>
/// CloseFlow 的摘要说明。
/// </summary>
public class EndFlow : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private SqlConnection conn=null;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public EndFlow()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.getConnection();
setCloseFlow();
//
// 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.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 16);
this.label1.TabIndex = 0;
this.label1.Text = "请选择流程";
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(112, 24);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(144, 20);
this.comboBox1.TabIndex = 1;
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Location = new System.Drawing.Point(48, 56);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 23);
this.button1.TabIndex = 2;
this.button1.Text = "终止该流程";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.Location = new System.Drawing.Point(144, 56);
this.button2.Name = "button2";
this.button2.TabIndex = 3;
this.button2.Text = "关闭窗口";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// CloseFlow
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.AliceBlue;
this.ClientSize = new System.Drawing.Size(292, 93);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Name = "CloseFlow";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "终止流程";
this.ResumeLayout(false);
}
#endregion
public void setCloseFlow()
{
try
{
string select = "select distinct t_flow.title from t_flow,t_flowstep where t_flow.autoid=t_flowstep.projectid and t_flowstep.operatorid="+MainForm.getUserAutoID()+" and t_flow.status=0";
Console.WriteLine(select);
using(SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = select;
using(SqlDataReader reader = cmd.ExecuteReader())
{
while(reader.Read())
{
this.comboBox1.Items.Add(reader.GetString(0));
}
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
public SqlConnection getConnection()
{
try
{
if(conn==null)
conn = MainForm.getConnection();
return conn;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return null;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
string sql="update t_flow set status=2 where title='"+this.comboBox1.SelectedItem.ToString()+"'";
Console.WriteLine(sql);
using(SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
MessageBox.Show("终止流程成功");
this.comboBox1.Items.Clear();
this.setCloseFlow();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -