Multiple forms, keep original input even though form is never used again - vb.net

in my project I have 3 forms.
On the first form is a textbox which gathers a username, which is then checked against a database and, if confirmed, logs the user into the project.
On the third form, there is a label that displays the username that was entered in the first forms' textbox. When the user is done with a project, they click a button that gives them the choice if they wish to start over...if yes is clicked, they start over from the second form (I don't want them to have to "login" again.
The first general run through the program works fine (first -> second -> third form)...
My problem is, since the first form was closed, never to be seen again, the data that was entered in the first forms' textbox is now gone and the third forms' label just displays "label1"
Is there a way to make it so they user logs in once (the first form) and then continues on about the project (going through the second and third forms over and over again) without having to login again? And having that label KEEP the original "username"?
Thanks to everyone in advance!

Related

How to have a form refresh a different form

So I have 4 forms that make reports, dates, location, costs, and materials. All of these forms can open a 5th form, projects, where you select which project/s you want the reports on, close, and then customize the reports in whatever of the first 4 forms you have open. You may also then go to a different of the first 4 and do another report on the same projects you selected.
My task is to put a warning that projects are selected and how many. I did this by making a flag table and a warning label, and upon loading one of the initial 4 forms it'll check the flag table and make the warning visible or not. The issue is that whatever form I used to get to projects is still open when I close projects, so the warning label won't appear until the form is refreshed/reloaded. How can I make the projects form detect which form is open and refresh it when I close projects?
Check if each form is loaded. Create a line for each form you need to check.
If CurrentProject.AllForms("formname").IsLoaded Then Forms!formname.Refresh
Alternatively, when 5th form is opened, pass a value to it identifying which form called it. Can use OpenForm command OpenArgs argument to pass form name then use the OpenArgs property of 5th form to refresh calling form.
Forms(Me.OpenArgs).Refresh

How do I write this BDD script?

I have an exit button in my application which I want to write a story for. It behaves this way:
If I have content filled in the form I am editing and I click on the exit button, it will pop up with a confirmation message letting me know there are unsaved content and if I am sure I want to exit from the page.
If I do not have any content filled in the form I am editing and I click on the exit button, the confirmation message will not show up and I am instantly exited from the form.
What I have so far is something like this:
Given as a User on New Profile page
And I fill in the customer name = "Bob"
When I click on the Exit button
And I click on the "Ok" in the confirmation dialog
Then I will be redirected to the landing page.
My question is the part on And when I fill in the customer name = "Bob" only covers one of the fields. How do I write the story in a succinct way that if any of the fields are filled or chosen (drop downs), the confirmation dialog will show up ? Secondly, is my story correct ?
You can use a scenario outline in conjunction with parameterizing the step that fills in a field with a dummy value.
Scenario Outline: The user is taken to the landing page after exiting new user profile
Given I am registering as a new user
And I have filled in the "<Profile Field>" field
And I have chosen to exit the current page
When I confirm I want to abandon my unsaved changes
Then I should be redirected to the landing page
Examples:
| Profile Field |
| Name |
| Phone Number |
| ... |
You didn't post the scenario title, which is just as important as the wording for each step, so I made on up. The important thing is to focus on the behavior:
Scenario Outline: The user is taken to the landing page after exiting new user profile
The step Given I am registering as a new user should navigate to the new user profile page.
The step Given I have filled in the "<Profile Field>" field should accept an argument where you name the field you want filled in. The definition for this step should fill in the field with dummy information, or blindly chose an option in a dropdown.
The step Given I have chosen to exit the current page should click the exit button. Notice there is no mention of "clicking" on anything. You should avoid language in your steps the sound like instructions on how to use the user interface, and instead focus on the behavior of the application using business terms.
Same thing for When I confirm I want to abandon my unsaved changes. It does not mention clicking on anything. It just focuses on the behavior (choosing to abandon your changes). The step definition should know how to click the "OK" button in the confirmation dialog. The fact a confirmation dialog even exists should only be known by the step definition.
Finally, Then I should be redirected to the landing page makes your assertion about where the user ends up. I like to include the word "should" in my Then steps. If find it easier to pinpoint the test failure when a Then step fails. The condition that comes after the "should" in my step is usually the thing that fails.
you can use datatable in that particular step as below
Given as a User on New Profile page
And I fill in the customer details
|name|address1|adress2|pincode| //can be accessed with DataTable datatype in SD*
When I click on the Exit button
And I click on the "Ok" in the confirmation dialog
Then I will be redirected to the landing page.
*SD-Stepdefinitions

