Ejemplo n.º 1
0
        protected void DoEditRegistration(string regisID)
        {
            DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC);
            db.Connect();

            theReg = new Registration();
            theReg.LoadFromDB(db, " regis_id=" + regisID);
            theReg.LoadCourse(db);
            theReg.LoadStudent(db);
            theReg.LoadBranch(db);
            //            Branch branch = new Branch();
            //            branch.LoadFromDB(db, " branch_id=" + theReg._branchID);

            // Generate HTML content
            TextReader reader = new StreamReader(Config.PATH_APP_ROOT + "\\template\\registration_edit.htm");
            String templateContent = reader.ReadToEnd();
            reader.Close();

            string promotionTxt = theReg._promotionID > 0 ?
                "<a href=\"PromotionManage.aspx?actPage=view&targetID="+ theReg._promotionID + "\" >" + Promotion.GetPromotionID(theReg._promotionID) + " </a>" : "-";

            String htmlContent =
                String.Format(templateContent
                    , theReg.GetRegisTransactionID()
                    , Registration.GetRegistrationID(theReg._regisID)
                    , "<a href=\"CourseManage.aspx?actPage=view&targetID=" + theReg._course._courseID + "\" >" + theReg._course._btsCourseID + " " + theReg._course._courseName + "</a>"
                    , promotionTxt
                    , "<a href=\"StudentManage.aspx?actPage=view&targetID=" + theReg._studentID + "\" >" + Student.GetStudentID(theReg._student._studentID) + " " + theReg._student._firstname + " " + theReg._student._surname + "</a>"
                    , StringUtil.ConvertYearToEng(theReg._regisdate, "yyyy/MM/dd HH:mm:ss")
                    , StringUtil.ConvertYearToEng(theReg._paiddate, "yyyy/MM/dd")
                    , theReg._branch._branchName
                    , StringUtil.Int2StrComma(theReg._fullCost)
                    , StringUtil.Int2StrComma(theReg._discountedCost)
                    , Registration.GetPaidMethodText(theReg._paidMethod.ToString())
                    , theReg._seatNo
                    , theReg._username
                    , Registration.GetStatusText(theReg._status)
                    );

            outBuf.Append(htmlContent);

            db.Close();
        }
Ejemplo n.º 2
0
        protected void DoEditSubmitRegistration(string regisID)
        {
            string paidMethod = Request.Form.Get("paid_method");
            string note = Request.Form.Get("note");

            DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC);
            db.Connect();
            db.BeginTransaction(IsolationLevel.ReadCommitted);

            theReg = new Registration();
            theReg.LoadFromDB(db, " regis_id=" + regisID);

            // Save to DB
            theReg.UpdateToDB(db);

            db.Commit();
            db.Close();

            msgText = "แก้ไขข้อมูลเรียบร้อย";
        }
