public EIBTable() { EIBTableConnector tableConnector = new EIBTableConnector(); tableConnector.AssociateMarkUpandDown(this); tableConnector.InitiateSettings(EIBFormDesigner.UIEventManager.form.currentBaseWindow.baseFrame); isMouseUp = true; }
//Deserialize individual base windows and there child control public static void DeserializeWindowXML(string fileName, Control baseFrame, XmlNode parentXMLNode) { DataSet dataset = new DataSet(); int nextTop = 0, nextLeft = 0; int maxHeight = 0, maxWidth = 0; int ParentWidth; Dictionary <string, EIBTable> listTable = new Dictionary <string, EIBTable>(); try { ParentWidth = baseFrame.Width; // disabling re-drawing of treeview till all nodes are added baseFrame.SuspendLayout(); fileName = fileName + ".xml"; string datasetName = System.IO.Path.GetFileNameWithoutExtension(fileName); List <string> M2MList = new List <string>(); dataset = DatabaseXMLServices.ReadSchema(datasetName, fileName, M2MList); //dataset.ReadXml(fileName); baseFrame.Controls.Clear(); ((BaseWindow)baseFrame.Parent).DatabaseDataSet = dataset; foreach (DataTable table in dataset.Tables) { EIBTable.counter++; EIBTable newNode = new EIBTable(); newNode.TableData = table; newNode.Height = 160; newNode.Width = 200; newNode.DatabaseDataSet = dataset; newNode.Name = table.TableName; listTable.Add(newNode.Name, newNode); newNode.ControlName = table.TableName; newNode.tableName.Text = table.TableName; if (M2MList.Contains(table.TableName)) { newNode.M2M = true; } else { newNode.M2M = false; } newNode.Top = nextTop; newNode.Left = nextLeft; UpdateControlProperties(newNode); newNode.AutoSize = false; baseFrame.Controls.Add(newNode); if (newNode.Height > maxHeight) { maxHeight = newNode.Height; } if (newNode.Width > maxWidth) { maxWidth = newNode.Width; } if ((nextLeft + newNode.Width + maxWidth) >= ParentWidth) { nextTop += maxHeight; nextLeft = 0; } else { nextLeft += newNode.Width; } foreach (DataColumn column in table.Columns) { ListViewItem lvItem = new ListViewItem(column.ColumnName); if (column.DataType.Name == typeof(string).Name) { int iCap; bool isVarChar = Int32.TryParse(column.Caption, out iCap); if (isVarChar) { lvItem.SubItems.Add(column.DataType.Name); } else { lvItem.SubItems.Add(Designer.Database.DatabaseConstants.LongTextType); } } else { lvItem.SubItems.Add(column.DataType.Name); } string autoIncrement = null; if (column.AutoIncrement) { autoIncrement = "Yes"; } else { autoIncrement = "No"; } lvItem.SubItems.Add(autoIncrement); string uniqueKey = null; if (column.Unique) { uniqueKey = "Yes"; } else { uniqueKey = "No"; } lvItem.SubItems.Add(uniqueKey); int iCaption; if (column.Caption != null && (!column.Caption.Trim().Equals("")) && Int32.TryParse(column.Caption, out iCaption)) { lvItem.SubItems.Add(column.Caption); } else { lvItem.SubItems.Add(""); } if (column.Unique) { lvItem.SubItems.Add("Not Null"); } else { lvItem.SubItems.Add((column.AllowDBNull ? "Null" : "Not Null")); } newNode.lvDatabase.Items.Add(lvItem); } } foreach (DataRelation relation in dataset.Relations) { EIBTableConnector tableConnector = new EIBTableConnector(); tableConnector.InitiateSettings((EIBPanel)baseFrame); tableConnector.Mark1 = (EIBTable)listTable[relation.ParentTable.TableName]; tableConnector.Mark2 = (EIBTable)listTable[relation.ChildTable.TableName]; tableConnector.createLine(); baseFrame.Controls.Add(tableConnector); } } catch (FileNotFoundException) { MessageBox.Show("Basewindow.xml not Found"); } catch (XmlException) { MessageBox.Show("DataPattern xml is changed."); } finally { // enabling redrawing of treeview after all nodes are added baseFrame.ResumeLayout(); baseFrame.Invalidate(); } }
//Deserialize individual base windows and there child control public static void DeserializeWindowXML(string fileName, Control baseFrame, XmlNode parentXMLNode) { DataSet dataset = new DataSet(); int nextTop = 0, nextLeft = 0; int maxHeight = 0, maxWidth = 0; int ParentWidth; Dictionary<string, EIBTable> listTable = new Dictionary<string, EIBTable>(); try { ParentWidth = baseFrame.Width; // disabling re-drawing of treeview till all nodes are added baseFrame.SuspendLayout(); fileName = fileName + ".xml"; string datasetName = System.IO.Path.GetFileNameWithoutExtension(fileName); List<string> M2MList = new List<string>(); dataset = DatabaseXMLServices.ReadSchema(datasetName, fileName,M2MList); //dataset.ReadXml(fileName); baseFrame.Controls.Clear(); ((BaseWindow)baseFrame.Parent).DatabaseDataSet = dataset; foreach (DataTable table in dataset.Tables) { EIBTable.counter++; EIBTable newNode = new EIBTable(); newNode.TableData = table; newNode.Height = 160; newNode.Width = 200; newNode.DatabaseDataSet = dataset; newNode.Name = table.TableName; listTable.Add(newNode.Name, newNode); newNode.ControlName = table.TableName; newNode.tableName.Text = table.TableName; if (M2MList.Contains(table.TableName)) { newNode.M2M = true; } else { newNode.M2M = false; } newNode.Top = nextTop; newNode.Left = nextLeft; UpdateControlProperties(newNode); newNode.AutoSize = false; baseFrame.Controls.Add(newNode); if (newNode.Height > maxHeight) { maxHeight = newNode.Height; } if (newNode.Width > maxWidth) { maxWidth = newNode.Width; } if ((nextLeft + newNode.Width + maxWidth) >= ParentWidth) { nextTop += maxHeight; nextLeft = 0; } else { nextLeft += newNode.Width; } foreach (DataColumn column in table.Columns) { ListViewItem lvItem = new ListViewItem(column.ColumnName); if (column.DataType.Name == typeof(string).Name) { int iCap; bool isVarChar = Int32.TryParse(column.Caption,out iCap); if (isVarChar) lvItem.SubItems.Add(column.DataType.Name); else lvItem.SubItems.Add(Designer.Database.DatabaseConstants.LongTextType); } else { lvItem.SubItems.Add(column.DataType.Name); } string autoIncrement = null; if (column.AutoIncrement) { autoIncrement = "Yes"; } else { autoIncrement = "No"; } lvItem.SubItems.Add(autoIncrement); string uniqueKey = null; if (column.Unique) { uniqueKey = "Yes"; } else { uniqueKey = "No"; } lvItem.SubItems.Add(uniqueKey); int iCaption; if (column.Caption != null && (!column.Caption.Trim().Equals("")) && Int32.TryParse(column.Caption,out iCaption)) { lvItem.SubItems.Add(column.Caption); } else { lvItem.SubItems.Add(""); } if (column.Unique) { lvItem.SubItems.Add("Not Null"); } else { lvItem.SubItems.Add((column.AllowDBNull ? "Null" : "Not Null")); } newNode.lvDatabase.Items.Add(lvItem); } } foreach (DataRelation relation in dataset.Relations) { EIBTableConnector tableConnector = new EIBTableConnector(); tableConnector.InitiateSettings((EIBPanel)baseFrame); tableConnector.Mark1 = (EIBTable)listTable[relation.ParentTable.TableName]; tableConnector.Mark2 = (EIBTable)listTable[relation.ChildTable.TableName]; tableConnector.createLine(); baseFrame.Controls.Add(tableConnector); } } catch (FileNotFoundException) { MessageBox.Show("Basewindow.xml not Found"); } catch (XmlException) { MessageBox.Show("DataPattern xml is changed."); } finally { // enabling redrawing of treeview after all nodes are added baseFrame.ResumeLayout(); baseFrame.Invalidate(); } }
private void Done_Click(object sender, EventArgs e) { this.eibRelation1.errorLabel.Text = ""; if (this.eibRelation1.relationName.Text.Trim().Equals("")) { this.eibRelation1.errorLabel.Text = "RelationShip Name can not be empty"; return; } if (this.eibRelation1.firstTableName.SelectedItem == null) { this.eibRelation1.errorLabel.Text = "Select First Table"; return; } if (this.eibRelation1.firstTableFields.SelectedItem == null) { this.eibRelation1.errorLabel.Text = "Select First Table Fields"; return; } if (this.eibRelation1.secondTableName.SelectedItem == null) { this.eibRelation1.errorLabel.Text = "Select Second Table"; return; } if (this.eibRelation1.secondTableFields.SelectedItem == null) { this.eibRelation1.errorLabel.Text = "Select Second Table Fields"; return; } Regex regex = new Regex("[a-zA-Z_][a-zA-Z0-9_]*"); Match match = regex.Match(this.eibRelation1.relationName.Text); if (!match.Success) { MessageBox.Show("Wrong relationship name."); this.eibRelation1.relationName.SelectAll(); this.eibRelation1.relationName.Focus(); return; } try { dataRelation = new DataRelation(this.eibRelation1.relationName.Text, databaseDataSet.Tables[this.eibRelation1.firstTableName.SelectedItem.ToString()].Columns[this.eibRelation1.firstTableFields.SelectedItem.ToString()], databaseDataSet.Tables[this.eibRelation1.secondTableName.SelectedItem.ToString()].Columns[this.eibRelation1.secondTableFields.SelectedItem.ToString()]); if (dataRelation != null) { databaseDataSet.Relations.Add(dataRelation); //EIBLabel relationLabel = new EIBLabel(); //relationLabel.InitiateSettings(null); //relationLabel.BorderStyle = BorderStyle.FixedSingle; //relationLabel.Text = dataRelation.RelationName; EIBTableConnector tableConnector = new EIBTableConnector(); tableConnector.InitiateSettings(panelControl); tableConnector.Mark1 = (EIBTable)panelControl.Controls[this.eibRelation1.firstTableName.SelectedItem.ToString()]; tableConnector.Mark2 = (EIBTable)panelControl.Controls[this.eibRelation1.secondTableName.SelectedItem.ToString()]; tableConnector.createLine(); //panelControl.Controls.Add(relationLabel); panelControl.Controls.Add(tableConnector); } } catch (Exception ex) { this.eibRelation1.errorLabel.Text = ex.Message; } if (this.eibRelation1.errorLabel.Text.Trim().Equals("")) { this.Close(); } }
private void Done_Click(object sender, EventArgs e) { this.eibRelation1.errorLabel.Text = ""; if (this.eibRelation1.relationName.Text.Trim().Equals("")) { this.eibRelation1.errorLabel.Text = "RelationShip Name can not be empty"; return; } if (this.eibRelation1.firstTableName.SelectedItem == null ) { this.eibRelation1.errorLabel.Text = "Select First Table"; return; } if (this.eibRelation1.firstTableFields.SelectedItem == null) { this.eibRelation1.errorLabel.Text = "Select First Table Fields"; return; } if (this.eibRelation1.secondTableName.SelectedItem == null) { this.eibRelation1.errorLabel.Text = "Select Second Table"; return; } if (this.eibRelation1.secondTableFields.SelectedItem == null) { this.eibRelation1.errorLabel.Text = "Select Second Table Fields"; return; } Regex regex = new Regex("[a-zA-Z_][a-zA-Z0-9_]*"); Match match = regex.Match(this.eibRelation1.relationName.Text); if (!match.Success) { MessageBox.Show("Wrong relationship name."); this.eibRelation1.relationName.SelectAll(); this.eibRelation1.relationName.Focus(); return; } try { dataRelation = new DataRelation(this.eibRelation1.relationName.Text, databaseDataSet.Tables[this.eibRelation1.firstTableName.SelectedItem.ToString()].Columns[this.eibRelation1.firstTableFields.SelectedItem.ToString()], databaseDataSet.Tables[this.eibRelation1.secondTableName.SelectedItem.ToString()].Columns[this.eibRelation1.secondTableFields.SelectedItem.ToString()]); if (dataRelation != null) { databaseDataSet.Relations.Add(dataRelation); //EIBLabel relationLabel = new EIBLabel(); //relationLabel.InitiateSettings(null); //relationLabel.BorderStyle = BorderStyle.FixedSingle; //relationLabel.Text = dataRelation.RelationName; EIBTableConnector tableConnector = new EIBTableConnector(); tableConnector.InitiateSettings(panelControl); tableConnector.Mark1 = (EIBTable)panelControl.Controls[this.eibRelation1.firstTableName.SelectedItem.ToString()]; tableConnector.Mark2 = (EIBTable)panelControl.Controls[this.eibRelation1.secondTableName.SelectedItem.ToString()]; tableConnector.createLine(); //panelControl.Controls.Add(relationLabel); panelControl.Controls.Add(tableConnector); } } catch (Exception ex) { this.eibRelation1.errorLabel.Text = ex.Message; } if (this.eibRelation1.errorLabel.Text.Trim().Equals("")) { this.Close(); } }