|
@@ -162,44 +162,12 @@ namespace UAS_MES
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- //赋值控件是否被GROUP包含
|
|
|
|
|
- Boolean groupcontains = false;
|
|
|
|
|
//先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
|
|
//先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
|
|
|
FormCollection fmCollection = Application.OpenForms;
|
|
FormCollection fmCollection = Application.OpenForms;
|
|
|
ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
|
|
ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
|
|
|
for (int i = 0; i < dt.Columns.Count; i++)
|
|
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]];
|
|
|
|
|
- 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;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- 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();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ fillControl(e, i, fmCollection[FormName]);
|
|
|
}
|
|
}
|
|
|
//发起DBFind的控件
|
|
//发起DBFind的控件
|
|
|
SuccessReturnData = true;
|
|
SuccessReturnData = true;
|
|
@@ -215,15 +183,38 @@ namespace UAS_MES
|
|
|
}
|
|
}
|
|
|
MainControl.Focus();
|
|
MainControl.Focus();
|
|
|
}
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
|
|
|
|
+ catch (Exception ea)
|
|
|
{
|
|
{
|
|
|
- LogManager.DoLog(ex.Message);
|
|
|
|
|
SuccessReturnData = false;
|
|
SuccessReturnData = false;
|
|
|
}
|
|
}
|
|
|
Dispose();
|
|
Dispose();
|
|
|
Close();
|
|
Close();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void fillControl(DataGridViewCellEventArgs e, 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(e, i, controls[k]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ if ((SetValueField[j] == dt.Columns[i].Caption || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ct != null && ct.Tag != null && ct.Tag.ToString() == dt.Columns[i].Caption)) && ct.Name.ToString() == SetValueField[j])
|
|
|
|
|
+ ct.Text = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
|
|
|
|
|
+ if (ct.Name == MainField)
|
|
|
|
|
+ {
|
|
|
|
|
+ MainControl = ct;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//按下Esc键的时候关闭当前的界面,用于DbFind
|
|
//按下Esc键的时候关闭当前的界面,用于DbFind
|
|
|
private void DbFindGridView_KeyPress(object sender, KeyPressEventArgs e)
|
|
private void DbFindGridView_KeyPress(object sender, KeyPressEventArgs e)
|
|
|
{
|
|
{
|