/// <summary> /// 显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnShowTables_Click(object sender, EventArgs e) { DataTable tb = null; Enumeration.DataBaseType type = (Enumeration.DataBaseType)cbxDataBase.SelectedIndex; //Generate gen = new Generate(type); if (type == Enumeration.DataBaseType.Oracle) { tb = new OracleInfo().DBTables(txtFilterTable.Text); } else if (type == Enumeration.DataBaseType.MySQL) { tb = new MySQLInfo().DBTables(txtFilterTable.Text); } else if (type == Enumeration.DataBaseType.MSSQL) { tb = new MSSQLInfo().DBTables(txtFilterTable.Text); } else if (type == Enumeration.DataBaseType.PostgreSQL) { tb = new PgInfo().DBTables(txtFilterTable.Text); } else { } this.dgvTables.DataSource = tb; //CheckAll(); }
/// <summary> /// 选获取表的主键 /// </summary> /// <param name="DBType"></param> /// <param name="dbTableName"></param> /// <returns></returns> public static List <string> GetPrimayKeys(Enumeration.DataBaseType DBType, string dbTableName) { List <string> keyList = null; if (DBType == Enumeration.DataBaseType.Oracle) { keyList = new OracleInfo().GetPrimayKeys(dbTableName); } else if (DBType == Enumeration.DataBaseType.MySQL) { keyList = new MySQLInfo().GetPrimayKeys(dbTableName); } else if (DBType == Enumeration.DataBaseType.MSSQL) { keyList = new MSSQLInfo().GetPrimayKeys(dbTableName); } else if (DBType == Enumeration.DataBaseType.PostgreSQL) { keyList = new PgInfo().GetPrimayKeys(dbTableName); } else { } for (int i = 0; i < keyList.Count(); i++) { keyList[i] = Words.reWriteWord(keyList[i]); } return(keyList); }
/// <summary> /// 获取表的注释 /// </summary> /// <param name="DBType"></param> /// <param name="dbTableName"></param> /// <returns></returns> public static string GetTableComments(Enumeration.DataBaseType DBType, string dbTableName) { string comment = null; if (DBType == Enumeration.DataBaseType.Oracle) { comment = new OracleInfo().TableComments(dbTableName); } else if (DBType == Enumeration.DataBaseType.MySQL) { comment = new MySQLInfo().TableComments(dbTableName); } else if (DBType == Enumeration.DataBaseType.MSSQL) { comment = new MSSQLInfo().TableComments(dbTableName); } else if (DBType == Enumeration.DataBaseType.PostgreSQL) { comment = new PgInfo().TableComments(dbTableName); } else { } return(comment); }
/// <summary> /// 选择数据库 /// </summary> /// <param name="DBType"></param> /// <param name="dbTableName"></param> /// <returns></returns> public static DataTable SelectColumnsByTableName(Enumeration.DataBaseType DBType, string dbTableName) { DataTable dtColumns = null; if (DBType == Enumeration.DataBaseType.Oracle) { dtColumns = new OracleInfo().getColumnsByTableName(dbTableName); } else if (DBType == Enumeration.DataBaseType.MySQL) { dtColumns = new MySQLInfo().getColumnsByTableName(dbTableName); } else if (DBType == Enumeration.DataBaseType.MSSQL) { dtColumns = new MSSQLInfo().getColumnsByTableName(dbTableName); } else if (DBType == Enumeration.DataBaseType.PostgreSQL) { dtColumns = new PgInfo().getColumnsByTableName(dbTableName); } else { } return(dtColumns); }
private void dgvTables_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1 || e.ColumnIndex == -1) { return; } //表中字段 DataTable dtColumns = null; if (cbxDataBase.SelectedIndex == 0) { dtColumns = new OracleInfo().getColumnsByTableName(this.dgvTables.Rows[e.RowIndex].Cells["Table_Name"].Value.ToString()); } else if (cbxDataBase.SelectedIndex == 1) { dtColumns = new MySQLInfo().getColumnsByTableName(this.dgvTables.Rows[e.RowIndex].Cells["Table_Name"].Value.ToString()); } else if (cbxDataBase.SelectedIndex == 2) { dtColumns = new MSSQLInfo().getColumnsByTableName(this.dgvTables.Rows[e.RowIndex].Cells["Table_Name"].Value.ToString()); } else if (cbxDataBase.SelectedIndex == 3) { dtColumns = new PgInfo().getColumnsByTableName(this.dgvTables.Rows[e.RowIndex].Cells["Table_Name"].Value.ToString()); } else { } dtColumns.TableName = "Columns"; createCorrespondingXmlWhenNotExist(); //显示骆驼表示法列名 for (int i = 0; i < dtColumns.Rows.Count; i++) { string name = dtColumns.Rows[i]["Column_Name"].ToString(); //if (dic.ContainsKey(name)) //{ // dtColumns.Rows[i]["CamelName"] = dic[name]; //} dtColumns.Rows[i]["Camel_Name"] = PublicHelper.GetCamelName(name); } dtColumns.AcceptChanges(); this.dgvColumns.DataSource = dtColumns; //this.dgvColumns.AutoResizeColumns(); }