Ejemplo n.º 3
0
        // Extract to multiple Registration
        // TODO: Check duplicated student-course
        public override bool AddToDB(DBManager db)
        {
            if ((_modCourses == null) && (_modPromotions == null)) return false;

            LinkedList<Registration> regList = new LinkedList<Registration>();
            DateTime now = DateTime.Now;
            CreateTransactionCode(db, now);

            // Promotion
            if (_modPromotions != null)
            {
                foreach (Promotion p in _modPromotions)
                {
                    if (!Promotion.LoadCourseList(db, p)) continue;

                    int accumDiscountedCost = 0;
                    int accumFullCost = 0;
                    for (int i = 0; i < p._courses.Length; i++)
                    {
                        Course c = p._courses[i];
                        int fullCostByRatio = (int)(((float)c._cost / (float)p._fullCost) * p._cost);
                        int discountedCostByRatio = (int)(((float)c._cost / (float)p._fullCost) * p._discountedCost);
                        accumFullCost += fullCostByRatio;
                        accumDiscountedCost += discountedCostByRatio;
                        // asjust to last course
                        if ((_isAdjustCost) && (i+1==p._courses.Length))
                        {
                            int fragmentFullCost = p._cost - accumFullCost;
                            int fragmentDiscountedCost = p._discountedCost - accumDiscountedCost;
                            // adjust
                            fullCostByRatio += fragmentFullCost;
                            discountedCostByRatio += fragmentDiscountedCost;
                        }

                        Registration reg = new Registration();
                        //reg._transactionID = this._transactionID;
                        // reg._regisID;  auto_increament
                        reg._regisdate = now;
                        reg._studentID = this._studentID;
                        reg._courseID = c._courseID;
                        reg._promotionID = p._promotionID;
                        reg._branchID = this._branchID;
                        reg._fullCost = fullCostByRatio;
                        reg._discountedCost = discountedCostByRatio;
                        reg._seatNo = (string)_seatNoMap[reg._courseID.ToString()];
                        reg._note = (string)_noteMap[reg._courseID.ToString()];
                        reg._username = this._username;
                        reg._status = 0;
                        reg._paidMethod = this._paidMethod;
                        reg._paidRound = 0;
                        reg._paiddate = this._paiddate;
                        reg._isPaid = false;

                        regList.AddLast(reg);
                    }
                }
            }
            // Course
            if (_modCourses != null)
            {
                foreach (Course c in _modCourses)
                {
                        Registration reg = new Registration();
                        //reg._transactionID = this._transactionID;
                        // reg._regisID;  auto_increament
                        reg._regisdate = now;
                        reg._studentID = this._studentID;
                        reg._courseID = c._courseID;
                        reg._promotionID = 0;
                        reg._branchID = this._branchID;
                        reg._fullCost = c._cost;
                        reg._discountedCost = c._discountedCost;
                        reg._seatNo = (string)_seatNoMap[reg._courseID.ToString()];
                        reg._note = (string)_noteMap[reg._courseID.ToString()];
                        reg._username = this._username;
                        reg._status = 0;
                        reg._paidMethod = this._paidMethod;
                        reg._paidRound = 0;
                        reg._paiddate = this._paiddate;
                        reg._isPaid = false;

                        regList.AddLast(reg);
                }
            }

            db.BeginTransaction(IsolationLevel.ReadCommitted);

            SynchronizedAddToDB(db, this, regList);

            db.Commit();

            return true;
        }
Ejemplo n.º 4
0
        protected void DoRefund(string regisID)
        {
            int status = Int32.Parse(Request.Form.Get("status"));
            int refundCost = Int32.Parse(Request.Form.Get("refund_cost"));
            string paidMethod = Request.Form.Get("paid_method");
            string note = Request.Form.Get("note");

            DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC);
            db.Connect();
            db.BeginTransaction(IsolationLevel.ReadCommitted);

            theReg = new Registration();
            theReg._status = status;
            theReg.LoadFromDB(db, " regis_id=" + regisID);
            theReg.LoadCourse(db);

            // TODO: Check if the fund is paid to teacher?
            if (refundCost <= theReg._discountedCost)
            {
                theReg._discountedCost -= refundCost;
            }
            theReg._status = status;
            theReg._paidMethod = Int32.Parse(paidMethod);
            theReg._note = note;

            // Save to DB
            theReg.UpdateToDB(db);

            // Update payment
            Payment.UpdatePaymentByCourse(db, theReg._course);

            db.Commit();
            db.Close();

            if (refundCost > 0)
            {
                msgText = "คืนเงิน " + refundCost + " บาท เรียบร้อยแล้ว คงเหลือเงิน " + theReg._discountedCost + " บาท";
            } else {
                msgText = "แก้ไขข้อมูลเรียบร้อย";
            }
        }
Ejemplo n.º 5
0
 public static Registration CreateForm(OdbcDataReader reader)
 {
     Registration registration = new Registration();
     Registration.CreateForm(reader, registration);
     return registration;
 }
