private void ReadUI() { if (currentAnnotation == null) { currentAnnotation = new StudentAnnotation(); } currentAnnotation.IsActive = chkCurrentAnnotationActive.Checked; currentAnnotation.IdSchoolYear = txtSchoolYear.Text; if (txtAnnotation.Text != "") { currentAnnotation.IdAnnotation = SafeDb.SafeInt(txtIdAnnotation.Text); } else { currentAnnotation.IdAnnotation = null; } if (currentAnnotation.IdStudent != 0) { currentAnnotation.IdStudent = SafeDb.SafeInt(txtIdStudent.Text); } else { currentAnnotation.IdStudent = null; } currentAnnotation.Annotation = txtAnnotation.Text; }
internal StudentAnnotation GetAnnotation(int?IdAnnotation) { StudentAnnotation a; if (IdAnnotation == null) { return(null); } a = new StudentAnnotation(); using (DbConnection conn = Connect()) { DbDataReader dRead; DbCommand cmd = conn.CreateCommand(); string query = "SELECT *" + " FROM StudentsAnnotations" + " WHERE IdAnnotation=" + IdAnnotation; query += ";"; cmd.CommandText = query; dRead = cmd.ExecuteReader(); dRead.Read(); a = GetAnnotationFromRow(dRead); cmd.Dispose(); } return(a); }
private void ReadUI() { if (currentAnnotation == null) { currentAnnotation = new StudentAnnotation(); } currentAnnotation.IdSchoolYear = txtSchoolYear.Text; //if (txtAnnotation.Text != "") currentAnnotation.IdAnnotation = Safe.Int(txtIdAnnotation.Text); ////else //// currentAnnotation.IdAnnotation = null; if (currentAnnotation.IdStudent != 0) { currentAnnotation.IdStudent = Safe.Int(txtIdStudent.Text); } else { currentAnnotation.IdStudent = null; } currentAnnotation.Annotation = txtAnnotation.Text; if (currentAnnotation.IsActive == null) { currentAnnotation.IsActive = false; } currentAnnotation.IsActive = chkCurrentActive.Checked; if (currentAnnotation.IsPopUp == null) { currentAnnotation.IsPopUp = false; } currentAnnotation.IsPopUp = chkPopUp.Checked; }
private void RefreshUI() { dgwNotes.DataSource = Commons.bl.AnnotationsAboutThisStudent(currentStudent, yearUsed, chkShowOnlyActive.Checked); if (dgwNotes.Rows.Count == 0) { currentAnnotation = new StudentAnnotation(); } WriteUI(); }
private void dgwNotes_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { dgwNotes.Rows[e.RowIndex].Selected = true; currentAnnotation = ((List <StudentAnnotation>)dgwNotes.DataSource)[e.RowIndex]; } WriteUI(); }
public frmGradesStudentsSummary(Student Student, string IdSchoolYear, GradeType GradeType, SchoolSubject SchoolSubject) { InitializeComponent(); currentStudent = Student; currentSchoolYear = IdSchoolYear; currentGradeType = GradeType; currentSchoolSubject = SchoolSubject; lblCurrentStudent.Text = $"{Student.LastName} {Student.FirstName}"; currentAnnotation = new StudentAnnotation(); }
public frmGradesStudentsSummary(Student Student, string IdSchoolYear, GradeType GradeType, SchoolSubject SchoolSubject) { InitializeComponent(); db = new DbAndBusiness(Commons.PathAndFileDatabase); currentStudent = Student; currentSchoolYear = IdSchoolYear; currentGradeType = GradeType; currentSchoolSubject = SchoolSubject; lblCurrentStudent.Text = $"{Student.LastName} {Student.FirstName}"; currentAnnotation = new StudentAnnotation(); }
private void dgwNotes_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { dgwNotes.Rows[e.RowIndex].Selected = true; currentAnnotation = ((List <StudentAnnotation>)dgwNotes.DataSource)[e.RowIndex]; txtIdAnnotation.Text = currentAnnotation.IdAnnotation.ToString(); txtAnnotation.Text = currentAnnotation.Annotation; chkCurrentAnnotationActive.Checked = (bool)currentAnnotation.IsActive; txtSchoolYear.Text = currentAnnotation.IdSchoolYear; txtIdStudent.Text = currentAnnotation.IdStudent.ToString(); chkCurrentAnnotationActive.Checked = (bool)currentAnnotation.IsActive; } }
private StudentAnnotation GetAnnotationFromRow(DbDataReader Row) { StudentAnnotation a = new StudentAnnotation(); a.IdAnnotation = Safe.Int(Row["idAnnotation"]); a.IdStudent = Safe.Int(Row["idStudent"]); a.IdSchoolYear = Safe.String(Row["idSchoolYear"]); a.Annotation = Safe.String(Row["annotation"]); a.InstantTaken = Safe.DateTime(Row["instantTaken"]); a.InstantClosed = Safe.DateTime(Row["instantClosed"]); a.IsActive = Safe.Bool(Row["isActive"]); // the program must work also with old versions of database if (FieldExists("StudentsAnnotations", "isPopUp")) { a.IsPopUp = Safe.Bool(Row["isPopUp"]); } return(a); }
internal List <StudentAnnotation> AnnotationsAboutThisStudent(Student currentStudent, string IdSchoolYear, bool IncludeOnlyActiveAnnotations) { if (currentStudent == null) { return(null); } List <StudentAnnotation> la = new List <StudentAnnotation>(); using (DbConnection conn = Connect()) { DbDataReader dRead; DbCommand cmd = conn.CreateCommand(); string query = "SELECT *" + " FROM StudentsAnnotations" + " WHERE StudentsAnnotations.idStudent=" + currentStudent.IdStudent; if (IdSchoolYear != null && IdSchoolYear != "") { query += " AND idSchoolYear=" + IdSchoolYear; } if (IncludeOnlyActiveAnnotations) { query += " AND isActive=true"; } query += " ORDER BY instantTaken DESC, instantClosed DESC"; query += ";"; cmd.CommandText = query; dRead = cmd.ExecuteReader(); while (dRead.Read()) { StudentAnnotation a = GetAnnotationFromRow(dRead); la.Add(a); } } return(la); }
internal int?SaveAnnotation(StudentAnnotation CurrentAnnotation, Student CurrentStudent) { return(dl.SaveAnnotation(CurrentAnnotation, CurrentStudent)); }
internal int?SaveAnnotation(StudentAnnotation Annotation, Student s) { using (DbConnection conn = Connect()) { DbCommand cmd = conn.CreateCommand(); string query = ""; if (Annotation.IdAnnotation != null && Annotation.IdAnnotation != 0) { query = "UPDATE StudentsAnnotations" + " SET" + " idStudent=" + SqlInt(s.IdStudent) + "," + " idSchoolYear=" + SqlString(Annotation.IdSchoolYear) + "," + " instantTaken=" + SqlDate(Annotation.InstantTaken) + "," + " instantClosed=" + SqlDate(Annotation.InstantClosed) + "," + " isActive=" + SqlBool(Annotation.IsActive) + ","; if (FieldExists("StudentsAnnotations", "isPopUp")) { query += " isPopUp=" + SqlBool(Annotation.IsPopUp) + ","; } query += " annotation=" + SqlString(Annotation.Annotation) + "" + " WHERE idAnnotation=" + SqlInt(Annotation.IdAnnotation) + ";"; } else { Annotation.InstantTaken = DateTime.Now; Annotation.IsActive = true; // create an annotation on database int?nextId = NextKey("StudentsAnnotations", "IdAnnotation"); Annotation.IdAnnotation = nextId; query = "INSERT INTO StudentsAnnotations " + "(idAnnotation, idStudent, annotation,instantTaken," + "instantClosed,isActive"; if (FieldExists("StudentsAnnotations", "isPopUp")) { query += ",isPopUp"; } if (Annotation.IdSchoolYear != null && Annotation.IdSchoolYear != "") { query += ",idSchoolYear"; } query += ")"; query += " Values("; query += "" + SqlInt(Annotation.IdAnnotation) + ","; query += "" + SqlInt(s.IdStudent) + ","; query += "" + SqlString(Annotation.Annotation) + ""; query += "," + SqlDate(Annotation.InstantTaken); query += "," + SqlDate(Annotation.InstantClosed); query += "," + SqlBool(Annotation.IsActive); if (FieldExists("StudentsAnnotations", "isPopUp")) { query += "," + SqlBool(Annotation.IsPopUp); } if (Annotation.IdSchoolYear != null && Annotation.IdSchoolYear != "") { query += "," + SqlString(Annotation.IdSchoolYear) + ""; } query += ");"; } cmd.CommandText = query; cmd.ExecuteNonQuery(); cmd.Dispose(); } return(Annotation.IdAnnotation); }
internal int?UpdateAnnotationsGroup(StudentAnnotation currentAnnotation, Student currentStudent) { throw new NotImplementedException(); }