using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
public partial class WorkOrder_ShowSkipRule : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//绑定数据
ViewState["CaseID"] = "0702091001";
BindFlowImage();
/*
if(Request.QueryString["CaseID"] != null)
{
ViewState["CaseID"] = Request.QueryString["CaseID"].ToString();
BindFlowImage();
}
* */
}
}
#region 绑定流程图
///
/// 绑定流程图
///
public void BindFlowImage()
{
DataTable dt = Base.BLL.WorkOrder.WorkOrder.GetWorkOrderBaseCaseID(ViewState["CaseID"].ToString());
Table tt = new Table();
tt.BorderWidth = 0;
tt.CellPadding = 0;
tt.CellSpacing = 0;
tt.Width = Unit.Percentage(100);
if (dt.Rows.Count > 0)
{
//添加标题栏
AddRow(tt, dt.Rows[0]["Case_ID"].ToString(), Color.Empty);
AddRow(tt, " ", Color.Empty);
for (int i = 0; i < dt.Rows.Count; i++)
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
Table Taborder = new Table();
TableRow trOrder = new TableRow();
TableCell tdOrder = new TableCell();
//Taborder.BorderWidth = 0;
//Taborder.CellPadding = 0;
//Taborder.CellSpacing = 0;
//Taborder.Width = Unit.Percentage(100);
tdOrder.HorizontalAlign = HorizontalAlign.Center;
tdOrder.VerticalAlign = VerticalAlign.Top;
//添加工单标题
AddRow(tt, "工单编号:" + dt.Rows[i]["WorkOrder_ID"].ToString(), Color.Empty);
//根据每个工单设计流程图
AddContentTable(tdOrder, dt.Rows[i]["CreatedBy"].ToString());
Label lblSpan = new Label();
lblSpan.Text = "↓";
tdOrder.Controls.Add(lblSpan);
AddStep(tdOrder, Convert.ToInt32(dt.Rows[i]["WorkOrder_ID"]), dt.Rows[i]["CreatedBy"].ToString());
trOrder.Cells.Add(tdOrder);
Taborder.Rows.Add(trOrder);
tc.Controls.Add(Taborder);
tr.Cells.Add(tdOrder);
tt.Rows.Add(tr);
//AddRow(tt, "∨", Color.Empty);
//AddRow(tt, " ", Color.Empty);
}
//AddRow(tt, "流程结束", Color.Empty);
}
FlowPlaceHolder.Controls.Add(tt);
}
#endregion
#region 添加行标头信息
///
/// 添加行标头信息
///
///
///
///
void AddRow(Table tab, string Label, Color BackColor)
{
TableRow tr = new TableRow();
TableCell td = new TableCell();
td.Text = Label;
td.HorizontalAlign = HorizontalAlign.Center;
td.BackColor = BackColor;
tr.Cells.Add(td);
tab.Rows.Add(tr);
}
#endregion
#region 添加底线
///
/// 添加底线
///
///
///
private void AddLineRow(TableCell cellObj,LinePostion PosLine)
{
Table lineTab = new Table();
TableRow lineTr = new TableRow();
TableCell lineTd1 = new TableCell();
TableCell lineTd2 = new TableCell();
lineTab.BorderWidth = 0;
lineTab.CellPadding = 0;
lineTab.CellSpacing = 0;
lineTab.Width = Unit.Percentage(100);
lineTab.Height = 1;
if (PosLine == LinePostion.All)
{
lineTd1.BackColor = Color.FromArgb(0, 0, 0);
lineTd1.Width = Unit.Percentage(50);
lineTd2.BackColor = Color.FromArgb(0, 0, 0);
lineTd2.Width = Unit.Percentage(50);
}
else if (PosLine == LinePostion.Left)
{
lineTd1.BackColor = Color.FromArgb(0, 0, 0);
lineTd1.Width = Unit.Percentage(50);
lineTd2.Width = Unit.Percentage(50);
}
else
{
lineTd1.Width = Unit.Percentage(50);
lineTd2.BackColor = Color.FromArgb(0, 0, 0);
lineTd2.Width = Unit.Percentage(50);
}
lineTr.Cells.Add(lineTd1);
lineTr.Cells.Add(lineTd2);
lineTab.Rows.Add(lineTr);
cellObj.Controls.Add(lineTab); //添加内容到表格中
}
#endregion
#region 添加内容Table
///
/// 添加内容列
///
///
private void AddContentTable(TableCell cellObj,string Content)
{
/*
*
如若然 |
contentTr.Cells.Add(contentTd);
contentTab.Rows.Add(contentTr);
cellObj.Controls.Add(contentTab); //添加到列中
}
#endregion
#region 添加步骤信息
///
/// 添加步骤信息
///
///
///
///
void AddStep(TableCell ParentTDObj,int WorkOrder_ID, string CreatedBy)
{
Table tabObj = new Table();
tabObj.BorderWidth = 0;
tabObj.CellSpacing = 0;
tabObj.CellPadding = 0;
tabObj.Width = Unit.Percentage(100);
TableRow tr = new TableRow();
DataView tmpDV = CreateDataView(WorkOrder_ID);
tmpDV.RowFilter = "CreatedBy='" + CreatedBy + "' and HandleBy_ID<>'" + CreatedBy+"'";
int childCount = 0;
foreach (DataRowView drvItem in tmpDV)
{
try
{
TableCell cellObj = new TableCell();
cellObj.VerticalAlign = VerticalAlign.Top;
cellObj.HorizontalAlign = HorizontalAlign.Center;
if (tmpDV.Count >= 2) //个数大于2时,如果只有一条记录不需要底线
{
if (childCount == 0)
{
//表示左边有底线
AddLineRow(cellObj, LinePostion.Right);
}
else if (childCount == tmpDV.Count - 1)
{
//表示右边有底线
AddLineRow(cellObj, LinePostion.Left);
}
else
{
//两都都有底线
AddLineRow(cellObj, LinePostion.All);
}
}
Label lblSpan = new Label();
lblSpan.Text = "↓";
cellObj.Controls.Add(lblSpan);
AddContentTable(cellObj,drvItem["HandleBy_ID"].ToString());
tr.Cells.Add(cellObj);
tabObj.Rows.Add(tr);
childCount++;
AddStep(cellObj,WorkOrder_ID,drvItem["HandleBy_ID"].ToString()); //继续递归调用
}
catch { }
}
ParentTDObj.Controls.Add(tabObj);
tabObj = null;
}
#endregion
#region 获取数据
///
/// 获取数据
///
///
private DataView CreateDataView(int WorkOrder_ID)
{
DataView daView = Base.BLL.WorkOrder.WorkOrder_StepPath.GetStepPathBaseOrderID(WorkOrder_ID).DefaultView;
return daView;
}
#endregion
}
#region 枚举位置变量
///
/// 枚举位置变量
///
public enum LinePostion
{
///
/// 左边
///
Left,
///
/// 右边
///
Right,
///
/// 两边都有
///
All
}
#endregion
效果图如下:
|