Ejemplo n.º 6
0
        public static bool CreateForm(OdbcDataReader reader, Registration reg)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "regis_id": reg._regisID = reader.GetInt32(i);
                                      break;
                    case "transaction_id": reg._transactionID = reader.GetInt32(i);
                                      break;
                    case "transaction_code": reg._transactionCode = reader.GetString(i);
                                      break;
                    case "regis_date": reg._regisdate = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "student_id": reg._studentID = reader.GetInt32(i);
                                      break;
                    case "promotion_id": reg._promotionID = reader.GetInt32(i);
                                      break;
                    case "course_id": reg._courseID = reader.GetInt32(i);
                                      break;
                    case "branch_id": reg._branchID = reader.GetInt32(i);
                                      break;

                    case "full_cost": reg._fullCost = reader.GetInt32(i);
                                      break;
                    case "discounted_cost": reg._discountedCost = reader.GetInt32(i);
                                      break;
                    case "seat_no": reg._seatNo = reader.GetString(i);
                                      break;
                    case "note": reg._note = reader.GetString(i);
                                      break;
                    case "paid_method": reg._paidMethod = reader.GetInt32(i);
                                      break;
                    case "paid_round": reg._paidRound = reader.GetInt32(i);
                                      break;
                    case "paid_date": reg._paiddate = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "username": reg._username = reader.GetString(i);
                                      break;
                    case "status": reg._status = reader.GetInt32(i);
                                      break;
                    case "is_paid": reg._isPaid = reader.GetInt32(i) > 0 ? true : false;
                                      break;

                    // helper info
                    case "bts_course_id":
                                      reg._btsCourseID = reader.GetString(i);
                                      break;
                    case "student_firstname":
                                      reg._studentFirstname = reader.GetString(i);
                                      break;
                    case "student_surname":
                                      reg._studentSurname = reader.GetString(i);
                                      break;
                    case "student_school":
                                      reg._studentSchool = reader.GetString(i);
                                      break;
                    case "student_level":
                                      reg._studentLevel = reader.GetInt32(i);
                                      break;
                    case "course_name":
                                      reg._courseName = reader.GetString(i);
                                      break;
                    case "course_type":
                                      reg._courseType = reader.GetString(i);
                                      break;
                    case "course_category":
                                      reg._courseCategotry = reader.GetString(i);
                                      break;
                    case "start_date": reg._courseStart = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "end_date": reg._courseEnd = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;

                    case "course_short_name":
                                      reg._courseShortName = reader.GetString(i);
                                      break;
                    case "branch_code":
                                      reg._branchCode = reader.GetString(i);
                                      break;

                }
            }
            return reader.HasRows;
        }
Ejemplo n.º 7
0
 public static StringBuilder PrintReceipt(DBManager db, int regisID, string title)
 {
     Registration theReg = new Registration();
     theReg.LoadFromDB(db, " regis_id=" + regisID);
     theReg.LoadCourse(db);
     theReg.LoadStudent(db);
     theReg.LoadBranch(db);
     return PrintReceipt(db, theReg, title);
 }
