Question

I am developing a Hotel Management project. And I am developing this application such a way that it can be used by small, medium, big hotels. For example, if it is a small hotel then billing will be entered in the reception. If it is a big hotel then billing details will be taken from service provided for particular table. So after the installation I will set which Forms needs to be called for?

Can I do this? If yes, then give me idea to do this and what concepts needs to know to do this.

Was it helpful?

Solution

You can follow one of the following approaches which best suits your requirements

  1. Create Two Installers This is one way to solve your problem, Rather than switching the forms after the installation, You can create two different installers, One will deploy application for small hotel(which will open specific form for small hotel) other one will deploy application for medium sized hotel.

  2. Decide on Installation Without creating two different installations you can create a single installer with a custom UI which during the application installation lets the users to select whether its for a small or medium sized hotel, Save the user selection to a configuration file, When users launches the application read this configuration flag value and load the specific screen.

  3. Decide on first launch This is last option bit similar to second point, Just create a simple installer. Add extra form to your application. This UI will be shown only when the application is launched first time, Simply this form will ask the user to select the option small/medium sized hotel and save the option to a configuration file or database. Thereafter whenever application launches it will read the flag values from this file/database and only launch the specific UI for the user.


Launching Windows Form based on Config file value

Example Config File

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <appSettings>
    <add key="FormToLaunch" value="small"/>
  </appSettings> 

</configuration>

Switching Windows forms based on config value

private void Form1_Load(object sender, EventArgs e)
{
    string firstFormFlag = ConfigurationManager.AppSettings["FormToLaunch"].ToString();

    if (firstFormFlag.Equals("small", StringComparison.OrdinalIgnoreCase))
    {
        SmallHotelForm form = new SmallHotelForm();
        form.Show();
    }
    else if (firstFormFlag.Equals("medium", StringComparison.OrdinalIgnoreCase))
    {
        MediumHotelForm form = new MediumHotelForm();
        form.Show();
    }
    else if (firstFormFlag.Equals("Big", StringComparison.OrdinalIgnoreCase))
    {
        BigHotelForm form = new BigHotelForm();
        form.Show();
    }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top