巨石化纤
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.

114 lines
5.0 KiB

using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Data;
namespace SSWMS.Client.UC
{
public partial class ucTopParentBottomChild : UserControl
{
public ucTopParentBottomChild()
{
InitializeComponent();
}
public delegate void DelegateParentSelectedChanged(string sParentID);
public DelegateParentSelectedChanged U_ParentSelectedChanged = null;
public bool U_ParentAllowChecked = false;
public bool U_AllowOperatData = false;
public string U_WindowName = "COMMON";
public string U_ParentHeader = string.Empty;
public string U_XmlTableParent = string.Empty;
public string U_TableParent = string.Empty;
public string U_TableParentOrderBy = string.Empty;
public string U_TableParentID = string.Empty;
public string U_TableParentWhere = string.Empty;
public string U_ChildHeader = string.Empty;
public string U_TableChild = string.Empty;
public string U_TableChildOrderBy = string.Empty;
public string U_TableChildWhere = "1<>1";
public string U_TimeIntervalColumn = string.Empty;
public bool U_AllowTimeInterval = false;
public void U_InitControl()
{
this.qqParent.U_Query += new UC.ucQuickQuery.U_QueryEventHandler((sQueryWhere) =>
{
if (this.U_AllowTimeInterval && true == this.dsDateSect.cbTime.IsChecked)
{
this.dgParent.U_AppendWhere = string.Format("{3} and {0}>='{1}' and {0}<='{2}'",
this.U_TimeIntervalColumn,
this.dsDateSect.dtpStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
this.dsDateSect.dtpEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
string.IsNullOrEmpty(sQueryWhere) ? "1=1" : sQueryWhere);
}
else
{
this.dgParent.U_AppendWhere = sQueryWhere;
}
this.dgParent.U_InitControl();
});
this.gbParent.Header = this.U_ParentHeader;
this.gbChild.Header = this.U_ChildHeader;
this.qqParent.U_WindowName = this.U_WindowName;
//this.qqParent.U_XmlTableName = this.U_TableParent;
this.qqParent.U_XmlTableName = string.IsNullOrWhiteSpace(this.U_XmlTableParent) ? this.U_TableParent : this.U_XmlTableParent;
this.qqParent.U_InitControl();
this.dgChild.U_WindowName = this.U_WindowName;
this.dgChild.U_TableName = this.U_TableChild;
this.dgChild.U_Where = this.U_TableChildWhere;
this.dgChild.U_OrderField = this.U_TableChildOrderBy;
this.dgChild.U_AllowChecked = this.U_ParentAllowChecked;
this.dgChild.U_AllowOperatData = this.U_AllowOperatData;
this.dgChild.U_InitControl();
if (this.U_AllowTimeInterval)
{
this.dsDateSect.Visibility = Visibility.Visible;
this.dgParent.U_AppendWhere = string.Format("{0}>='{1}' and {0}<='{2}'",
U_TimeIntervalColumn,
this.dsDateSect.dtpStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
this.dsDateSect.dtpEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
}
this.dgParent.U_SelectedChanged += () =>
{
DataRowView drv = dgParent.gridApp.SelectedItem as DataRowView;
string sParentID = string.Empty;
if (drv == null)
{
this.dgChild.U_AllowOperatData = false;
this.dgChild.U_Where = this.U_TableChildWhere;
}
else
{
this.dgChild.U_AllowOperatData = this.U_AllowOperatData;
sParentID = drv[this.U_TableParentID].ToString();
this.dgChild.U_Where = string.Format("{0}={1}", this.U_TableParentID, sParentID);
if (this.U_AllowOperatData)
{
this.dgChild.U_DefaultRowValues = new Dictionary<string, string>
{
{ this.U_TableParentID, sParentID }
};
}
}
this.dgChild.U_InitControl();
if (this.U_ParentSelectedChanged != null)
{
this.U_ParentSelectedChanged(sParentID);
}
};
this.dgParent.U_WindowName = this.U_WindowName;
this.dgParent.U_XmlTableName = this.U_XmlTableParent;
this.dgParent.U_TableName = this.U_TableParent;
this.dgParent.U_Where = this.U_TableParentWhere;
this.dgParent.U_OrderField = this.U_TableParentOrderBy;
this.dgParent.U_AllowOperatData = this.U_AllowOperatData;
this.dgParent.U_InitControl();
}
public void U_InitControlParent()
{
this.dgParent.U_InitControl();
}
}
}