Example #1
0
        private void BtnClassGenerate_Click(object sender, EventArgs e)
        {
            string classDescription = currentSchool.Desc + " " + TxtSchoolYearNext.Text + TxtClassNext.Text;
            int    classCode        = db.CreateClass((string)dtClass.Rows[0]["abbreviation"], classDescription,
                                                     TxtSchoolYearNext.Text, TxtOfficialSchoolAbbreviation.Text);

            int studentDone = 0;

            foreach (DataGridViewRow r in DgwStudents.Rows)
            {
                // don't include students whose rows are non checked
                if ((bool)r.Cells["SaveThisStudent"].Value == true)
                {
                    studentDone++;
                    ((Student)r.DataBoundItem).RegisterNumber = studentDone.ToString();
                    db.PutStudentInClass((int)r.Cells["idStudent"].Value, classCode);
                    db.AddLinkToOldPhoto((int)r.Cells["idStudent"].Value, CmbPresentSchoolYear.Text, TxtSchoolYearNext.Text);
                    db.SaveStudent((Student)r.DataBoundItem, null);
                }
            }
            MessageBox.Show("Creazione classe " + TxtClassNext.Text + " " + TxtSchoolYearNext.Text + " terminata");
            BtnStudentNew.Visible = false;
        }