Ejemplo n.º 8
0
        public static StringBuilder PrintReceipt(DBManager db, Registration theReg, string title)
        {
            StringBuilder outBuf = new StringBuilder();

            Branch branch = theReg._branch;
            AppUser authorizer = new AppUser();
            authorizer.LoadFromDB(db, " username='******'");
            // Load all course registered in the same transaction
            String sql = "SELECT rg.*,c.course_name as course_name "
                        +" FROM registration rg, course c "
                        +" WHERE rg.course_id=c.course_id AND transaction_id=" + theReg._transactionID + " AND branch_id="+ theReg._branchID  +" ORDER BY regis_id ";

            Registration[] regCourses = Registration.LoadListFromDBCustom(db, sql);
            // load branch code
            regCourses[0].LoadBranch(db);

            // Generate HTML content
            TextReader reader = new StreamReader(Config.PATH_APP_ROOT + "\\template\\registration_print_receipt.htm");
            String templateContent = reader.ReadToEnd();
            reader.Close();

            StringBuilder courseTxt = new StringBuilder();
            int sumFullCost = 0;
            int sumDiscountedCost = 0;
            for (int i = 0; i < regCourses.Length; i++)
            {
                regCourses[i].LoadCourse(db);
                Branch b = regCourses[i]._course.LoadBranchInfo(db);

                sumFullCost += regCourses[i]._fullCost;
                sumDiscountedCost += regCourses[i]._discountedCost;

                String startDateInfo = "-";
                String endDateInfo = "-";
                if (regCourses[i]._courseType == "คอร์สสด")
                {
                    startDateInfo = StringUtil.ConvertYearToEng(regCourses[i]._course._startdate, "dd/MM/yyyy");
                    endDateInfo = StringUtil.ConvertYearToEng(regCourses[i]._course._enddate, "dd/MM/yyyy");
                }

                courseTxt.Append("<tr>");
                courseTxt.Append("<td align=center><font size=2>" + regCourses[i]._course._btsCourseID + "</font></td>");
                courseTxt.Append("<td><font size=1>" + regCourses[i]._courseName + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + startDateInfo + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + endDateInfo + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + regCourses[i]._course._opentime + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + StringUtil.Int2StrComma(regCourses[i]._fullCost) + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + StringUtil.Int2StrComma(regCourses[i]._fullCost - regCourses[i]._discountedCost) + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + b._branchCode + "</font></td>");
                courseTxt.AppendLine("</tr>");
            }

            // paid method
            StringBuilder paidMethodTxt = new StringBuilder();
            for (int i = 0; i < PAID_METHOD.Length; i++)
            {
                if (theReg._paidMethod == i)
                {
                    paidMethodTxt.Append("  [√]");
                }
                else
                {
                    paidMethodTxt.Append("  [&nbsp&nbsp]");
                }
                paidMethodTxt.Append(GetPaidMethodText(i.ToString()));
            }

            String htmlContent =
                String.Format(templateContent
                    , theReg.GetRegisTransactionID()
                    , branch._branchName
                    , StringUtil.ConvertYearToEng(theReg._regisdate, "dd/MM/yyyy HH:mm")
                    , Student.GetStudentID(theReg._student._studentID)
                    , theReg._student._firstname + " " + theReg._student._surname
                    , theReg._student._school
                    , StringUtil.ConvertEducateLevel(theReg._student._level)
                    , theReg._student.GetTel()
                    , courseTxt.ToString()
                    , paidMethodTxt.ToString()
                    , StringUtil.Int2StrComma(sumFullCost - sumDiscountedCost)
                    , StringUtil.Int2StrComma(sumDiscountedCost)
                    , authorizer._firstname + " " + authorizer._surname
                    , title
                    , StringUtil.ConvertYearToEng(theReg._paiddate, "dd/MM/yyyy")
                    );

            outBuf.Append(htmlContent);

            return outBuf;
        }
