object Selection before you start the main application content

For example, when ordering you want the shop was already installed. This choice should be provided at the beginning of the program.

Perhaps another solution to this problem:

A user-level solution would be: have a list of stores when you start the application form appears where you can select the current store. When you create a record of the purchase the current store is automatically inserted.

Work in Flexberry Tool

In Flexberry was created the class diagram. To determine the current shop was created phranky class](fo_using-not-stored-classes.html) ВыборМагазинаПоУмолчанию and the generated code.

Work with program code

In public the applications you develop in class to determine static field.

public class Магазин : ICSSoft.STORMNET.DataObject
{
	public static Магазин CurrentShop;
	//... 
}

On the form nehrenovo class to suppress the message about saving data on a form, override the method OnClosing where to ban the call to the base method.

To set field values when the form is opened to override the event Edit.

To determine the behavior of the form by clicking on the button.

private void buttonAuthorize_Click(object sender, EventArgs e) //clicking on "Authorize" 
{
	//verify that the store you selected 
	if ((DataObject as ВыборМагазинаПоУмолчанию).ТекущийМагазин != null)
	{		
		Магазин.CurrentShop = ((ВыборМагазинаПоУмолчанию)DataObject).ТекущийМагазин; //save the current store 
		this.DialogResult = DialogResult.OK; //to finish the authorization 
		this.Close();
	}
	else
	{
		MessageBox.Show("You have not selected a store for authorization.");
	}
}
private void buttonExit_Click(object sender, EventArgs e) //clicking the "Exit" button 
{
	this.Close();
}

To run a form modal to launch the desktop application. Example from class МенеджерМагазиновDesktop:

public static bool Run_SetCurrentShopForm()
{
	bool result = false;
	try
	{
		ICSSoft.STORMNET.RightManager.DisableAllRightChecks();
		CheckForIllegalCrossThreadCalls = false;
			IIS.WinUI.Runners.EditFormRunner fr =
				new IIS.WinUI.Runners.EditFormRunner(typeof(C__ВыборМагазинаПоУмолчаниюE),
											"", "Current store", "",
											new ВыборМагазинаПоУмолчанию(),
											typeof(ВыборМагазинаПоУмолчанию), false);
			System.Windows.Forms.Form frm = null;
			frm = fr.RunAndGetForm();
			if (!frm.IsDisposed && !frm.Disposing)
			{
				frm.BringToFront();
				frm.Visible = false;
				CheckForIllegalCrossThreadCalls = false;
				if (frm.ShowDialog() == DialogResult.OK)
				{
					result = true;
				}
			}
		return result;
	}
	catch (Exception)
	{
		throw new Exception("Failed to set the default value.");
	}
}

static void Main()
{
	try
	{
		// *** Start programmer edit section *** (Managermagazin Before authorization) 
		//below code for launching the form 
		if (!Run_SetCurrentShopForm())
		{
			return; //that is, the user did not want to choose the default value, stop working 
		}
		// *** End programmer edit section *** (Managermagazin Before authorization) 
		//... 
	}
	//... 
}