FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Data aware DFL controls

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
un_guru



Joined: 14 Sep 2005
Posts: 32

PostPosted: Tue Feb 21, 2006 1:59 am    Post subject: Data aware DFL controls Reply with quote

If you are familyar with DAO or DBexpress you know what I mean, if not...:
A form (or maybe any parent control) has a recordset defined, and some of it's child controls are binded to records of that recodset. So when the data changes, recodset changes, control's value changes ...and vice versa.

Another thing i'm thinking is automatic data driven forms generator
ie: you get some data from a database (or xml) and this "thing" will create a form for you to edit that data, and/or create a report, a fancy sheet.
I can make the data layer, but I can't help much with the win api.
So, Chris, are you in?
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Tue Feb 21, 2006 2:54 am    Post subject: Re: Data aware DFL controls Reply with quote

Can you provide more information and/or a programmatic example? and why would Windows API be needed? Thanks
Back to top
View user's profile Send private message
un_guru



Joined: 14 Sep 2005
Posts: 32

PostPosted: Tue Feb 21, 2006 4:28 am    Post subject: Reply with quote

Let's say we have a form with a few textboxes ,navigation buttons and a database. To browse the records I do
Code:

Form form;
DataBase db;
/* form initialization code here*/

// retrive data
result = db.query("SELECT * FROM `mytabe`");
row = result.fetch_row();
current_row = 0;
textBox1.text = row[1];
......

// browsing ....
protected void previousButton_click(Object sender, EventArgs ea)
{
  (current_row >0) ? current_row-- : return ;
  result.data_seek(current_row);
  row = result.fetch_row();
textBox1.text = row[1] // we can make a function to update this fields....
                                  //but I wanted it to look more dramatic
}
protected void nextButton_click ....

// to update records ...
db.exec("UPDATE `mytable` SET .... WHERE ...")
//and we need some code to define the where clause

Using data aware components one should just add a datacontrol to the form and bind DFL controls to it like
Code:

Form form;
DataComponent dc = new DataComponent(databaseConnection, queryString, method)
// method whould be a const int - read_only/read_write/auto_update/
dc.bind(DFLcontrol, "recordField"); // call this once for each control
dc.navigator.bounds = .... // this is a panel with the navigation buttons

And that's all the programmer needs to do. the DataComponent will do the rest. WinAPI? We neet to bind DFL controls to it, so we need events. That's what I don't know how to do.

The seccond thing ...
Code:

Form form;
DataSource ds = new DataSource(); // DataSource extends DataBase, it is also used to read xml and csv
result = ds.query(querString);
row = result.fetch_row();
for(int i=0, i<=result.num_fields(); i++)
{
   if(/* field is of type x */) {
    // add new DFL control that coresponds to x
  } else if (/* field is of type y */) {
     // ...
  }...
}

How to add those DFL controls knowing that we'll need to access their values?!
I tought of something like declare a dynamic area for each dfl control at the initialization stage and than
Code:

TextBox[] textbox;

for(int i=0, i<=result.num_fields(); i++)
{
   if(/* field is of type String */) {
     textbox.length = textbox.length + 1;
     textbox[i].text = row[i];
  } else if (/* field is of type y */) {
     // ...
  }...
}

Is this any good?
thanks
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed Feb 22, 2006 7:50 am    Post subject: Reply with quote

Maybe this is something for after DFL 1.0, unless you want to get started on it, I'll try to help you along the way.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group