/// <summary> /// Load information /// </summary> public MethodResult loadTables () { MethodResult result = new MethodResult (); SqlConnection connection = getConnection (); // Check Connection if (null == connection) result.status = MethodResult.Result.failed; else { // Server ready? if (!BaseDAL.DBaseHelper.IsServerConnected (connection)) result.status = MethodResult.Result.failed; else { if (null == tables) tables = new List<Table> (); // Create new instance of list else clearTables (); // Clear current tables list #region Load tables information // Generate command string cmd = string.Format (Resources.Database.GetTables, getName ()); // Run CommandResult dRes = BaseDAL.DBaseHelper.executeCommand (BaseDAL.Base.EnumExecuteType.reader, connection, cmd, true); if (dRes.status == BaseDAL.Base.EnumCommandStatus.success) { if (dRes.model is DataTable) { DataTable table = dRes.model as DataTable; foreach (DataRow row in table.Rows) { string tableName; Table newTable; tableName = row["TABLE_NAME"].ToString (); newTable = new Table (this, tableName, getAutoload ()); tables.Add (newTable); } } result.status = MethodResult.Result.success; } else result.status = MethodResult.Result.failed; #endregion } } return result; }
/// <summary> /// Set parent /// </summary> /// <param name="value"></param> public void setParent (Table value) { parent = value; }
/// <summary> /// Refresh Field List /// </summary> void refreshFieldList () { if ((currentDB != null) && (null != tablesGrid.CurrentRow)) { string tableName = tablesGrid.CurrentRow.Cells["Table"].Value.ToString (); currentTable = currentDB[tableName]; currentTable.loadFields (); // Show in grid if (fieldsGrid.DataSource is DataTable) ((DataTable)fieldsGrid.DataSource).Dispose (); fieldsGrid.DataSource = fieldsToDatatable (currentTable.getFields ()); pageTabControl.SelectedTab = fieldsTabPage; // Change Tab } else MessageBox.Show (this, "Please select a table", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
/// <summary> /// Constructor /// </summary> /// <param name="parent"></param> /// <param name="name"></param> public Field (Table parent, string name, bool autoLoad = true) : base (C_Type, name, autoLoad) { if (null == parent) throw new NullReferenceException ("Parent is null!"); setParent (parent); }