Example #1
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));
        }
        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();
        }
        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 = "แก้ไขข้อมูลเรียบร้อย";
        }
        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 = "แก้ไขข้อมูลเรียบร้อย";
            }
        }
Example #5
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);
 }
Example #6
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;
        }
Example #7
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);
        }