Need prompt to save changes in Windows form when changing displayed record

I am relatively new to programming, so this may be an easy one. I have a Windows form that connects to SQL Server and displays the data in a form where a user can edit and add or delete records (via databinding). The form works well, and has record navigation controls as well as context menus that allow the user to filter data on any field.
Currently, the user can make changes and switch to new records, etc... but changes are not applied until the user clicks the "save" button. However, I'd like to prompt the user to save records whenever the user navigates to a new record (either through navigator or through application of a filter which displays a different record).
What event can I use that will trigger whenever a different record is reflected in the form?
Thanks,
Jay

Opened form won't reactivate after closing modal

Within VB.NET Visual Studio 2013
I have an mdi application with several forms. Only one form is open at a given time, then while the user enters amounts by typing in the control, the form is recalculating itself constantly via code.
I also have buttons above (on the mdiform) to open modal dialogs to enter certain information; the information entered is somewhat long, but at the end what I need from the dialog is the result of certain calculation.
That number (the result) should be shown on the opened form after the user close the modal dialog; but it is not happening unless I press the enter key so the form is again recalculated.
I am looking for a way that the form recalculate when the user close the dialog.
I tried everything at my disposal, "Activate", "a public sub", "raise an event", and many others, but the form is not recalculating, what happens is that the cursor is there on the last control the user works in.
The only way to see those changes is reloading the form, but it is not elegant.
Any help will be highly appreciated.
PS. I have looked everywhere about how to do it, but seems I am looking on a haystack
Please need help badly.
ariel

Making multiple forms appear as one in VB.NET

I am writing a Windows Forms application in VB.NET. I have three forms: the main form, which shows a list of accounts, the account form which allows the user to view/edit the information for a specific account, and the policy form which allows the user to view/edit the information on a specific policy for that account. I want the forms to appear as if they are all the same window. Example: when the application starts, the user clicks an account name in the list box on the main form and clicks "edit". What I want to happen is that the window stays in the exact same place and stays the same exact size, only the content of the main form appears to be replaced with the content of the account form. Same thing if the user then chooses to edit a policy from the account form. When the user finishes and clicks "save", the main form comes back up. Through this entire use case, it would appear to the user as if they were viewing the same window the entire time, with the content of that window changing.
How can I do this? I have tried something like:
Dim newForm as New AcctForm
newForm.Location = Me.Location
newForm.Show()
Me.Close()
The problem is that if the user moves the original window, the new window appears where the parent form originally appeared, not where it ended up.
I see this is already in the comments, but what I have done in this case in the past is build each "form" in the application as a custom control. Then I have one actual form, and navigation works by changing which custom control is currently loaded on the parent form. To move from one screen/view to another, you remove the current custom control from the form's controls collection and add the new custom control.
I believe this is superior to manually setting the startup position and size, because you can use the form's .SuspendLayout()/.ResumeLayout() methods to hide the interim state, where there is no control loaded, from the user. This is harder to do when you want one form to be completely replaced by another.
This also makes it easy to set certain form properties in one place and have them be consistent for the application. You can even have an area on the form with controls that will now show in every view.
When using this pattern, I typically have each of my custom controls inherit from a common base. You may not have anything specific you will do with that base at the outset, but it almost always comes in handy later.
Finally, switching to use this scheme is easier than you think. Just go to the code for the each of your current forms, and you will find that each class currently inherits from System.Windows.Forms.Form. Most of the time, all you really need to do is change them to inherit from System.Windows.Forms.Panel and you're most of the way there.
As others have said, it may be better to redesign your application using custom controls or panels etc.
However, to answer your question regarding the seemingly random location of your forms, the first thing to check is that each form has it's StartPosition property set to Manual.
If your main form is resizable, then I would also add code to adjust newForm to the same size too.
I hope that helps with your immediate issues; so that you can move on to redesigning the application!
good morning there is another way . set property for second form to (top most) and use also
from2.show();
that make you switch between forms and keep form2 top other
Thanks
try using ShowDialog()
Dim newForm as New AcctForm
newForm.Location = Me.Location
newForm.ShowDialog()
Me.Close() <-- removed this