Ejemplo n.º 9
0
        public static StringBuilder PrintCard(DBManager db, int regisID)
        {
            StringBuilder outBuf = new StringBuilder();

            Registration theReg = new Registration();
            theReg.LoadFromDB(db, " regis_id=" + regisID);
            theReg.LoadCourse(db);
            theReg.LoadStudent(db);
            Branch branch = new Branch();
            branch.LoadFromDB(db, " branch_id=" + theReg._branchID);
            AppUser authorizer = new AppUser();
            authorizer.LoadFromDB(db, " username='******'");

            // Load all registration in the same transaction
            Registration[] reg = Registration.LoadListFromDBIncludeCourseHelper(db, " r.transaction_id="+theReg._transactionID + " AND r.branch_id="+theReg._branchID);

            // Generate HTML content
            TextReader reader = new StreamReader(Config.PATH_APP_ROOT + "\\template\\registration_print_card.htm");
            String templateContent = reader.ReadToEnd();
            reader.Close();

            int[] rowH = { 22, 20, 20, 20, 20, 20, 20 };

            StringBuilder courseCalendar = new StringBuilder();
            for (int i = 0; i < reg.Length; i++)
            {
                reg[i].LoadCourse(db);
                Branch b = reg[i]._course.LoadBranchInfo(db);

                courseCalendar.Append("<tr height=\"24px\">");
                courseCalendar.Append("<td width=\"38px\" align=left><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">&nbsp&nbsp&nbsp" + reg[i]._btsCourseID + "</font></td>");
                courseCalendar.Append("<td width=\"100px\" align=left><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">&nbsp" + reg[i]._courseShortName + "</font></td>");
                courseCalendar.Append("<td width=\"17px\" align=left><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">" + b._branchCode + "</font></td>");
                courseCalendar.Append("<td width=\"48px\"><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">" + StringUtil.ConvertYearToEng(reg[i]._course._startdate, "dd/MM/yy") + "</font></td>");
                courseCalendar.Append("<td width=\"25px\"><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">" + reg[i]._course._dayOfWeek+"</font></td>");
                courseCalendar.Append("<td width=\"70px\"><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">" + reg[i]._course._opentime + "</font></td>");

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

            /*
                <tr height="10px"><td colspan=2></td></tr>
            <tr><td width="10px" align="right">&nbsp</td><td><font size=2>คอร์ส: {4}</font></td></tr>
            <tr><td align="right">&nbsp</td><td><font size=2>ชื่อคอร์ส: {5} </font></td></tr>
            <tr><td align="right">&nbsp</td><td><font size=2>วันที่เริ่ม: {6}</font></td></tr>
            <tr><td align="right">&nbsp</td><td><font size=2>เวลา: {7}</font></td></tr>
            <tr><td align="right">&nbsp</td><td><font size=2>หนังสือ: </font></td></tr>
            */

            String htmlContent =
                String.Format(templateContent
                    , theReg._student._firstname + " " + theReg._student._surname
                    , Student.GetStudentID(theReg._student._studentID)
                    , StringUtil.ConvertYearToEng(theReg._regisdate, "dd/MM/yyyy")
                    , authorizer._firstname + " " + authorizer._surname
                    , reg[0].GetRegisTransactionID()
                    , courseCalendar.ToString()
                    );

            outBuf.Append(htmlContent);
            return outBuf;
        }
Ejemplo n.º 10
0
        public static Registration[] LoadListFromDBCustom(DBManager db, string sqlAll)
        {
            OdbcDataReader reader = db.Query(sqlAll);
            LinkedList<Registration> list = new LinkedList<Registration>();
            while (reader.Read())
            {
                list.AddLast(Registration.CreateForm(reader));
            }

            Registration[] entities = new Registration[list.Count];
            int i = 0;
            foreach (Registration t in list)
            {
                entities[i++] = t;
            }
            return entities;
        }
Ejemplo n.º 11
0
        public static StringBuilder PrintReceipt(DBManager db, Registration theReg, string title)
        {
            StringBuilder outBuf = new StringBuilder();

            Branch  branch     = theReg._branch;
            AppUser authorizer = new AppUser();

            authorizer.LoadFromDB(db, " username='******'");
            // Load all course registered in the same transaction
            String sql = "SELECT rg.*,c.course_name as course_name "
                         + " FROM registration rg, course c "
                         + " WHERE rg.course_id=c.course_id AND transaction_id=" + theReg._transactionID + " AND branch_id=" + theReg._branchID + " ORDER BY regis_id ";

            Registration[] regCourses = Registration.LoadListFromDBCustom(db, sql);
            // load branch code
            regCourses[0].LoadBranch(db);

            // Generate HTML content
            TextReader reader          = new StreamReader(Config.PATH_APP_ROOT + "\\template\\registration_print_receipt.htm");
            String     templateContent = reader.ReadToEnd();

            reader.Close();

            StringBuilder courseTxt         = new StringBuilder();
            int           sumFullCost       = 0;
            int           sumDiscountedCost = 0;

            for (int i = 0; i < regCourses.Length; i++)
            {
                regCourses[i].LoadCourse(db);
                Branch b = regCourses[i]._course.LoadBranchInfo(db);

                sumFullCost       += regCourses[i]._fullCost;
                sumDiscountedCost += regCourses[i]._discountedCost;

                String startDateInfo = "-";
                String endDateInfo   = "-";
                if (regCourses[i]._courseType == "คอร์สสด")
                {
                    startDateInfo = StringUtil.ConvertYearToEng(regCourses[i]._course._startdate, "dd/MM/yyyy");
                    endDateInfo   = StringUtil.ConvertYearToEng(regCourses[i]._course._enddate, "dd/MM/yyyy");
                }

                courseTxt.Append("<tr>");
                courseTxt.Append("<td align=center><font size=2>" + regCourses[i]._course._btsCourseID + "</font></td>");
                courseTxt.Append("<td><font size=1>" + regCourses[i]._courseName + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + startDateInfo + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + endDateInfo + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + regCourses[i]._course._opentime + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + StringUtil.Int2StrComma(regCourses[i]._fullCost) + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + StringUtil.Int2StrComma(regCourses[i]._fullCost - regCourses[i]._discountedCost) + "</font></td>");
                courseTxt.Append("<td align=center><font size=2>" + b._branchCode + "</font></td>");
                courseTxt.AppendLine("</tr>");
            }

            // paid method
            StringBuilder paidMethodTxt = new StringBuilder();

            for (int i = 0; i < PAID_METHOD.Length; i++)
            {
                if (theReg._paidMethod == i)
                {
                    paidMethodTxt.Append("  [√]");
                }
                else
                {
                    paidMethodTxt.Append("  [&nbsp&nbsp]");
                }
                paidMethodTxt.Append(GetPaidMethodText(i.ToString()));
            }

            String htmlContent =
                String.Format(templateContent
                              , theReg.GetRegisTransactionID()
                              , branch._branchName
                              , StringUtil.ConvertYearToEng(theReg._regisdate, "dd/MM/yyyy HH:mm")
                              , Student.GetStudentID(theReg._student._studentID)
                              , theReg._student._firstname + " " + theReg._student._surname
                              , theReg._student._school
                              , StringUtil.ConvertEducateLevel(theReg._student._level)
                              , theReg._student.GetTel()
                              , courseTxt.ToString()
                              , paidMethodTxt.ToString()
                              , StringUtil.Int2StrComma(sumFullCost - sumDiscountedCost)
                              , StringUtil.Int2StrComma(sumDiscountedCost)
                              , authorizer._firstname + " " + authorizer._surname
                              , title
                              , StringUtil.ConvertYearToEng(theReg._paiddate, "dd/MM/yyyy")
                              );

            outBuf.Append(htmlContent);

            return(outBuf);
        }
Ejemplo n.º 12
0
        public static StringBuilder PrintCard(DBManager db, int regisID)
        {
            StringBuilder outBuf = new StringBuilder();

            Registration theReg = new Registration();

            theReg.LoadFromDB(db, " regis_id=" + regisID);
            theReg.LoadCourse(db);
            theReg.LoadStudent(db);
            Branch branch = new Branch();

            branch.LoadFromDB(db, " branch_id=" + theReg._branchID);
            AppUser authorizer = new AppUser();

            authorizer.LoadFromDB(db, " username='******'");

            // Load all registration in the same transaction
            Registration[] reg = Registration.LoadListFromDBIncludeCourseHelper(db, " r.transaction_id=" + theReg._transactionID + " AND r.branch_id=" + theReg._branchID);

            // Generate HTML content
            TextReader reader          = new StreamReader(Config.PATH_APP_ROOT + "\\template\\registration_print_card.htm");
            String     templateContent = reader.ReadToEnd();

            reader.Close();

            int[] rowH = { 22, 20, 20, 20, 20, 20, 20 };

            StringBuilder courseCalendar = new StringBuilder();

            for (int i = 0; i < reg.Length; i++)
            {
                reg[i].LoadCourse(db);
                Branch b = reg[i]._course.LoadBranchInfo(db);

                courseCalendar.Append("<tr height=\"24px\">");
                courseCalendar.Append("<td width=\"38px\" align=left><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">&nbsp&nbsp&nbsp" + reg[i]._btsCourseID + "</font></td>");
                courseCalendar.Append("<td width=\"100px\" align=left><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">&nbsp" + reg[i]._courseShortName + "</font></td>");
                courseCalendar.Append("<td width=\"17px\" align=left><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">" + b._branchCode + "</font></td>");
                courseCalendar.Append("<td width=\"48px\"><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">" + StringUtil.ConvertYearToEng(reg[i]._course._startdate, "dd/MM/yy") + "</font></td>");
                courseCalendar.Append("<td width=\"25px\"><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">" + reg[i]._course._dayOfWeek + "</font></td>");
                courseCalendar.Append("<td width=\"70px\"><font style=\"font: 10px 'Trebuchet MS', Verdana, Arial, Helvetica, sans-serif;\">" + reg[i]._course._opentime + "</font></td>");

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


/*
 *              <tr height="10px"><td colspan=2></td></tr>
 *  <tr><td width="10px" align="right">&nbsp</td><td><font size=2>คอร์ส: {4}</font></td></tr>
 *  <tr><td align="right">&nbsp</td><td><font size=2>ชื่อคอร์ส: {5} </font></td></tr>
 *  <tr><td align="right">&nbsp</td><td><font size=2>วันที่เริ่ม: {6}</font></td></tr>
 *  <tr><td align="right">&nbsp</td><td><font size=2>เวลา: {7}</font></td></tr>
 *  <tr><td align="right">&nbsp</td><td><font size=2>หนังสือ: </font></td></tr>
 */

            String htmlContent =
                String.Format(templateContent
                              , theReg._student._firstname + " " + theReg._student._surname
                              , Student.GetStudentID(theReg._student._studentID)
                              , StringUtil.ConvertYearToEng(theReg._regisdate, "dd/MM/yyyy")
                              , authorizer._firstname + " " + authorizer._surname
                              , reg[0].GetRegisTransactionID()
                              , courseCalendar.ToString()
                              );

            outBuf.Append(htmlContent);
            return(outBuf);
        }
Ejemplo n.º 13
0
        public static bool CreateForm(OdbcDataReader reader, Registration reg)
        {
            int fCount = reader.FieldCount;

            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name)
                {
                case "regis_id": reg._regisID = reader.GetInt32(i);
                    break;

                case "transaction_id": reg._transactionID = reader.GetInt32(i);
                    break;

                case "transaction_code": reg._transactionCode = reader.GetString(i);
                    break;

                case "regis_date": reg._regisdate = new DateTime(reader.GetDateTime(i).Ticks);
                    break;

                case "student_id": reg._studentID = reader.GetInt32(i);
                    break;

                case "promotion_id": reg._promotionID = reader.GetInt32(i);
                    break;

                case "course_id": reg._courseID = reader.GetInt32(i);
                    break;

                case "branch_id": reg._branchID = reader.GetInt32(i);
                    break;

                case "full_cost": reg._fullCost = reader.GetInt32(i);
                    break;

                case "discounted_cost": reg._discountedCost = reader.GetInt32(i);
                    break;

                case "seat_no": reg._seatNo = reader.GetString(i);
                    break;

                case "note": reg._note = reader.GetString(i);
                    break;

                case "paid_method": reg._paidMethod = reader.GetInt32(i);
                    break;

                case "paid_round": reg._paidRound = reader.GetInt32(i);
                    break;

                case "paid_date": reg._paiddate = new DateTime(reader.GetDateTime(i).Ticks);
                    break;

                case "username": reg._username = reader.GetString(i);
                    break;

                case "status": reg._status = reader.GetInt32(i);
                    break;

                case "is_paid": reg._isPaid = reader.GetInt32(i) > 0 ? true : false;
                    break;

                // helper info
                case "bts_course_id":
                    reg._btsCourseID = reader.GetString(i);
                    break;

                case "student_firstname":
                    reg._studentFirstname = reader.GetString(i);
                    break;

                case "student_surname":
                    reg._studentSurname = reader.GetString(i);
                    break;

                case "student_school":
                    reg._studentSchool = reader.GetString(i);
                    break;

                case "student_level":
                    reg._studentLevel = reader.GetInt32(i);
                    break;

                case "course_name":
                    reg._courseName = reader.GetString(i);
                    break;

                case "course_type":
                    reg._courseType = reader.GetString(i);
                    break;

                case "course_category":
                    reg._courseCategotry = reader.GetString(i);
                    break;

                case "start_date": reg._courseStart = new DateTime(reader.GetDateTime(i).Ticks);
                    break;

                case "end_date": reg._courseEnd = new DateTime(reader.GetDateTime(i).Ticks);
                    break;

                case "course_short_name":
                    reg._courseShortName = reader.GetString(i);
                    break;

                case "branch_code":
                    reg._branchCode = reader.GetString(i);
                    break;
                }
            }
            return(reader.HasRows);
        }