//加载表数据 void loadTableData() { try { dt = new ReadTable(_systemName.ToUpper().Trim()); dt.SetCustomFunctionName("ZVI_RFC_READ_TABLE"); dt.TableName = _tableName; // dt.Fields.Clear(); // dt.Options.Clear(); //从界面上加载条件与字段列表 for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells["FieldName"].Value != null) { if (dataGridView1.Rows[i].Cells["Select"] != null & (bool)dataGridView1.Rows[i].Cells["Select"].Value == true) { string s = dataGridView1.Rows[i].Cells["FieldName"].Value.ToString(); if (!string.IsNullOrEmpty(s)) { dt.AddField(s); } } } } for (int i = 0; i < dataGridView2.Rows.Count; i++) { if (dataGridView2[0, i].Value != null) { string s = dataGridView2[0, i].Value.ToString(); if (!string.IsNullOrEmpty(s)) { dt.AddCriteria(s); } } } dt.RowCount = Convert.ToInt32(rowNum.Text); dt.Run(); } catch (Exception ee) { MessageBox.Show(ee.Message); } }
private DataTable BeginExecuteQuery() { string name; string str2 = this._query; SAPTableAttribute[] customAttributes = (SAPTableAttribute[])this._originalType.GetCustomAttributes(typeof(SAPTableAttribute), false); if ((customAttributes == null) || (customAttributes.Length == 0)) { name = this._originalType.Name; } else if (!string.IsNullOrEmpty(customAttributes[0].Name)) { name = customAttributes[0].Name; } else { name = this._originalType.Name; } //if (!this.Connection.Ping()) //{ // this.Connection. // this.Connection.Open(); //} ReadTable table = new ReadTable(this.Connection) { TableName = name }; table.EventMessage += table_eventMessage; if (this._useMultibyteExtraction) { table.Delimiter = "|"; } if (!string.IsNullOrEmpty(str2)) { table.WhereClause = str2; } if (this._skip > 0) { table.RowSkip = this._skip; } if (this._take > 0) { table.RowCount = this._take; } if (((customAttributes != null) && (customAttributes.Length > 0)) && !string.IsNullOrEmpty(customAttributes[0].CustomFunctionName)) { table.SetCustomFunctionName(customAttributes[0].CustomFunctionName); } PropertyInfo[] properties = this._originalType.GetProperties(); for (int i = 0; i < properties.Length; i++) { SAPColumnAttribute[] attributeArray2 = (SAPColumnAttribute[])properties[i].GetCustomAttributes(typeof(SAPColumnAttribute), false); string fieldName = properties[i].Name; if (((attributeArray2 != null) && (attributeArray2.Length > 0)) && !string.IsNullOrEmpty(attributeArray2[0].Name)) { fieldName = attributeArray2[0].Name; } table.AddField(fieldName); } if (this.Log != null) { this.Log.WriteLine("SAPConnect.ReadTable:"); this.Log.WriteLine(" => TableName = {0}", name); this.Log.WriteLine(" => RowSkip = {0}", this._skip); this.Log.WriteLine(" => RowCount = {0}", this._take); this.Log.WriteLine(" => WhereClause = {0}", str2); this.Log.WriteLine(" => OrderByClause = {0}", this._orderBy); } table.Run(); DataTable result = table.Result; if (!string.IsNullOrEmpty(this._orderBy)) { result.DefaultView.Sort = this._orderBy; } return(result); }
//加载表数据 void loadTableData() { try { SendMessage("开始"); m_dt = new ReadTable(m_systemName); m_dt.EventMessage += dt_eventMessage; // dt.SetCustomFunctionName("Z_XTRACT_IS_TABLE"); m_dt.SetCustomFunctionName("ZVI_RFC_READ_TABLE"); m_dt.TableName = m_tableName; m_dt.Delimiter = m_delimiter; // dt.Fields.Clear(); // dt.Options.Clear(); //从界面上加载条件与字段列表 SendMessage("加载字段列表"); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells["FieldName"].Value != null) { if (dataGridView1.Rows[i].Cells[0].Value != null) { if ((bool)dataGridView1.Rows[i].Cells[0].Value == true) { string s = dataGridView1.Rows[i].Cells["FieldName"].Value.ToString(); if (!string.IsNullOrEmpty(s)) { m_dt.AddField(s); } } } } } SendMessage("加载条件"); for (int i = 0; i < dataGridView2.Rows.Count; i++) { if (dataGridView2[0, i].Value != null) { string s = dataGridView2[0, i].Value.ToString(); if (!string.IsNullOrEmpty(s)) { m_dt.AddCriteria(s); } } } m_dt.RowCount = Convert.ToInt32(rowNum.Text); SendMessage("开始异步调用"); try { Thread thread = new Thread(new ThreadStart(excute)); thread.Start(); } catch (Exception e) { MessageBox.Show(e.Message); } } catch (Exception ee) { MessageBox.Show(ee.Message); } }