简体   繁体   English

安装后设置Windows应用程序

[英]Setting windows application after installation

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? 所以在安装之后我会设置需要调用哪些Forms?

Can I do this? 我可以这样做吗? If yes, then give me idea to do this and what concepts needs to know to do this. 如果是,那么请让我知道这样做以及需要知道哪些概念才能做到这一点。

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. 确定安装在不创建两个不同安装的情况下,您可以使用自定义UI创建单个安装程序,在应用程序安装期间,用户可以选择是将其用于中小型酒店,将用户选择保存到配置文件,用户何时启动应用程序读取此配置标志值并加载特定屏幕。

  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. 只有在第一次启动应用程序时才会显示此UI。只需此表单将要求用户选择小型/中型酒店选项并将选项保存到配置文件或数据库。 Thereafter whenever application launches it will read the flag values from this file/database and only launch the specific UI for the user. 此后,每当应用程序启动时,它将从该文件/数据库中读取标志值,并仅启动用户的特定UI。


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 根据配置值切换Windows窗体

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();
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM