void BoutonSuivantClick(object sender, System.EventArgs e) { arrayAttributs = new ArrayList(); for (int i = 0 ; i < table.Rows.Count-1; i++) { Attribut att = new Attribut(table.Rows[i].Cells[0].FormattedValue.ToString(), table.Rows[i].Cells[1].FormattedValue.ToString()); att.propTable = tableWizard1.nomTable; if (!table.Rows[i].Cells[2].FormattedValue.ToString().Equals("")) { att.propTaille = table.Rows[i].Cells[2].FormattedValue.ToString(); } if (!table.Rows[i].Cells[3].FormattedValue.ToString().Equals ("")){ att.propDefaultValue = table.Rows[i].Cells[3].FormattedValue.ToString(); } if (!table.Rows[i].Cells[4].FormattedValue.ToString().Equals(Boolean.FalseString)) { att.notNull = true; } if (!table.Rows[i].Cells[5].FormattedValue.ToString().Equals("")) { att.nomNotNull = table.Rows[i].Cells[5].FormattedValue.ToString(); } if (!table.Rows[i].Cells[6].FormattedValue.ToString().Equals(Boolean.FalseString)) { att.autoNotNull = true; } arrayAttributs.Add(att); Console.WriteLine(att.ToString()); } if (tableWizard3 == null) { tableWizard3 = new CreateTableWizard3(); tableWizard3.propTableWizard2 = this; tableWizard3.propTables = arrayTables; tableWizard3.propAttributs = arrayAttributs; tableWizard3.propListe = liste; tableWizard3.initialiser(); } this.Visible = false; tableWizard3.Visible = true; }
private void ConstruireContrainte(string ligne) { //check for primary key int posi = ligne.IndexOf("primary"); if (posi != -1) { PrimaryKey pk = new PrimaryKey("whateverXxX"); //penser a parser le nom de la contrainte ligne = ligne.Substring(posi); posi = ligne.IndexOf('('); ligne = ligne.Substring(posi); int posi2 = ligne.IndexOf(')'); // Console.Out.WriteLine(posi2); ligne = ligne.Substring(1, posi2-1); // Console.Out.WriteLine(ligne); //parser les attributs entre parenthèses posi = ligne.IndexOf(','); if (posi == -1) { ligne = ligne.Trim(); ligne = ligne.Trim('\t'); Attribut attr = new Attribut(ligne); ArrayList arr = new ArrayList(); arr.Add(attr); pk.attributs = arr; tempTable.PK = pk; } else { ArrayList arr = new ArrayList(); while (posi != -1) { string nomattr = ligne.Substring(0, posi); nomattr = nomattr.Trim(); nomattr = nomattr.Trim('\t'); nomattr = nomattr.Trim(','); Attribut attr = new Attribut(nomattr); arr.Add(attr); ligne = ligne.Substring(++posi); posi = ligne.IndexOf(','); Console.Out.WriteLine(posi); ligne = ligne.Trim(); ligne = ligne.Trim('\t'); ligne = ligne.Trim(','); Console.Out.WriteLine(ligne); } Attribut attr2 = new Attribut (ligne); arr.Add(attr2); for (int i= 0 ; i < arr.Count; i++) { Attribut temp = (Attribut) arr[i]; Console.Out.WriteLine("name: " + temp.propNom + " das"); } pk.attributs = arr; tempTable.PK = pk; } } }
public override string ToString() { if (boolCompleteCode) { string contenu = "\nCREATE TABLE " + this.nom + "\n("; for (int i = 0; i < arrayAttributs.Count; i++) { contenu += "\n\t"; Attribut att = (Attribut)arrayAttributs[i]; contenu += att.ToString(); contenu += ", "; } if (!pk.propCode.Equals("")) { contenu += "\n\t"; contenu += pk.propCode; contenu += ", "; } for (int i = 0; i < arrayFK.Count; i++) { contenu += "\n\t"; ForeignKey fktemp = (ForeignKey)arrayFK[i]; contenu += fktemp.propCode; contenu += ", "; } for (int i = 0; i < arrayCK.Count; i++) { contenu += "\n\t"; Check cktemp = (Check)arrayCK[i]; contenu += cktemp.propCode; contenu += ", "; } for (int i = 0; i < arrayUQ.Count; i++) { contenu += "\n\t"; Unique uqtemp = (Unique)arrayUQ[i]; contenu += uqtemp.propCode; contenu += ", "; } contenu = contenu.Substring(0, contenu.Length - 2); contenu += "\n);"; return(contenu); // // if (pk.nom == null && arrayFK.Count == 0 && arrayCK.Count == 0 && arrayUQ.Count == 0) { // for (int i = 0; i < arrayAttributs.Count; i++) { // contenu += "\n\t"; // Attribut att = (Attribut) arrayAttributs[i]; // contenu += att.ToString(); // contenu += ","; // } // contenu += "\n);"; // return contenu; // } else { // for (int i = 0; i < arrayAttributs.Count; i++) { // contenu += "\n\t"; // Attribut att = (Attribut) arrayAttributs[i]; // contenu += att.ToString(); // contenu += ","; // } // // if (pk.nom != null) { // contenu += code // } // // contenu += "\n);"; // return contenu; // } // return "listing okay"; } else { string contenu = "\nCREATE TABLE " + this.nom + "\n("; contenu += autoCode; return(contenu + ";"); } }
private void ConstruireAttribut(string ligne) { Attribut attr = null; // Console.Out.WriteLine(ligne); ligne = ligne.Replace(' ', '\t'); ligne = ligne.Trim('\t'); int posi = ligne.IndexOf('\t'); //nom string nom = ligne.Substring(0, posi); ligne = ligne.Substring(posi); ligne = ligne.Trim('\t'); //type string type = ""; string taille = ""; posi = ligne.IndexOf('('); if (posi == -1) { //pas de valeur pour le type posi = ligne.IndexOf('\t'); if (posi == -1) { type = ligne; } else { type = ligne.Substring(0, posi); } } else { type = ligne.Substring(0, posi); ligne = ligne.Substring(posi); ligne = ligne.Trim('\t'); //taille du type posi = ligne.IndexOf(')'); taille = ligne.Substring(1, posi-1); } attr = new Attribut(nom, type); attr.propTaille = taille; tempTable.attributs.Add(attr); // //s'il reste encore des trucs à lire sur la ligne // string nomnn = ""; //nom contrainte not null // string defval = ""; //valeur par défault // if (posi != -1) { // ligne = ligne.Substring(posi); // ligne = ligne.Trim('\t'); // // // // //vérifier nom contrainte not null // posi = ligne.IndexOf("constraint"); // if (posi == -1) { // //verifier not null // posi = ligne.IndexOf("null"); // if (posi != -1) { // attr.notNull = true; // } // } else { // int posi2 = ligne.IndexOf("not"); // nomnn = ligne.Substring(posi + "constraint".Length, posi2); // nomnn = nomnn.Trim('\t'); // } // } // Console.Out.WriteLine("Nom: " + nom); // Console.Out.WriteLine("Type: " + type); // Console.Out.WriteLine("Taille: " + taille); // Console.Out.WriteLine("Nomnn: " + nomnn); }