using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Data; using System.Net; using System.Net.Sockets; namespace SiaSun.LMS.WPFClient.FLOW_ACTION { /// /// FLOW_ACTION.xaml 的交互逻辑 /// public partial class PLAN_ACTION : AvalonDock.DocumentContent { string strExceptPlanStatus = string.Empty; private IList _lsFLOW_PARA; private string[] _aFLOW_PARA; private string str_IP = string.Empty; /// /// 构造函数 /// public PLAN_ACTION() { InitializeComponent(); string name = Dns.GetHostName(); IPAddress[] ipadrlist = Dns.GetHostAddresses(name); foreach (IPAddress ipa in ipadrlist) { if (ipa.AddressFamily == AddressFamily.InterNetwork) { //if (ipa.ToString().StartsWith("192.168.0")) //{ str_IP = ipa.ToString(); // } } } this.ucQueryPlan.U_Query += new UC.ucQuickQuery.U_QueryEventHandler ((QueryWhere) => { try { this.gridPlan.U_AppendWhere = QueryWhere; this.gridPlan.U_InitControl(); this.PLAN_Bind(); this.SelectPlanDefault(); } catch (Exception ex) { MainApp._MessageDialog.ShowException(ex); } } ); this.ucFlowPlanAction.U_ExecuteUpdate += new UC.ucStatusFlowActionsPanel.ExecuteUpdateEventHandler (() => { try { this.gridPlan.U_AppendWhere = this.ucQueryPlan.U_GetQuery(); this.gridPlan.U_InitControl(); this.PLAN_Bind(); this.SelectPlanDefault(); } catch (Exception ex) { MainApp._MessageDialog.ShowException(ex); } } ); } /// /// 构造函数 /// public PLAN_ACTION(string EXCEPT_STATUS) : this() { strExceptPlanStatus = EXCEPT_STATUS; } /// /// 加载窗体 /// private void DocumentContent_Loaded(object sender, RoutedEventArgs e) { this._lsFLOW_PARA = MainApp._I_FlowService.FlowGetParameters("FLOW_PLAN"); this._aFLOW_PARA = new string[this._lsFLOW_PARA.Count]; this.PLAN_Query_Bind(); this.PLAN_Bind(); this.gridPlan.gridApp.GotFocus += new RoutedEventHandler(gridApp_GotFocus); } void gridApp_GotFocus(object sender, RoutedEventArgs e) { this.gridPlan.gridApp.SelectionChanged -= new SelectionChangedEventHandler(gridApp_SelectionChanged); this.gridPlan.gridApp.SelectionChanged += new SelectionChangedEventHandler(gridApp_SelectionChanged); } /// /// /// void gridApp_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.gridPlan.gridApp.SelectedItem == null) { this.gridPlanList.U_DataSource = null; return; } DataRowView drvPlan = this.gridPlan.gridApp.SelectedItem as DataRowView; int intPlanID = drvPlan == null ? 0 : Convert.ToInt32(drvPlan["PLAN_ID"].ToString()); this.PLAN_LIST_Bind(intPlanID); this.PLAN_ACTION_Bind(drvPlan.Row); this.gridPlan.gridApp.SelectionChanged -= new SelectionChangedEventHandler(gridApp_SelectionChanged); } /// /// /// private void PLAN_Query_Bind() { try { this.ucQueryPlan.U_XmlTableName = "V_PLAN"; this.ucQueryPlan.U_WindowName = this.GetType().Name; this.ucQueryPlan.U_InitControl(); } catch (Exception ex) { MainApp._MessageDialog.ShowException(ex); } } //查询 void ucQueryPlan_U_Query(string QueryWhere) { } /// /// /// private void PLAN_Bind() { try { int index = this.gridPlan.gridApp.SelectedIndex; //设置数据源 this.gridPlan.U_WindowName = this.GetType().Name; this.gridPlan.U_TableName = "V_PLAN"; this.gridPlan.U_OrderField = "PLAN_ID"; //设置筛选条件 //this.gridPlan.U_Where = strExceptPlanStatus.Length > 0 ? string.Format("PLAN_STATUS NOT IN('" + strExceptPlanStatus.Replace("|", "','") + "') {0}",MainApp._USER.USER_NAME == "super"?"":string.Format("AND PLAN_CREATER ='{0}'",MainApp._USER.USER_NAME)) : string.Empty; this.gridPlan.U_Where = strExceptPlanStatus.Length > 0 ? string.Format("PLAN_STATUS NOT IN('" + strExceptPlanStatus.Replace("|", "','") + "')") : string.Empty; this.gridPlan.U_AllowChecked = false; this.gridPlan.U_AllowOperatData = false; this.gridPlan.U_AllowPage = true; //初始化控件 this.gridPlan.U_InitControl(); //加载默认数据 this.SelectPlanDefault(); if (this.gridPlan.gridApp.Items.Count > index) { //this.gridPlan.gridApp.SelectedIndex = index; } } catch (Exception ex) { MainApp._MessageDialog.ShowException(ex); } } /// /// 加载默认数据 /// private void SelectPlanDefault() { if (this.gridPlan.gridApp.SelectedItem != null) { DataRowView drvPlan = this.gridPlan.gridApp.SelectedItem as DataRowView; int intPlanID = drvPlan == null ? 0 : Convert.ToInt32(drvPlan["PLAN_ID"].ToString()); //加载计划清单 this.PLAN_LIST_Bind(intPlanID); //流程行为按钮绑定 this.PLAN_ACTION_Bind(drvPlan.Row); } } /// /// 加载 /// private void PLAN_LIST_Bind(int PLAN_ID) { //数据源属性 this.gridPlanList.U_Clear(); this.gridPlanList.U_WindowName = this.GetType().Name; this.gridPlanList.U_TableName = "V_PLAN_LIST"; this.gridPlanList.U_XmlTableName = "V_PLAN_LIST"; this.gridPlanList.U_Fields = "*"; this.gridPlanList.U_Where = string.Format("PLAN_ID ={0}", PLAN_ID); this.gridPlanList.U_OrderField = "PLAN_LIST_ID"; this.gridPlanList.U_AllowChecked = false; this.gridPlanList.U_AllowOperatData = false; this.gridPlanList.U_AllowShowPage = false; //拆分列属性 this.gridPlanList.U_SplitPropertyType = "GOODS_TYPE"; this.gridPlanList.U_SplitGroupColumn = "GOODS_TYPE_ID"; this.gridPlanList.U_SplitPropertyColumn = "GOODS_PROPERTY"; this.gridPlanList.U_SplitGroupHeader = "GOODS_TYPE.GOODS_TYPE_NAME"; //明细属性 //this.gridPlanList.U_DetailTableName = "PLAN_DETAIL"; //this.gridPlanList.U_DetailRelatvieColumn = "PLAN_LIST_ID"; try { //初始化控件 this.gridPlanList.U_InitControl(); } catch (Exception ex) { MainApp._MessageDialog.ShowException(ex); } } /// /// 状态流按钮加载 /// private void PLAN_ACTION_Bind(DataRow rowPlan) { //初始化控件 this.ucFlowPlanAction.U_FLOW_TYPE = "FLOW_PLAN"; this.ucFlowPlanAction.U_FLOW_SOURCE_ROW = rowPlan; this.ucFlowPlanAction.U_DataSource = MainApp._I_FlowService.PlanGetAction(rowPlan["PLAN_ID"].ToString()); this.ucFlowPlanAction.U_InitControl(); } } }