Exemplo n.º 1
0
        protected void DoViewCourse(string courseID)
        {
            DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC);
            theCourse = new Course();
            theCourse.LoadFromDB(db, " course_id=" + courseID);
            theCourse.LoadTeacher(db);
            theCourse.LoadPaidGroup(db);
            db.Close();

            TextReader reader = new StreamReader(Config.PATH_APP_ROOT + "\\template\\course_view.htm");
            String templateContent = reader.ReadToEnd();
            reader.Close();

            String[,] students = LoadStudentList(db, courseID);
            StringBuilder  stdTxt = new StringBuilder();
            int numStudent = (students.Length / 9);
            int numCancel = 0;
            for (int i = 0; i < numStudent; i++)
            {
                stdTxt.Append("<tr>");
                for (int j = 0; j < 9; j++)
                {
                    // edit registration
                    if (j == 8)
                    {
                        stdTxt.Append("<td>&nbsp&nbsp<a href=\"javascript:jumpToEditRegistration(" + students[i, j] + ")\"><img src=\"img/sys/edit.gif\" border=\"0\" alt=\"Edit\"></a></td>");
                        continue;
                    }

                    stdTxt.Append("<td>&nbsp&nbsp" + students[i, j]+"</td>");
                    if ((j == 6) && (students[i, j].Equals("ยกเลิก")))
                    {
                        numCancel++;
                    }

                }
                stdTxt.Append("</tr>");
            }

            String courseScheduleDetail = "-";
            if (theCourse._courseType == "คอร์สสด") {
                courseScheduleDetail =  theCourse._startdate.ToString("dd/MM/yyyy", ci) + " - " + theCourse._enddate.ToString("dd/MM/yyyy", ci) + "<br>" + theCourse._dayOfWeek + " " + theCourse._opentime;
            }

            String htmlContent =
                String.Format(templateContent
                    , Config.URL_PIC_COURSE + "/" + theCourse._img
                    , theCourse._btsCourseID + " " + theCourse._courseName
                    , theCourse._shortName
                    , theCourse._courseType
                    , theCourse._category
                    , courseScheduleDetail
                    , theCourse._teacher._firstname + " " + theCourse._teacher._surname
                    , PaidGroup.GetPaidGroupID(theCourse._paidGroupID)+ " " + theCourse._paidGroup._name
                    , StringUtil.Int2StrComma(theCourse._cost)
                    , theCourse._seatLimit.ToString()
                    , theCourse._bankRegisLimit.ToString()
                    , (numStudent - numCancel).ToString()
                    , theCourse._courseDesc
                    , "สมัคร " + numStudent + " คน ยกเลิก " + (numCancel) + " คน คงเหลือ " + (numStudent - numCancel) + " คน"
                    , stdTxt.ToString() );

            outBuf.Append(htmlContent);
        }