|
|
@@ -57,6 +57,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
|
|
|
/// 查询的字段
|
|
|
/// </summary>
|
|
|
private string selectField;
|
|
|
+ DataTable dt = new DataTable();
|
|
|
|
|
|
public override string Text
|
|
|
{
|
|
|
@@ -286,6 +287,28 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
|
|
|
TextBox.Width = this.Width - Search_Icon.Width - 3;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ private void fillControl(int i, Control ct)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < setValueField.Length; j++)
|
|
|
+ {
|
|
|
+ if (ct.Controls.Count > 0 && ct.Name.ToString() != setValueField[j])
|
|
|
+ {
|
|
|
+ Control.ControlCollection controls = ct.Controls;
|
|
|
+ for (int k = 0; k < ct.Controls.Count; k++)
|
|
|
+ {
|
|
|
+ fillControl(i, controls[k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if ((setValueField[j] == dt.Columns[i].Caption.ToLower() || setValueField[j] == dt.Columns[i].ColumnName.ToLower() || setValueField[j].Contains(dt.Columns[i].Caption.ToLower()) || (ct != null && ct.Tag != null && ct.Tag.ToString() == dt.Columns[i].Caption.ToLower())) && ct.Name.ToString() == setValueField[j])
|
|
|
+ ct.Text = dt.Rows[0][dt.Columns[i].ColumnName].ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void GetData()
|
|
|
{
|
|
|
if (TextBox.Text != "")
|
|
|
@@ -305,43 +328,14 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
|
|
|
{
|
|
|
sql += " and " + condition;
|
|
|
}
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
|
|
|
- Boolean groupcontains = false;
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql, "select");
|
|
|
//先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
|
|
|
FormCollection fmCollection = Application.OpenForms;
|
|
|
ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
|
|
|
for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
{
|
|
|
- for (int k = 0; k < controls.Count; k++)
|
|
|
- {
|
|
|
- Control ctl = controls[k];
|
|
|
- if (ctl.Controls.Count > 0)
|
|
|
- {
|
|
|
- for (int j = 0; j < SetValueField.Length; j++)
|
|
|
- {
|
|
|
- Control ct2 = ctl.Controls[SetValueField[j]];
|
|
|
- if (ct2 != null)
|
|
|
- {
|
|
|
- if (SetValueField[j] == dt.Columns[i].Caption.ToLower() || SetValueField[j] == dt.Columns[i].ColumnName.ToLower() || SetValueField[j].Contains(dt.Columns[i].Caption.ToLower()) || (ct2 != null && ct2.Tag != null && ct2.Tag.ToString() == dt.Columns[i].Caption.ToLower()))
|
|
|
- ct2.Text = dt.Rows[0][dt.Columns[i].ColumnName].ToString();
|
|
|
- groupcontains = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!groupcontains)
|
|
|
- {
|
|
|
- for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
- {
|
|
|
- for (int j = 0; j < SetValueField.Length; j++)
|
|
|
- {
|
|
|
- Control ctl = fmCollection[FormName].Controls[SetValueField[j]];
|
|
|
- if (SetValueField[j] == dt.Columns[i].Caption || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ctl != null && ctl.Tag != null && ctl.Tag.ToString() == dt.Columns[i].Caption))
|
|
|
- fmCollection[FormName].Controls[SetValueField[j]].Text = dt.Rows[0][dt.Columns[i].ColumnName].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ fillControl(i, fmCollection[FormName]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|