Learning Employee Directory: How to add a field to employee data?
Let’s say you want to modify Employee Directory for your own company and you want to add another filed (fax) to the employee data. How to do this?
In EmployeePanelDetail.mxml, add the following block.
<!-- fax -->
<mx:HBox id="faxBox" width="100%" verticalAlign="top" horizontalGap="4">
<mx:Canvas width="100">
<mx:Label right="0" text="Fax:" styleName="dataPanelLabel" />
</mx:Canvas>
<mx:Text text="{ employee.fax }" styleName="dataPanelText" selectable="true" width="165" />
</mx:HBox>
In Employee.as, add
/** fax **/ public var fax : String;
In EmployeeCSVParser.as, add
employee.fax = (itemArr[15] != '' ? itemArr[15]:null);
In InsertEmployeeDataCommand.as, add fax column
stmt.text = "INSERT INTO employee ('id', 'firstName', 'lastName', 'displayName', 'title', 'department', 'managerId', 'email', " +
"'phone', 'phoneExtension', 'fax', 'cellPhone', 'deskLocation', 'location', 'city', 'state', 'postalCode', 'countryCode') " +
" VALUES (:id, :firstName, :lastName, :displayName, :title, :department, :managerId, :email," +
" :phone, :phoneExtension, :fax, :cellPhone, :deskLocation, :location, :city, :state, :postalCode, :countryCode);";
stmt.parameters[":fax"] = employee.fax ;
In InitDatabaseCommand.as, change
var stmtText : String = "CREATE TABLE employee( id TEXT, firstName TEXT, lastName TEXT, displayName TEXT, title TEXT, department TEXT" + ", managerId TEXT, email TEXT, phone TEXT, phoneExtension TEXT, fax TEXT, cellPhone TEXT, deskLocation TEXT, " + " location TEXT, city TEXT, state TEXT, postalCode TEXT, countryCode TEXT )";
The sample data are in employee.csv. So append another column in this file. In this column, fill in the fax info for every employee.
Then compress employee.csv to employee.csv.zip; replacing the original employee.csv.zip in samplehtdocs under src.
Then clean your project (removing contents from folder bin-debug).
Clean the old data in C:\Documents and Settings\Xu Cui\Application Data\employeedirectory\Local Store (change Xu Cui to your own directory)
Build and run your application. It will be fine.



