Exemple #1
0
        protected void DoInitPrintAll(string regisTransactionID)
        {
            DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC);

            db.Connect();

            outBuf = new StringBuilder();
            // find one of registration from list by transaction id
            AppUser user = (AppUser)Session[SessionVar.USER];

            Registration[] reg = Registration.LoadListFromDB(db, " WHERE transaction_id=" + regisTransactionID + " AND branch_id=" + user._branchID + " ORDER BY regis_id ");

            // print
            PageBreaker   pb     = new PageBreaker(Config.PAGE_BREAK_MAX);
            StringBuilder tmpBuf = Registration.PrintCard(db, reg[0]._regisID);

            pb.Print(outBuf, tmpBuf, Config.PAGE_BREAK_CARD);
            outBuf.AppendLine("<br>");

            pb.Print(outBuf, Registration.PrintReceipt(db, reg[0]._regisID, "สำหรับนักเรียน"), Config.PAGE_BREAK_RECEIPT);
            outBuf.AppendLine("<br>");
            pb.Print(outBuf, Registration.PrintReceipt(db, reg[0]._regisID, "สำหรับโรงเรียน"), Config.PAGE_BREAK_RECEIPT);

            db.Close();
            // Save to session
            Session[SessionVar.PRINT_INFO] = new StringBuilder(outBuf.ToString());
        }
        //    protected System.Web.UI.HtmlControls.HtmlInputFile portrait;

        protected void Page_Load(object sender, EventArgs e)
        {
            // Authentication
            string redirect = VerifyAA.Verify(Session
                                              , Request
                                              , Response
                                              , "NoRight.aspx");

            // Collect paramters
            actPage = Request.Form.Get("actPage");
            if (actPage == null)
            {
                actPage = Request["actPage"];
            }
            targetID = Request.Form.Get("targetID");
            if (targetID == null)
            {
                targetID = Request["targetID"];
            }

            // log
            log.StampLine(Logger.DETAILED, "Request [" + Request["ASP.NET_SessionId"] + "][" + Request.RawUrl + "][actPage=" + actPage + "&targetID=" + targetID + "]");
            log.StampLine(Logger.DEBUG, "Param [" + Request["ASP.NET_SessionId"] + "][" + Request.Params.ToString() + "]");

            if ((actPage == null) || (actPage.Trim().Length == 0) || (actPage.Equals("list")))
            {
                string qSearch     = Request.Form.Get("qsearch");
                bool   isNewSearch = false;
                if (qSearch != null)
                {
                    isNewSearch = true;
                }
                else
                {
                    qSearch = Request["qsearch"];
                }
                DoListRegistration(qSearch, isNewSearch);
            }
            else if (actPage.Equals("edit"))
            {
                DoEditRegistration(targetID);
            }
            else if (actPage.Equals("edit_submit"))
            {
                targetID = Request["targetID"];
                DoEditSubmitRegistration(targetID);
                Response.Redirect("RegistrationManage.aspx?actPage=edit&targetID=" + targetID + "&msgText=" + msgText);
                //Response.Redirect("RegistrationManage.aspx?actPage=init_print&targetId=" + registrationID);
            }
            else if (actPage.Equals("refund"))
            {
                targetID = Request["targetID"];
                DoRefund(targetID);
                Response.Redirect("RegistrationManage.aspx?actPage=edit&targetID=" + targetID + "&msgText=" + msgText);
                //Response.Redirect("RegistrationManage.aspx?actPage=init_print&targetId=" + registrationID);
            }
            else if (actPage.Equals("init_print_card"))
            {
                targetID = Request["targetID"];
                outBuf   = new StringBuilder();
                outBuf.Append(DoInitPrinRegistrationCard(targetID));
                Session[SessionVar.PRINT_INFO] = new StringBuilder(outBuf.ToString());
            }
            else if (actPage.Equals("init_print_receipt"))
            {
                targetID = Request["targetID"];
                outBuf   = new StringBuilder();
                outBuf.Append(DoInitPrinRegistrationReceipt(targetID, "สำหรับนักเรียน"));
                outBuf.Append(DoInitPrinRegistrationReceipt(targetID, "สำหรับโรงเรียน"));
                Session[SessionVar.PRINT_INFO] = new StringBuilder(outBuf.ToString());
            }
            else if (actPage.Equals("init_print_all"))
            {
                targetID = Request["targetID"];
                outBuf   = new StringBuilder();

                PageBreaker pb = new PageBreaker(Config.PAGE_BREAK_MAX);

                StringBuilder tmpBuf = DoInitPrinRegistrationCard(targetID);
                pb.Print(outBuf, tmpBuf, Config.PAGE_BREAK_CARD);
                outBuf.AppendLine("<br>");

                tmpBuf = DoInitPrinRegistrationReceipt(targetID, "ต้นฉบับ");
                pb.Print(outBuf, tmpBuf, Config.PAGE_BREAK_RECEIPT);
                outBuf.AppendLine("<br>");
                tmpBuf = DoInitPrinRegistrationReceipt(targetID, "สำเนา");
                pb.Print(outBuf, tmpBuf, Config.PAGE_BREAK_RECEIPT);

                Session[SessionVar.PRINT_INFO] = new StringBuilder(outBuf.ToString());
            }
        }