Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 private void RefreshUI()
 {
     dgwNotes.DataSource = Commons.bl.AnnotationsAboutThisStudent(currentStudent, yearUsed,
                                                                  chkShowOnlyActive.Checked);
     if (dgwNotes.Rows.Count == 0)
     {
         currentAnnotation = new StudentAnnotation();
     }
     WriteUI();
 }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 8
0
        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;
            }
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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));
 }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
 internal int?UpdateAnnotationsGroup(StudentAnnotation currentAnnotation, Student currentStudent)
 {
     throw new NotImplementedException();
 }