|
@@ -161,21 +161,50 @@ namespace UAS_MES
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ //赋值控件是否被GROUP包含
|
|
|
+ Boolean groupcontains = false;
|
|
|
//先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
|
|
|
FormCollection fmCollection = Application.OpenForms;
|
|
|
SuccessReturnData = true;
|
|
|
for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
{
|
|
|
- for (int j = 0; j < SetValueField.Length; j++)
|
|
|
+ ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
|
|
|
+ for (int k = 0; k < controls.Count; k++)
|
|
|
{
|
|
|
- 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();
|
|
|
+ Control ctl = controls[k];
|
|
|
+ if (ctl.Controls.Count > 0)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < SetValueField.Length; j++)
|
|
|
+ {
|
|
|
+ Control ct2 = ctl.Controls[SetValueField[j]];
|
|
|
+ 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();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
fmCollection[FormName].Controls[MainField].Focus();
|
|
|
}
|
|
|
- catch (Exception) { SuccessReturnData = false; }
|
|
|
+ catch (Exception exa)
|
|
|
+ {
|
|
|
+ SuccessReturnData = false;
|
|
|
+ }
|
|
|
Dispose();
|
|
|
Close();
|
|
|
}
|