Detach row from BindingSource or DataTable, which was deleted independently - concurrency

In winforms app, I created myBindingSource, myTableAdapter etc via designer, by drag-n-dropping datatable to the form. In the form I have buttons Save and Delete. The requirement is
when Delete button is clicked it should immediately delete a record from database,
not when Save button is clicked. So I added DeleteMyRecord query to MyDataSet via
designer and use that delete query to do deletion. The problem is deleted
record is still in myDataSet instance, so I need to detach it from its datatable.
If I simply do the following:
myBindingSource.DeleteCurrent();
it will still make myDataSet dirty, so, when I click Save button it will result in concurrency conflict. What I want is just detach the deleted row, but not affect other changes if there were any, before I deleted that record.

You can use the Remove method of the DataRowCollection object to accomplish this.
Whether this is a good design is another matter.

Related

BindingNavigator: AddItem button saves the form, but does not clear the form for the new Record

I have a Visual Basic project that uses a form to save information to a XML database. The form controls are bound to a DataTableBindingSource and all is fine except the "AddNewItem" button on the BindingNavigator seems to be saving the form. This is not the behavior I expected since there is also a SaveItem button that works great for saving the data to the DataTable. And since I wish to automatically clear the form for a new record after saving, I wrote a routine that clears all the TextBoxes, CheckBoxes, DropDowns, etc… when the SaveItem is clicked. The SaveItem also writes the DataSet to the XML database so no data is lost, but then when I click the AddItem button, it saves the Cleared form over the existing record in the DataTable, so when I click the SaveItem the altered DateTable gets written to the XML Database.
Is there any way to grab the control of the AddItem button and alter its behavior so that it doesn’t save the form, or am I not seeing a bigger problem if I did that?
I Know I could write my own AddNewItem routine, but the button would be in the wrong place…

Perfrom action based on user input without custom dialog in filemaker

I am developing a database solution in Filemaker Pro 16. I have a "customers" and "projects" table.
What I want to achieve is the following:
User clicks on a button
New window appears in which the user selects a customer from a drop down list
New project will be created
New window appears in which the user can enter the project information.
How can I do this. One can think, of course of an additional table in which temporary values are stored. In that case, I can store my customer selection in this table. However, what about concurrency. What if two people are going to add a project at the same time? In that case you would need a temporary values table for each user.
The most straightforward solution would be to directly store the selected customer in a variable. However, I don't think you can do that.
PS: I don't want to use a Custom Dialog. In that case, I think, you cannot add a drop down list.
Hope someone can help!
Use a Popover button for your customer selection.
Place your Drop Down list in the Popover panel, and store the Customer ID in a global field (they are local for each user).
Perform your script and navigate to your project layout upon selection, for instance using an OnObjectModify Script Trigger.

How to restore original MailItem of an Inspector?

I'm changing the body of a MailItem object associated with an Inspector, and I would like to restore the original state. Currently I'm saving the original content (i.e., email body, subject, etc) and setting it back again, but whenever a user closes the Inspector he is presented with a dialog asking if he wants to save changes. Does anyone know if there's a way to restore the original MailItemwithout having to present the user with a dialog asking if he wants to save it?
Don't do that. If you need to display data different from what is stored in Outlook, create a form region, task pane, or a custom message form. Resetting/restoring is a hack that will break at the worst possible moment.

Updating CPropertyPage on tab selection

I am looking for the best way to update a CPropertyPage once it is clicked. Currently, my pages receive it's information during OnInitDialog(). However, when the user does something on page one, it can effect what is on page two.
The only solution I can think to use is an "Update" button. Once the button is clicked, the page refreshes its information by calling the same functions that take place during OnInitDialog(). Is there an event that occurs when the user clicks on a different CPropertyPage of a CPropertySheet?
Using an "Update" button is poor design because it requires the user to force the update. Instead, you should look to maintain the state of the values that could cause the update. This can be done in a structure or class object that can then be made accessible to CPropertyPage::OnSetActive of the page that needs the updated values. OnSetActive is called just before the page is to be made the active one. It's your opportunity to update values on the page before it displays.

Rolling back an unsaved record? Cancelling an edit of a record should revert to its state prior to the edit, not to the blank state

In my app, i let the user create a record on clientside and fiddle with it prior to saving. The record is of a pretty complex model with a lot of realtionships. To edit the record, a modal dialog opens and displays a form.
Example scenario:
You've created a new record on client side. It's in the blank state.
Then you proceed to edit the record. You make changes to the form in the modal dialog and press OK. The record now is in state A.
Then you proceed to edit the record again, turning the record to state B. But this time you mess the form up and decide to Cancel.
When you hit Cancel, the record should revert to state A.
The problem is that this is an unsaved record and thus record.rollback() can not be used.
All i could think of is making a copy of a record and feeding it to the form. But most of the form's fields are bound to related records, thus, you'd have to clone the record's related records recursively. This is a huge hack that i don't want to go for.
Any simpler suggestions?
The approach I have used is based on the buffered proxy pattern within my controllers.
This way your controller can just throw away the buffer on cancel or apply the buffer to models and orchestrate model saves when the user OKs the changes.
Here is an ember package you can use to get started:
https://www.npmjs.com/package/ember-buffered-proxy