protected void ProcessWizAddSelectedStudent(string student_id) { // get data from session RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if (reg == null) { reg = new RegisTransaction(); } DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); Student student = new Student(); student.LoadFromDB(db, " student_id=" + student_id); db.Close(); if (student != null) { reg._student = student; reg._studentID = student._studentID; } // save back to session Session[SessionVar.CURRENT_REGIS] = reg; }
protected void ProcessWizAddSelectedCourse(string course_id) { // get data from session RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if (reg == null) { reg = new RegisTransaction(); } DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); Course course = new Course(); course.LoadFromDB(db, " course_id=" + course_id); db.Close(); if (course != null) { reg.AddCourse(course); } // save back to session Session[SessionVar.CURRENT_REGIS] = reg; }
// TODO: Check duplicated registration protected void ProcessRegistration(RegisTransaction reg) { AppUser user = (AppUser)Session[SessionVar.USER]; // Collect additional variable // * User information comes from session NOT DB reg._username = user._username; reg._paidMethod = Int32.Parse(Request["paid_method"]); if (Session[SessionVar.BRANCH_SELECTED] == null) { reg._branchID = user._branchID; } else { reg._branchID = Int32.Parse((String)Session[SessionVar.BRANCH_SELECTED]); user._branchID = reg._branchID; Session[SessionVar.USER] = user; } reg._paiddate = StringUtil.getDate(Request["paid_date"]); // seat for (int i = 0; i < Request.Form.AllKeys.Length; i++) { if (Request.Form.AllKeys[i].StartsWith("seat_no")) { string courseID = Request.Form.AllKeys[i].Substring(7); string seatNo = Request[Request.Form.AllKeys[i]]; try { reg._seatNoMap.Add(courseID, seatNo); } catch (Exception ex) { } continue; } if (Request.Form.AllKeys[i].StartsWith("note")) { string courseID = Request.Form.AllKeys[i].Substring(4); string note = Request[Request.Form.AllKeys[i]]; try { reg._noteMap.Add(courseID, note); } catch (Exception ex) { } continue; } } DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); reg.AddToDB(db); db.Close(); }
protected void ProcessPrintAdditionalInfoForm(RegisTransaction reg) { outBuf = new StringBuilder(); foreach (Course c in reg._courses) { string seatName = "seat_no" + c._courseID; string noteName = "note" + c._courseID; outBuf.AppendLine("<tr><td align=left>" + c._btsCourseID + "</td>"); outBuf.AppendLine("<td align=center><input type=text class=\"txtbox1\" style=\"width:20px\" maxlength=\"10\" name=\"" + seatName + "\"></td>"); outBuf.AppendLine("<td align=center><input type=text class=\"txtbox1\" style=\"width:150px\" maxlength=\"200\" name=\"" + noteName + "\"></td></tr>"); } }
protected void ProcessWizRemoveSelectedStudent(string course_id) { // get data from session RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if (reg == null) { return; } foreach (Course c in reg._courses) { if (c._courseID.ToString().Equals(course_id)) { reg._courses.Remove(c); break; } } }
protected void DiscountCourse(string course_id, string cost) { // get data from session RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if (reg == null) { reg = new RegisTransaction(); } int cid = Int32.Parse(course_id); foreach (Course c in reg._modCourses) { if (c._courseID == cid) { c._discountedCost = Int32.Parse(cost); } } }
protected void DiscountPromotion(string promotion_id, string cost) { // get data from session RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if (reg == null) { reg = new RegisTransaction(); } int pid = Int32.Parse(promotion_id); foreach (Promotion p in reg._modPromotions) { if (p._promotionID == pid) { p._discountedCost = Int32.Parse(cost); } } }
// 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("new")) || (actPage.Equals("select_course"))) { if ((actPage == null) || (actPage.Trim().Length == 0) || (actPage.Equals("new"))) { // clear session data Session[SessionVar.CURRENT_REGIS] = null; } // DoListPromotion(Request["qsearch"]); } else if (actPage.Equals("select_student")) { RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if ((reg == null) || (reg._courses == null) || (reg._courses.Count == 0)) { actPage = "select_course"; return; } } else if (actPage.Equals("confirm_registration")) { RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if ((reg == null) || (reg._student == null)) { actPage = "select_student"; return; } ProcessPrintAdditionalInfoForm(reg); } else if (actPage.Equals("add_new_student_submit")) { Student t = ProcessWizAddNewStudent(); if (t == null) { Response.Redirect("RegisterCourse.aspx?actPage=select_student&errorText=" + errorText); return; } // save to session RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; reg._student = t; reg._studentID = t._studentID; Session[SessionVar.CURRENT_REGIS] = reg; // list Response.Redirect("RegisterCourse.aspx?actPage=select_student"); } else if (actPage.Equals("submit_registration")) { RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if ((reg == null) || (reg._courses == null) || (reg._courses.Count == 0)) { errorText = "ข้อมูลการลงทะเบียนไม่สมบูรณ์ โปรดลองใหม่อีกครั้ง"; return; } ProcessRegistration(reg); // clear session data Session[SessionVar.CURRENT_REGIS] = null; Response.Redirect("RegisterCourse.aspx?actPage=registration_complete&targetId=" + reg._transactionID); } else if (actPage.Equals("registration_complete")) { DoInitPrintAll(targetID); } else if (actPage.Equals("cancel_registration")) { // clear session data Session[SessionVar.CURRENT_REGIS] = null; Response.Redirect("Home.aspx"); } }
protected void ProcessWizListSelectedStudent() { outBuf.Append("<br>"); // get data from session RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if (reg == null) { return; } if (reg._student == null) { outBuf.Append("  ยังไม่ได้เลือกนักเรียน"); return; } // Query registration history DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); Registration[] reghis = Registration.LoadListFromDBCustom(db, "SELECT rg.*, c.bts_course_id as bts_course_id, c.course_name as course_name FROM registration rg, course c WHERE " + " student_id=" + reg._student._studentID + " AND rg.course_id=c.course_id ORDER BY rg.regis_id "); db.Close(); StringBuilder regHisTxt = new StringBuilder(); if (reghis.Length > 0) { for (int i = 0; i < reghis.Length; i++) { string statusTxt = Registration.GetStatusText(reghis[i]._status); if (reghis[i]._status == Registration.STATUS_CANCELLED) { statusTxt = "<font color=red>" + statusTxt + "</font>"; } regHisTxt.AppendLine("<tr>"); regHisTxt.AppendLine("<td> " + reghis[i]._regisdate.ToString("dd/MM/yyyy HH:mm", ci) + "</td>"); regHisTxt.AppendLine("<td> " + "<a href=\"CourseManage.aspx?actPage=view&targetID=" + reghis[i]._courseID + "\" >" + reghis[i]._btsCourseID + " " + reghis[i]._courseName + "</a>" + "</td>"); regHisTxt.AppendLine("<td align=center>" + StringUtil.Int2StrComma(reghis[i]._fullCost) + "</td>"); regHisTxt.AppendLine("<td align=center>" + StringUtil.Int2StrComma(reghis[i]._discountedCost) + "</td>"); regHisTxt.AppendLine("<td align=center>" + statusTxt + "</td>"); regHisTxt.AppendLine("<td align=center>" + reghis[i]._note + "</td>"); regHisTxt.AppendLine("</tr>"); } } else { regHisTxt.AppendLine("<tr><td colspan=3 align=center>ไม่พบข้อมูลการลงทะเบียน</td></tr>"); } TextReader reader = new StreamReader(Config.PATH_APP_ROOT + "\\template\\" + AjaxSvc.WIZ_LIST_SELECTED_STUDENT + ".htm"); String templateContent = reader.ReadToEnd(); reader.Close(); Student s = reg._student; String htmlContent = String.Format(templateContent , Config.URL_PIC_STUDENT + "/" + s._img , Student.GetStudentID(s._studentID) , s._firstname + " " + s._surname + " (" + s._nickname + ")" , s._citizenID , Config.URL_PIC_SYS + (s._sex.Equals("Male") ? "/boy.gif" : "/girl.gif") , s._school , s._birthday.ToString("dd/MM/yyyy", ci) , s._addr , s.GetTel() , s._email , regHisTxt.ToString()); outBuf.Append(htmlContent); }
protected void ProcessWizListSelectedCourse(string enableAction, bool recalculatePromotion) { bool enableAct; Boolean.TryParse(enableAction, out enableAct); outBuf.Append("<br>"); // get data from session RegisTransaction reg = (RegisTransaction)Session[SessionVar.CURRENT_REGIS]; if (reg == null) { return; } if (reg._courses.Count == 0) { outBuf.Append("  ยังไม่ได้เลือกคอร์ส"); } if (recalculatePromotion) { // copy to temp list Course[] courses = new Course[reg._courses.Count]; reg._courses.CopyTo(courses, 0); LinkedList <Course> copyCourses = new LinkedList <Course>(courses); // find matching promotions DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); PromotionMatcher matcher = Promotion.LoadFromDBByMatchingCourses(db, reg._courses); db.Close(); // store back to reg reg._modCourses = (matcher._matchedCourses != null) ? matcher._matchedCourses : new LinkedList <Course>(); reg._modPromotions = (matcher._matchedPromotions != null) ? matcher._matchedPromotions : new LinkedList <Promotion>(); Session[SessionVar.CURRENT_REGIS] = reg; } // print Promotion[] proArray = new Promotion[reg._modPromotions.Count]; reg._modPromotions.CopyTo(proArray, 0); int sumCost = 0; int sumFullCost = 0; outBuf.Append("<table>"); for (int i = 0; i < proArray.Length; i++) { sumCost += proArray[i]._discountedCost; outBuf.Append("<tr valign=middle><td>   </td><td>" + Promotion.GetPromotionID(proArray[i]._promotionID) + " " + proArray[i]._promotionName); string costTxt = StringUtil.Int2StrComma(proArray[i]._discountedCost); if (!enableAct) { costTxt = " <a href=\"javascript:modifyPCost(" + proArray[i]._promotionID + "," + proArray[i]._discountedCost + ")\" >" + StringUtil.Int2StrComma(proArray[i]._discountedCost) + "</a>"; } if (proArray[i]._cost != proArray[i]._discountedCost) { costTxt = " <strike>" + StringUtil.Int2StrComma(proArray[i]._cost) + "</strike>   ลดพิเศษเหลือ " + costTxt; } outBuf.Append(" ( <strike>" + StringUtil.Int2StrComma(proArray[i].GetFullCost()) + "</strike>  " + costTxt + " )</td></tr>"); for (int j = 0; j < proArray[i]._courses.Length; j++) { Course c = proArray[i]._courses[j]; sumFullCost += c._cost; string jsShowDiv = " onmouseover=\"queryCourseDetail(" + c._courseID + ");showDivAt('divdetail')\" onmouseout=\"hideDiv('divdetail')\" "; string icon = "<img style=\"cursor:pointer\" border=0 src=\"" + Config.URL_PIC_SYS + "/info.gif\" " + jsShowDiv + ">"; string courseLine = c._btsCourseID + " " + c._courseName; string costLine = " ( <strike>" + StringUtil.Int2StrComma(c._cost) + "</strike> )"; if (enableAct) { courseLine = "<a href=\"javascript:removeCourse('" + c._courseID + "')\">" + courseLine + "</a>"; } outBuf.Append("<tr valign=middle><td>  " + icon + "</td><td>   " + courseLine + costLine + "</td></tr>"); // remove from copied list //copyCourses.Remove(c); } } // print no promotion foreach (Course c in reg._modCourses) { sumCost += c._discountedCost; sumFullCost += c._cost; string jsShowDiv = " onmouseover=\"queryCourseDetail(" + c._courseID + ");showDivAt('divdetail')\" onmouseout=\"hideDiv('divdetail')\" "; string icon = "<img style=\"cursor:pointer\" border=0 src=\"" + Config.URL_PIC_SYS + "/info.gif\" " + jsShowDiv + ">"; string courseLine = c._btsCourseID + " " + c._courseName; if (enableAct) { courseLine = "<a href=\"javascript:removeCourse('" + c._courseID + "')\">" + courseLine + "</a>"; } string costTxt = " ( "; if (c._cost != c._discountedCost) { costTxt = costTxt + " <strike>" + StringUtil.Int2StrComma(c._cost) + "</strike>   ลดพิเศษเหลือ "; } if (!enableAct) { costTxt = costTxt + "<a href=\"javascript:modifyCCost(" + c._courseID + "," + c._discountedCost + ")\" >" + StringUtil.Int2StrComma(c._discountedCost) + "</a> )"; } else { costTxt = costTxt + StringUtil.Int2StrComma(c._discountedCost) + " )"; } outBuf.Append("<tr valign=middle><td>  " + icon + "</td><td>" + courseLine + costTxt + "</td></tr>"); } outBuf.Append("</table><br><br>"); outBuf.Append("  <b>รวมค่าใช้จ่ายทั้งหมด <strike>" + StringUtil.Int2StrComma(sumFullCost) + "</strike> <font size=2 color=red>" + StringUtil.Int2StrComma(sumCost) + "</font> บาท</b>"); }