巨石化纤
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.2 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Data;
using SSWMS.Common;
namespace SSWMS.Client.UC
{
public partial class ucStatusFlowActionsPanel : UserControl
{
public ucStatusFlowActionsPanel()
{
InitializeComponent();
}
public delegate void DelegateExecuteUpdate();
public event DelegateExecuteUpdate U_ExecuteUpdate;
public string U_FLOW_TYPE = string.Empty;
public string U_FLOW_ID = string.Empty;
public void U_InitControl()
{
try
{
this.pActions.Children.Clear();
string strSQL = string.Empty;
switch (this.U_FLOW_TYPE)
{
case "FLOW_MANAGE":
strSQL = string.Format("select FLOW_ID,FLOW_NAME,FLOW_EVENT from V_FLOW_MANAGE"
+ " where MANAGE_ID={0} order by FLOW_ORDER", this.U_FLOW_ID);
break;
case "FLOW_PLAN":
strSQL = string.Format("select FLOW_ID,FLOW_NAME,FLOW_EVENT from V_FLOW_PLAN"
+ " where PLAN_ID={0} order by FLOW_ORDER", this.U_FLOW_ID);
break;
}
DataTable dt = WCFChannel._I_BaseService.GetDataTable(strSQL);
if (dt == null)
{
return;
}
IList<SYS_RELATION> lRelation = WCFChannel._I_SystemService.GetUserRelation(
SystemCode.RELATION_TYPE.Flow, MainApp._USER.USER_ID);
foreach (DataRow dr in dt.Rows)
{
if (MainApp._USER.USER_ID == 0 || MainApp._USER.USER_ID == 1 ||
lRelation.Count(r => r.RELATION_ID2 == Convert.ToInt32(dr["FLOW_ID"])) > 0)
{
this.pActions.Children.Add(new Button
{
Width = 90,
Margin = new Thickness(5, 5, 5, 5),
Padding = new Thickness(5, 0, 5, 0),
Content = dr["FLOW_NAME"].ToString(),
Tag = dr["FLOW_EVENT"].ToString()
});
}
}
}
catch (Exception ex)
{
MessageDialog.ShowException(ex.Message);
}
}
public void U_Clear()
{
this.pActions.Children.Clear();
}
private void pActions_Click(object sender, RoutedEventArgs e)
{
try
{
Button bAction = e.OriginalSource as Button;
if (bAction == null)
{
return;
}
string sTag = bAction.Tag.ToString();
if (sTag == "PLAN_EDIT" || sTag == "PLAN_IN_STATION" ||
sTag == "PLAN_OUT_CELL" || sTag == "PLAN_OUT_STATION" ||
sTag == "PLAN_OUT_AUTO" || sTag == "PLAN_EXECUTING" || sTag == "PLAN_PAUSE" ||
MessageDialog.ShowDialog(string.Format("确认执行{0}操作", bAction.Content.ToString())))
{
string sResult = string.Empty;
bool bResult = DynamicCode.DicDynamicFlow[bAction.Tag.ToString()](Convert.ToInt32(U_FLOW_ID), out sResult);
if (!(sTag == "PLAN_EDIT" || sTag == "PLAN_IN_STATION" ||
sTag == "PLAN_OUT_CELL" || sTag == "PLAN_OUT_STATION"))
{
if (bResult && U_ExecuteUpdate != null)
{
U_ExecuteUpdate();
}
if (!(sTag == "PLAN_OUT_AUTO" || sTag == "PLAN_EXECUTING" || sTag == "PLAN_PAUSE"))
{
MessageDialog.ShowResult(bResult, sResult);
}
}
}
}
catch (Exception ex)
{
MessageDialog.ShowException(ex);
}
}
}
}