public Address(Field street1, Field street2, Field city, Field state, Field zip, Field contact) { street1Field = street1; street2Field = street2; cityField = city; stateField = state; zipField = zip; contactField = contact; fieldMode = true; }
//Factory that returns a TableWrapper object. Keeps track of objects that have been created already // and will return the old object if it exists //NOTE: This may not be threadsafe, if more than one thread tries to access the same Wrapper // REALLY IMPORTANT NOTE: This function needs to return a COPY of the cached Wrapper - Need to change. /* public static TableWrapper GetTableWrapper(string TableName) { TableWrapper returnWrapper; if (TableWrapperCache.TryGetValue(TableName, out returnWrapper)) { return returnWrapper; } else { returnWrapper = new TableWrapper(TableName); TableWrapperCache.Add(TableName, returnWrapper); //Save it for later return returnWrapper; } } */ //WrapField - This function puts the delimiters around the field value // based on the type of database we are connected to. Also escapes any values // for safety public static string WrapField(Field field) { string s; //TODO - Add differences based on type of database if (null == field.Value) { return "null"; } switch (field.DataType) { case "System.String": s = "'" + WWH.QuoteString(field.Value.ToString()) + "'"; break; case "System.DateTime": s = "#" + field.Value.ToString() + "#"; break; default: s = field.Value.ToString(); break; } return s; }
//Constructor public TableWrapper(string Name) { m_name = Name; m_fields = new Dictionary<string,Field>(); //Find the fields DataTable lTable = WWD.GetTableSchema(Name); foreach (DataRow d in lTable.Rows) { int val; string fName; string fDataType; int fLength; bool fIsKey; fName = d["ColumnName"].ToString(); fDataType = d["DataType"].ToString(); if (Int32.TryParse(d["ColumnSize"].ToString(), out val)) { fLength = val; } else { fLength = 0; } fIsKey = (bool)d["IsKey"]; Field f = new Field(fName, fDataType, fLength, fIsKey) { Value = "", Changed = false }; Fields.Add(f.Name, f); //Add it to the collection } lTable.Dispose(); }