Пример #1
0
        private void frmTestGrades_Load(object sender, EventArgs e)
        {
            currentTest  = db.GetTest(1);                                 //!!!!!!!!!!!!!!
            currentClass = db.GetClass(Commons.IdSchool, "1920", "IFTS"); //!!!!!!!!!!!!!!

            RefreshUi();
        }
        private void CmbClasses_SelectedIndexChanged(object sender, EventArgs e)
        {
            Class tempClass = db.GetClass(TxtOfficialSchoolAbbreviation.Text,
                                          CmbSchoolYear.Text, CmbClasses.SelectedItem.ToString());

            if (tempClass.IdClass != null && tempClass.IdClass != 0)
            {
                currentClass          = tempClass;
                TxtPathStartLink.Text = currentClass.PathRestrictedApplication;
                refreshGrid();
            }
            else
            {
                DgwLinks.DataSource = null;
            }
        }
Пример #3
0
        private void BtnImportStudentsOfClass_Click(object sender, EventArgs e)
        {
            // give warning to avoid modifying existing class instead of making a new one
            if (db.GetClass(currentSchool.IdSchool, idSchoolYear, CmbClasses.Text).Abbreviation != null)
            {
                MessageBox.Show("Esiste già una classe con il nome \"" + CmbClasses.Text + "\" in questo anno!", "Avviso",
                                MessageBoxButtons.OK);
                return;
            }
            if (CmbClasses.Text.Contains(" "))
            {
                DialogResult d = MessageBox.Show("E' meglio non mettere spazi nella sigla della classe." +
                                                 "\r\nDevo metterli lo stesso?",
                                                 "Informazione", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                if (d != DialogResult.Yes)
                {
                    return;
                }
            }
            if (!File.Exists(TxtFileOfStudentsImport.Text) ||
                TxtFileOfStudentsImport.Text.Substring(TxtFileOfStudentsImport.Text.Length - 1, 1) == "\\")
            {
                MessageBox.Show("Il file \"" + TxtFileOfStudentsImport.Text + "\" non esiste!", "Avviso",
                                MessageBoxButtons.OK);
                return;
            }
            string[,] datiAllievi = TextFile.FileToMatrix(TxtFileOfStudentsImport.Text, '\t');
            int   idClass;
            Class newClass = new Class(0, CmbClasses.Text, CmbSchoolYear.Text, TxtOfficialSchoolAbbreviation.Text);

            if (!RdbPhotoUserChoosen.Checked)
            {
                newClass.IdClass = db.CreateClassAndStudents(datiAllievi, CmbClasses.Text, TxtClassDescription.Text,
                                                             CmbSchoolYear.Text, TxtOfficialSchoolAbbreviation.Text, RdbPhotoAlreadyPresent.Checked);
            }
            else
            {
                idClass = db.CreateClass(CmbClasses.Text, TxtClassDescription.Text,
                                         CmbSchoolYear.Text, TxtOfficialSchoolAbbreviation.Text);
                for (int riga = 1; riga < datiAllievi.GetLength(0); riga++)
                {
                    int codiceStudente = db.CreateStudentFromStringMatrix(datiAllievi, riga);
                    if (codiceStudente > 0)
                    {
                        db.PutStudentInClass(codiceStudente, idClass);
                        if (rdbChooseStudentsPhotoWhileImporting.Checked)
                        {
                            using (OpenFileDialog dlg = new OpenFileDialog())
                            {
                                dlg.Title = "Scegli una foto dello studente " + datiAllievi[riga, 1] + " " +
                                            datiAllievi[riga, 2] + ", " + CmbClasses.Text + " " + CmbSchoolYear.Text;
                                dlg.Filter           = "jpg files (*.jpg)|*.jpg";
                                dlg.InitialDirectory = TxtPathImages.Text;
                                if (dlg.ShowDialog() == DialogResult.OK)
                                {
                                    Student s = new Student();
                                    s.IdStudent = codiceStudente;
                                    s.LastName  = datiAllievi[riga, 1];
                                    s.FirstName = datiAllievi[riga, 2];
                                    db.CopyAndLinkOnePhoto(s, newClass, dlg.FileName);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("Importazione terminata");
            this.Close();
        }