Load New Record

B

BD

Writing C# front end for SQL Server 2005 back-end database. I have a
form I want to use to enter new workorders but I don't want to
retrieve existing workorders on the system. I only want to retrieve a
new record. This is do to overhead concerns. I have been able to
modify my query for the dataset to retrieve last entered record and go
to a new record, but have hit complications on some objects on the
form. Appears the load method is overloaded. The same method loads
the recordset that holds last record entered and then tries to go a
new record. This works, but some of the other objects are not being
set to null. I have a button on the form that will do it without
fail. Makes me think the method is doing too much at one time. Is
there a way to load form to a new record only?

Any help is fantastic.

BD
 
N

Nicholas Paldino [.NET/C# MVP]

BD,

How this is done is completely dependent on the code you are writing to
generate new records. You haven't shown any of that, so it's impossible to
say, since we can't see what you are doing.
 
B

BD

BD,

How this is done is completely dependent on the code you are writing to
generate new records. You haven't shown any of that, so it's impossible to
say, since we can't see what you are doing.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Writing C# front end for SQL Server 2005 back-end database. I have a
form I want to use to enter new workorders but I don't want to
retrieve existing workorders on the system. I only want to retrieve a
new record. This is do to overhead concerns. I have been able to
modify my query for the dataset to retrieve last entered record and go
to a new record, but have hit complications on some objects on the
form. Appears the load method is overloaded. The same method loads
the recordset that holds last record entered and then tries to go a
new record. This works, but some of the other objects are not being
set to null. I have a button on the form that will do it without
fail. Makes me think the method is doing too much at one time. Is
there a way to load form to a new record only?
Any help is fantastic.

I am using the wizard to create typed datasets and then my own
querries to filter out data. The code I am using for new records
follows:

Code for button on already opened form:
private void btnSaveNewWO_Click(object sender, EventArgs e)
{
this.work_OrderBindingSource.AddNew();
this.work_FinishedCheckBox.Checked = false;
this.hasBeenBilledCheckBox.Checked = false;
}

Code for loading form:
internal void WorkOrderNew()
{

this.work_OrderTableAdapter.FillByNew(this.datasetNewWO.Work_Order);

this.btnSaveNewWO.Visible = true;
this.btnCancelNewWO.Visible = true;
this.btnCloseNewWO.Visible = true;
this.work_OrderDataGridView.Visible = false;
this.btnSave.Visible = false;

New Record();
}


internal void NewRecord()
{
this.work_OrderBindingSource.AddNew();
this.work_FinishedCheckBox.Checked = false;
this.hasBeenBilledCheckBox.Checked = false;
}

The load method uses a query I wrote to pull the last record from the
server and then of course the code addes a new record. The problem I
have is that the check boxes are not showing false and some combo
boxes are showing existing data. I can overwrite the existing data in
the combo boxes and set the checkboxes to false with a mouse click,
but I am trying to keep the users hands on the keyboard as much as
possible and reduce the risk of data entry errors. I am sure there is
a better way to pull this off especially since I really don't need the
last record, just the indentity number from and increase by one. As
another note, this form which is a Workorder form is tied to 3 tables,
one for the main record (date, customer, location, problem description
etc) the other two tables are used for line items on the workorder
(material and labor). Another note, in realty, to add a new workorder
record, I don't per say need the line items and could leave them out
of the picture.

Thanks again,

BD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top