467,077 Members | 947 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

Data Entry Form

Background:
I have a data entry form that is bound to a DataSet. This DataSet contains
9 tables and the form displays data from each table in textboxes, not a
DataGrid. One of the tables in the ParentTable and the rest are children.

For Example:
The form shows the Customer and their most recently added Contact (in
textboxes, not in a DataGrid). When I click the Add button on the form, I
enumerate through all of the DataTables in the DataSet and call
BindingContext(DataTable).AddNew(). (Now, make note that the end user may
not always decide to enter a contact's information.) (For this example,
assume that the user did not enter a contact.) When the user clicks on Save,
I again enumerate through all of the DataTables in the DataSet and call
BindingContext(DataTable).EndCurrentEdit(). At this point every table in the
DataSet shows as having 1 row. When really the row for the Contacts table is
blank. This creates problems when trying to insert the data into the
database.

Is there a better way of doing this? I know that I could watch for entry
into any of the fields for the Contacts table and then call AddNew, but that
would be cumbersome to code.

PS - I know that the best way to do this would be to have a button that the
user clicks on to "Add New Contact" and then display a dialog form that would
allow the end user to enter the nessary information, or even just enable the
controls on the main form. That is the best and easiest way to accomplish
what I need to accomplish, however, my client wants it done the way described
above. They are moving from a DOS-based DBase application and want this to
act as much like the old app as possible.

Thanks in advance!!
Nov 23 '05 #1
  • viewed: 2757
Share:
5 Replies
ASPNOT,

Have a look at this one.

http://www.vb-tips.com/default.aspx?...8-2e91e5295e7c

In the same way as in this sample at the delete in this sample you can of
course as well try the rejectchanges

http://msdn.microsoft.com/library/de...angestopic.asp

I hope this helps,

Cor

"Aspnot" <NO******************@nc.rr.com> schreef in bericht
news:62**********************************@microsof t.com...
Background:
I have a data entry form that is bound to a DataSet. This DataSet
contains
9 tables and the form displays data from each table in textboxes, not a
DataGrid. One of the tables in the ParentTable and the rest are children.

For Example:
The form shows the Customer and their most recently added Contact (in
textboxes, not in a DataGrid). When I click the Add button on the form, I
enumerate through all of the DataTables in the DataSet and call
BindingContext(DataTable).AddNew(). (Now, make note that the end user may
not always decide to enter a contact's information.) (For this example,
assume that the user did not enter a contact.) When the user clicks on
Save,
I again enumerate through all of the DataTables in the DataSet and call
BindingContext(DataTable).EndCurrentEdit(). At this point every table in
the
DataSet shows as having 1 row. When really the row for the Contacts table
is
blank. This creates problems when trying to insert the data into the
database.

Is there a better way of doing this? I know that I could watch for entry
into any of the fields for the Contacts table and then call AddNew, but
that
would be cumbersome to code.

PS - I know that the best way to do this would be to have a button that
the
user clicks on to "Add New Contact" and then display a dialog form that
would
allow the end user to enter the nessary information, or even just enable
the
controls on the main form. That is the best and easiest way to accomplish
what I need to accomplish, however, my client wants it done the way
described
above. They are moving from a DOS-based DBase application and want this
to
act as much like the old app as possible.

Thanks in advance!!

Nov 23 '05 #2
Cor,

Thanks for the reply. My example appears to have been lacking some
important information. Let me see if I can elaborate.

For ease, let's just consider a form that uses a DataSet that contains 2
tables named Customers and Contacts. The Contacts table can contain multiple
records for each Customer. On the form, I have a groupbox with information
about the customer and another groupbox with information about the last
contact created. The only buttons on the form are a New and Save button.
The New button creates a new customer (which in turn creates a new contact)
and the Save button saves the data. When the user clicks on the New button,
I do not know at that point whether they are going to enter a Contact or not,
so I call BindingContext(ds.Customers).AddNew() and
BindingContext(ds.Contacts).AddNew(). Assuming that the user entered data
for the customer, but not for the contact, when the user clicks Save, I need
a way to determine if information was entered for the contact section.

I know that I can loop through each field in ds.Contacts and determine if
any of them have values other than the defaults, but there has to be an
easier way.

If you have a better way of going about this, please let me know.

Again, thanks.

"Cor Ligthert [MVP]" wrote:
ASPNOT,

Have a look at this one.

http://www.vb-tips.com/default.aspx?...8-2e91e5295e7c

In the same way as in this sample at the delete in this sample you can of
course as well try the rejectchanges

http://msdn.microsoft.com/library/de...angestopic.asp

I hope this helps,

Cor

