Esempio n. 1
0
 public Essenishial(ErDiagram diagram, ErEssence essence, string Name)
 {
     InitializeComponent();
     dataGridView1.ColumnCount = 3;
     dataGridView1.Columns[0].HeaderText = "Key Value";
     dataGridView1.Columns[1].HeaderText = "Field Name";
     dataGridView1.Columns[2].HeaderText = "Field Type";
     targetEssence = essence;
     targetDiagram = diagram;
     EssenishialName = Name;
     targetEssence.Name = Name;
 }
Esempio n. 2
0
        public static void Export(ErDiagram diagram, string server, string user, string port, string pass)
        {
            string connStr = "server="+server+";user="******";port="+port+";password="******";";
            MySqlConnection conn = new MySqlConnection(connStr);
            conn.Open();
            string s0 = "CREATE DATABASE IF NOT EXISTS `" + diagram.Name + "`;";
            MySqlCommand cmd = new MySqlCommand(s0, conn);
            cmd.ExecuteNonQuery();
            conn.Close();
            string connStrDat = connStr + "database=" + diagram.Name + ";";
            conn = new MySqlConnection(connStrDat);
            conn.Open();
            MessageBox.Show(conn.Database);

            for (int i = 0; i < diagram.Essences.Count; i++)
            {
                ErEssence essence = diagram.Essences[i];
                string createTableString =  "CREATE TABLE "+essence.Name.Replace(" ","")+" (";
                for (int j = 0; j < essence.Fields.Count - 1; j++)
                {
                    createTableString += essence.Fields[j].Name + " " + essence.Fields[j].Type + ", ";
                }
                if(essence.Fields.Count-1>-1)
                    createTableString += essence.Fields[essence.Fields.Count - 1].Name + " "
                        + essence.Fields[essence.Fields.Count - 1].Type;
                createTableString += ");";
                if (essence.Keys.Count > 0)
                {
                    string Keys = "primary key (";
                    for (int j = 0; j < essence.Keys.Count; j++)
                    {
                        Keys += essence.Fields[essence.Keys[j]].Name + ", ";
                    }
                    Keys = Keys.Remove(Keys.Length - 2);
                    Keys += ") ";
                    int insertIndex = createTableString.IndexOf(")");
                    createTableString = createTableString.Insert(insertIndex, ", "+Keys);
                }
                cmd = new MySqlCommand(createTableString,conn);
                cmd.ExecuteNonQuery();
            }

            conn.Close();
        }
Esempio n. 3
0
        public RelationshipView(Control.ControlCollection collection, Essenishial one, Essenishial two, 
            ErRelationshipConnectType firsType, ErRelationshipConnectType secType,
            ErDiagram Diagram
            )
        {
            targetDiagram = Diagram;
            ErConnectEssencePair firstPair = new ErConnectEssencePair(one.Essence, firsType);
            ErConnectEssencePair secondPair = new ErConnectEssencePair(two.Essence, secType);
            targetRelationship = new ErRelationship(firstPair, secondPair);
            targetDiagram.AddRelationship(targetRelationship);

            oneEssenishial = one;
            twoEssenishial = two;
            one.OneOrTwoList.Add(1);
            two.OneOrTwoList.Add(2);
            OnePoint = one.GetCentralPoint();
            TwoPoint = two.GetCentralPoint();
            one.RelationshipViewList.Add(this);
            two.RelationshipViewList.Add(this);

            MiddlePoint = new Point((OnePoint.X + TwoPoint.X) / 2, (OnePoint.Y + TwoPoint.Y) / 2);
            containerOne = new ShapeContainer();
            OneToMiddleLine = new LineShape(OnePoint.X, OnePoint.Y, MiddlePoint.X, MiddlePoint.Y);
            OneToMiddleLine.DoubleClick += OpenRelationshipEditorWindow;
            OneToMiddleLine.BorderWidth = 3;
            OneToMiddleLine.BorderStyle = GetLineStyle(firsType.ModalType);
            MiddelToTwoLine = new LineShape(MiddlePoint.X, MiddlePoint.Y, TwoPoint.X, TwoPoint.Y);
            MiddelToTwoLine.BorderWidth = 3;
            MiddelToTwoLine.DoubleClick += OpenRelationshipEditorWindow;
            MiddelToTwoLine.BorderStyle = GetLineStyle(secType.ModalType);

            containerOne.Shapes.Add(OneToMiddleLine);
            containerOne.Shapes.Add(MiddelToTwoLine);
            //shape.
            collection.Add(containerOne);
        }