|
@@ -58,6 +58,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
private string selectField;
|
|
private string selectField;
|
|
|
DataTable dt = new DataTable();
|
|
DataTable dt = new DataTable();
|
|
|
|
|
+ DbFind db;
|
|
|
|
|
|
|
|
private DataTable returnData;
|
|
private DataTable returnData;
|
|
|
|
|
|
|
@@ -259,12 +260,13 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
|
|
|
private void Search_Icon_Click(object sender, EventArgs e)
|
|
private void Search_Icon_Click(object sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
SearchIconClick?.Invoke(sender, new EventArgs());
|
|
SearchIconClick?.Invoke(sender, new EventArgs());
|
|
|
- DbFind db = new DbFind(Name, tableName, selectField, setValueField, caller, formName, condition);
|
|
|
|
|
|
|
+ db = new DbFind(Name, tableName, selectField, setValueField, caller, formName, condition);
|
|
|
db.Text = DBTitle1;
|
|
db.Text = DBTitle1;
|
|
|
LogManager.DoLog("DbFind查询,发起窗口【" + formName + "】,查询表【" + tableName + "】,字段" + selectField + ",条件" + condition);
|
|
LogManager.DoLog("DbFind查询,发起窗口【" + formName + "】,查询表【" + tableName + "】,字段" + selectField + ",条件" + condition);
|
|
|
if (db.IsAbleDbFind1)
|
|
if (db.IsAbleDbFind1)
|
|
|
{
|
|
{
|
|
|
db.ShowDialog();
|
|
db.ShowDialog();
|
|
|
|
|
+ GetData();
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -317,26 +319,6 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
|
|
|
TextBox.Width = this.Width - Search_Icon.Width - 3;
|
|
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()
|
|
public void GetData()
|
|
|
{
|
|
{
|
|
|
if (TextBox.Text != "")
|
|
if (TextBox.Text != "")
|
|
@@ -350,24 +332,21 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
|
|
|
if (i % 2 == 0)
|
|
if (i % 2 == 0)
|
|
|
fields.Add(field[i]);
|
|
fields.Add(field[i]);
|
|
|
}
|
|
}
|
|
|
|
|
+ string sql;
|
|
|
//将查询到的结果返回界面
|
|
//将查询到的结果返回界面
|
|
|
- string sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + TextBox.Text + "'";
|
|
|
|
|
- if (condition != null)
|
|
|
|
|
|
|
+ if (TextBox.Text != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + TextBox.Text + "'";
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + db.TextBoxValue1 + "'";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (condition != null)
|
|
|
{
|
|
{
|
|
|
sql += " and " + condition;
|
|
sql += " and " + condition;
|
|
|
}
|
|
}
|
|
|
dt = (DataTable)dh.ExecuteSql(sql, "select");
|
|
dt = (DataTable)dh.ExecuteSql(sql, "select");
|
|
|
- ReturnDataToForm();
|
|
|
|
|
- //先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
|
|
|
|
|
- //if (dt.Rows.Count > 0)
|
|
|
|
|
- //{
|
|
|
|
|
- // FormCollection fmCollection = Application.OpenForms;
|
|
|
|
|
- // ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
|
|
|
|
|
- // for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
|
|
- // {
|
|
|
|
|
- // fillControl(i, fmCollection[FormName]);
|
|
|
|
|
- // }
|
|
|
|
|
- //}
|
|
|
|
|
|
|
+ ReturnDataToForm();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|