/// <summary> /// 获取表类型配置[仅支持XmlConfig] /// </summary> /// <param name="ClassName">类名</param> /// <param name="TableElementName">表元素名</param> /// <returns></returns> public System.Data.DataTable GetTableConfig(string ClassName, string TableElementName) { XmlConfig AsmCfg = AsmConfig as XmlConfig; XmlConfig UserCfg = UserConfig as XmlConfig; if (AsmCfg != null && UserCfg != null) { System.Data.DataTable dtAsm = AsmCfg.GetTableConfig(ClassName, TableElementName); System.Data.DataTable dtUser = UserCfg.GetTableConfig(ClassName, TableElementName); if (dtAsm != null && dtUser != null) { dtUser.Merge(dtAsm); return(Apq.Data.DataTable.GetDistinct(dtUser, null)); } if (dtAsm != null) { return(dtAsm); } return(dtUser); } if (AsmCfg != null) { return(AsmCfg.GetTableConfig(ClassName, TableElementName)); } return(UserCfg.GetTableConfig(ClassName, TableElementName)); }
protected override void ProcessRecord() { var target_pages = new VisioScripting.Models.TargetPages(this.Pages); var template = new VisioPowerShell.Models.PageCells(); var celldic = VisioPowerShell.Models.NameCellDictionary.FromCells(template); var cellnames = celldic.Keys.ToArray(); var query = _CreateQuery(celldic, cellnames); var surface = this.Client.ShapeSheet.GetShapeSheetSurface(); var result_dt = new System.Data.DataTable(); foreach (var target_page in target_pages.Pages) { var target_pagesheet = target_page.PageSheet; var target_shapeids = new List <int> { target_pagesheet.ID }; var dt = VisioPowerShell.Models.DataTableHelpers.QueryToDataTable(query, this.OutputType, target_shapeids, surface); result_dt.Merge(dt); } // Annotate the returned datatable to disambiguate rows var pageindex_col = result_dt.Columns.Add("PageIndex", typeof(System.Int32)); pageindex_col.SetOrdinal(0); for (int row_index = 0; row_index < target_pages.Pages.Count; row_index++) { result_dt.Rows[row_index][pageindex_col.ColumnName] = target_pages.Pages[row_index].Index; } this.WriteObject(result_dt); }
private void GetMoreTransactions() { string[] custTransactionsLanguageTexts = new string[3]; custTransactionsLanguageTexts[0] = ApplicationLocalizer.Language.Translate(51151); custTransactionsLanguageTexts[1] = ApplicationLocalizer.Language.Translate(51152); custTransactionsLanguageTexts[2] = ApplicationLocalizer.Language.Translate(51153); int topRowIndex = this.grViewTransactions.TopRowIndex; if ((grViewTransactions.IsLastRow) && (grViewTransactions.RowCount > 0)) { System.Data.DataRow Row = grViewTransactions.GetDataRow(grViewTransactions.GetSelectedRows()[0]); string lastTransactionId = Row["TRANSACTIONID"].ToString(); customerTransactions.Merge(customerData.GetCustomerTransactions(lastTransactionId, customerId, maxRowsAtEachQuery, custTransactionsLanguageTexts)); grViewTransactions.TopRowIndex = topRowIndex; } }
protected override void ProcessRecord() { var valuetype = this.Results ? VisioAutomation.ShapeSheet.CellValueType.Result : VisioAutomation.ShapeSheet.CellValueType.Formula; var targetpages = new VisioScripting.TargetPages(this.Page).ResolveToPages(this.Client); if (targetpages.Pages.Count < 1) { return; } var template = new VisioPowerShell.Models.PageCells(); var dicof_name_to_cell = VisioPowerShell.Internal.NamedSrcDictionary.FromCells(template); var desired_cells = this.Cell ?? dicof_name_to_cell.Keys.ToArray(); var query = _create_query(dicof_name_to_cell, desired_cells); var datatable = new System.Data.DataTable(); foreach (var page in targetpages.Pages) { var shapesheet = page.PageSheet; var shapeids = new List <int> { shapesheet.ID }; var surface = new VisioAutomation.SurfaceTarget(page); var temp_datatable = VisioPowerShell.Internal.DataTableHelpers.QueryToDataTable(query, valuetype, this.ResultType, shapeids, surface); datatable.Merge(temp_datatable); } // Annotate the returned datatable to disambiguate rows var pageid_col = datatable.Columns.Add("PageID", typeof(int)); int pageid_colindex = 0; pageid_col.SetOrdinal(pageid_colindex); foreach (int row_index in Enumerable.Range(0, targetpages.Pages.Count)) { var page = targetpages.Pages[row_index]; datatable.Rows[row_index][pageid_colindex] = page.ID; } this.WriteObject(datatable); }
/// <summary> /// Count all tables records. /// </summary> /// <param name="p_tables">List of table names.</param> /// <param name="p_filters">List of table filters.</param> public System.Data.DataTable CountTablesRecords(System.Collections.Generic.List <string> p_tables, System.Collections.Generic.List <string> p_filters) { System.Data.DataTable v_count_total_table = new System.Data.DataTable(); int v_timeout = v_connection.v_timeout; v_connection.SetTimeout(0); string v_sql = ""; bool v_first = true; int v_block_counter = 0; for (int j = 0; j < p_tables.Count; j++) { if (!v_first) { v_sql += " union all "; } v_first = false; v_block_counter++; string v_table_name = ""; if (v_has_schema) { v_table_name = v_schema + "." + p_tables[j]; } else { v_table_name = p_tables[j]; } v_sql += "select count(*) as total, " + v_trim_function + "('" + p_tables[j] + "') as table_name from " + v_table_name + " " + p_filters[j] + " "; if (v_block_counter >= 50 || (j == p_tables.Count - 1)) { if (v_count_total_table == null) { v_count_total_table = v_connection.Query(v_sql, "t1"); } else { v_count_total_table.Merge(v_connection.Query(v_sql, "t1")); } v_first = true; v_block_counter = 0; v_sql = ""; } } System.Data.DataTable dt2 = v_count_total_table.Clone(); dt2.Columns["total"].DataType = Type.GetType("System.Int32"); foreach (System.Data.DataRow dr in v_count_total_table.Rows) { dt2.ImportRow(dr); } dt2.AcceptChanges(); System.Data.DataView dv = dt2.DefaultView; dv.Sort = "total DESC"; v_count_total_table = dv.ToTable(); v_connection.SetTimeout(v_timeout); return(v_count_total_table); }
/// <summary> /// Get a datatable with all tables indexes. /// </summary> /// <param name="p_table">Table name.</param> public override System.Data.DataTable QueryTablesIndexes(string p_table) { if (p_table == null) { System.Data.DataTable v_tables = this.QueryTables(false); System.Data.DataTable v_all_indexes = new System.Data.DataTable(); v_all_indexes.Columns.Add("table_name"); v_all_indexes.Columns.Add("index_name"); v_all_indexes.Columns.Add("column_name"); v_all_indexes.Columns.Add("uniqueness"); foreach (System.Data.DataRow v_tabletemp in v_tables.Rows) { System.Data.DataRow v_row; System.Data.DataTable v_indexes = new System.Data.DataTable("TableIndexes"); v_indexes.Columns.Add("table_name"); v_indexes.Columns.Add("index_name"); v_indexes.Columns.Add("column_name"); v_indexes.Columns.Add("uniqueness"); com.healthmarketscience.jackcess.Database v_database = com.healthmarketscience.jackcess.DatabaseBuilder.open(new java.io.File(this.v_connection.v_service)); com.healthmarketscience.jackcess.Table v_table = v_database.getTable(v_tabletemp["table_name"].ToString().Replace("[", "").Replace("]", "")); java.util.List v_list = v_table.getIndexes(); object[] v_obj = v_list.toArray(); foreach (object o in v_obj) { com.healthmarketscience.jackcess.Index v_index = (com.healthmarketscience.jackcess.Index)o; java.util.List v_list2 = v_index.getColumns(); object[] v_obj2 = v_list2.toArray(); foreach (object o2 in v_obj2) { com.healthmarketscience.jackcess.Index.Column c = (com.healthmarketscience.jackcess.Index.Column)o2; v_row = v_indexes.NewRow(); v_row["table_name"] = v_tabletemp["table_name"].ToString(); v_row["index_name"] = v_index.getName(); v_row["column_name"] = c.getName(); if (v_index.isUnique()) { v_row["uniqueness"] = "Unique"; } else { v_row["uniqueness"] = "Non Unique"; } v_indexes.Rows.Add(v_row); } } v_all_indexes.Merge(v_indexes); } return(v_all_indexes); } else { System.Data.DataRow v_row; System.Data.DataTable v_indexes = new System.Data.DataTable("TableIndexes"); v_indexes.Columns.Add("table_name"); v_indexes.Columns.Add("index_name"); v_indexes.Columns.Add("column_name"); v_indexes.Columns.Add("uniqueness"); com.healthmarketscience.jackcess.Database v_database = com.healthmarketscience.jackcess.DatabaseBuilder.open(new java.io.File(this.v_connection.v_service)); com.healthmarketscience.jackcess.Table v_table = v_database.getTable(p_table.Replace("[", "").Replace("]", "")); java.util.List v_list = v_table.getIndexes(); object[] v_obj = v_list.toArray(); foreach (object o in v_obj) { com.healthmarketscience.jackcess.Index v_index = (com.healthmarketscience.jackcess.Index)o; java.util.List v_list2 = v_index.getColumns(); object[] v_obj2 = v_list2.toArray(); foreach (object o2 in v_obj2) { com.healthmarketscience.jackcess.Index.Column c = (com.healthmarketscience.jackcess.Index.Column)o2; v_row = v_indexes.NewRow(); v_row["table_name"] = p_table; v_row["index_name"] = v_index.getName(); v_row["column_name"] = c.getName(); if (v_index.isUnique()) { v_row["uniqueness"] = "Unique"; } else { v_row["uniqueness"] = "Non Unique"; } v_indexes.Rows.Add(v_row); } } return(v_indexes); } }
/// <summary> /// Get a datatable with all tables primary keys. /// </summary> /// <param name="p_schema">Schema name.</param> /// <param name="p_table">Table name.</param> public override System.Data.DataTable QueryTablesPrimaryKeys(string p_schema, string p_table) { if (p_table == null) { System.Data.DataTable v_tables = this.QueryTables(false); System.Data.DataTable v_pk_all = new System.Data.DataTable(); v_pk_all.Columns.Add("constraint_name"); v_pk_all.Columns.Add("column_name"); v_pk_all.Columns.Add("table_name"); foreach (System.Data.DataRow v_tabletemp in v_tables.Rows) { System.Data.DataRow v_row; System.Data.DataTable v_pk = new System.Data.DataTable("TablePrimaryKeys"); v_pk.Columns.Add("constraint_name"); v_pk.Columns.Add("column_name"); v_pk.Columns.Add("table_name"); com.healthmarketscience.jackcess.Database v_database = com.healthmarketscience.jackcess.DatabaseBuilder.open(new java.io.File(this.v_connection.v_service)); com.healthmarketscience.jackcess.Table v_table = v_database.getTable(v_tabletemp["table_name"].ToString().Replace("[", "").Replace("]", "")); com.healthmarketscience.jackcess.Index v_index = v_table.getPrimaryKeyIndex(); java.util.List v_list = v_index.getColumns(); object[] v_obj = v_list.toArray(); foreach (object o in v_obj) { com.healthmarketscience.jackcess.Index.Column c = (com.healthmarketscience.jackcess.Index.Column)o; v_row = v_pk.NewRow(); v_row["constraint_name"] = v_index.getName(); v_row["column_name"] = c.getName(); v_row["table_name"] = v_tabletemp["table_name"].ToString(); v_pk.Rows.Add(v_row); } v_pk_all.Merge(v_pk); } return(v_pk_all); } else { System.Data.DataRow v_row; System.Data.DataTable v_pk = new System.Data.DataTable("TablePrimaryKeys"); v_pk.Columns.Add("constraint_name"); v_pk.Columns.Add("column_name"); v_pk.Columns.Add("table_name"); com.healthmarketscience.jackcess.Database v_database = com.healthmarketscience.jackcess.DatabaseBuilder.open(new java.io.File(this.v_connection.v_service)); com.healthmarketscience.jackcess.Table v_table = v_database.getTable(p_table.Replace("[", "").Replace("]", "")); com.healthmarketscience.jackcess.Index v_index = v_table.getPrimaryKeyIndex(); java.util.List v_list = v_index.getColumns(); object[] v_obj = v_list.toArray(); foreach (object o in v_obj) { com.healthmarketscience.jackcess.Index.Column c = (com.healthmarketscience.jackcess.Index.Column)o; v_row = v_pk.NewRow(); v_row["constraint_name"] = v_index.getName(); v_row["column_name"] = c.getName(); v_row["table_name"] = p_table; v_pk.Rows.Add(v_row); } return(v_pk); } }
/// <summary> /// Get a datatable with all tables foreign keys. /// </summary> /// <param name="p_table">Table name.</param> public override System.Data.DataTable QueryTablesForeignKeys(string p_table) { if (p_table == null) { System.Data.DataTable v_tables = this.QueryTables(false); System.Data.DataTable v_all_fks = new System.Data.DataTable(); v_all_fks.Columns.Add("table_name"); v_all_fks.Columns.Add("constraint_name"); v_all_fks.Columns.Add("r_table_name"); v_all_fks.Columns.Add("column_name"); v_all_fks.Columns.Add("r_column_name"); v_all_fks.Columns.Add("update_rule"); v_all_fks.Columns.Add("delete_rule"); foreach (System.Data.DataRow v_tabletemp in v_tables.Rows) { System.Data.DataRow v_row; System.Data.DataTable v_fks = new System.Data.DataTable("TableForeignKeys"); v_fks.Columns.Add("table_name"); v_fks.Columns.Add("constraint_name"); v_fks.Columns.Add("r_table_name"); v_fks.Columns.Add("column_name"); v_fks.Columns.Add("r_column_name"); v_fks.Columns.Add("update_rule"); v_fks.Columns.Add("delete_rule"); com.healthmarketscience.jackcess.Database v_database = com.healthmarketscience.jackcess.DatabaseBuilder.open(new java.io.File(this.v_connection.v_service)); com.healthmarketscience.jackcess.Table v_table = v_database.getTable(v_tabletemp["table_name"].ToString().Replace("[", "").Replace("]", "")); java.util.Set v_set = v_database.getTableNames(); object[] v_obj = v_set.toArray(); foreach (object v_tablename in v_obj) { com.healthmarketscience.jackcess.Table v_table2 = v_database.getTable((string)v_tablename); try { com.healthmarketscience.jackcess.Index v_index = v_table.getForeignKeyIndex(v_table2); if (!v_index.getName().StartsWith(".")) { com.healthmarketscience.jackcess.Index v_index2 = v_index.getReferencedIndex(); java.util.List v_list = v_index.getColumns(); object[] v_obj2 = v_list.toArray(); java.util.List v_list2 = v_index2.getColumns(); object[] v_obj3 = v_list2.toArray(); java.util.List v_list3 = v_database.getRelationships(v_table, v_table2); object[] v_obj4 = v_list3.toArray(); bool v_dcascade = false; bool v_ucascade = false; foreach (object o in v_obj4) { com.healthmarketscience.jackcess.Relationship r = (com.healthmarketscience.jackcess.Relationship)o; if (r.getName() == v_index.getName()) { v_dcascade = r.cascadeDeletes(); v_ucascade = r.cascadeUpdates(); } } int k = 0; foreach (object o in v_obj2) { com.healthmarketscience.jackcess.Index.Column c = (com.healthmarketscience.jackcess.Index.Column)o; com.healthmarketscience.jackcess.Index.Column c2 = (com.healthmarketscience.jackcess.Index.Column)v_obj3[k]; v_row = v_fks.NewRow(); v_row["table_name"] = v_tabletemp["table_name"].ToString(); v_row["constraint_name"] = v_index.getName(); v_row["r_table_name"] = (string)v_tablename; v_row["column_name"] = c.getName(); v_row["r_column_name"] = c2.getName(); if (v_ucascade) { v_row["update_rule"] = "CASCADE"; } else { v_row["update_rule"] = "SET NULL"; } if (v_dcascade) { v_row["delete_rule"] = "CASCADE"; } else { v_row["delete_rule"] = "SET NULL"; } v_fks.Rows.Add(v_row); k++; } } } catch (java.lang.IllegalArgumentException) { } } v_all_fks.Merge(v_fks); } return(v_all_fks); } else { System.Data.DataRow v_row; System.Data.DataTable v_fks = new System.Data.DataTable("TableForeignKeys"); v_fks.Columns.Add("table_name"); v_fks.Columns.Add("constraint_name"); v_fks.Columns.Add("r_table_name"); v_fks.Columns.Add("column_name"); v_fks.Columns.Add("r_column_name"); v_fks.Columns.Add("update_rule"); v_fks.Columns.Add("delete_rule"); com.healthmarketscience.jackcess.Database v_database = com.healthmarketscience.jackcess.DatabaseBuilder.open(new java.io.File(this.v_connection.v_service)); com.healthmarketscience.jackcess.Table v_table = v_database.getTable(p_table.Replace("[", "").Replace("]", "")); java.util.Set v_set = v_database.getTableNames(); object[] v_obj = v_set.toArray(); foreach (object v_tablename in v_obj) { com.healthmarketscience.jackcess.Table v_table2 = v_database.getTable((string)v_tablename); try { com.healthmarketscience.jackcess.Index v_index = v_table.getForeignKeyIndex(v_table2); if (!v_index.getName().StartsWith(".")) { com.healthmarketscience.jackcess.Index v_index2 = v_index.getReferencedIndex(); java.util.List v_list = v_index.getColumns(); object[] v_obj2 = v_list.toArray(); java.util.List v_list2 = v_index2.getColumns(); object[] v_obj3 = v_list2.toArray(); java.util.List v_list3 = v_database.getRelationships(v_table, v_table2); object[] v_obj4 = v_list3.toArray(); bool v_dcascade = false; bool v_ucascade = false; foreach (object o in v_obj4) { com.healthmarketscience.jackcess.Relationship r = (com.healthmarketscience.jackcess.Relationship)o; if (r.getName() == v_index.getName()) { v_dcascade = r.cascadeDeletes(); v_ucascade = r.cascadeUpdates(); } } int k = 0; foreach (object o in v_obj2) { com.healthmarketscience.jackcess.Index.Column c = (com.healthmarketscience.jackcess.Index.Column)o; com.healthmarketscience.jackcess.Index.Column c2 = (com.healthmarketscience.jackcess.Index.Column)v_obj3[k]; v_row = v_fks.NewRow(); v_row["table_name"] = p_table; v_row["constraint_name"] = v_index.getName(); v_row["r_table_name"] = (string)v_tablename; v_row["column_name"] = c.getName(); v_row["r_column_name"] = c2.getName(); if (v_ucascade) { v_row["update_rule"] = "CASCADE"; } else { v_row["update_rule"] = "SET NULL"; } if (v_dcascade) { v_row["delete_rule"] = "CASCADE"; } else { v_row["delete_rule"] = "SET NULL"; } v_fks.Rows.Add(v_row); k++; } } } catch (java.lang.IllegalArgumentException) { } } return(v_fks); } }
/// <summary> /// Get a datatable with all tables fields. /// </summary> /// <param name="p_table">Table name.</param> public override System.Data.DataTable QueryTablesFields(string p_table) { if (p_table == null) { System.Data.DataTable v_tables = this.QueryTables(false); System.Data.DataTable v_table_columns_all = new System.Data.DataTable(); v_table_columns_all.Columns.Add("column_name"); v_table_columns_all.Columns.Add("data_type"); v_table_columns_all.Columns.Add("nullable"); v_table_columns_all.Columns.Add("data_length"); v_table_columns_all.Columns.Add("data_precision"); v_table_columns_all.Columns.Add("data_scale"); v_table_columns_all.Columns.Add("table_name"); foreach (System.Data.DataRow v_tabletemp in v_tables.Rows) { System.Data.DataRow v_row; System.Data.DataTable v_table_columns = new System.Data.DataTable("TableFields"); v_table_columns.Columns.Add("column_name"); v_table_columns.Columns.Add("data_type"); v_table_columns.Columns.Add("nullable"); v_table_columns.Columns.Add("data_length"); v_table_columns.Columns.Add("data_precision"); v_table_columns.Columns.Add("data_scale"); v_table_columns.Columns.Add("table_name"); com.healthmarketscience.jackcess.Database v_database = com.healthmarketscience.jackcess.DatabaseBuilder.open(new java.io.File(this.v_connection.v_service)); com.healthmarketscience.jackcess.Table v_table = v_database.getTable(v_tabletemp["table_name"].ToString().Replace("[", "").Replace("]", "")); java.util.List v_list = v_table.getColumns(); object[] v_obj = v_list.toArray(); foreach (object o in v_obj) { com.healthmarketscience.jackcess.Column c = (com.healthmarketscience.jackcess.Column)o; v_row = v_table_columns.NewRow(); v_row["column_name"] = c.getName(); v_row["data_type"] = c.getType().ToString(); v_row["nullable"] = "YES"; v_row["data_length"] = c.getLength().ToString(); v_row["data_precision"] = c.getPrecision().ToString(); v_row["data_scale"] = c.getScale().ToString(); v_row["table_name"] = v_tabletemp["table_name"].ToString(); v_table_columns.Rows.Add(v_row); } v_table_columns_all.Merge(v_table_columns); } return(v_table_columns_all); } else { System.Data.DataRow v_row; System.Data.DataTable v_table_columns = new System.Data.DataTable("TableFields"); v_table_columns.Columns.Add("column_name"); v_table_columns.Columns.Add("data_type"); v_table_columns.Columns.Add("nullable"); v_table_columns.Columns.Add("data_length"); v_table_columns.Columns.Add("data_precision"); v_table_columns.Columns.Add("data_scale"); com.healthmarketscience.jackcess.Database v_database = com.healthmarketscience.jackcess.DatabaseBuilder.open(new java.io.File(this.v_connection.v_service)); com.healthmarketscience.jackcess.Table v_table = v_database.getTable(p_table.Replace("[", "").Replace("]", "")); java.util.List v_list = v_table.getColumns(); object[] v_obj = v_list.toArray(); foreach (object o in v_obj) { com.healthmarketscience.jackcess.Column c = (com.healthmarketscience.jackcess.Column)o; v_row = v_table_columns.NewRow(); v_row["column_name"] = c.getName(); v_row["data_type"] = c.getType().ToString(); v_row["nullable"] = "YES"; v_row["data_length"] = c.getLength().ToString(); v_row["data_precision"] = c.getPrecision().ToString(); v_row["data_scale"] = c.getScale().ToString(); v_table_columns.Rows.Add(v_row); } return(v_table_columns); } }
/// <summary> /// Get a datatable with all tables foreign keys. /// </summary> /// <param name="p_table">Table name.</param> public override System.Data.DataTable QueryTablesForeignKeys(string p_table) { if (p_table == null) { System.Data.DataTable v_all_fks = new System.Data.DataTable(); v_all_fks.Columns.Add("r_table_name"); v_all_fks.Columns.Add("table_name"); v_all_fks.Columns.Add("r_column_name"); v_all_fks.Columns.Add("column_name"); v_all_fks.Columns.Add("constraint_name"); v_all_fks.Columns.Add("update_rule"); v_all_fks.Columns.Add("delete_rule"); System.Data.DataTable v_tables = v_connection.Query("select name as table_name " + "from sqlite_master " + "where type='table'", "Tables"); foreach (System.Data.DataRow v_table in v_tables.Rows) { System.Data.DataTable v_fks = v_connection.Query("PRAGMA foreign_key_list('" + v_table["table_name"].ToString() + "')", "ForeignKeys"); if (v_fks.Rows.Count > 0) { v_fks.Columns ["table"].ColumnName = "r_table_name"; v_fks.Columns ["from"].ColumnName = "column_name"; v_fks.Columns ["to"].ColumnName = "r_column_name"; v_fks.Columns ["id"].ColumnName = "constraint_name"; v_fks.Columns ["on_update"].ColumnName = "update_rule"; v_fks.Columns ["on_delete"].ColumnName = "delete_rule"; v_fks.Columns.Remove("seq"); v_fks.Columns.Remove("match"); v_fks.Columns.Add("table_name"); foreach (System.Data.DataRow v_fk in v_fks.Rows) { v_fk ["table_name"] = v_table ["table_name"].ToString(); v_fk ["constraint_name"] = v_table ["table_name"].ToString() + "_fk_" + v_fk ["constraint_name"]; } if (v_all_fks.Columns.Count == 0) { v_all_fks = v_fks; } else { v_all_fks.Merge(v_fks); } } } return(v_all_fks); } else { System.Data.DataTable v_fks = v_connection.Query("PRAGMA foreign_key_list('" + p_table + "')", "ForeignKeys"); if (v_fks.Rows.Count > 0) { v_fks.Columns ["table"].ColumnName = "r_table_name"; v_fks.Columns ["from"].ColumnName = "column_name"; v_fks.Columns ["to"].ColumnName = "r_column_name"; v_fks.Columns ["id"].ColumnName = "constraint_name"; v_fks.Columns ["on_update"].ColumnName = "update_rule"; v_fks.Columns ["on_delete"].ColumnName = "delete_rule"; v_fks.Columns.Remove("seq"); v_fks.Columns.Remove("match"); v_fks.Columns.Add("table_name"); foreach (System.Data.DataRow v_fk in v_fks.Rows) { v_fk ["table_name"] = p_table; v_fk ["constraint_name"] = p_table + "_fk_" + v_fk ["constraint_name"]; } } return(v_fks); } }
/// <summary> /// Get a datatable with all tables fields. /// </summary> /// <param name="p_table">Table name.</param> public override System.Data.DataTable QueryTablesFields(string p_table) { if (p_table == null) { System.Data.DataTable v_tables = this.QueryTables(false); System.Data.DataTable v_table_columns_all = new System.Data.DataTable(); v_table_columns_all.Columns.Add("column_name"); v_table_columns_all.Columns.Add("data_type"); v_table_columns_all.Columns.Add("nullable"); v_table_columns_all.Columns.Add("data_length"); v_table_columns_all.Columns.Add("data_precision"); v_table_columns_all.Columns.Add("data_scale"); v_table_columns_all.Columns.Add("table_name"); foreach (System.Data.DataRow v_table in v_tables.Rows) { System.Data.DataTable v_table_columns = v_connection.Query("pragma table_info('" + v_table["table_name"] + "')", "TableFields"); v_table_columns.Columns ["name"].ColumnName = "column_name"; v_table_columns.Columns ["type"].ColumnName = "data_type"; v_table_columns.Columns.Add("nullable"); v_table_columns.Columns.Add("data_length"); v_table_columns.Columns.Add("data_precision"); v_table_columns.Columns.Add("data_scale"); v_table_columns.Columns.Add("table_name"); foreach (System.Data.DataRow v_column in v_table_columns.Rows) { v_column ["table_name"] = v_table ["table_name"]; if (v_column ["notnull"].ToString() == "1") { v_column ["nullable"] = "NO"; } else { v_column ["nullable"] = "YES"; } v_column ["data_type"] = v_column ["data_type"].ToString().ToLower(); string v_type = v_column ["data_type"].ToString(); if (v_type.Contains("(")) { int v_index = v_type.IndexOf('('); if (v_type.Contains(",")) { string v_size = v_type.Substring(v_index + 1, v_type.IndexOf(')') - v_index - 1); string[] v_sizes = v_size.Split(','); v_column ["data_type"] = v_type.Substring(0, v_index); v_column ["data_length"] = ""; v_column ["data_precision"] = v_sizes [0]; v_column ["data_scale"] = v_sizes [1]; } else { v_column ["data_type"] = v_type.Substring(0, v_index); v_column ["data_length"] = v_type.Substring(v_index + 1, v_type.IndexOf(')') - v_index - 1); v_column ["data_precision"] = ""; v_column ["data_scale"] = ""; } } else { v_column ["data_length"] = ""; } } v_table_columns.Columns.Remove("notnull"); v_table_columns.Columns.Remove("dflt_value"); v_table_columns.Columns.Remove("pk"); v_table_columns_all.Merge(v_table_columns); } return(v_table_columns_all); } else { System.Data.DataTable v_table_columns = v_connection.Query("pragma table_info('" + p_table + "')", "TableFields"); v_table_columns.Columns ["name"].ColumnName = "column_name"; v_table_columns.Columns ["type"].ColumnName = "data_type"; v_table_columns.Columns.Add("nullable"); v_table_columns.Columns.Add("data_length"); v_table_columns.Columns.Add("data_precision"); v_table_columns.Columns.Add("data_scale"); v_table_columns.Columns.Add("table_name"); foreach (System.Data.DataRow v_column in v_table_columns.Rows) { v_column ["table_name"] = p_table; if (v_column ["notnull"].ToString() == "1") { v_column ["nullable"] = "NO"; } else { v_column ["nullable"] = "YES"; } v_column ["data_type"] = v_column ["data_type"].ToString().ToLower(); string v_type = v_column ["data_type"].ToString(); if (v_type.Contains("(")) { int v_index = v_type.IndexOf('('); if (v_type.Contains(",")) { string v_size = v_type.Substring(v_index + 1, v_type.IndexOf(')') - v_index - 1); string[] v_sizes = v_size.Split(','); v_column ["data_type"] = v_type.Substring(0, v_index); v_column ["data_length"] = ""; v_column ["data_precision"] = v_sizes [0]; v_column ["data_scale"] = v_sizes [1]; } else { v_column ["data_type"] = v_type.Substring(0, v_index); v_column ["data_length"] = v_type.Substring(v_index + 1, v_type.IndexOf(')') - v_index - 1); v_column ["data_precision"] = ""; v_column ["data_scale"] = ""; } } else { v_column ["data_length"] = ""; } } v_table_columns.Columns.Remove("notnull"); v_table_columns.Columns.Remove("dflt_value"); v_table_columns.Columns.Remove("pk"); return(v_table_columns); } }
private void button1_Click(object sender, EventArgs e) { if (txt_Order_number.Text != "" && txt_Order_number.Text.Length > 0) { SplashScreenManager.ShowForm(this, typeof(Masters.WaitForm1), true, true, false); try { //cPro.startProgress(); // form_loader.Start_progres(); Hashtable htselect = new Hashtable(); dtselect.Clear(); string OrderNumber = txt_Order_number.Text.ToString(); htselect.Add("@Trans", "SEARCH"); htselect.Add("@Search_By", OrderNumber); dtnewselect = dataAccess.ExecuteSP("Sp_Order", htselect); dt = dtnewselect; // Check in Old Server htselect.Clear(); htselect.Add("@Trans", "SEARCH"); htselect.Add("@Search_By", OrderNumber); dtoldselect = oldbdatacess.ExecuteSP("Sp_Order", htselect); if (dtoldselect.Rows.Count > 0) { Old_Server_Value = "True"; } else { Old_Server_Value = "False"; } dtselect = dtnewselect.Copy(); dtselect.Merge(dtoldselect); if (dtselect.Rows.Count > 0) { grd_order.Rows.Clear(); for (int i = 0; i < dtselect.Rows.Count; i++) { grd_order.Rows.Add(); grd_order.Rows[i].Cells[1].Value = dtselect.Rows[i]["Client_Order_Number"].ToString(); if (userroleid == "1") { grd_order.Rows[i].Cells[2].Value = dtselect.Rows[i]["Client_Name"].ToString(); grd_order.Rows[i].Cells[3].Value = dtselect.Rows[i]["Sub_ProcessName"].ToString(); } else { grd_order.Rows[i].Cells[2].Value = dtselect.Rows[i]["Client_Number"].ToString(); grd_order.Rows[i].Cells[3].Value = dtselect.Rows[i]["Subprocess_Number"].ToString(); } grd_order.Rows[i].Cells[4].Value = dtselect.Rows[i]["Date"].ToString(); grd_order.Rows[i].Cells[5].Value = dtselect.Rows[i]["Client_Order_Ref"].ToString(); grd_order.Rows[i].Cells[6].Value = dtselect.Rows[i]["Order_Type"].ToString(); grd_order.Rows[i].Cells[7].Value = dtselect.Rows[i]["Borrower_Name"].ToString();//BArrower Namr grd_order.Rows[i].Cells[8].Value = dtselect.Rows[i]["Address"].ToString(); grd_order.Rows[i].Cells[9].Value = dtselect.Rows[i]["County"].ToString(); grd_order.Rows[i].Cells[10].Value = dtselect.Rows[i]["State"].ToString(); grd_order.Rows[i].Cells[11].Value = dtselect.Rows[i]["County_Type"].ToString(); grd_order.Rows[i].Cells[12].Value = dtselect.Rows[i]["Date"].ToString();//Process date Should be Completed or Recived date grd_order.Rows[i].Cells[13].Value = dtselect.Rows[i]["Order_Status"].ToString(); grd_order.Rows[i].Cells[14].Value = dtselect.Rows[i]["Progress_Status"].ToString(); grd_order.Rows[i].Cells[15].Value = dtselect.Rows[i]["User_Name"].ToString(); grd_order.Rows[i].Cells[16].Value = dtselect.Rows[i]["Order_ID"].ToString(); grd_order.Rows[i].Cells[17].Value = dtselect.Rows[i]["Order_old_New"].ToString(); grd_order.Rows[i].Cells[18].Value = dtselect.Rows[i]["Delq_Status"].ToString(); if (!string.IsNullOrEmpty(grd_order.Rows[i].Cells[18].Value.ToString())) { if (grd_order.Rows[i].Cells[18].Value.ToString() == "1") { grd_order.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#ed3e3e"); } } } } else { grd_order.Visible = true; grd_order.Rows.Clear(); grd_order.DataSource = null; } //cPro.stopProgress(); } catch (Exception ex) { //Close Wait Form SplashScreenManager.CloseForm(false); MessageBox.Show("Error Occured Please Check With Administrator"); } finally { //Close Wait Form SplashScreenManager.CloseForm(false); } } }