/// <summary> /// Copies table with help of factory /// </summary> /// <param name="table">The table</param> /// <param name="factoty">The factory</param> /// <returns>Table copy</returns> public static ITable Copy(ITable table, IDataSetDesktopFactory factoty) { ITable t = factoty.Table; t.Name = table.Name; t.X = table.X; t.Y = table.Y; foreach (string name in table.Columns.Keys) { IColumn c = table.Columns[name]; IColumn col = factoty.Column; t.Columns[name] = col; col.Column = c.Column; col.IsMarked = c.IsMarked; col.Table = t; col.Type = c.Type; col.IsNullable = c.IsNullable; col.IsNull = c.IsNull; col.Modifier = c.Modifier; col.Length = c.Length; col.Value = c.Value; col.Name = name; } return(t); }
/// <summary> /// Creates table from DataTable prototype /// </summary> /// <param name="dataTable">The prototype</param> /// <param name="factory">The factory</param> /// <returns>The table</returns> public static ITable Create(DataTable dataTable, IDataSetDesktopFactory factory) { ITable table = factory.Table; table.Name = dataTable.TableName; table.Table = dataTable; foreach (DataColumn col in dataTable.Columns) { IColumn c = factory.Column; string name = col.ColumnName; c.Column = col; c.Table = table; c.Type = col.DataType + ""; c.IsNullable = col.AllowDBNull; try { c.Length = col.MaxLength; } catch (Exception ex) { ex.ShowError(10); } c.Name = name; table.Columns[name] = c; } return(table); }
/// <summary> /// Constructor /// </summary> /// <param name="desktop">Desktop</param> /// <param name="factory">Desktop facr\tory</param> /// <param name="dataFactory">Data set factorty</param> /// <param name="connectionString">Connection string</param> public FormDataSet(IDataSetDesktop desktop, IDataSetDesktopFactory factory, IDataSetFactory dataFactory, string connectionString) { InitializeComponent(); this.connectionString = connectionString; this.dataFactory = dataFactory; ResourceService.Resources.LoadControlResources(this, DataSetService.Forms.Utils.ControlUtilites.Resources); this.factory = factory; if (desktop == null) { createDesktop(); } else { this.desktop = desktop; } try { createPanel(); } catch (Exception) { } }
/// <summary> /// Creates desktop from prototype /// </summary> /// <param name="dataSet">Prototype</param> /// <param name="factory">Factory</param> /// <returns>Desktop</returns> public static IDataSetDesktop Create(DataSet dataSet, IDataSetDesktopFactory factory) { IDataSetDesktop d = factory.Desktop; foreach (DataTable table in dataSet.Tables) { ITable t = Create(table, factory); d.Tables[t.Name] = t; t.Desktop = d; } return(d); }
/// <summary> /// Copies desktop with help of factory /// </summary> /// <param name="desktop">The desktop</param> /// <param name="factory">The factory</param> /// <returns>Desktop copy</returns> public static IDataSetDesktop Copy(IDataSetDesktop desktop, IDataSetDesktopFactory factory) { IDataSetDesktop d = factory.Desktop; Dictionary <string, Dictionary <string, IColumn> > dictionary = new Dictionary <string, Dictionary <string, IColumn> >(); foreach (string name in desktop.Tables.Keys) { ITable t = Copy(desktop.Tables[name], factory); d.Tables[name] = t; t.Desktop = d; } foreach (ITable t in d.Tables.Values) { Dictionary <string, IColumn> dic = new Dictionary <string, IColumn>(); dictionary[t.Name] = dic; foreach (IColumn c in t.Columns.Values) { dic[c.Name] = c; } } foreach (ILink link in desktop.Links) { ILink l = factory.Link; l.Desktop = d; l.IsMarked = link.IsMarked; l.SourceTable = link.SourceTable; l.TargetTable = link.TargetTable; l.SourceColumn = link.SourceColumn; l.TargetColumn = link.TargetColumn; l.Source = dictionary[l.SourceTable][l.SourceColumn]; l.Target = dictionary[l.TargetTable][l.TargetColumn]; if (!d.Links.Contains(l)) { d.Links.Add(l); } } return(d); }
/// <summary> /// Copies itfelf /// </summary> /// <param name="factory">Fasctory</param> /// <returns>The copy</returns> public IDataSetDesktop Save(IDataSetDesktopFactory factory) { return(factory.Copy(this)); }