|
|
@@ -166,52 +166,45 @@ namespace UAS_MES
|
|
|
Boolean groupcontains = false;
|
|
|
//先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
|
|
|
FormCollection fmCollection = Application.OpenForms;
|
|
|
- //SuccessReturnData = true;
|
|
|
- //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 || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ct2 != null && ct2.Tag != null && ct2.Tag.ToString() == dt.Columns[i].Caption))
|
|
|
- // ct2.Text = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
|
|
|
- // groupcontains = true;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // break;
|
|
|
- // }
|
|
|
- //}
|
|
|
- //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 = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- //发起DBFind的控件
|
|
|
- SuccessReturnData = true;
|
|
|
+ ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
|
|
|
MainControl = fmCollection[FormName].Controls[MainField];
|
|
|
for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
{
|
|
|
- if (MainControl.Name == dt.Columns[i].Caption.ToLower() || (MainControl.Tag != null && MainControl.Tag.ToString() == dt.Columns[i].Caption.ToLower()))
|
|
|
+ for (int k = 0; k < controls.Count; k++)
|
|
|
{
|
|
|
- MainControl.Text = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
|
|
|
+ Control ctl = controls[k];
|
|
|
+ if (ctl.Controls.Count > 0)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < SetValueField.Length; j++)
|
|
|
+ {
|
|
|
+ Control ct2 = ctl.Controls[SetValueField[j]];
|
|
|
+ MainControl = ctl.Controls[MainField];
|
|
|
+ if (ct2 != null)
|
|
|
+ {
|
|
|
+ if (SetValueField[j] == dt.Columns[i].Caption || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ct2 != null && ct2.Tag != null && ct2.Tag.ToString() == dt.Columns[i].Caption))
|
|
|
+ ct2.Text = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
|
|
|
+ groupcontains = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ 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]];
|
|
|
+ MainControl = fmCollection[FormName].Controls[MainField];
|
|
|
+ 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 = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //发起DBFind的控件
|
|
|
+ SuccessReturnData = true;
|
|
|
if (MainControl is MaCodeSearchTextBox)
|
|
|
{
|
|
|
MaCodeSearchTextBox ctl = (MainControl as MaCodeSearchTextBox);
|