"Aspnot" <NO******************@nc.rr.com> schreef in bericht
news:62**********************************@microsof t.com...
Background:
I have a data entry form that is bound to a DataSet. This DataSet
contains
9 tables and the form displays data from each table in textboxes, not a
DataGrid. One of the tables in the ParentTable and the rest are children.

For Example:
The form shows the Customer and their most recently added Contact (in
textboxes, not in a DataGrid). When I click the Add button on the form, I
enumerate through all of the DataTables in the DataSet and call
BindingContext(DataTable).AddNew(). (Now, make note that the end user may
not always decide to enter a contact's information.) (For this example,
assume that the user did not enter a contact.) When the user clicks on
Save,
I again enumerate through all of the DataTables in the DataSet and call
BindingContext(DataTable).EndCurrentEdit(). At this point every table in
the
DataSet shows as having 1 row. When really the row for the Contacts table
is
blank. This creates problems when trying to insert the data into the
database.

Is there a better way of doing this? I know that I could watch for entry
into any of the fields for the Contacts table and then call AddNew, but
that
would be cumbersome to code.

PS - I know that the best way to do this would be to have a button that
the
user clicks on to "Add New Contact" and then display a dialog form that
would
allow the end user to enter the nessary information, or even just enable
the
controls on the main form. That is the best and easiest way to accomplish
what I need to accomplish, however, my client wants it done the way
described
above. They are moving from a DOS-based DBase application and want this
to
act as much like the old app as possible.

Thanks in advance!!


Nov 23 '05 #3
ASPNOT,

Did you try the sample, if you use that for both your customers and your
contacts than you get in my idea a nicer application with much less work.

Your contacts should than have in the rowfilter of the defaultview the id of
the customer.,

In your case I would just use the sample. It is so easy to try and probably
is changing your program than almost no work.

I hope this helps,

Cor
Nov 23 '05 #4
I looked at the example on your site and that uses navigation buttons to move
around and to add a new record. That would be far too easy for this client.
They do not want to have to click a button to add a Contact. They want to
click the Add New button for the Customer and have it automatically set them
up with a blank Contact. Then they want to let the application determine
whether they typed anything into the Contact or not.

I am currently working on some code to loop through each DataTable in the
DataSet and then each DataRow in the DataTable and then through each
DataColumn in each DataRow to compare the values to the Default values to see
if any changes have been made to the data for the Contacts table. I find
this way of doing it to be very cumbersome. There has to be a better way. I
have run into an issue with this mechanism that if I RejectChanges() on a
DataRow, then I can no longer enumerate through the DataRows since the
collection has now changed.

"Cor Ligthert [MVP]" wrote:
ASPNOT,

Did you try the sample, if you use that for both your customers and your
contacts than you get in my idea a nicer application with much less work.

Your contacts should than have in the rowfilter of the defaultview the id of
the customer.,

In your case I would just use the sample. It is so easy to try and probably
is changing your program than almost no work.

I hope this helps,

Cor

Nov 23 '05 #5
Aspnot,

I don't find it an advanced application that your customer wants, sounds as
from the first ms DOS 1.1 time, however that is what you wrote.

Now I assume that you just want to know the rowstate of the last edited row.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
"Aspnot" <NO******************@nc.rr.com> schreef in bericht
news:F8**********************************@microsof t.com...
I looked at the example on your site and that uses navigation buttons to
move
around and to add a new record. That would be far too easy for this
client.
They do not want to have to click a button to add a Contact. They want to
click the Add New button for the Customer and have it automatically set
them
up with a blank Contact. Then they want to let the application determine
whether they typed anything into the Contact or not.

I am currently working on some code to loop through each DataTable in the
DataSet and then each DataRow in the DataTable and then through each
DataColumn in each DataRow to compare the values to the Default values to
see
if any changes have been made to the data for the Contacts table. I find
this way of doing it to be very cumbersome. There has to be a better way.
I
have run into an issue with this mechanism that if I RejectChanges() on a
DataRow, then I can no longer enumerate through the DataRows since the
collection has now changed.

"Cor Ligthert [MVP]" wrote:
ASPNOT,

Did you try the sample, if you use that for both your customers and your
contacts than you get in my idea a nicer application with much less work.

Your contacts should than have in the rowfilter of the defaultview the id
of
the customer.,

In your case I would just use the sample. It is so easy to try and
probably
is changing your program than almost no work.

I hope this helps,

Cor

Nov 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Iain Miller | last post: by
reply views Thread by tamilan71@yahoo.com | last post: by
6 posts views Thread by Brian Blair | last post: by
reply views Thread by Tyler | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.