Main Page | Alphabetical List | Class List | File List | Class Members | File Members

generatortool.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Ko Kok Leong                                    *
00003  *   [email protected]                                           *
00004  *                                                                         *
00005  *   Final Year Project: FastApp                                           *
00006  *   File Name: generatortool.h                                            *
00007  ***************************************************************************/
00008 #include "generatortool.h"
00009 
00010 BEGIN_EVENT_TABLE( GeneratorToolFrame, wxFrame )
00011         EVT_MENU( Menu_File_Quit, GeneratorToolFrame::OnQuit )
00012         EVT_MENU( Menu_File_About, GeneratorToolFrame::OnAbout )
00013         EVT_BUTTON(ID_BTN_LOGIN, GeneratorToolFrame::OnButtonLogin)
00014         EVT_TEXT_ENTER(ID_TCTRL_PW,GeneratorToolFrame::OnButtonLogin) 
00015         EVT_BUTTON(ID_BTN_LOGOUT, GeneratorToolFrame::OnButtonLogout)
00016         //Application Screen Events
00017         EVT_LISTBOX_DCLICK(ID_LB_APPLIST, GeneratorToolFrame::OnButtonLaunch) 
00018         EVT_BUTTON(ID_BTN_LAUNCH, GeneratorToolFrame::OnButtonLaunch)
00019 END_EVENT_TABLE()
00020 
00021 
00022 IMPLEMENT_APP(GeneratorToolapp)
00023 
00024 wxString myString;
00025 wxTextValidator NumericValidator = wxTextValidator(wxFILTER_NUMERIC, &myString);
00026 wxTextValidator AlphanumericValidator = wxTextValidator(wxFILTER_ALPHANUMERIC, &myString);
00027 wxTextValidator ASCIIValidator= wxTextValidator(wxFILTER_ASCII, &myString);
00028 wxHashTable formtable = wxHashTable(wxKEY_INTEGER);
00029 wxHashTable objecttable = wxHashTable(wxKEY_INTEGER);
00030 
00031 //! Initialises the Application Window.
00032 //! This method of GeneratorToolapp initialises an instance of the GeneratorToolFrame class for the application.
00033 
00034 bool 
00035 GeneratorToolapp::OnInit()
00036 {
00037         GeneratorToolFrame *frame = new GeneratorToolFrame( wxT( "FastApp Generator Tool" ), wxPoint(50,50), wxSize(450,356), wxTAB_TRAVERSAL|wxRESIZE_BORDER | wxRESIZE_BOX | wxMAXIMIZE_BOX,"Main Frame");
00038         frame->Centre(wxBOTH);
00039         frame->Show(TRUE);
00040         SetTopWindow(frame);
00041         return TRUE;
00042 } 
00043 
00044 //! Constructor. 
00045 /*!     Initialises the Window of the FastApp Binary Client with a login screen.
00046         
00047         - title = label/ title of window
00048         - pos = pixel position of the window referenced from top left of screen (0,0). e.g. wxPoint(200,300)
00049         - size = size of the window to be displayed
00050         - style = style of the window. See the wxWidgets documentation. e.g. wxMAXIMISE 
00051         - name = identifying name of the frame for wxWidgets
00052         
00053         Also see GeneratorToolFrame::~GeneratorToolFrame()
00054 */
00055 GeneratorToolFrame::GeneratorToolFrame( const wxString& title, const wxPoint& pos, const wxSize& size, long style,const wxString& name )
00056         : wxFrame((wxFrame *)NULL, -1, title, pos, size,style,name)
00057 {
00058         //Menu And StatusBar
00059         wxMenu *menuFile = new wxMenu;
00060         menuFile->Append( Menu_File_About, wxT( "&About..." ) );
00061         menuFile->AppendSeparator();
00062         menuFile->Append( Menu_File_Quit, wxT( "E&xit" ) );
00063         wxMenuBar *menuBar = new wxMenuBar;
00064         menuBar->Append( menuFile, wxT( "&File" ) );
00065         SetMenuBar( menuBar );
00066         CreateStatusBar();
00067         SetStatusText( wxT( "FastApp Generator Tool (c) Ko Kok Leong" ) );
00068         //Login Fields
00069         loginStaticText = new wxStaticText(this, -1, "Login Screen");
00070         dummy = new wxStaticText(this, -1, "");
00071         nameStaticText = new wxStaticText(this, -1, "Username:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT|wxALIGN_CENTRE);
00072         passwordStaticText = new wxStaticText(this, -1, "Password:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
00073         usernameTextCtrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB, AlphanumericValidator);
00074         passwordTextCtrl = new wxTextCtrl(this, ID_TCTRL_PW, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB |wxTE_PROCESS_ENTER|wxTE_PASSWORD);
00075         //Login Button
00076         loginButton = new wxButton( this, ID_BTN_LOGIN, wxT("Login"),wxDefaultPosition,wxSize(80,30));
00077         //Adjusting the look and feel
00078         set_properties();
00079         do_layout();
00080 }
00081 
00082 //* Destructor.
00083 /**     
00084 
00085 Destructor of GeneratorToolFrame
00086 */
00087 GeneratorToolFrame::~GeneratorToolFrame()
00088 {
00089         delete [] arrAppname;
00090         delete [] arrAppid;
00091         delete [] arrSdbid;
00092         delete [] arrAppformid;
00093 }
00094 
00095 //!     Sets the propeties of the frame.
00096 /*!
00097         It is a corner for programmer to do simple configuration of the controls within the frame. 
00098         In this function, many miscellaneous configurations of the frame's controls are coded here.
00099 */
00100 void 
00101 GeneratorToolFrame::set_properties()
00102 {
00103         loginStaticText->SetSize(wxSize(100, 80));
00104         loginStaticText->SetFont(wxFont(14, wxSWISS, wxNORMAL, wxNORMAL, 1, ""));
00105         loginStaticText->SetToolTip("Enter User Login Name and Password");
00106         nameStaticText->SetSize(wxSize(100, 50));
00107         nameStaticText->SetFont(wxFont(13, wxSWISS, wxNORMAL, wxNORMAL, 0, ""));
00108         usernameTextCtrl->SetSize(wxSize(150, 25));
00109         usernameTextCtrl->SetToolTip("Enter User Name Here");
00110         usernameTextCtrl->SetFocus();
00111         usernameTextCtrl->SetValue("Developer");
00112         passwordStaticText->SetSize(wxSize(100, 25));
00113         passwordStaticText->SetFont(wxFont(13, wxSWISS, wxNORMAL, wxNORMAL, 0, ""));
00114         passwordTextCtrl->SetSize(wxSize(150, 25));
00115         passwordTextCtrl->SetToolTip("Enter Password Here");
00116         passwordTextCtrl->SetValue("1");
00117 }
00118 
00119 //!     Sets the layout of the frame.
00120 /*!     
00121 *       It is a corner for the programmer to do easy adjustments of the Sizers and the layout of the frame.
00122 */
00123 
00124 void 
00125 GeneratorToolFrame::do_layout()
00126 {
00127         frameSizer = new wxBoxSizer(wxVERTICAL);
00128         grid_sizer_1 = new wxFlexGridSizer(4, 2, 10, 5);
00129         grid_sizer_1->Add(loginStaticText, 0, wxALIGN_BOTTOM, 0);
00130         grid_sizer_1->Add(dummy, 0, wxALIGN_RIGHT, 0);
00131         grid_sizer_1->Add(nameStaticText, 0, wxALIGN_RIGHT, 0);
00132         grid_sizer_1->Add(usernameTextCtrl, 0, 0, 0);
00133         grid_sizer_1->Add(passwordStaticText, 0, wxALIGN_RIGHT, 0);
00134         grid_sizer_1->Add(passwordTextCtrl, 0, 0, 0);
00135         grid_sizer_1->Add(dummy, 0, wxALIGN_RIGHT, 0);
00136         grid_sizer_1->Add(loginButton, 0, wxALIGN_RIGHT, 0);
00137         frameSizer->Add(grid_sizer_1, 1, wxALIGN_CENTER_HORIZONTAL, 0);
00138         SetAutoLayout(true);
00139         SetSizer(frameSizer);
00140         Layout();
00141 }
00142 
00143 //!     Event Handling Method of GeneratorToolFrame.
00144 /*!
00145 *       Closes the window when a user clicks on the Quit Menu Item or Quit Button.
00146 */
00147 
00148 void 
00149 GeneratorToolFrame::OnQuit( wxCommandEvent& event)
00150 {
00151         Close(TRUE);
00152 }
00153 
00154 //!     Event Handling Method for the event when the About menu item is clicked.
00155 /**
00156         A Message Box will pop up with a brief description of the program and its version.
00157 */
00158 
00159 void 
00160 GeneratorToolFrame::OnAbout( wxCommandEvent&  event)
00161 {
00162         wxMessageBox( wxT( "This is the Generator Tool of FastApp.\nIt allows you to execute applications \nstored in the database.\n\n(c)Ko Kok Leong" ),
00163                         wxT( "About Generator Tool" ), wxOK | wxICON_INFORMATION, this );
00164                         
00165 }
00166 
00167 //! Event Handling Method for the Login Button
00168 /*!
00169 *
00170 *       This method handles the event that is triggered by the clicking of the login button of the first screen. 
00171 *       
00172 *       This method does the following:
00173 *               -# Checking of whether both fields are filled up.
00174 *               -# Authentication of Login Name and Password
00175 *               -# After a match of the login information, a Connection with the PostgreSQL database will be established with DbEstb()
00176 *               -# After the DB connection is established, the List of Designed Applications will be displayed in the Listbox on the following screen.
00177 *
00178 *
00179 */
00180 
00181 void GeneratorToolFrame::OnButtonLogin( wxCommandEvent& event )
00182 {
00183         //Show BUSY Cursor
00184         wxBeginBusyCursor(wxHOURGLASS_CURSOR);
00185         wxString strUname, strPword;
00186         strUname=strPword="";
00187         noforms=0;
00188         strUname = usernameTextCtrl->GetValue();
00189         strPword = passwordTextCtrl->GetValue();
00190         
00191         //Check if Text Ctrls are filled properly
00192         if(strUname.IsEmpty() || strPword.IsEmpty())
00193         {       
00194                 wxMessageBox("Please fill in both fields before proceeding.","Missing Fields",wxOK|wxICON_EXCLAMATION,this);
00195                 usernameTextCtrl->Clear();
00196                 passwordTextCtrl->Clear();
00197                 wxEndBusyCursor();
00198                 return;
00199         }
00200         //Establish DB Connection with successfully Login.
00201         DbEstb();
00202         
00203         //Check user name and password
00204         if(tbFa_App->Open())
00205         {       
00206                 tbFa_App->SetWhereClause("susername='"+strUname+"' AND spassword='"+strPword+"'");
00207                 if(!tbFa_App->Query())
00208                 {
00209                         wxMessageBox("Problem with Query on Fa_App");
00210                 }
00211                 else
00212                 {
00213                         int nNumofapp = tbFa_App->Count();
00214                         if(nNumofapp>0)
00215                         {
00216                                 wxMessageBox("Welcome.\nPlease select your application to launch.","Successful Login",wxOK|wxICON_INFORMATION,this,50,50);
00217                                 arrAppname = NULL;
00218                                 arrAppid = arrSdbid= arrAppformid =NULL;
00219                                 arrAppname = new wxString[nNumofapp+1];
00220                                 arrAppid = arrSdbid= arrAppformid = new int[nNumofapp+1];
00221                                 //get the other information for this user. Scan thru each row of result
00222                                 wxList UserAppList=wxList(wxKEY_INTEGER);
00223                                 int count=0;
00224                                 while(tbFa_App->GetNext())
00225                                 {
00226                                         arrAppname[count]=sAppname;
00227                                         arrAppid[count]=sAppid, 
00228                                         arrSdbid[count]=sSdbid, 
00229                                         arrAppformid[count]=sAppformid;
00230                                         count++;
00231                                 }
00232                                 grid_sizer_1->Clear();
00233                                 loginStaticText->Show(FALSE);
00234                                 dummy->Show(FALSE);
00235                                 nameStaticText->Show(FALSE);
00236                                 usernameTextCtrl->Show(FALSE);
00237                                 passwordStaticText->Show(FALSE);
00238                                 passwordTextCtrl->Show(FALSE);
00239                                 loginButton->Show(FALSE);
00240                                 
00241                                 //Application List
00242                                 applistStaticText= new wxStaticText(this, -1, "Your Applications:");
00243                                 applistStaticText->SetFont(wxFont(13, wxSWISS, wxNORMAL, wxNORMAL, 0, ""));
00244                                 appListBox =new wxListBox(this, ID_LB_APPLIST, wxDefaultPosition, wxSize(200,60), nNumofapp, arrAppname, 0, wxDefaultValidator, "Application listBox");
00245                                 launchButton = new wxButton( this, ID_BTN_LAUNCH, wxT("Launch"),wxDefaultPosition,wxSize(80,30));
00246                                 logoutButton = new wxButton( this, ID_BTN_LOGOUT, wxT("Log Out"),wxDefaultPosition,wxSize(80,30));
00247                                 ButtonBox = new wxBoxSizer(wxHORIZONTAL);
00248                                 ButtonBox->Add(logoutButton,0,wxALIGN_CENTRE,0);
00249                                 ButtonBox->Add(launchButton,0,wxALIGN_CENTRE,0);
00250                                 grid_sizer_1->Add(dummy, 0, wxALIGN_RIGHT,0);
00251                                 grid_sizer_1->Add(dummy, 0, wxALIGN_RIGHT,0);
00252                                 grid_sizer_1->Add(applistStaticText, 0, wxALIGN_RIGHT, 0);
00253                                 grid_sizer_1->Add(appListBox, 0, wxALIGN_RIGHT, 0);
00254                                 grid_sizer_1->Add(dummy, 0, wxALIGN_RIGHT, 0);
00255                                 grid_sizer_1->Add(ButtonBox, 0, wxALIGN_RIGHT, 0);
00256                                 //grid_sizer_1->();
00257                                 //Get Position in ListBox and then locate all the array information     
00258                         }
00259                         else
00260                         {
00261                                 wxMessageBox("Either the username and/or password is wrongly entered.\nPlease try again.","Incorrect Login",wxOK,this,50,50);
00262                                 usernameTextCtrl->Clear();
00263                                 passwordTextCtrl->Clear();
00264                                 wxEndBusyCursor();
00265                         }
00266                 }
00267         }
00268         else
00269         {
00270                 wxMessageBox("Database cannot be opened","Unable to establish DB Connection",wxOK,this,50,50);
00271                 wxEndBusyCursor();
00272                 return;
00273         }       
00274         wxEndBusyCursor();
00275         SetStatusText( wxT( "Select an application to launch" ) );
00276 }
00277 
00278 /**
00279 * Event Handling Method for Logout.
00280 * Reverts User back to login screen.
00281 */
00282 void GeneratorToolFrame::OnButtonLogout( wxCommandEvent& event )
00283 {
00284         grid_sizer_1->Clear();
00285         dummy->Show(FALSE);
00286         applistStaticText->Show(FALSE);
00287         appListBox->Show(FALSE);
00288         logoutButton->Show(FALSE);
00289         launchButton->Show(FALSE);
00290         //ButtonBox->Show(FALSE);
00291         grid_sizer_1->Add(loginStaticText, 0, wxALIGN_RIGHT,0);
00292         grid_sizer_1->Add(dummy, 0, wxALIGN_RIGHT,0);
00293         grid_sizer_1->Add(nameStaticText, 0, wxALIGN_RIGHT, 0);
00294         grid_sizer_1->Add(usernameTextCtrl, 0, wxALIGN_RIGHT, 0);
00295         grid_sizer_1->Add(passwordStaticText, 0, wxALIGN_RIGHT, 0);
00296         grid_sizer_1->Add(passwordTextCtrl, 0, wxALIGN_RIGHT, 0);
00297         grid_sizer_1->Add(loginButton, 0, wxALIGN_RIGHT, 0);
00298 
00299         loginStaticText->Show(TRUE);
00300         dummy->Show(TRUE);
00301         nameStaticText->Show(TRUE);
00302         usernameTextCtrl->Show(TRUE);
00303         passwordStaticText->Show(TRUE);
00304         passwordTextCtrl->Clear();
00305         passwordTextCtrl->Show(TRUE);
00306         loginButton->Show(TRUE);
00307 }
00308 
00309 /* Event Handling Method for the Launch Button of the Application Selection Screen
00310 */
00311 
00312 /**
00313 *       This method is the most crucial component of the entire programme.      
00314 *       
00315 *       It comprises of the following key steps:
00316 *       
00317 *       This method does the following:
00318 *       - Get the Selected Application's name and id
00319 *       - Establish an ODBC Connection with the System Database, the SysDB.
00320 *       - Collect all the necessary information/ attributes/ parameters for the construction of the forms and objects from the SysDB.
00321 *       - Using the Run Time Type Identification (RTTI) Methods of (e.g. wxDynamicCast) provided by wxWidgets 
00322                 -# Render out the Forms by storing them into the form wxHashTable formtable and instantiate it with InstantiateForm()
00323 *               -# For each Form, Render out their Objects(Controls) by first storing them into objecttable and then instantiate it with InstantiateObject()
00324 *               -# For each Object rendered, connect them to the Dynamic Event Handling Functions through the wxWidgets Dynamic Event Handling features.
00325 *
00326 *
00327 *       
00328 */
00329 void GeneratorToolFrame::OnButtonLaunch( wxCommandEvent& event )
00330 {
00331         
00332         if(appListBox->GetSelection()>=0)
00333         {
00334                 int n= appListBox->GetSelection();
00335                 wxString s = appListBox->GetStringSelection();
00336                 
00337                 wxProgressDialog *Progress = new wxProgressDialog("Launching...", "Launching...", 100, this, wxPD_AUTO_HIDE | wxPD_APP_MODAL/*| wxPD_REMAINING_TIME */);
00338 
00339                 strDsnname ="";
00340                 tbFa_Db->Open();
00341                 tbFa_Db->SetWhereClause("dbid="+IntToWxstring(arrSdbid[n]));
00342                 if(tbFa_Db->Query())
00343                 {
00344                         if(tbFa_Db->GetNext())
00345                         {
00346                                 strDsnname=sDsnname;
00347                                 //wxMessageBox("Dsn="+strDsnname);
00348                                 UserDbConnectInf = NULL;
00349                                 UserDbConnectInf = new wxDbConnectInf( NULL, strDsnname, "", "", "" );
00350                                 if ( !UserDbConnectInf || !UserDbConnectInf->GetHenv() )
00351                                 {
00352                                         wxMessageBox("Unable to define data source connection info.", "Data Source Fault",wxOK|wxICON_HAND,this);
00353                                 }
00354                                 dbUser = NULL;
00355                                 dbUser = wxDbGetConnection( UserDbConnectInf );
00356                                 
00357                         }
00358                         else
00359                         {
00360                                 wxMessageBox("Cannot Get DSN Results","",wxOK|wxICON_EXCLAMATION,this);
00361                                 Progress->Update( 100, "Closing attempts on Connection");
00362                         }
00363                 }
00364                 Progress->Update( 25, "Connecting to Application Database...");
00365                 wxSleep(1);
00366                 
00367                 //Using RTTI Class and Methods
00368                 //Steps:
00369                 //1.    Scan thru the appform table ; collect the formids
00370                 //2.    with each formid, launch the form
00371                 //3.    With each form, launch the objects
00372                 
00373                 //wxMessageBox("Appformid = "+IntToWxstring(arrAppformid[n]));
00374                 //Collect the related forms from the 1-to-m table appform
00375                 int nNumForms =0;
00376                 if(!tbFa_Appform->Open())
00377                         wxMessageBox("Appform Table cannot be opened, please try again.");
00378                 tbFa_Appform->SetWhereClause("appid="+IntToWxstring(arrAppformid[n]));
00379                 if(tbFa_Appform->Query())
00380                         nNumForms = tbFa_Appform->Count();
00381                 arrFormid=new int[nNumForms];
00382                 tbFa_Appform->SetWhereClause("appid="+IntToWxstring(arrAppformid[n]));
00383                 if(tbFa_Appform->Query())
00384                 {
00385                         int k=0;
00386                         while(tbFa_Appform->GetNext())
00387                         {
00388                                 arrFormid[k]=sAF_Formid;
00389                                 k++;
00390                                 
00391                         }
00392                 }
00393                 else
00394                 {
00395                         wxMessageBox("Cannot execute the Query");
00396                 }
00397                 //Step 1. Instantiate the Forms first
00398                 formtable.Clear();
00399                 objecttable.Clear();
00400                 wxBeginBusyCursor(wxHOURGLASS_CURSOR);
00401                 
00402                 //Look at App and also related UserDB name, userDB dsn. 
00403                 //From UserDB info, point to the related tables and get the code below ready for the db operations 
00404                 Progress->Update( 75, "Rendering "+s+" GUI...");
00405                 wxSleep(1);
00406                 
00407                 if(tbFa_Form->Open()&& tbFa_Object->Open())
00408                 { 
00409                         for(int i=0; i<nNumForms;i++)
00410                         {
00411                                 tbFa_Form->SetWhereClause("fid = "+IntToWxstring(arrFormid[i]));
00412                                 if(!tbFa_Form->Query())
00413                                         wxMessageBox("FA_FORM Query Failed");
00414                                 else
00415                                 {
00416                                         while(tbFa_Form->GetNext())
00417                                         {
00418                                                 InstantiateForm(sFid, sFormx, sFormy, sFormw, sFormh,sFormtype, sFormstyle, sCaption,sIsindex);
00419                                                 tbFa_Object->SetWhereClause("formid = "+IntToWxstring(arrFormid[i]));
00420                                                 if(!tbFa_Object->Query())
00421                                                         wxMessageBox("Cannot Execute Render Object Query");
00422                                                 else
00423                                                 {
00424                                                         while(tbFa_Object->GetNext())
00425                                                         {
00426                                                                 InstantiateObject(sObjtype,sFormid, sObjid, sObjlabel,sObjdefault,sObjx, sObjy, sObjw, sObjh, sObjstyle,atoi(sO_Attrtype));
00427                                                         }
00428                                                 }
00429                                         }
00430                                 }
00431                         }
00432                 }
00433                 else
00434                 {
00435                         wxMessageBox("DB Can't Open","Failed");
00436                 }
00437                 wxEndBusyCursor();
00438                 Progress->Update( 100, "Launching Complete");
00439                 return;
00440         }
00441         else
00442         {
00443                 wxMessageBox("Please select a valid application first.");
00444                 return;
00445         }
00446         delete UserDbConnectInf;
00447         delete [] arrFormid;
00448 
00449 }
00450 
00451 /* Method for Conversion of Integer type into a wxString type.
00452 */
00453 
00454 /**
00455 *       
00456 *       Handy tool for the Conversion of integer type into the wxWidget Compliant string type, wxString.
00457 *       This method is the opposite of atoi()
00458 */
00459 
00460 wxString GeneratorToolFrame::IntToWxstring(int id)
00461 {
00462         wxString s;
00463         s+=wxString::Format("%d",id);
00464         return s;
00465 }
00466 
00467 /* Method which makes use of the Run Time Type Identification capability in C++ and wxWidgets to do a dynamic cast of Windows from their base classes
00468 */
00469 
00470 /**
00471 *       - Before looking at the InstantiateForm Functionality, we need to look at the RTTI mechanism: 
00472         
00473         - It consists of 3 major parts:
00474 *               -# wxDynamicCast() method: For obtaining a pointer to an object of a derived class given the pointer to a base class of that object. This method delivers the pointer only if the object pointed to is REALLY of the specified derived class; otherwise it will return a 0.
00475                 -# the Type ID: In FastApp, each Form(window) and Control has a classifying typeid which differentiates it type from the other controls. (e.g. Buttons are of the typeid = 101 while StaticTexts are of the typeid = 100) Hence, this type id is used for identifying the exact type of an object given a pointer to a base class.
00476                 -# wxClassInfo : This acts as a hook for further Runtime information associated with a type. 
00477         
00478         - Next the utilisation of wxHashTables, the main reasons for their usage are:
00479                 -# Each Form or Control in the SysDB are Uniquely identified by their FIDs or ObjIDs. Hence, with a potentially large pool of these objects as the programme's utilisation increases, the best data structure has to be one that can grow with no major concerns of indexing and also one which allows any arbitrary key(id) to be used to index a new object.
00480                 -# We will pass in the form information into a hashtable entry with its id as the key to the hash table
00481                 
00482         - How this method works:
00483                 -# The parameters of the forms are passed into the function.
00484                 -# By recognising the type of the form, (e.g. Frame), it will move into the appropriate instantiation branch of a switch condition.
00485                 -# Within each case of the switch(which corresponds to the typeid of the form), we will do the following:
00486                         - "new" the Form object and then store into the formtable has table by its formid, this is to allow easy control and manipulation in further steps in the program 
00487                         - Extract the newly-inserted item as its base object and Dynamic Cast it into its appropriate derived Object.
00488                         - Connect this Form Object with its appropriate Dynamic Event Handling Methods.
00489                         .
00490 *
00491 */
00492 void 
00493 GeneratorToolFrame::InstantiateForm(int id, int x, int y, int w, int h, int type, int style, wxString title, int isindex)
00494 {
00495 /******************************************************************************************************************/
00496 //Key Milestone:
00497 //We will pass in the form information into a hashtable entry with its id as the key to the hash table
00498 //The storage into the hash table is to allow us to identify and keep track of each form with the original key and with
00499 //no major concerns of indexing (Hashing is quite fast as the fastapp structure grows exponentially)
00500 /******************************************************************************************************************/
00501 
00502         //Very important to release the older allocations of memory by clearing the nodes
00503         //Scan through for match of type and then create its instance and store it
00504         switch(type)
00505         {
00506                 case 1:
00507                 {//This form is a frame
00508                         
00509                         formtable.Put(sFid,(new wxFrame(NULL,id,title,wxPoint(x,y),wxSize(w,h),wxDEFAULT_FRAME_STYLE, "frame")));
00510                         if(isindex==1)
00511                                 wxDynamicCast((formtable.Get(id)),wxFrame)->Show(TRUE);
00512                         else
00513                                 wxDynamicCast((formtable.Get(id)),wxFrame)->Show(FALSE);
00514                         break;
00515                 }
00516                 default:
00517                 {
00518                         //maybe a dialog or some other managed window
00519                         //In the case of dialogues, we need to sometimes state the parent , hence we might need to include the 
00520                         //DO nothing at the moment
00521                 }
00522         }
00523 }
00524 
00525 /* Method which makes use of the Run Time Type Identification capability in C++ and wxWidgets to do a dynamic cast of Controls  from their base classes
00526 */
00527 
00528 /**
00529         - How this method works:
00530                 -# The parameters of the Controls are passed into the function.
00531                 -# By recognising the type of the Control, (e.g. wxButton), it will move into the appropriate instantiation branch of a switch condition.
00532                 -# Within each case of the switch(which corresponds to the typeid of the Control), we will do the following:
00533                         - "new" the required Control object without a hard coded name and then store into the objecttable has table by its formid, this is to allow easy control and manipulation in further steps in the program 
00534                         - Extract the newly-inserted item as its base object and Dynamic Cast it into its appropriate derived Control Object.
00535                         - Connect this Control Object with its appropriate Dynamic Event Handling Methods.
00536 */
00537 void 
00538 GeneratorToolFrame::InstantiateObject(int type, int formid, int oid, wxString olabel,wxString odefault, int ox, int oy, int ow, int oh, int ostyle, int oAttrtype)
00539 {
00540 switch(type)
00541 {       
00542         case 101:
00543         {//Buttons are type no. 101
00544                 wxWindow *parent= FindWindowById(formid,NULL);
00545                 objecttable.Put(oid,(new wxButton(parent,oid,olabel,wxPoint(ox,oy),wxSize(ow,oh),ostyle)));
00546                 //wxDynamicCast((objecttable.Get(oid)),wxButton);
00547                 
00548                 //Dynamic Event Handling Creation
00549                 wxDynamicCast((objecttable.Get(oid)),wxButton)->Connect( oid, /* -1,*/ wxEVT_COMMAND_BUTTON_CLICKED,
00550                   (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
00551                   &GeneratorToolFrame::ButtonGenericEventFunc );
00552                 break;
00553         }
00554         case 100:
00555         {//wxStaticText == type no. 100
00556                 wxWindow *parent= FindWindowById(formid,NULL);
00557                 objecttable.Put(oid,(new wxStaticText(parent,oid,olabel,wxPoint(ox,oy), wxSize(ow,oh),ostyle, "staticText")));
00558                 break;
00559         }
00560         case 104:
00561         {//and wxStaticBox== type no. 104
00562                 wxWindow *parent= FindWindowById(formid,NULL);
00563                 objecttable.Put(oid,(new wxStaticBox(parent,oid,olabel,wxPoint(ox,oy), wxSize(ow,oh),ostyle, "staticBox")));
00564                 break;
00565         }
00566         case 5:
00567         {//wxGrid == type no. 5
00568                 //wxMessageBox("Entered Grid");
00569                 int fid= formid;
00570                 wxWindow *parent= FindWindowById(formid,NULL);
00571                 objecttable.Put(oid,(new wxGrid(parent, oid, wxPoint(ox,oy), wxSize(ow,oh),1 ,"Grid")));
00572                 wxDynamicCast((objecttable.Get(oid)),wxGrid)->CreateGrid(0, ostyle, wxGrid::wxGridSelectCells);
00573                 
00574                 for(int k=0; k<ostyle;k++)
00575                 {
00576                         wxString temp;
00577                         if(k<ostyle-1)
00578                         {       
00579                                 temp = odefault.BeforeFirst(',');
00580                                 odefault=odefault.AfterFirst(',');
00581                         }
00582                         else
00583                                 temp = odefault;
00584                         ((wxGrid *)FindWindowById(oid,NULL))->SetLabelValue(wxHORIZONTAL, temp,k);
00585                         ((wxGrid *)FindWindowById(oid,NULL))->AutoSize();
00586                 }
00587                 RefreshGrid(fid,oid);
00588                 break;
00589         }
00590         case 107:
00591         {//textctrl == type no. 107
00592                 //Type constants below determine the validation of the text box.
00593                 //e.g. If the type is a varchar, then the Validator used is the ASCII Validator
00594                 
00595                 /******************
00596                 int     1
00597                 varchar 2
00598                 char    3
00599                 text    4
00600                 long    5
00601                 float   6
00602                 double  7
00603                 date    8
00604                 time    9
00605                 SERIAL 10
00606                 *******************/
00607                 
00608                 if(oAttrtype==1||oAttrtype==5||oAttrtype==6||oAttrtype==7)
00609                 {       
00610                         //numeric validators
00611                         wxWindow *parent= FindWindowById(formid,NULL);
00612                         objecttable.Put(oid,(new wxTextCtrl(parent, oid, "", wxPoint(ox,oy),wxSize(ow,oh), ostyle,NumericValidator)));
00613                         //Dynamic Event Handling 
00614                         wxDynamicCast((objecttable.Get(oid)),wxTextCtrl)->Connect( oid, /* -1,*/  wxEVT_COMMAND_TEXT_UPDATED,
00615                         (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
00616                         &GeneratorToolFrame::TextCtrlGenericEventFunc);
00617                         //wxDynamicCast((objecttable.Get(oid)),wxTextCtrl);
00618                 }
00619                 else
00620                 {
00621                         //alphanumeric validators
00622                         wxWindow *parent= FindWindowById(formid,NULL);
00623                         objecttable.Put(oid,(new wxTextCtrl(parent, oid, "", wxPoint(ox,oy),wxSize(ow,oh), ostyle,ASCIIValidator)));
00624                         //Dynamic Event Handling
00625                         wxDynamicCast((objecttable.Get(oid)),wxTextCtrl)->Connect( oid, /* -1,*/  wxEVT_COMMAND_TEXT_UPDATED,
00626                         (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
00627                         &GeneratorToolFrame::TextCtrlGenericEventFunc);
00628                 }
00629                 break;
00630         }
00631         default:
00632         {
00633                 //TODO provision for more controls in the future
00634         }
00635 }
00636 }
00637 /** Generic Event Handling Function for Forms
00638 */
00639 void 
00640 GeneratorToolFrame::FormGenericEventFunc(wxCommandEvent& event)
00641 {
00642 
00643 }
00644 /** Generic Method that refreshes grids. 
00645 */
00646 /**
00647 * Note that this generic code is used for the dynamically rendered program, and will be able to take in any grid.
00648 */
00649 void 
00650 GeneratorToolFrame::RefreshGrid(int formid, int objectid)
00651 {
00652         //wxMessageBox("Formid= "+IntToWxstring(formid)+", Objectid="+ IntToWxstring(objectid));
00653         
00654         SDWORD cb;
00655         wxChar reqVal[255];
00656         wxString sqlStmt;
00657         int numCols;
00658         
00659         wxDbConnectInf *uDbConnInf;
00660         wxDb *dbuFA;
00661         uDbConnInf = NULL;
00662         uDbConnInf = new wxDbConnectInf( NULL, "fastapp-dsn", "", "", "" );
00663         if ( !uDbConnInf || !uDbConnInf->GetHenv() )
00664         {
00665                 wxMessageBox(wxT("Unable to define data source connection info."),
00666                              wxT("SysDB CONNECTION ERROR..."),wxOK | wxICON_EXCLAMATION);
00667         }
00668         dbuFA = NULL;
00669         dbuFA = wxDbGetConnection( uDbConnInf );
00670         sqlStmt="SELECT objstyle,attrtable FROM fa_object WHERE objid ='"+IntToWxstring(objectid)+"' AND formid = '"+IntToWxstring(formid)+"';";
00671 
00672         if (!dbuFA->ExecSql(sqlStmt.c_str()))
00673         {
00674                 wxMessageBox("DB SQL STMT CANNOT EXECUTE.");
00675                 return;
00676         }
00677         else
00678         {
00679                 if(dbuFA->GetNext())
00680                 {//Can get next row
00681                         dbuFA->GetData(1, SQL_C_CHAR, reqVal, sizeof(reqVal), &cb);
00682                         //wxMessageBox(reqVal);
00683                         numCols=atoi(reqVal);
00684                         dbuFA->GetData(2, SQL_C_CHAR, reqVal, sizeof(reqVal), &cb);
00685                         sqlStmt="SELECT * FROM ";
00686                         sqlStmt+=reqVal;
00687                         sqlStmt+=";";
00688                         //wxMessageBox("sqlStmt= "+sqlStmt);
00689                 }
00690                 else
00691                 {
00692                         wxMessageBox("Cannot Get Next");
00693                 }
00694         }
00695         //wxMessageBox("B");
00696         
00697         /***************************************************/   
00698         //wxMessageBox(strDsnname);
00699         wxDbConnectInf *uUserDbConnInf; 
00700         uUserDbConnInf = NULL;
00701         uUserDbConnInf = new wxDbConnectInf( NULL, strDsnname, "", "", "" );
00702         if(!uUserDbConnInf || !uUserDbConnInf->GetHenv() )
00703         {
00704                 wxMessageBox(wxT("Unable to define User data source connection info."),
00705                              wxT("UserDB CONNECTION ERROR..."),wxOK | wxICON_EXCLAMATION);
00706         }
00707         wxDb *dbuU;
00708         dbuU = NULL;
00709         dbuU = wxDbGetConnection( uUserDbConnInf );
00710 //MUST CHECK FOR THE USER DB's PRESENCE
00711 
00712         //sqlStmt = "SELECT * FROM person;";
00713 
00714         // Perform the query
00715         if (!dbuU->ExecSql(sqlStmt.c_str()))
00716         {
00717                 wxMessageBox("DB SQL STMT CANNOT EXECUTE.");
00718                 return;
00719         }
00720         else{
00721                 //wxMessageBox("Till here");
00722                 int row=0;
00723                 while(dbuU->GetNext())
00724                 {
00725                         //wxMessageBox(");
00726                         //Can get next row
00727                 //      wxMessageBox("Getting Next now");
00728                         //wxMessageBox("Attempting to set cell value with OBJECTID="+IntToWxstring(objectid));
00729                         // Request the first row of the result set
00730                 
00731                         wxDynamicCast((objecttable.Get(objectid)),wxGrid)->AppendRows(1,FALSE);
00732                 //      wxMessageBox("Appended New Row");
00733 
00734                         //if (cb == SQL_NULL_DATA)
00735                         //      break;
00736                         //wxMessageBox("One Row Added");        
00737                         for(int col=1; col<=numCols;col++)
00738                         {
00739                                 if (!dbuU->GetData(col, SQL_C_CHAR, reqVal, sizeof(reqVal), &cb))
00740                                 {
00741                                         wxMessageBox("Error in Getting Data.");
00742                                 }
00743                                 else
00744                                 {
00745                                         wxDynamicCast((objecttable.Get(objectid)),wxGrid)->SetCellValue(row,col-1,reqVal);
00746                                 }
00747                         }
00748                         row++;
00749                 }
00750         }
00751 //      wxMessageBox("D");
00752 
00753         wxDynamicCast((objecttable.Get(objectid)),wxGrid)->AutoSize();
00754 //      wxMessageBox("E");
00755 
00756         wxDbFreeConnection(dbuU);
00757         wxDbFreeConnection(dbuFA);
00758 }
00759 
00760 /** Generic Event Handling Function for BUTTONS
00761 */
00762 /** 
00763         This event handling method is used to cater to the possible actions required of a button (e.g. INSERT some new records, Invoke a POPUP, Delete a record, etc.)
00764         
00765         Hence, the 3 designers (Feifei, Hweeli and myself) of the components of FastApp has agreed on an Event Handling Protocol which will serve as the common method of executing the dynamic events according to the different situations.
00766         
00767         Briefly, this is how this method works:
00768                 -# From the event object passed into the method, we can obtain the object ID where the event occurred.
00769                 -# Then, knowing the ID, we will enter the SysDB to check out its corresponding Event ID.
00770                 -# With the Event ID, we will be able to check the Fa_Process Relation(This is where all the relevant event handling steps are stored for their relevant objects) in the SysDB. We will extract the Steps (aka. Process IDs and Process Descriptions related to this Event ID) 
00771                 -# We will execute the event according to its previously agreed protocol.
00772 */
00773 
00774 void 
00775 GeneratorToolFrame::ButtonGenericEventFunc(wxCommandEvent& event)
00776 {
00777 /////////////////////////////
00778 //Set up new ODBC connections
00779 /////////////////////////////
00780         
00781         wxDbConnectInf *uDbConnectInf,*uUserDbConnectInf;
00782         wxDb *dbuFastApp, *dbuUser;
00783         /***************FASTAPP SYSDB CONNECTION SETUP********************/
00784         uDbConnectInf = NULL;
00785         uDbConnectInf = new wxDbConnectInf( NULL, "fastapp-dsn", "", "", "" );
00786         if ( !uDbConnectInf || !uDbConnectInf->GetHenv() )
00787         {
00788                 wxMessageBox(wxT("Unable to define data source connection info."),
00789                              wxT("SysDB CONNECTION ERROR..."),wxOK | wxICON_EXCLAMATION);
00790         }
00791         dbuFastApp = NULL;
00792         dbuFastApp = wxDbGetConnection( uDbConnectInf );
00793 
00794         /**************UserDB Connection Setup******************/
00795         uUserDbConnectInf = NULL;
00796         uUserDbConnectInf = new wxDbConnectInf( NULL, strDsnname, "", "", "" );
00797         if(!uUserDbConnectInf || !uUserDbConnectInf->GetHenv() )
00798         {
00799                 wxMessageBox(wxT("Unable to define User data source connection info."),
00800                              wxT("UserDB CONNECTION ERROR..."),wxOK | wxICON_EXCLAMATION);
00801         }
00802         dbuUser = NULL;
00803         dbuUser = wxDbGetConnection( uUserDbConnectInf );
00804 
00805 /////////////////////////////////////////////////
00806 //Get the Object ID and Retrieve the Eventids
00807 ////////////////////////////////////////////////
00808         //Get the Object ID which the event occured.
00809         wxString objectid = IntToWxstring(event.GetId());
00810         wxString strEventid="";
00811 
00812         /*******EXECUTING THE SQL STMT TO RETRIEVE THE EVENT INSTRUCTIONS FOR THE OBJECT'S EVENTID******/
00813         SDWORD cb;
00814         ULONG reqQty;
00815         wxString sqlStmt;
00816         sqlStmt = "SELECT eventid FROM FA_OBJECT WHERE objid="+objectid+";";
00817 
00818         // Perform the query
00819         if (!dbuFastApp->ExecSql(sqlStmt.c_str()))
00820         {
00821                 wxMessageBox("Cannot Execute SQL String");
00822         }
00823         else
00824         {
00825                 // Request the first row of the result set
00826                 if (!dbuFastApp->GetNext())
00827                 {       wxMessageBox("Cannot Get Next in Fastapp");
00828                 }
00829                 if (!dbuFastApp->GetData(1, SQL_C_ULONG,&reqQty, 0, &cb))
00830                 {
00831                         wxMessageBox("Cannot extract data out.");
00832                 }
00833                 else
00834                 {
00835                         strEventid= IntToWxstring(reqQty);
00836                         dbuFastApp->CommitTrans();
00837                 }
00838                 // Check for a NULL result
00839                 if (cb == SQL_NULL_DATA)
00840                         wxMessageBox("No records returned");    
00841         }
00842 
00843 ////////////////////////////////////////////////////////////////
00844 //With Eventid , We can now retrieve the processes' Description
00845 ////////////////////////////////////////////////////////////////
00846         
00847         //2 Arrays to store the PIDs and ProcessDescs
00848         wxArrayString arrPid = wxArrayString();
00849         wxArrayString arrProcessdesc = wxArrayString();
00850         
00851         //Prep for the SELECT Stmt for the ProcessDesc
00852         //SDWORD cb;
00853         wxChar strPid[50+1];
00854         wxChar strProcessdesc[50+1];
00855         //ULONG processdesc;
00856         
00857         wxString sqlProcessStmt;
00858         sqlProcessStmt = "SELECT pid, processdesc FROM FA_PROCESS WHERE eventid="+strEventid+" ORDER BY pid;";
00859         
00860         //tbFa_Columndef->SetColDefs(0, "colid", DB_DATA_TYPE_INTEGER, &sColid, SQL_C_LONG, sizeof(sColid), true, true);
00861 
00862         // Perform the query
00863         if (!dbuFastApp->ExecSql(sqlProcessStmt.c_str()))
00864         {
00865                 wxMessageBox("Cannot Execute SQL String");
00866         }
00867         else
00868         {
00869                 // Request the first row of the result set
00870                 while(dbuFastApp->GetNext())
00871                 {       
00872                 //GetData(UWORD colNo, SWORD cType, PTR pData, SDWORD maxLen, SDWORD FAR * cbReturned )
00873                         dbuFastApp->GetData(1, SQL_C_CHAR,strPid, sizeof(strPid), &cb);
00874                         dbuFastApp->GetData(2, SQL_C_CHAR,strProcessdesc, sizeof(strProcessdesc), &cb);
00875                         //wxMessageBox(strPid);
00876                         arrPid.Add(strPid,1);
00877                         arrProcessdesc.Add(strProcessdesc,1);
00878                         dbuFastApp->CommitTrans();
00879                 }
00880                 //for(int z = 0; z<arrProcessdesc.GetCount(); z++)
00881                 //      wxMessageBox(arrProcessdesc[z]);
00882         }
00883         if(arrProcessdesc[0].IsSameAs("REFRESHGRID"))
00884         {
00885                 int formid = atoi(arrProcessdesc[2].BeforeFirst(','));
00886                 int gridid = atoi(arrProcessdesc[2].AfterFirst(','));
00887                 
00888                 SDWORD cb;
00889                 wxChar reqVal[255];
00890                 wxString sqlStmt;
00891                 int numCols;
00892                 sqlStmt="SELECT objstyle,attrtable FROM fa_object WHERE objid ='"+IntToWxstring(gridid)+"' AND formid = '"+IntToWxstring(formid)+"';";
00893                 //wxMessageBox(sqlStmt);
00894                 if (!dbuFastApp->ExecSql(sqlStmt.c_str()))
00895                 {
00896                         wxMessageBox("DB SQL STMT CANNOT EXECUTE.");
00897                         return;
00898                 }
00899                 else
00900                 {
00901                         if(dbuFastApp->GetNext())
00902                         {
00903                                 dbuFastApp->GetData(1, SQL_C_CHAR, reqVal, sizeof(reqVal), &cb);
00904                                 numCols=atoi(reqVal);
00905                                 dbuFastApp->GetData(2, SQL_C_CHAR, reqVal, sizeof(reqVal), &cb);
00906                                 sqlStmt="SELECT * FROM ";
00907                                 sqlStmt+=reqVal;
00908                                 sqlStmt+=";";
00909                         }
00910                         else
00911                         {
00912                                 wxMessageBox("Cannot Get Next");
00913                         }
00914                 }
00915                 wxGrid *targetGrid = (wxGrid *) (wxGetTopLevelParent(this)->FindWindowById(gridid));
00916                 // Perform the query
00917                 if (!dbuUser->ExecSql(sqlStmt.c_str()))
00918                 {
00919                         wxMessageBox("DB SQL STMT CANNOT EXECUTE.");
00920                         return;
00921                 }
00922                 else{
00923                         //wxMessageBox("Till here");
00924                         int row=0;
00925                         targetGrid->DeleteRows(0,targetGrid->GetNumberRows());
00926                         while(dbuUser->GetNext())
00927                         {
00928                                 targetGrid->AppendRows(1,FALSE);
00929                                 for(int col=1; col<=numCols;col++)
00930                                 {
00931                                         if (!dbuUser->GetData(col, SQL_C_CHAR, reqVal, sizeof(reqVal), &cb))
00932                                         {
00933                                                 wxMessageBox("Error in Getting Data.");
00934                                         }
00935                                         else
00936                                         {
00937                                         targetGrid->SetCellValue(row,col-1,reqVal);
00938                                         }
00939                                 }
00940                                 row++;
00941                         }
00942                 }
00943                 targetGrid->AutoSize();
00944         }
00945         else if(arrProcessdesc[0].IsSameAs("DELETE"))
00946         {
00947                 //Delete Event Protocol
00948                 /*
00949                         Process Table
00950                         pid= 1 => DELETE
00951                         pid= 2 => person
00952                         pid= 3 => grid id
00953                         pid= 4 => pid
00954                 */
00955                 wxString $Table = arrProcessdesc[1];
00956                 wxString $Object = arrProcessdesc[2];
00957                 long objid = atoi($Object);
00958                 wxString $condition = arrProcessdesc[3];
00959                 int row= ((wxGrid *) (wxGetTopLevelParent(this)->FindWindowById(objid)))->GetGridCursorRow();
00960                 if(row<0)
00961                         wxMessageBox("Please Select a record to delete in the table.");
00962                 else
00963                 {
00964                         wxString sPid = ((wxGrid *) (wxGetTopLevelParent(this)->FindWindowById(objid)))->GetCellValue(row, 0);
00965                         int reply= wxMessageBox("Are you sure you want to delete this record?","Confirmation",wxYES_NO,this);
00966                         if(reply==wxYES)
00967                         {
00968                                 wxString deleteSqlStmt="DELETE FROM "+$Table+" WHERE "+$condition+" = '"+sPid+"';";
00969                                 //wxMessageBox(deleteSqlStmt);
00970                                 if (!dbuUser->ExecSql(deleteSqlStmt.c_str()))
00971                                 {
00972                                         wxMessageBox("Can't execute Delete statement");
00973                                         //return;
00974                                 }
00975                                 else
00976                                 {
00977                                         wxMessageBox("Record Deleted.","Deleted",wxOK, this);
00978                                         dbuUser->CommitTrans();
00979                                 }
00980                         }
00981                         else
00982                         {
00983                                 return;
00984                         }
00985                 }
00986         }
00987         else if(arrProcessdesc[0].IsSameAs("POPUP"))
00988         {
00989                 wxString $Formids = arrProcessdesc[2];
00990                 int nNumforms = $Formids.Freq(',')+1;
00991                 int arrFormids[nNumforms];
00992                 if(nNumforms>0)
00993                 {
00994                         int i=0;
00995                         while(i<nNumforms)
00996                         {
00997                                 arrFormids[i]=atoi($Formids.BeforeFirst(','));
00998                                 $Formids=$Formids.AfterFirst(',');
00999                                 i++;
01000                         }
01001                         //Popup the screens(frames) listed
01002                         for(int k=0;k<nNumforms;k++)
01003                         {
01004                                 if((FindWindowById(arrFormids[k])))
01005                                         (FindWindowById(arrFormids[k]))->Show(TRUE);
01006                                 else
01007                                 {
01008                                         //wxMessageBox("Window Not Found, Recreate the window");
01009                                         wxChar fid[50+1],formx[50+1],formy[50+1],formw[50+1],formh[50+1],formtype[50+1],formstyle[50+1],caption[100+1];
01010                                         wxString formSqlstmt = "Select fid,formx,formy,formw,formh,formtype,formstyle,caption from fa_form where fid = '"+IntToWxstring(arrFormids[k])+"';";
01011                                         if (!dbuFastApp->ExecSql(formSqlstmt.c_str()))
01012                                         {
01013                                                 wxMessageBox("DB SQL STMT CANNOT EXECUTE.");
01014                                                 return;
01015                                         }
01016                                         else
01017                                         {
01018                                                 if(dbuFastApp->GetNext())
01019                                                 {
01020                                                         dbuFastApp->GetData(1, SQL_C_CHAR, fid, sizeof(fid), &cb);
01021                                                         dbuFastApp->GetData(2, SQL_C_CHAR, formx, sizeof(formx), &cb);
01022                                                         dbuFastApp->GetData(3, SQL_C_CHAR, formy, sizeof(formy), &cb);
01023                                                         dbuFastApp->GetData(4, SQL_C_CHAR, formw, sizeof(formw), &cb);
01024                                                         dbuFastApp->GetData(5, SQL_C_CHAR, formh, sizeof(formh), &cb);
01025                                                         dbuFastApp->GetData(6, SQL_C_CHAR, formtype, sizeof(formtype), &cb);
01026                                                         dbuFastApp->GetData(7, SQL_C_CHAR, formstyle, sizeof(formstyle), &cb);
01027                                                         dbuFastApp->GetData(8, SQL_C_CHAR, caption, sizeof(caption), &cb);
01028                                                         
01029                                                         if(atoi(formtype) == 1)
01030                                                         {
01031                                                         (new wxFrame(NULL,atoi(fid),caption,wxPoint(atoi(formx),atoi(formy)),wxSize(atoi(formw),atoi(formh)),wxDEFAULT_FRAME_STYLE, "popup frame"))->Show(TRUE);
01032                                                         }
01033                                                         
01034                                                         wxChar formid[50+1], objid[50+1], objx[50+1], objy[50+1], objw[50+1], objh[50+1], objtype[50+1], objstyle[50+1], objlabel[50+1], objdefault[50+1], attrtype[50+1];
01035                                                         
01036                                                         wxString objSqlStmt = "SELECT formid, objid,objx,objy,objw,objh,objtype, objstyle, objlabel, objdefault, attrtype FROM fa_object WHERE formid = '"+IntToWxstring(arrFormids[k])+"';";
01037                                                         wxWindow *parent= FindWindowById(atoi(fid),NULL);
01038                                                         
01039                                                         if (!dbuFastApp->ExecSql(objSqlStmt.c_str()))
01040                                                         {
01041                                                                 wxMessageBox("DB SQL STMT CANNOT EXECUTE.");
01042                                                                 return;
01043                                                         }
01044                                                         else
01045                                                         {
01046                                                                 while(dbuFastApp->GetNext())
01047                                                                 {
01048                                                                 dbuFastApp->GetData(1, SQL_C_CHAR, formid, sizeof(formid), &cb);
01049                                                                 dbuFastApp->GetData(2, SQL_C_CHAR, objid, sizeof(objid), &cb);
01050                                                                 dbuFastApp->GetData(3, SQL_C_CHAR, objx, sizeof(objx), &cb);
01051                                                                 dbuFastApp->GetData(4, SQL_C_CHAR, objy, sizeof(objy), &cb);
01052                                                                 dbuFastApp->GetData(5, SQL_C_CHAR, objw, sizeof(objw), &cb);
01053                                                                 dbuFastApp->GetData(6, SQL_C_CHAR, objh, sizeof(objh), &cb);
01054                                                                 dbuFastApp->GetData(7, SQL_C_CHAR, objtype, sizeof(objtype), &cb);
01055                                                                 dbuFastApp->GetData(8, SQL_C_CHAR, objstyle, sizeof(objstyle), &cb);
01056                                                                 dbuFastApp->GetData(9, SQL_C_CHAR, objlabel, sizeof(objlabel), &cb);
01057                                                                 dbuFastApp->GetData(10, SQL_C_CHAR,objdefault, sizeof(objdefault), &cb);
01058                                                                 dbuFastApp->GetData(11, SQL_C_CHAR,attrtype, sizeof(attrtype), &cb);
01059                                                                 
01060                                                                 if(atoi(objtype) == 101)
01061                                                                 {//Buttons are type no. 101
01062                                                                         (new wxButton(parent,atoi(objid),objlabel,wxPoint(atoi(objx),atoi(objy)),wxSize(atoi(objw),atoi(objh)),atoi(objstyle)))->Connect( atoi(objid), wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)  &GeneratorToolFrame::ButtonGenericEventFunc );
01063                                                                 }
01064                                                                 else if(atoi(objtype)==100)
01065                                                                 {//wxStaticText == type no. 100
01066                                                                         (new wxStaticText(parent,atoi(objid),objlabel,wxPoint(atoi(objx),atoi(objy)), wxSize(atoi(objw),atoi(objh)),atoi(objstyle), "staticText"));
01067                                                                 }
01068                                                                 else if(atoi(objtype)==104)
01069                                                                 {//wxStaticBox == type no. 104
01070                                                                         (new wxStaticBox(parent,atoi(objid),objlabel,wxPoint(atoi(objx),atoi(objy)), wxSize(atoi(objw),atoi(objh)),atoi(objstyle), "staticBox"));
01071                                                                 }
01072                                                                 else if(atoi(objtype)==5)
01073                                                                 {//wxGrid
01074                                                                         (new wxGrid(parent, atoi(objid), wxPoint(atoi(objx),atoi(objy)), wxSize(atoi(objw),atoi(objh)),1 ,"Grid"))->CreateGrid(0, atoi(objstyle), wxGrid::wxGridSelectCells);
01075                                                                         wxString sDefault = objdefault;
01076                                                                         for(int k=0; k<atoi(objstyle);k++)
01077                                                                         {
01078                                                                                 wxString temp;
01079                                                                                 if(k<atoi(objstyle)-1)
01080                                                                                 {       
01081                                                                                         temp = sDefault.BeforeFirst(',');
01082                                                                                         sDefault=sDefault.AfterFirst(',');
01083                                                                                 }
01084                                                                                 else
01085                                                                                         temp = sDefault;
01086                                                                                 ((wxGrid *)(FindWindowById(atoi(objid),NULL)))->SetLabelValue(wxHORIZONTAL, temp,k);
01087                                                                                 ((wxGrid *)(FindWindowById(atoi(objid),NULL)))->AutoSize();
01088                                                                         }
01089                                                                         RefreshGrid(atoi(formid),atoi(objid));
01090                                                                 }
01091                                                                 else if(atoi(objtype)==107)
01092                                                                 {//textctrl
01093                                                                         if(atoi(attrtype)==1||atoi(attrtype)==5||atoi(attrtype)==6||atoi(attrtype)==7)
01094                                                                         {//numeric validators
01095                                                                                 objecttable.Put(atoi(objid),(new wxTextCtrl(parent, atoi(objid), "", wxPoint(atoi(objx),atoi(objy)),wxSize(atoi(objw),atoi(objh)), atoi(objstyle),NumericValidator)));
01096                                                                         }
01097                                                                         else
01098                                                                         {//alphanumeric validators
01099                                                                                 (new wxTextCtrl(parent, atoi(objid), "", wxPoint(atoi(objx),atoi(objy)),wxSize(atoi(objw),atoi(objh)), atoi(objstyle),ASCIIValidator));
01100                                                                         }
01101                                                                 }
01102                                                                 }
01103                                                         }
01104                                                 }
01105                                                 else
01106                                                 {
01107                                                         wxMessageBox("Cannot Get Next");
01108                                                 }
01109                                         }
01110                                 
01111                                 }
01112                         }
01113                 }
01114                 else
01115                 {
01116                         wxMessageBox("Less than one field");
01117                         arrFormids[0]=atoi($Formids);
01118                 }       
01119         }
01120         else if(arrProcessdesc[0].IsSameAs("INSERT"))
01121         {
01122                 //Placing the process description lines into variables for string manipulation
01123                 wxString $Table = arrProcessdesc[1];
01124                 wxString $Fields = arrProcessdesc[2];
01125                 wxString $Attributes = "";
01126                 //Count the number of fields to be inserted into
01127                 int nNumfields = $Fields.Freq(',')+1;
01128                 
01129                 wxArrayString arrControlIds = wxArrayString(); 
01130                 wxArrayString arrControlValues = wxArrayString();
01131                 wxArrayString arrAttr = wxArrayString();
01132                 
01133                 if(nNumfields>0)
01134                 {
01135                         int i=0;
01136                         while(i<nNumfields)
01137                         {
01138                                 //Extract the Control IDs to extract text from and store into the array
01139                                 if(i==(nNumfields-1))
01140                                 {
01141                                         arrControlIds.Add($Fields,1);
01142                                         
01143                                 }
01144                                 else{
01145                                         arrControlIds.Add($Fields.BeforeFirst(','),1);
01146                                         $Fields=$Fields.AfterFirst(',');
01147                                 }
01148                                 //wxMessageBox("arrControlIds["+IntToWxstring(i)+"] = "+arrControlIds[i]);
01149                                 i++;
01150                         }
01151                 }
01152                 else
01153                 {
01154                         wxMessageBox("Less than one field");
01155                         arrControlIds.Add($Fields,1);
01156                 }
01157                 //ReInit $Fields and $Attributes
01158                 $Fields="";
01159                 $Attributes="";
01160                 
01161                 //Collect the values of the controls
01162                 int numOfIds = arrControlIds.GetCount();
01163                 for(int z=0; z<numOfIds; z++)
01164                 {
01165                         //wxMessageBox(arrControlIds[z]);
01166                         int id = atoi(arrControlIds[z]);
01167                         wxString input= ((wxTextCtrl *)(wxGetTopLevelParent(this)->FindWindow(id)))->GetValue();
01168                         //wxMessageBox(input);
01169                         if(input.IsEmpty())
01170                         {
01171                                 wxMessageBox("Please fill in the Empty Fields", "Missing Fields", wxICON_INFORMATION,this);
01172                                 ((wxTextCtrl *)(wxGetTopLevelParent(this)->FindWindow(id)))->SetFocus();
01173                                 return;
01174                         }
01175                         arrControlValues.Add(input,1);
01176                         
01177                         if(z!=(nNumfields-1))
01178                                 $Fields+=("'"+arrControlValues[z]+"',");
01179                         else
01180                                 $Fields+=("'"+arrControlValues[z]+"'");
01181                 }
01182                 //wxMessageBox($Fields);
01183                 for(int k=0; k<numOfIds; k++)
01184                 {
01185                         int id = atoi(arrControlIds[k]);
01186                         SDWORD cb;
01187                         wxChar reqQty[50+1];
01188                         wxString strTemp = arrControlIds[k];
01189                         //int id = atoi(arrControlIds[k]);
01190                         //Extracting the corresponding attr name in the userdb table
01191                         wxString strAttrSqlStmt = "SELECT attr FROM FA_OBJECT WHERE objid='"+strTemp+"';";      
01192                         //wxMessageBox(strAttrSqlStmt);
01193                         // Perform the query
01194                         if (!dbuFastApp->ExecSql(strAttrSqlStmt.c_str()))
01195                         {
01196                                 wxMessageBox("Can't execute Select Attr SQL Statement");
01197                                 return;
01198                         }
01199                         else{
01200                                 if (!dbuFastApp->GetNext())
01201                                         wxMessageBox("Aghh2");
01202                                 else{
01203                                         if (!dbuFastApp->GetData(1, SQL_C_CHAR,reqQty, sizeof(reqQty), &cb))
01204                                                 wxMessageBox("Aghh3");
01205                                         else
01206                                         {
01207                                                 arrAttr.Add(reqQty,1);
01208                                                 if(k!=(numOfIds-1))
01209                                                         $Attributes+=(arrAttr[k]+",");
01210                                                 else
01211                                                         $Attributes+=arrAttr[k];
01212                                                 dbuFastApp->CommitTrans();
01213                                         }
01214                                         // Check for a NULL result
01215                                         if (cb == SQL_NULL_DATA)
01216                                                 wxMessageBox("No records returned");    
01217                                 }
01218                         }
01219                         ((wxTextCtrl *)(wxGetTopLevelParent(this)->FindWindow(id)))->Clear();
01220                 }
01221                 
01222                 wxString userSqlStmt="INSERT INTO "+$Table+" ("+$Attributes+") VALUES ("+$Fields+");";
01223                 //wxMessageBox(userSqlStmt);
01224                 if (!dbuUser->ExecSql(userSqlStmt.c_str()))
01225                 {
01226                         wxMessageBox("Can't execute Insert statement");
01227                         //return;
01228                 }
01229                 else
01230                 {
01231                         wxMessageBox("New Record Inserted.","Insert",wxOK, this);
01232                         dbuUser->CommitTrans();
01233                 }
01234                 arrControlIds.Clear(); 
01235                 arrControlValues.Clear();
01236                 arrAttr.Clear();
01237         }
01238         else if(arrProcessdesc[0].IsSameAs("UPDATEPOPUP"))
01239         {
01240                 wxString $Table = arrProcessdesc[1];
01241                 wxString origin = arrProcessdesc[2];
01242                 wxString OriginFormId = origin.BeforeFirst(',');
01243                 wxString OriginGridId = origin.AfterFirst(',');
01244                 wxString PopupScreenId = arrProcessdesc[4];
01245                 
01246                 wxString $Attributes= arrProcessdesc[3];
01247                 int numAttribs = $Attributes.Freq(',')+1;
01248                 wxArrayString arrDbAttrib = wxArrayString();
01249                 wxArrayString arrDbStoredAttrib = wxArrayString();
01250 
01251                 for(int x =0; x<numAttribs; x++)
01252                 {
01253                         if(x==(numAttribs-1))
01254                                 arrDbAttrib.Add($Attributes,1);
01255                         else
01256                         {
01257                                 arrDbAttrib.Add($Attributes.BeforeFirst(','),1);
01258                                 $Attributes = $Attributes.AfterFirst(',');
01259                         }
01260                 }
01261                 
01262                 wxString PopupScreenObjids= arrProcessdesc[5];
01263                 int numObjs =PopupScreenObjids.Freq(',')+1;
01264                 wxArrayString arrObjectIds = wxArrayString();
01265                 
01266                 for(int x =0; x<numObjs; x++)
01267                 {
01268                         if(x==(numObjs-1))
01269                                 arrObjectIds.Add(PopupScreenObjids,1);
01270                         else
01271                         {
01272                                 arrObjectIds.Add(PopupScreenObjids.BeforeFirst(','),1);
01273                                 PopupScreenObjids = PopupScreenObjids.AfterFirst(',');
01274                         }
01275                 }
01276                 
01277                 //wxMessageBox(arrDbAttrib[3]);
01278                 int row= ((wxGrid *) (wxGetTopLevelParent(this)->FindWindowById(atoi(OriginGridId))))->GetGridCursorRow();
01279                 //wxMessageBox(IntToWxstring(row));
01280                 if(row<0)
01281                         wxMessageBox("Please Select a record to delete in the table.");
01282                 else
01283                 {
01284                         int gridid = atoi(OriginGridId);
01285                         wxString sPid = ((wxGrid *) (wxGetTopLevelParent(this)->FindWindowById(gridid)))->GetCellValue(row, 0);
01286                         
01287                         wxString ExtractSqlStmt="SELECT * FROM "+$Table+" WHERE "+arrDbAttrib[0]+" = '"+sPid+"';";
01288                         //wxMessageBox(ExtractSqlStmt);
01289                         
01290                         if (!dbuUser->ExecSql(ExtractSqlStmt.c_str()))
01291                         {
01292                                 wxMessageBox("Can't execute Delete statement");
01293                         }
01294                         else
01295                         {
01296                                 while(dbuUser->GetNext())
01297                                 {       
01298                                         SDWORD cb;
01299                                         int count=1;
01300                                         int numAttr = arrDbAttrib.GetCount();
01301                                         while(count<=numAttr)
01302                                         {
01303                                                 wxChar buf[50];
01304                                                 dbuUser->GetData(count, SQL_C_CHAR, buf, sizeof(buf), &cb);
01305                                                 //wxString value= buf;
01306                                                 arrDbStoredAttrib.Add(buf,1);
01307                                                 count++;
01308                                         }       
01309                                 }
01310                         /*
01311                         //Test Display
01312                         wxString testdisplay="";
01313                         for(int z= 0; z<arrDbStoredAttrib.GetCount();z++)
01314                                 testdisplay+=arrDbStoredAttrib[z]+"\n";
01315                         wxMessageBox(testdisplay);
01316                         */      
01317                                 ////////////////////////////////////////////
01318                                 //Popup the Update Frame
01319                                 ////////////////////////////////////////////
01320                                 //wxMessageBox("Formid to popup ="+PopupScreenId);
01321                                 
01322                                 wxString strFormId = PopupScreenId;
01323                                 int nFormId = atoi(strFormId);
01324                                         if((FindWindowById(nFormId)))
01325                                                 (FindWindowById(nFormId))->Show(TRUE);
01326                                         else
01327                                         {
01328                                                 //wxMessageBox("Window Not Found, Recreate the window");
01329                                                 wxChar fid[50+1],formx[50+1],formy[50+1],formw[50+1],formh[50+1],formtype[50+1],formstyle[50+1],caption[100+1];
01330                                                 wxString formSqlstmt = "Select fid,formx,formy,formw,formh,formtype,formstyle,caption from fa_form where fid = '"+strFormId+"';";
01331                                                 if (!dbuFastApp->ExecSql(formSqlstmt.c_str()))
01332                                                 {
01333                                                         wxMessageBox("DB SQL STMT CANNOT EXECUTE.");
01334                                                         return;
01335                                                 }
01336                                                 else
01337                                                 {
01338                                                         if(dbuFastApp->GetNext())
01339                                                         {
01340                                                                 dbuFastApp->GetData(1, SQL_C_CHAR, fid, sizeof(fid), &cb);
01341                                                                 dbuFastApp->GetData(2, SQL_C_CHAR, formx, sizeof(formx), &cb);
01342                                                                 dbuFastApp->GetData(3, SQL_C_CHAR, formy, sizeof(formy), &cb);
01343                                                                 dbuFastApp->GetData(4, SQL_C_CHAR, formw, sizeof(formw), &cb);
01344                                                                 dbuFastApp->GetData(5, SQL_C_CHAR, formh, sizeof(formh), &cb);
01345                                                                 dbuFastApp->GetData(6, SQL_C_CHAR, formtype, sizeof(formtype), &cb);
01346                                                                 dbuFastApp->GetData(7, SQL_C_CHAR, formstyle, sizeof(formstyle), &cb);
01347                                                                 dbuFastApp->GetData(8, SQL_C_CHAR, caption, sizeof(caption), &cb);
01348                                                                 
01349                                                                 if(atoi(formtype) == 1)
01350                                                                 {
01351                                                                 (new wxFrame(NULL,atoi(fid),caption,wxPoint(atoi(formx),atoi(formy)),wxSize(atoi(formw),atoi(formh)),wxDEFAULT_FRAME_STYLE, "popup frame"))->Show(TRUE);
01352                                                                 }
01353                                                                 
01354                                                                 wxChar formid[50+1], objid[50+1], objx[50+1], objy[50+1], objw[50+1], objh[50+1], objtype[50+1], objstyle[50+1], objlabel[50+1], objdefault[50+1], attrtype[50+1];
01355                                                                 
01356                                                                 wxString objSqlStmt = "SELECT formid, objid,objx,objy,objw,objh,objtype, objstyle, objlabel, objdefault, attrtype FROM fa_object WHERE formid = '"+strFormId+"';";
01357                                                                 wxWindow *parent= FindWindowById(atoi(fid),NULL);
01358                                                                 
01359                                                                 if (!dbuFastApp->ExecSql(objSqlStmt.c_str()))
01360                                                                 {
01361                                                                         wxMessageBox("DB SQL STMT CANNOT EXECUTE.");
01362                                                                         return;
01363                                                                 }
01364                                                                 else
01365                                                                 {
01366                                                                         while(dbuFastApp->GetNext())
01367                                                                         {
01368                                                                         dbuFastApp->GetData(1, SQL_C_CHAR, formid, sizeof(formid), &cb);
01369                                                                         dbuFastApp->GetData(2, SQL_C_CHAR, objid, sizeof(objid), &cb);
01370                                                                         dbuFastApp->GetData(3, SQL_C_CHAR, objx, sizeof(objx), &cb);
01371                                                                         dbuFastApp->GetData(4, SQL_C_CHAR, objy, sizeof(objy), &cb);
01372                                                                         dbuFastApp->GetData(5, SQL_C_CHAR, objw, sizeof(objw), &cb);
01373                                                                         dbuFastApp->GetData(6, SQL_C_CHAR, objh, sizeof(objh), &cb);
01374                                                                         dbuFastApp->GetData(7, SQL_C_CHAR, objtype, sizeof(objtype), &cb);
01375                                                                         dbuFastApp->GetData(8, SQL_C_CHAR, objstyle, sizeof(objstyle), &cb);
01376                                                                         dbuFastApp->GetData(9, SQL_C_CHAR, objlabel, sizeof(objlabel), &cb);
01377                                                                         dbuFastApp->GetData(10, SQL_C_CHAR,objdefault, sizeof(objdefault), &cb);
01378                                                                         dbuFastApp->GetData(11, SQL_C_CHAR,attrtype, sizeof(attrtype), &cb);
01379                                                                         
01380                                                                         
01381                                                                         if(atoi(objtype) == 101)
01382                                                                         {//Buttons are type no. 101
01383                                                                                 (new wxButton(parent,atoi(objid),objlabel,wxPoint(atoi(objx),atoi(objy)),wxSize(atoi(objw),atoi(objh)),atoi(objstyle)))->Connect( atoi(objid), wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)  &GeneratorToolFrame::ButtonGenericEventFunc );
01384                                                                         }
01385                                                                         else if(atoi(objtype)==100)
01386                                                                         {//wxStaticText == type no. 100
01387                                                                                 (new wxStaticText(parent,atoi(objid),objlabel,wxPoint(atoi(objx),atoi(objy)), wxSize(atoi(objw),atoi(objh)),atoi(objstyle), "staticText"));
01388                                                                         }
01389                                                                         else if(atoi(objtype)==104)
01390                                                                         {//wxStaticBox == type no. 104
01391                                                                                 (new wxStaticBox(parent,atoi(objid),objlabel,wxPoint(atoi(objx),atoi(objy)), wxSize(atoi(objw),atoi(objh)),atoi(objstyle), "staticBox"));
01392                                                                         }
01393                                                                         else if(atoi(objtype)==5)
01394                                                                         {//wxGrid
01395                                                                                 (new wxGrid(parent, atoi(objid), wxPoint(atoi(objx),atoi(objy)), wxSize(atoi(objw),atoi(objh)),1 ,"Grid"))->CreateGrid(0, atoi(objstyle), wxGrid::wxGridSelectCells);
01396                                                                                 wxString sDefault = objdefault;
01397                                                                                 for(int k=0; k<atoi(objstyle);k++)
01398                                                                                 {
01399                                                                                         wxString temp;
01400                                                                                         if(k<atoi(objstyle)-1)
01401                                                                                         {       
01402                                                                                                 temp = sDefault.BeforeFirst(',');
01403                                                                                                 sDefault=sDefault.AfterFirst(',');
01404                                                                                         }
01405                                                                                         else
01406                                                                                                 temp = sDefault;
01407                                                                                         ((wxGrid *)(FindWindowById(atoi(objid),NULL)))->SetLabelValue(wxHORIZONTAL, temp,k);
01408                                                                                         ((wxGrid *)(FindWindowById(atoi(objid),NULL)))->AutoSize();
01409                                                                                 }
01410                                                                                 RefreshGrid(atoi(formid),atoi(objid));
01411                                                                         }
01412                                                                         else if(atoi(objtype)==107)
01413                                                                         {//textctrl
01414                                                                                 if(atoi(attrtype)==1||atoi(attrtype)==5||atoi(attrtype)==6||atoi(attrtype)==7)
01415                                                                                 {//numeric validators
01416                                                                                         objecttable.Put(atoi(objid),(new wxTextCtrl(parent, atoi(objid), "", wxPoint(atoi(objx),atoi(objy)),wxSize(atoi(objw),atoi(objh)), atoi(objstyle),NumericValidator)));
01417                                                                                 }
01418                                                                                 else
01419                                                                                 {//alphanumeric validators
01420                                                                                         (new wxTextCtrl(parent, atoi(objid), "", wxPoint(atoi(objx),atoi(objy)),wxSize(atoi(objw),atoi(objh)), atoi(objstyle),ASCIIValidator));
01421                                                                                 }
01422                                                                                 
01423                                                                                 int matchingIndex = arrObjectIds.Index(objid,FALSE,TRUE);
01424                                                                                 if(matchingIndex!=wxNOT_FOUND)
01425                                                                                 ((wxTextCtrl *) FindWindowById(atoi(arrObjectIds[matchingIndex])))->SetValue(arrDbStoredAttrib[matchingIndex]); 
01426                                                                         }
01427                                                                         }
01428                                                                 }
01429                                                         }
01430                                                         else
01431                                                         {
01432                                                                 wxMessageBox("Cannot Get Next");
01433                                                         }
01434                                                 }
01435                                                 FindWindowById(atoi(arrObjectIds[0]))->Show(FALSE);
01436                                         }
01437                                 }
01438                         }
01439         //Steps:
01440         //1. Read from grid     
01441         //2. store into temp storage places
01442         //3. popup the desired form and render its objects
01443         //4. populate the respective textctrls , hide the respective pk textctrl
01444         //5. wait for input
01445         }
01446         else if(arrProcessdesc[0].IsSameAs("UPDATE"))
01447         {
01448                 wxString $Table = arrProcessdesc[1];
01449                 wxString $Objects = arrProcessdesc[2];
01450                 wxString $Attributes = arrProcessdesc[3];
01451                 
01452                 wxArrayString arrInputValues = wxArrayString();
01453                 wxArrayString arrDbTableAttr = wxArrayString();
01454                 wxArrayString arrObjs = wxArrayString();
01455                 
01456                 //Break up Attributes list and store into a String Array
01457                 int numAttribs = $Attributes.Freq(',')+1;
01458                 
01459                 for(int x =0; x<numAttribs; x++)
01460                 {
01461                         if(x==(numAttribs-1))
01462                                 arrDbTableAttr.Add($Attributes,1);
01463                         else
01464                         {
01465                                 arrDbTableAttr.Add($Attributes.BeforeFirst(','),1);
01466                                 $Attributes = $Attributes.AfterFirst(',');
01467                         }
01468                 }
01469                 
01470                 //Break up the Objectids and Store into a String Array
01471                 int numObjs = $Objects.Freq(',')+1;
01472                 
01473                 for(int y =0; y<numObjs; y++)
01474                 {
01475                         if(y==(numObjs-1))
01476                                 arrObjs.Add($Objects,1);
01477                         else
01478                         {
01479                                 arrObjs.Add($Objects.BeforeFirst(','),1);
01480                                 $Objects = $Objects.AfterFirst(',');
01481                         }
01482                 }
01483                 
01484                 for(int z =0; z<numObjs; z++)
01485                 {
01486                         wxString input= ((wxTextCtrl *)(wxGetTopLevelParent(this)->FindWindow(atoi(arrObjs[z]))))->GetValue();
01487                         if(input.IsEmpty())
01488                         {
01489                                 wxMessageBox("Please fill in the Empty Fields", "Missing Fields", wxICON_INFORMATION,this);
01490                                 ((wxTextCtrl *)(wxGetTopLevelParent(this)->FindWindow(atoi(arrObjs[z]))))->SetFocus();
01491                                 return;
01492                         }
01493                         arrInputValues.Add(input,1);
01494                 }
01495                 //wxMessageBox(arrInputValues[3]);
01496                 wxString FinalAttribString;
01497                 for(int x =1; x<numAttribs; x++)
01498                 {
01499                         if(x==numAttribs-1)
01500                                 FinalAttribString+= (arrDbTableAttr[x]+" = '"+arrInputValues[x]+"'");
01501                         else
01502                                 FinalAttribString+= (arrDbTableAttr[x]+" = '"+arrInputValues[x]+"', ");
01503                         
01504                 }
01505                 for(int z =0; z<numObjs; z++)
01506                 {
01507                         ((wxTextCtrl *)(wxGetTopLevelParent(this)->FindWindow(atoi(arrObjs[z]))))->Clear();
01508                 }
01509                 
01510                 wxString UpdateSqlStmt = "UPDATE "+$Table+" SET "+FinalAttribString+" WHERE "+arrDbTableAttr[0]+" = '"+arrInputValues[0]+"';";
01511                 if (!dbuUser->ExecSql(UpdateSqlStmt.c_str()))
01512                 {
01513                         wxMessageBox("Can't execute Update SQL Statement");
01514                         return;
01515                 }
01516                 else{
01517                         wxMessageBox("Attributes Updated", "Success", wxICON_INFORMATION, this);
01518                         dbuUser->CommitTrans();
01519                 }
01520         //1. Retrieve the first value (the pid value)from the hidden text ctrl
01521         //2. Retrieve the values from the textctrls
01522         //3. retrieve the names of the attributes in the person table to update
01523         //4. exec the update stmt
01524         //5. feedback
01525         
01526         }
01527         else
01528         {
01529                 wxMessageBox("Remember that the LORD is in CONTROL");   
01530         }
01531         //CLEANING UP
01532         /**********Clear String Arrays and Free Up Memory*********/
01533         arrPid.Clear();
01534         arrProcessdesc.Clear();
01535         /************* FREE UP ODBC CONNECTIONS **********/
01536         wxDbFreeConnection(dbuFastApp);
01537         wxDbFreeConnection(dbuUser);
01538         /********************GO TO NEXT HANDLER**********************/
01539         //event.Skip();
01540         //return;
01541 }
01542 
01543 
01544 /** Generic Event Handling Function for StaticText
01545 */
01546 
01547 void 
01548 GeneratorToolFrame::StaticTextGenericEventFunc(wxCommandEvent& event)
01549 {
01550 
01551 }
01552 
01553 /** Generic Event Handling Function for Menus
01554 */
01555 
01556 void 
01557 GeneratorToolFrame::MenuGenericEventFunc(wxCommandEvent& event)
01558 {
01559 
01560 }
01561 
01562 /** Generic Event Handling Function for TextCtrls
01563 */
01564 
01565 void 
01566 GeneratorToolFrame::TextCtrlGenericEventFunc(wxCommandEvent& event)
01567 {
01568 
01569 }
01570 
01571 /** Generic Event Handling Function for Forms
01572 */
01573 /**
01574 *       This is the core of the ODBC Connections with the SysDB in the process of collecting data.
01575 *       //Check currency of the ODBC.INI file with the server.
01576 *       The program RSYNC will be run in the shell script that is executed by the system() function.
01577 *       The simple BASH Script checkodbc.sh will do the following:
01578 *               - Do a password-less connection through SSH
01579 *               - Do a check if the file has been updated. If it has, download the updated version, if not, do nothing.
01580 *       
01581 *       Prior to this execution of scripts, a system administrator will have to configure the password-less SSH Connection with the server so that the synching with the server's ODBC.ini file is done seamlessly. 
01582 *
01583 *       As a TODO For the future, we may again write a BASH Script to automate this pre-configuration process.
01584 */
01585 void 
01586 GeneratorToolFrame::DbEstb()
01587 {
01588         //Check currency of the ODBC.INI file with the server.
01589         //The program RSYNC will be run in the shell script that is executed by the system() function.
01590         //checkodbc.sh will do the following:
01591         //      - Do a password-less connection through SSH
01592         //      - Do a check if the file has been updated. If it has, download the updated version, if not, do nothing.
01593         system("/home/koryan/generatortool/src/checkodbc.sh");
01594 
01595         //ODBC DB CONNECTION SETUP
01596         DbConnectInf = NULL;
01597         DbConnectInf = new wxDbConnectInf( NULL, "fastapp-dsn", "", "", "" );
01598         if ( !DbConnectInf || !DbConnectInf->GetHenv() )
01599         {
01600                 wxMessageBox(wxT("Unable to define data source connection info."),
01601                              wxT("DB CONNECTION ERROR..."),wxOK | wxICON_EXCLAMATION);
01602         }
01603         dbFastApp = NULL;
01604         dbFastApp = wxDbGetConnection( DbConnectInf );
01605 
01606         ////////////////////////////////////////////////////////////////////////////////////////////
01607         //DATABASE TABLE DEFINITIONS FOR THE ODBC CONNECTIONS.
01608         //Hard Definition is done here as these system database tables are regularly referenced to.
01609         ////////////////////////////////////////////////////////////////////////////////////////////
01610         
01611         //FA_APP Table Definition
01612         wxString tbFa_AppName = "fa_app";
01613         const UWORD numFa_AppTableColumns = 7;
01614         sAppname[0]=0;sSusername[0]=0; sSpassword[0]=0;
01615         sAppid=0;sSuserid=0;sSdbid=0;sAppformid=0;
01616         tbFa_App = NULL;
01617         tbFa_App = new wxDbTable(dbFastApp, tbFa_AppName, numFa_AppTableColumns, "", !wxDB_QUERY_ONLY, "");
01618         tbFa_App->SetColDefs(0, "appid", DB_DATA_TYPE_INTEGER, &sAppid, SQL_C_LONG, sizeof(sAppid), true, true);
01619         tbFa_App->SetColDefs(1, "appname", DB_DATA_TYPE_VARCHAR, sAppname, SQL_C_CHAR, sizeof(sAppname), true, true);
01620         tbFa_App->SetColDefs(2, "suserid", DB_DATA_TYPE_INTEGER, &sSuserid, SQL_C_LONG, sizeof(sSuserid), true, true);
01621         tbFa_App->SetColDefs(3, "sdbid", DB_DATA_TYPE_INTEGER, &sSdbid, SQL_C_LONG, sizeof(sSdbid), true, true);
01622         tbFa_App->SetColDefs(4, "appformid", DB_DATA_TYPE_INTEGER, &sAppformid, SQL_C_LONG, sizeof(sAppformid), true, true);
01623         tbFa_App->SetColDefs(5, "susername", DB_DATA_TYPE_VARCHAR, sSusername, SQL_C_CHAR, sizeof(sSusername), true, true);
01624         tbFa_App->SetColDefs(6, "spassword", DB_DATA_TYPE_VARCHAR, sSpassword, SQL_C_CHAR, sizeof(sSpassword), true, true);
01625 
01626         //FA_INIFILE Table Definition
01627         wxString tbFa_InifileName = "fa_inifile";
01628         const UWORD numFa_InifileTableColumns = 6;
01629         sLastdateupdated[0]=0;sLasttimeupdated[0]=0; sFilelocation[0]=0;sScphost[0]=0;sScpuser[0]=0;sScppw[0]=0;
01630         tbFa_Inifile = NULL;
01631         tbFa_Inifile = new wxDbTable(dbFastApp, tbFa_InifileName, numFa_InifileTableColumns, "", !wxDB_QUERY_ONLY, "");
01632         tbFa_Inifile->SetColDefs(0, "lastdateupdated", DB_DATA_TYPE_DATE, sLastdateupdated, SQL_C_CHAR, sizeof(sLastdateupdated), true, true);
01633         tbFa_Inifile->SetColDefs(1, "lasttimeupdated", DB_DATA_TYPE_VARCHAR, sLasttimeupdated, SQL_C_CHAR, sizeof(sLasttimeupdated), true, true);
01634         tbFa_Inifile->SetColDefs(2, "filelocation", DB_DATA_TYPE_VARCHAR, sFilelocation, SQL_C_CHAR, sizeof(sFilelocation), true, true);
01635         tbFa_Inifile->SetColDefs(3, "scphost", DB_DATA_TYPE_VARCHAR, sScphost, SQL_C_CHAR, sizeof(sScphost), true, true);
01636         tbFa_Inifile->SetColDefs(4, "scpuser", DB_DATA_TYPE_VARCHAR, sScpuser, SQL_C_CHAR, sizeof(sScpuser), true, true);
01637         tbFa_Inifile->SetColDefs(5, "scppw", DB_DATA_TYPE_VARCHAR, sScppw, SQL_C_CHAR, sizeof(sScppw), true, true);
01638         
01639         //FA_DB Table Definition
01640         wxString tbFa_DbName = "fa_db";
01641         const UWORD numFa_DbTableColumns = 4;
01642         sDbid=0;sNooftables=0;
01643         sDbname[50+1]=0;sDsnname[0]=0;
01644         tbFa_Db = NULL;
01645         tbFa_Db = new wxDbTable(dbFastApp, tbFa_DbName, numFa_DbTableColumns, "", !wxDB_QUERY_ONLY, "");
01646         tbFa_Db->SetColDefs(0, "Dbid", DB_DATA_TYPE_INTEGER, &sDbid, SQL_C_LONG, sizeof(sDbid), true, true);
01647         tbFa_Db->SetColDefs(1, "dbname", DB_DATA_TYPE_VARCHAR, sDbname, SQL_C_CHAR, sizeof(sDbname), true, true);
01648         tbFa_Db->SetColDefs(2, "nooftables", DB_DATA_TYPE_INTEGER, &sNooftables, SQL_C_LONG, sizeof(sNooftables), true, true);
01649         tbFa_Db->SetColDefs(3, "dsnname", DB_DATA_TYPE_VARCHAR, sDsnname, SQL_C_CHAR, sizeof(sDsnname), true, true);
01650 
01651         //FA_TABLEDEF Table Definition
01652         wxString tbFa_TabledefName = "fa_tabledef";
01653         const UWORD numFa_TabledefTableColumns = 4;
01654         sTableid=0;sNoofcolumns=0;sTD_Deleted=0;
01655         sTablename[50+1]=0;
01656         tbFa_Tabledef = NULL;
01657         tbFa_Tabledef = new wxDbTable(dbFastApp, tbFa_TabledefName, numFa_TabledefTableColumns, "", !wxDB_QUERY_ONLY, "");
01658         tbFa_Tabledef->SetColDefs(0, "tableid", DB_DATA_TYPE_INTEGER, &sTableid, SQL_C_LONG, sizeof(sTableid), true, true);
01659         tbFa_Tabledef->SetColDefs(1, "tablename", DB_DATA_TYPE_INTEGER, sTablename, SQL_C_CHAR, sizeof(sTablename), true, true);
01660         tbFa_Tabledef->SetColDefs(2, "noofcolumns", DB_DATA_TYPE_INTEGER, &sNoofcolumns, SQL_C_LONG, sizeof(sNoofcolumns), true, true);
01661         tbFa_Tabledef->SetColDefs(3, "deleted", DB_DATA_TYPE_INTEGER, &sTD_Deleted, SQL_C_LONG, sizeof(sTD_Deleted), true, true);
01662 
01663         //FA_DBTABLE Table Definition
01664         wxString tbFa_DbtableName = "fa_dbtable";
01665         const UWORD numFa_DbtableTableColumns = 2;
01666         sDBT_Dbid=0;sDBT_Tabid=0;
01667         tbFa_Dbtable = NULL;
01668         tbFa_Dbtable = new wxDbTable(dbFastApp, tbFa_DbtableName, numFa_DbtableTableColumns, "", !wxDB_QUERY_ONLY, "");
01669         tbFa_Dbtable->SetColDefs(0, "dbid", DB_DATA_TYPE_INTEGER, &sDBT_Dbid, SQL_C_LONG, sizeof(sDBT_Dbid), true, true);
01670         tbFa_Dbtable->SetColDefs(1, "tabid", DB_DATA_TYPE_INTEGER, &sDBT_Tabid, SQL_C_LONG, sizeof(sDBT_Tabid), true, true);
01671         
01672         //FA_COLUMNDEF Table Definition
01673         wxString tbFa_ColumndefName = "fa_columndef";
01674         const UWORD numFa_ColumndefTableColumns = 9;
01675         sColid=0;sAttrtype=0;sAttrlength=0;sAttrpkey=0;sFkeytableid=0;sFkeyattrib=0;sCD_Deleted=0;
01676         sAttrname[50+1]=0;sAttrdefault[50+1]=0;
01677         tbFa_Columndef = NULL;
01678         tbFa_Columndef = new wxDbTable(dbFastApp, tbFa_ColumndefName, numFa_ColumndefTableColumns, "", !wxDB_QUERY_ONLY, "");
01679         tbFa_Columndef->SetColDefs(0, "colid", DB_DATA_TYPE_INTEGER, &sColid, SQL_C_LONG, sizeof(sColid), true, true);
01680         tbFa_Columndef->SetColDefs(1, "attrname", DB_DATA_TYPE_VARCHAR, sAttrname, SQL_C_CHAR, sizeof(sAttrname), true, true);
01681         tbFa_Columndef->SetColDefs(2, "attrtype", DB_DATA_TYPE_INTEGER, &sAttrtype, SQL_C_LONG, sizeof(sAttrtype), true, true);
01682         tbFa_Columndef->SetColDefs(3, "attrlength", DB_DATA_TYPE_INTEGER, &sAttrlength, SQL_C_LONG, sizeof(sAttrlength), true, true);
01683         tbFa_Columndef->SetColDefs(4, "attrdefault", DB_DATA_TYPE_VARCHAR,sAttrdefault,SQL_C_CHAR,sizeof(sAttrdefault), true, true);
01684         tbFa_Columndef->SetColDefs(5, "attrpkey", DB_DATA_TYPE_INTEGER, &sAttrpkey, SQL_C_LONG, sizeof(sAttrpkey), true, true);
01685         tbFa_Columndef->SetColDefs(6, "fkeytableid", DB_DATA_TYPE_INTEGER, &sFkeytableid, SQL_C_LONG, sizeof(sFkeytableid), true, true);
01686         tbFa_Columndef->SetColDefs(7, "fkeyattrib", DB_DATA_TYPE_INTEGER, &sFkeyattrib, SQL_C_LONG, sizeof(sFkeyattrib), true, true);
01687         tbFa_Columndef->SetColDefs(8, "deleted", DB_DATA_TYPE_INTEGER, &sCD_Deleted, SQL_C_LONG, sizeof(sCD_Deleted), true, true);
01688 
01689         //FA_TABLECOL Table Definition
01690         wxString tbFa_TablecolName = "fa_tablecol";
01691         const UWORD numFa_TablecolTableColumns = 2;
01692         sTC_Tabid=0;sTC_Colid=0;
01693         tbFa_Tablecol = NULL;
01694         tbFa_Tablecol = new wxDbTable(dbFastApp, tbFa_TablecolName, numFa_TablecolTableColumns, "", !wxDB_QUERY_ONLY, "");
01695         tbFa_Tablecol->SetColDefs(0, "tabid", DB_DATA_TYPE_INTEGER, &sTC_Tabid, SQL_C_LONG, sizeof(sTC_Tabid), true, true);
01696         tbFa_Tablecol->SetColDefs(1, "colid", DB_DATA_TYPE_INTEGER, &sColid, SQL_C_LONG, sizeof(sTC_Colid), true, true);
01697 
01698         //FA_LANGUAGE Table Definition
01699         wxString tbFa_LanguageName = "fa_language";
01700         const UWORD numFa_LanguageTableColumns = 4;
01701         sLanguage[0]=0;sLstyle[0]=0;
01702         sLid=0;sFont=0;
01703         tbFa_Language = NULL;
01704         tbFa_Language = new wxDbTable(dbFastApp, tbFa_LanguageName, numFa_LanguageTableColumns, "", !wxDB_QUERY_ONLY, "");
01705         tbFa_Language->SetColDefs(0, "lid", DB_DATA_TYPE_INTEGER, &sLid, SQL_C_LONG, sizeof(sLid), true, true);
01706         tbFa_Language->SetColDefs(1, "language", DB_DATA_TYPE_VARCHAR, sLanguage, SQL_C_CHAR, sizeof(sLanguage), true, true);
01707         tbFa_Language->SetColDefs(2, "font", DB_DATA_TYPE_INTEGER, &sFont, SQL_C_LONG, sizeof(sFont), true, true);
01708         tbFa_Language->SetColDefs(3, "lstyle", DB_DATA_TYPE_VARCHAR, sLstyle, SQL_C_LONG, sizeof(sLstyle), true, true);
01709 
01710         //fa_process table definition
01711         //****************Note the SQL_C_LONG of pid**********************
01712         wxString tbFa_ProcessName = "fa_process";
01713         const UWORD numFa_ProcessTableColumns = 3;
01714         sPid[0]=0;sProcessdesc[0]=0;
01715         sEventid = 0;
01716         tbFa_Process = NULL;
01717         tbFa_Process = new wxDbTable(dbFastApp, tbFa_ProcessName, numFa_ProcessTableColumns, "", !wxDB_QUERY_ONLY, "");
01718         tbFa_Process->SetColDefs(0, "pid", DB_DATA_TYPE_INTEGER, sPid, SQL_C_CHAR, sizeof(sPid), true, true);
01719         tbFa_Process->SetColDefs(1, "processdesc", DB_DATA_TYPE_VARCHAR, sProcessdesc, SQL_C_CHAR, sizeof(sProcessdesc), true, true);
01720         tbFa_Process->SetColDefs(2, "eventid", DB_DATA_TYPE_INTEGER, &sEventid, SQL_C_LONG, sizeof(sEventid), true, true);
01721 
01722         //fa_form table
01723         wxString tbFa_FormName = "fa_form";
01724         const UWORD numFa_FormTableColumns = 12;
01725         sFid=0; sFormx=0; sFormy=0; sFormw=0; sFormh=0; sFormtype=0; sFormstyle=0; sCaption[0]=0; sInitialisation=0; sPreprocessing=0; sPostprocessing=0;sIsindex=0;
01726         tbFa_Form = NULL;
01727         tbFa_Form = new wxDbTable(dbFastApp, tbFa_FormName, numFa_FormTableColumns, "", !wxDB_QUERY_ONLY, "");
01728         tbFa_Form->SetColDefs(0, "fid", DB_DATA_TYPE_INTEGER, &sFid, SQL_C_LONG, sizeof(sFid), true, true);
01729         tbFa_Form->SetColDefs(1, "formx", DB_DATA_TYPE_INTEGER, &sFormx, SQL_C_LONG, sizeof(sFormx), true, true);
01730         tbFa_Form->SetColDefs(2, "formy", DB_DATA_TYPE_INTEGER, &sFormy, SQL_C_LONG, sizeof(sFormy), true, true);
01731         tbFa_Form->SetColDefs(3, "formw", DB_DATA_TYPE_INTEGER, &sFormw, SQL_C_LONG, sizeof(sFormw), true, true);
01732         tbFa_Form->SetColDefs(4, "formh", DB_DATA_TYPE_INTEGER, &sFormh, SQL_C_LONG, sizeof(sFormh), true, true);
01733         tbFa_Form->SetColDefs(5, "formtype", DB_DATA_TYPE_INTEGER, &sFormtype, SQL_C_LONG, sizeof(sFormtype), true, true);
01734         tbFa_Form->SetColDefs(6, "formstyle", DB_DATA_TYPE_INTEGER, &sFormstyle, SQL_C_LONG, sizeof(sFormstyle), true, true);
01735         tbFa_Form->SetColDefs(7, "caption", DB_DATA_TYPE_VARCHAR, sCaption, SQL_C_CHAR, sizeof(sCaption), true, true);
01736         tbFa_Form->SetColDefs(8, "initialisation", DB_DATA_TYPE_INTEGER, &sInitialisation, SQL_C_LONG, sizeof(sInitialisation), true, true);
01737         tbFa_Form->SetColDefs(9, "preprocessing", DB_DATA_TYPE_INTEGER, &sPreprocessing, SQL_C_LONG, sizeof(sPreprocessing), true, true);
01738         tbFa_Form->SetColDefs(10, "postprocessing", DB_DATA_TYPE_INTEGER, &sPostprocessing, SQL_C_LONG, sizeof(sPostprocessing), true, true);
01739         tbFa_Form->SetColDefs(11, "isindex", DB_DATA_TYPE_INTEGER, &sIsindex, SQL_C_LONG, sizeof(sIsindex), true, true);
01740         
01741         //FA_APPFORM TABLE definition
01742         wxString tbFa_AppformName = "fa_appform";
01743         const UWORD numFa_AppformTableColumns = 2;
01744         sAF_Appid=0; sAF_Formid=0;
01745         tbFa_Appform = NULL;
01746         tbFa_Appform = new wxDbTable(dbFastApp, tbFa_AppformName, numFa_AppformTableColumns, "", !wxDB_QUERY_ONLY, "");
01747         tbFa_Appform->SetColDefs(0, "appid", DB_DATA_TYPE_INTEGER, &sAF_Appid, SQL_C_LONG, sizeof(sAF_Appid), true, true);
01748         tbFa_Appform->SetColDefs(1, "formid", DB_DATA_TYPE_INTEGER, &sAF_Formid, SQL_C_LONG, sizeof(sAF_Formid), true, true);
01749         
01750         //fa_object table
01751         wxString tbFa_ObjectName = "fa_object";
01752         const UWORD numFa_ObjectTableColumns = 16;
01753         sFormid=0; sObjid=0; sChildid=0; sLangid=0; sObjx=0; sObjy=0; sObjw=0; sObjh=0; sObjtype=0;sObjstyle=0;sOT_Eventid[0]=0;
01754         sObjlabel[0]=0; sObjdefault[0]=0;sAttrtable[0]=0;sAttr[0]=0;sO_Attrtype[0]=0;
01755         
01756         tbFa_Object = NULL;
01757         tbFa_Object = new wxDbTable(dbFastApp, tbFa_ObjectName, numFa_ObjectTableColumns, "", !wxDB_QUERY_ONLY, "");
01758         tbFa_Object->SetColDefs(0, "formid", DB_DATA_TYPE_INTEGER, &sFormid, SQL_C_LONG, sizeof(sFormid), true, true);
01759         tbFa_Object->SetColDefs(1, "objid", DB_DATA_TYPE_INTEGER, &sObjid, SQL_C_LONG, sizeof(sObjid), true, true);     tbFa_Object->SetColDefs(2, "childid", DB_DATA_TYPE_INTEGER, &sChildid, SQL_C_LONG, sizeof(sChildid), true, true);       tbFa_Object->SetColDefs(3, "langid", DB_DATA_TYPE_INTEGER, &sLangid, SQL_C_LONG, sizeof(sLangid), true, true);  tbFa_Object->SetColDefs(4, "objx", DB_DATA_TYPE_INTEGER, &sObjx, SQL_C_LONG, sizeof(sObjx), true, true);        tbFa_Object->SetColDefs(5, "objy", DB_DATA_TYPE_INTEGER, &sObjy, SQL_C_LONG, sizeof(sObjy), true, true);
01760         tbFa_Object->SetColDefs(6, "objw", DB_DATA_TYPE_INTEGER, &sObjw, SQL_C_LONG, sizeof(sObjw), true, true);
01761         tbFa_Object->SetColDefs(7, "objh", DB_DATA_TYPE_INTEGER, &sObjh, SQL_C_LONG, sizeof(sObjh), true, true);
01762         tbFa_Object->SetColDefs(8, "objtype", DB_DATA_TYPE_INTEGER, &sObjtype, SQL_C_LONG, sizeof(sObjtype), true, true);
01763         tbFa_Object->SetColDefs(9, "objstyle", DB_DATA_TYPE_INTEGER, &sObjstyle, SQL_C_LONG, sizeof(sObjstyle), true, true);
01764         tbFa_Object->SetColDefs(10, "objlabel", DB_DATA_TYPE_VARCHAR, sObjlabel, SQL_C_CHAR, sizeof(sObjlabel), true, true);
01765         tbFa_Object->SetColDefs(11, "objdefault", DB_DATA_TYPE_VARCHAR, sObjdefault, SQL_C_CHAR, sizeof(sObjdefault), true, true);
01766         tbFa_Object->SetColDefs(12, "eventid", DB_DATA_TYPE_INTEGER, sOT_Eventid, SQL_C_CHAR, sizeof(sOT_Eventid), true, true);
01767         tbFa_Object->SetColDefs(13, "attrtable", DB_DATA_TYPE_VARCHAR, sAttrtable, SQL_C_CHAR, sizeof(sAttrtable), true, true);
01768         tbFa_Object->SetColDefs(14, "attr", DB_DATA_TYPE_VARCHAR, sAttr, SQL_C_CHAR, sizeof(sAttr), true, true);
01769         tbFa_Object->SetColDefs(15, "attrtype", DB_DATA_TYPE_INTEGER, sO_Attrtype, SQL_C_CHAR, sizeof(sO_Attrtype), true, true);
01770 }

Generated on Thu Mar 3 01:54:37 2005 for FastApp Binary Client by doxygen 1.3.6
Hosted by www.Geocities.ws

1