private void BtnClassMigration_Click(object sender, EventArgs e) { Class currentClass; BtnStudentNew.Visible = true; if (CmbClasses.Text == "") { MessageBox.Show("Scegliere una classe di partenza"); return; } // try to increase the number of the class, leaving the rest untouched string previousClass = CmbClasses.Text; string oldClassNo = new String(previousClass.Where(Char.IsDigit).ToArray()); // LINQ int newNo = int.Parse(oldClassNo); newNo++; string newClassNo = newNo.ToString(); string nextClass = previousClass.Replace(oldClassNo, (newNo).ToString()); TxtClassNext.Text = nextClass; Class c = (Class)CmbClasses.SelectedItem; if (c != null) { dtClass = db.GetClassTable(c.IdClass); DgwStudents.DataSource = db.GetStudentsOfClassList(TxtOfficialSchoolAbbreviation.Text, CmbPresentSchoolYear.Text, CmbClasses.Text, true); currentClass = (Class)CmbClasses.SelectedItem; // check all the student's rows foreach (DataGridViewRow dr in DgwStudents.Rows) { Student st = (Student)dr.DataBoundItem; st.IdClass = 0; st.RegisterNumber = ""; st.SchoolYear = TxtSchoolYearNext.Text; st.Class = TxtClassNext.Text; st.Disabled = false; st.Eligible = false; dr.Cells[0].Value = false; } TxtClassDescription.Text = currentSchool.Name + " " + TxtSchoolYearNext.Text + " " + TxtClassNext.Text; TxtClassDescription.Visible = true; lblClassDescription.Visible = true; MessageBox.Show("Aggiustare i dati della classe e degli studenti\r\nSegnare gli studenti da ESCLUDERE " + "dalla nuova classe, con il segno di spunta a sinistra, poi premere 'Genera classe'" + "\r\nPer aggiungere allievi tornare alla finestra precedente di gestione classi" + "\r\nPer preparare la classe successiva premere di nuovo 'Prepara classe'" + "\r\nPremendo 'Annulla' non si importerà la classe", "Modifiche classe", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); } }
private void FillClassData(Class Class) { dtClass = db.GetClassTable(Class.IdClass); DgwClass.DataSource = dtClass; //dgwAllievi.DataSource = db.GetClass(txtOfficialSchoolAbbreviation.Text, idSchoolYear, cmbClasses.Text); DgwStudents.DataSource = db.GetStudentsOfClassList(TxtOfficialSchoolAbbreviation.Text, idSchoolYear, CmbClasses.Text, true); TxtClassDescription.Text = SafeDb.SafeString(DgwClass.Rows[DgwClass.CurrentRow.Index].Cells["desc"].Value); currentClass = (Class)CmbClasses.SelectedItem; TxtStartLinksFolder.Text = currentClass.PathRestrictedApplication; }