Exemple #1
0
        public bool GetDataOfAllStudentsInClassPrepareToPrint(InfomationOfStudensResultOfClassPrepareToPrint input, string classID)
        {
            bool success = Connect();

            if (!success)
            {
                return(false);
            }
            try
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    string strQuery = "SELECT st.Surname,st.Firstname,st.StudentID," +
                                      "se1.SemesterAverage as AveragePointS1,se2.SemesterAverage " +
                                      "as AveragePointS2, l.AverageScore as AveragePointYear,l.ConductSE01 as ConductS1,l.ConductSE02 as " +
                                      "ConductS2,l.YearConduct as ConductYear FROM STUDENT st INNER JOIN " +
                                      "LEARNRESULT l ON l.StudentID  = st.StudentID JOIN SCOREBOARD se1" +
                                      " ON l.ScoreBoardSE01ID = se1.ScoreBoardID JOIN SCOREBOARD se2 ON " +
                                      "l.ScoreBoardSE02ID =se2.ScoreBoardID WHERE st.ClassID = @classID " +
                                      "ORDER BY st.Firstname, st.Surname";
                    cmd.CommandText = strQuery;
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = connection;
                    cmd.Parameters.AddWithValue("classID", classID);
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    adapter.Fill(input.ds, "CLASRESULT");

                    strQuery = "SELECT SurName,FirstName FROM CLASS JOIN TEACHER" +
                               " ON CLASS.TeacherID = TEACHER.TeacherID " +
                               "WHERE CLASS.ClassID = @classID";
                    cmd.CommandText     = strQuery;
                    input.formalTeacher = "";
                    using (SqlDataReader reader = cmd.ExecuteReader())
                        if (reader.Read())
                        {
                            if (!reader.IsDBNull(0))
                            {
                                input.formalTeacher += reader.GetString(0);
                            }
                            if (!reader.IsDBNull(1))
                            {
                                input.formalTeacher += " " + reader.GetString(1);
                            }
                        }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            finally
            {
                Disconnect();
            }
            return(true);
        }
Exemple #2
0
        private void frmStudentPrinter_Load(object sender, EventArgs e)
        {
            if (printerType == PrinterType.StudentList)
            {
                DataSet SchoolInfo = new DataSet();
                if (!schController.GetSchoolInfoPrepareToPrint(SchoolInfo))
                {
                    return;
                }
                DataSet ds            = new DataSet();
                string  formalTeacher = "";
                // Hàm lấy thông tin về lớp để chuẩn bị in
                if (!stController.GetDataSetPrepareToPrint(ds, ref formalTeacher, this.classID))
                {
                    return;
                }

                this.reportStudentViewer.LocalReport.ReportEmbeddedResource
                    = "TutteeFrame.Reports.ReportStudent.rdlc";
                ReportDataSource rds = new ReportDataSource();
                rds.Name  = "DataSetStudent";
                rds.Value = ds.Tables[0];
                ReportDataSource rds1 = new ReportDataSource();
                rds1.Name  = "DataSet1";
                rds1.Value = SchoolInfo.Tables[0];
                ReportParameter[] pars = new ReportParameter[]
                {
                    new ReportParameter("namePage", $"{this.classID}"),
                    new ReportParameter("formalTeacher", $"{formalTeacher}")
                };
                this.reportStudentViewer.LocalReport.SetParameters(pars);
                this.reportStudentViewer.LocalReport.DataSources.Add(rds);
                this.reportStudentViewer.LocalReport.DataSources.Add(rds1);


                this.reportStudentViewer.RefreshReport();
                reportStudentViewer.ShowExportButton = false;
            }
            else
            {
                if (printerType == PrinterType.StudentResult)
                {
                    DataSet SchoolInfo = new DataSet();
                    if (!schController.GetSchoolInfoPrepareToPrint(SchoolInfo))
                    {
                        return;
                    }
                    if (!stController.GetAllInfoAndResultOfStudentPrepareToPrint(informationOfStudent, this.studentID))
                    {
                        return;
                    }

                    this.reportStudentViewer.LocalReport.ReportEmbeddedResource = "TutteeFrame.Reports.ReportStudentResult.rdlc";
                    ReportDataSource  rds  = new ReportDataSource("DataSet1", informationOfStudent.scoreBoards.Tables[0]);
                    ReportDataSource  rds2 = new ReportDataSource("DataSet2", informationOfStudent.scoreBoards.Tables[1]);
                    ReportDataSource  rds3 = new ReportDataSource("DataSet3", SchoolInfo.Tables[0]);
                    ReportParameter[] pars = new ReportParameter[]
                    {
                        new ReportParameter("studentName", $"{this.informationOfStudent.nameOfStudent}"),
                        new ReportParameter("studentClass", $"{ this.informationOfStudent.classOfStudent}"),
                        new ReportParameter("averageYearPoint", $"{ this.informationOfStudent.averageResult}"),
                        new ReportParameter("emulationTitle", $"{ this.informationOfStudent.emulationTitle}"),
                        new ReportParameter("conductS1", $"{ this.informationOfStudent.conductS1}"),
                        new ReportParameter("conductS2", $"{ this.informationOfStudent.conductS2}"),
                        new ReportParameter("conductYear", $"{ this.informationOfStudent.conductS3}")
                    };
                    this.reportStudentViewer.LocalReport.SetParameters(pars);
                    this.reportStudentViewer.LocalReport.DataSources.Add(rds);
                    this.reportStudentViewer.LocalReport.DataSources.Add(rds2);
                    this.reportStudentViewer.LocalReport.DataSources.Add(rds3);

                    this.reportStudentViewer.RefreshReport();
                    this.reportStudentViewer.ShowExportButton = true;
                }
                else
                {
                    if (this.printerType == PrinterType.StudentResultList)
                    {
                        DataSet SchoolInfo = new DataSet();
                        if (!schController.GetSchoolInfoPrepareToPrint(SchoolInfo))
                        {
                            return;
                        }
                        InfomationOfStudensResultOfClassPrepareToPrint iforresulttofclas
                            = new InfomationOfStudensResultOfClassPrepareToPrint();
                        if (!stController.GetDataOfAllStudentsInClassPrepareToPrint(iforresulttofclas, this.classID))
                        {
                            return;
                        }
                        this.reportStudentViewer.LocalReport.ReportEmbeddedResource = "TutteeFrame.Reports.ReportClassResult.rdlc";
                        ReportDataSource rds = new ReportDataSource();
                        rds.Name  = "DataSet1";
                        rds.Value = iforresulttofclas.ds.Tables[0];
                        ReportDataSource rds2 = new ReportDataSource();
                        rds2.Name  = "DataSet2";
                        rds2.Value = SchoolInfo.Tables[0];

                        ReportParameter[] pars = new ReportParameter[]
                        {
                            new ReportParameter("fomalTeacher", $"{iforresulttofclas.formalTeacher}"),
                            new ReportParameter("className", $"{this.classID}")
                        };
                        this.reportStudentViewer.LocalReport.SetParameters(pars);
                        this.reportStudentViewer.LocalReport.DataSources.Add(rds);
                        this.reportStudentViewer.LocalReport.DataSources.Add(rds2);
                        this.reportStudentViewer.RefreshReport();
                        this.reportStudentViewer.ShowExportButton = true;
                    }
                }
            }
        }
Exemple #3
0
 public bool GetDataOfAllStudentsInClassPrepareToPrint(InfomationOfStudensResultOfClassPrepareToPrint input, string classID)
 {
     return(studentDA.GetDataOfAllStudentsInClassPrepareToPrint(input, classID));
 }