Exemple #1
0
 private void SaveAnnotations(bool SaveMany)
 {
     if (currentAnnotation.IdAnnotation == null)
     {
         if (!SaveMany)
         {
             if (!CommonsWinForms.CheckIfStudentChosen(currentStudent))
             {
                 return;
             }
             currentAnnotation.IdAnnotation = null;
             currentAnnotation.IdAnnotation = Commons.bl.SaveAnnotation(currentAnnotation, currentStudent);
         }
         else
         {
             foreach (Student s in chosenStudents)
             {
                 currentAnnotation.IdAnnotation = null;
                 currentAnnotation.IdAnnotation = Commons.bl.SaveAnnotation(currentAnnotation, s);
             }
         }
         return;
     }
     else
     {
         // if IsActive has changed from what is in database then we change dates
         // according to the status
         if (Commons.bl.GetAnnotation(currentAnnotation.IdAnnotation).IsActive != currentAnnotation.IsActive)
         {
             if (currentAnnotation.IsActive == true)
             {
                 // if it wasn't active and now it is, we set date taken now
                 currentAnnotation.InstantTaken  = DateTime.Now;
                 currentAnnotation.InstantClosed = null;
             }
             else
             {
                 // if it was active and now it isn't, we set the date closed now
                 currentAnnotation.InstantClosed = DateTime.Now;
             }
         }
         if (SaveMany)
         {
             foreach (Student s in chosenStudents)
             {
                 Commons.bl.SaveAnnotation(currentAnnotation, s);
             }
         }
         else
         {
             Commons.bl.SaveAnnotation(currentAnnotation, currentStudent);
         }
     }
     RefreshUI();
 }
Exemple #2
0
 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;
 }
Exemple #3
0
        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());
        }