private void frmSetup_Load(object sender, EventArgs e) { CommonsWinForms.ReadConfigFile(); TxtPathDatabase.Text = Commons.PathDatabase; TxtFileDatabase.Text = Commons.FileDatabase; TxtPathImages.Text = Commons.PathImages; TxtPathStartLinks.Text = Commons.PathStartLinks; // not longer used Commons.PathAndFileDatabase = Commons.PathDatabase + "\\" + Commons.FileDatabase; TxtPathDocuments.Text = Commons.PathDocuments; chkSaveBackup.Checked = CommonsWinForms.SaveBackupWhenExiting; }
static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // read configuration file or run configuration if (!CommonsWinForms.ReadConfigFile()) { // config file is unexistent or broken if (Commons.PathAndFileDatabase.Contains("DEMO") && File.Exists(Commons.PathAndFileDatabase)) { // if demo database exists, save the configuration program with demo file WriteConfigFile(); } else { // we don't want the demo file or it doesn't exist. Let's ask the user MessageBox.Show("Configurazione del programma.\r\nSistemare le cartelle con il percorso dei file (in particolare la cartella che contiene il database), " + "poi scegliere il file di dati .sqlite e premere 'Salva configurazione'", "SchoolGrades", MessageBoxButtons.OK, MessageBoxIcon.Information); FrmSetup f = new FrmSetup(); f.ShowDialog(); if (!File.Exists(Commons.PathAndFileDatabase)) { MessageBox.Show("Configurare il programma!", "SchoolGrades", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } else { // config file has been read // do nothing } // create Businnes and Data layer objects, to be used throughout the program // keep this order of creation. Create after reading config file Commons.dl = new DataLayer(Commons.PathAndFileDatabase); Commons.bl = new BusinessLayer(Commons.PathAndFileDatabase); //Application.Run(new frmLogin()); Application.Run(new frmMain()); }