示例#1
0
 private void TxtPaths_DoubleClick(object sender, EventArgs e)
 {
     Commons.ProcessStartLink(((TextBox)sender).Text);
 }
示例#2
0
        private void WriteConfigFile()
        {
            string[] dati = new string[6];
            try
            {
                if (!Directory.Exists(Commons.PathConfig))
                {
                    Directory.CreateDirectory(Commons.PathConfig);
                }

                if (!Directory.Exists(Commons.PathLogs))
                {
                    Directory.CreateDirectory(Commons.PathLogs);
                }

                Commons.PathImages = dati[1] = TxtPathImages.Text;
                if (!Directory.Exists(Commons.PathImages))
                {
                    Directory.CreateDirectory(Commons.PathImages);
                }

                // path of the startlinks (PathStartLinks) is not longer used, substituted by PathRestrictedApp
                Commons.PathStartLinks = dati[2] = TxtPathStartLinks.Text;
                if (!Directory.Exists(Commons.PathStartLinks))
                {
                    Directory.CreateDirectory(Commons.PathStartLinks);
                }

                Commons.PathDatabase = dati[3] = TxtPathDatabase.Text;
                if (!Directory.Exists(Commons.PathDatabase))
                {
                    Directory.CreateDirectory(Commons.PathDatabase);
                }

                Commons.PathDocuments = dati[4] = TxtPathDocuments.Text;
                if (!Directory.Exists(Commons.PathDocuments))
                {
                    if (Commons.PathDocuments != "")
                    {
                        Directory.CreateDirectory(Commons.PathDocuments);
                    }
                    else
                    {
                        Commons.PathDocuments = ".";
                    }
                }
                Commons.FileDatabase = dati[0] = TxtFileDatabase.Text;

                Commons.SaveBackupWhenExiting = chkSaveBackup.Checked;
                dati[5] = Commons.SaveBackupWhenExiting.ToString();

                Commons.PathAndFileDatabase = Commons.PathDatabase + "\\" + Commons.FileDatabase;
                if (!File.Exists(Commons.PathAndFileDatabase))
                {
                    File.Copy(".\\SchoolGrades.sqlite", Commons.PathAndFileDatabase);
                }
#if DEBUG
                TextFile.ArrayToFile(Commons.PathAndFileConfig + "_DEBUG", dati, false);
#else
                TextFile.ArrayToFile(Commons.PathAndFileConfig, dati, false);
#endif

                MessageBox.Show("File di configurazione salvato in " + Commons.PathAndFileConfig);
            }
            catch (Exception e)
            {
                Commons.ErrorLog(e.Message, false);
                return;
                //throw new FileNotFoundException(@"[Error in program's directories] \r\n" + e.Message);
            }
            //Application.Exit();
            NewDatabaseFile = true;
            this.Close();
        }
 private void TxtPathStartLink_DoubleClick(object sender, EventArgs e)
 {
     Commons.ProcessStartLink(TxtPathStartLink.Text);
 }
示例#4
0
 private void btnOpenConfigurationFolder_Click(object sender, EventArgs e)
 {
     Commons.ProcessStartLink(Commons.PathConfig);
 }
示例#5
0
 private void cmbSchoolSubject_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.BackColor = Commons.ColorFromNumber(currentSubject);
 }
示例#6
0
 private void picImage_DoubleClick(object sender, EventArgs e)
 {
     Commons.ProcessStartLink(Commons.PathImages + "\\" +
                              currentImage.RelativePathAndFilename);
 }
示例#7
0
        private void btnCreateGroups_Click(object sender, EventArgs e)
        {
            DataTable tb = db.GetGradesWeightedAveragesOfClass(schoolClass, schoolGrade.IdGradeType, schoolSubject.IdSchoolSubject, (DateTime)schoolPeriod.DateStart, (DateTime)schoolPeriod.DateFinish);
            List<StudentAndGrade> listStudents = new List<StudentAndGrade>();
            foreach (DataRow row in tb.Rows)
                listStudents.Add(new StudentAndGrade(row.ItemArray[2].ToString(), row.ItemArray[3].ToString(), (double)row.ItemArray[4]));

            listStudents.Sort((firstGrade, secondGrade) => firstGrade.grade.CompareTo(secondGrade.grade));
            listStudents.Reverse(); //Lista studenti in ordine decrescente in base al voto
            List<Student> listTempStudents;

            if (rbdGroupsRandom.Checked)
            {
                Commons.ShuffleList(listGroups);
            }
            else if (rdbGroupsBestGradesTogether.Checked)
            {
                listTempStudents = new List<Student>();

                for (int i = 0; i < listStudents.Count; i++)
                {
                    for (int j = 0; j < listGroups.Count; j++)
                    {
                        if (listStudents[i].lastName == listGroups[j].LastName && listStudents[i].firstName == listGroups[j].FirstName)
                        {
                            listTempStudents.Add(listGroups[j]);
                        }
                    }

                }
                listGroups = listTempStudents;
            }
            else if (rdbGradesBalanced.Checked)
            {
                int lengthLista = listStudents.Count;
                listTempStudents = new List<Student>();
               
                for (int i = 0, g = 0; g < lengthLista ; g++)
                {
                    for (int j = 0; j < listGroups.Count; j++)
                    {
                        if (listStudents[i].lastName == listGroups[j].LastName && listStudents[i].firstName == listGroups[j].FirstName)
                        {
                            listTempStudents.Add(listGroups[j]);
                        }
                    }
                    listStudents.RemoveAt(i);
                    
                    if (i == 0)
                        i = listStudents.Count - 1;
                    else
                        i = 0;
                }
                listGroups = listTempStudents;
            }
            // create groups into groups array
            string[,] groups = new string[nGroups, nStudentsPerGroup];
            int stud = 0;
            for (int i = 0; i < nGroups; i++)
            {
                for (int j = 0; j < nStudentsPerGroup; j++)
                {
                    Student s = listGroups[stud];
                    groups[i, j] = s.LastName + " " + s.FirstName;
                    stud++;
                    if (stud == listGroups.Count)
                        break;
                }
                if (stud == listGroups.Count)
                    break;
            }
            // make the string to show groups
            string groupsString = "";
            for (int j = 0; j < nGroups; j++)
            {
                groupsString += "Gruppo " + (j + 1).ToString() + "\r\n";
                int nStud = 1; 
                for (int i = 0; i < nStudentsPerGroup; i++)
                {
                    if (groups[j, i] != null && groups[j, i] != " " && groups[j, i] != "  ")
                    {
                        groupsString += $"{nStud.ToString("00")} - {groups[j, i]} \r\n";
                        nStud++; 
                    }
                }
                groupsString += "\r\n";
            }
            groupsString += "\r\n";
            txtGroups.Text = groupsString;
        }
 internal void GroupStudentsByRandom(ref List <StudentAndGrade> ListStudents)
 {
     Commons.ListShuffleRandom(ListStudents);
 }
示例#9
0
        private void dgwLessonsImages_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string RelativePath = Path.GetDirectoryName(currentImage.RelativePathAndFilename);

            Commons.ProcessStartLink(Commons.PathImages + "\\" + RelativePath);
        }