protected AppUser ValidateLogin(string username, string passwd) { List <String> list = GetSystemDriverList(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); OdbcDataReader reader = null; try { reader = db.Query("SELECT u.*, b.branch_name as branch_name FROM user u, branch b WHERE u.username='******' AND u.branch_id=b.branch_id"); while (reader.Read()) { AppUser user = AppUser.CreateForm(reader); if (user._encodedPassword == null) { return(null); } if (user._encodedPassword.Equals(AppUser.GetMD5Encoded(passwd))) { return(user); } } return(null); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(null); } finally { db.Close(reader); } }
public void DoEditTeacher(string teacherID) { DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); //Load GroupList groupList = PaidGroup.LoadListFromDB(db, ""); theTeacher = new Teacher(); if (!theTeacher.LoadFromDB(db, "teacher_id=" + teacherID)) theTeacher = null; // List Course History string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; string query = "SELECT * from course "; query = query + "WHERE teacher_id='"; query = query + teacherID + "' order by start_date desc"; OdbcDataReader reader = db.Query(query); int i = 0; while (reader.Read()) { Course course = Course.CreateForm(reader); outBuf3.Append("<tr>"); outBuf3.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + " align=center>" + course._startdate.ToString("dd MMM yyyy", ci) + " </th>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " align=center>" + course._btsCourseID + " </td>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " align=left>" + course._courseName + " </td>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " >" + course._cost + " </td>"); outBuf3.Append("</tr>\n"); i++; } db.Close(); }
protected List <string> GetListUser(string branch_id) { List <string> list = new List <String>(); if (string.IsNullOrEmpty(branch_id)) { return(list); } string sql = "SELECT username,firstname,surname FROM user WHERE branch_id='" + branch_id + "'"; string ret = String.Empty; DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); OdbcDataReader reader = db.Query(sql); int fCount = reader.FieldCount; while (reader.Read()) { string tmp = "[" + reader.GetString(0).ToUpper() + "] " + reader.GetString(1) + " " + reader.GetString(2); list.Add(tmp); } db.Close(); return(list); }
public void DoEditStudent(string studentID) { DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); theStudent = new Student(); if (!theStudent.LoadFromDB(db, "student_id=" + studentID)) theStudent = null; // List Course History string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; string query = "SELECT * from course "; query = query + "WHERE course.course_id in (select registration.course_id from registration where registration.student_id='"; query = query + studentID + "') order by start_date desc"; OdbcDataReader reader = db.Query(query); int i = 0; while (reader.Read()) { Course course = Course.CreateForm(reader); outBuf3.Append("<tr>"); outBuf3.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + " align=center>" + course._startdate.ToString("dd MMM yyyy", ci) + " </th>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " align=center>" + course._btsCourseID + " </td>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " align=left>" + course._courseName + " </td>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " >" + course._cost + " </td>"); outBuf3.Append("</tr>\n"); i++; } db.Close(); }
protected void DoListRegister(string searchStr) { // get Page int pg = 1; if (Request["pg"]!=null) pg = Int32.Parse(Request["pg"]); string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; // listRegistration = new List<Registration>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); if (searchStr.Trim().Length > 0) searchStr = " WHERE " + searchStr; int numRec = db.QueryCount("SELECT Count(*) FROM registration " + searchStr); OdbcDataReader reader = db.Query("SELECT * FROM registration " + searchStr + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Registration regis = Registration.CreateForm(reader); outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + regis._regisID + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._transactionID + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._regisdate.ToString("dd/MM/yyyy",ci) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._studentID + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._courseID + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._fullCost + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._promotionID + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._discountedCost + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._isPaid.ToString() + " </td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (maxpg % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>"+i+"</b> "); } else { outBuf2.Append(String.Format("<a href=\"ReportRegis.aspx?pg={0}\">{1}</a> ", i.ToString(), i.ToString())); } } }
public static void Reload() { _authDB.Clear(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); OdbcDataReader reader = db.Query("SELECT r.role_id,r.name,rightname,action FROM authorization a, role r WHERE a.role_id = r.role_id"); while (reader.Read()) { int roleID = reader.GetInt32(0); string right = reader.GetString(2); string action = reader.GetString(3); Add(roleID, right, action); } db.Close(); }
public static int GetMaxRecord() { DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); OdbcDataReader reader = db.Query("SELECT MAX(teacher_id) FROM teacher"); if (!reader.Read()) { return(0); } long max = reader.IsDBNull(0) ? -1 : reader.GetInt64(0); db.Close(); return((int)(max + 1)); }
protected string GetBranchName(int branch_id) { if (branch_id <= 0) { return(""); } string sql = "SELECT branch_name FROM branch WHERE branch_id='" + branch_id + "'"; string ret = String.Empty; DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); OdbcDataReader reader = db.Query(sql); reader.Read(); ret = reader.GetString(0); db.Close(); return(ret); }
public void DoEditTeacher(string teacherID) { DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); //Load GroupList groupList = PaidGroup.LoadListFromDB(db, ""); theTeacher = new Teacher(); if (!theTeacher.LoadFromDB(db, "teacher_id=" + teacherID)) { theTeacher = null; } // List Course History string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; string query = "SELECT * from course "; query = query + "WHERE teacher_id='"; query = query + teacherID + "' order by start_date desc"; OdbcDataReader reader = db.Query(query); int i = 0; while (reader.Read()) { Course course = Course.CreateForm(reader); outBuf3.Append("<tr>"); outBuf3.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + " align=center>" + course._startdate.ToString("dd MMM yyyy", ci) + " </th>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " align=center>" + course._btsCourseID + " </td>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " align=left>" + course._courseName + " </td>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " >" + course._cost + " </td>"); outBuf3.Append("</tr>\n"); i++; } db.Close(); }
public void DoEditStudent(string studentID) { DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); theStudent = new Student(); if (!theStudent.LoadFromDB(db, "student_id=" + studentID)) { theStudent = null; } // List Course History string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; string query = "SELECT * from course "; query = query + "WHERE course.course_id in (select registration.course_id from registration where registration.student_id='"; query = query + studentID + "') order by start_date desc"; OdbcDataReader reader = db.Query(query); int i = 0; while (reader.Read()) { Course course = Course.CreateForm(reader); outBuf3.Append("<tr>"); outBuf3.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + " align=center>" + course._startdate.ToString("dd MMM yyyy", ci) + " </th>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " align=center>" + course._btsCourseID + " </td>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " align=left>" + course._courseName + " </td>"); outBuf3.Append("<td " + bgclass[i % 2, 1] + " >" + course._cost + " </td>"); outBuf3.Append("</tr>\n"); i++; } db.Close(); }
protected void DoListPaidGroup(string searchStr) { // get Page int pg = 1; if (Request["pg"] != null) pg = Int32.Parse(Request["pg"]); string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); int numRec = db.QueryCount("SELECT Count(*) FROM paid_group " + GetQSearchSQL(searchStr)); OdbcDataReader reader = db.Query("SELECT * FROM paid_group " + GetQSearchSQL(searchStr) + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { PaidGroup group = BTS.Entity.PaidGroup.CreateForm(reader); // teacher member list Teacher[] memberList = group.LoadMemberTeachers(db); StringBuilder memberTxt = new StringBuilder(); for (int j = 0; j < memberList.Length; j++) { String txt = Teacher.GetTeacherID(memberList[j]._teacherID) + " " + memberList[j]._firstname + " " + memberList[j]._surname; memberTxt.Append( "<a href=\"TeacherManage.aspx?actPage=view&targetID="+memberList[j]._teacherID+"\">"+ txt + "<br>"); } outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + PaidGroup.GetPaidGroupID(group._paidGroupID) + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + group._name + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + group._rawRateInfo + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left >" + memberTxt + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + group._paidGroupID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this user?')) { setVal('actPage','delete');setVal('targetID','" + group._paidGroupID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (maxpg % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"PaidGroupManage.aspx?pg={0}\">{1}</a> ", i.ToString(), i.ToString())); } } // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected AppUser ValidateLogin(string username, string passwd) { List<String> list = GetSystemDriverList(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); OdbcDataReader reader = null; try { reader = db.Query("SELECT u.*, b.branch_name as branch_name FROM user u, branch b WHERE u.username='******' AND u.branch_id=b.branch_id"); while (reader.Read()) { AppUser user = AppUser.CreateForm(reader); if (user._encodedPassword == null) return null; if (user._encodedPassword.Equals(AppUser.GetMD5Encoded(passwd) )) return user; } return null; } catch (Exception e) { Console.WriteLine(e.StackTrace); return null; } finally { db.Close(reader); } }
protected void DoListRoom(string searchStr, bool isNewSearch) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) pg = Int32.Parse(Request["pg"]); string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listRoom = new List<Room>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); string whereSQL = Room.GetQSearchSQL(searchStr); if (whereSQL.Length > 0) whereSQL = " WHERE " + whereSQL; int numRec = db.QueryCount("SELECT Count(*) FROM room " + whereSQL); if (whereSQL.Length > 0) whereSQL = whereSQL + " AND r.branch_id=b.branch_id "; else whereSQL = " WHERE r.branch_id=b.branch_id "; OdbcDataReader reader = db.Query("SELECT r.*,b.branch_name as branch_name FROM room r, branch b " + whereSQL +"ORDER BY room_id LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg-1)*Config.TBRECORD_PER_PAGE)) ); int i = 0; while (reader.Read()) { Room room = Room.CreateForm(reader); string divtxt = Config.URL_PIC_TEACHER + "/" + room._img; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + " align=center valign=top width=100px>" +Room.GetRoomID(room._roomID) + "  </th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left><p><b>ห้อง: </b>" + room._name + "</p>"); outBuf.Append("<p><b>สาขา: </b>" + room._branchName + " </p>"); outBuf.Append("<p><b>จำนวนที่นั่ง: </b>" + room._seatNo + " </p>"); outBuf.Append("<p><b>รายละเอียด: </b></p><p>" + room._description.Replace("\r\n","<br>") + " </p>"); outBuf.Append(" </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center><a href=\"" + Config.URL_PIC_ROOM + "/" + room._img + "\" ><img border=0 width=200px height=150px src=\"" + Config.URL_PIC_ROOM + "/" + room._img + "\" ></a></td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + room._roomID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this room?')) { setVal('actPage','delete');setVal('targetID','" + room._roomID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>"+i+"</b> "); } else { outBuf2.Append(String.Format("<a href=\"TeacherManage.aspx?pg={0}&qsearch={1}\">{0}</a> ", i.ToString(), searchStr)); } } }
protected void DoListBranch(string searchStr, bool isNewSearch) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) { pg = Int32.Parse(Request["pg"]); } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listBranch = new List <Branch>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); string qSearchSQL = Branch.GetQSearchSQL(searchStr); if (qSearchSQL.Trim().Length > 0) { qSearchSQL = " WHERE " + qSearchSQL; } int numRec = db.QueryCount("SELECT Count(*) FROM branch " + qSearchSQL); OdbcDataReader reader = db.Query("SELECT * FROM branch " + qSearchSQL + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Branch branch = Branch.CreateForm(reader); string divtxt = Config.URL_PIC_BRANCH + "/" + branch._img; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + " align=center valign=top width=100px>" + Branch.GetBranchID(branch._branchID) + "  </th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + branch._branchCode + "</td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left><p><b>สาขา: </b>" + branch._branchName + "</p>"); outBuf.Append("<p><b>ที่ตั้ง: </b>" + branch._address.Replace("\r\n", "<br>") + " </p>"); outBuf.Append("<p><b>เบอร์ติดต่อ: </b>" + branch._tel + " </p>"); outBuf.Append("<p><b>ชื่อผู้ดูแล: </b>" + branch._supervisor + " </p>"); outBuf.Append(" </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center><a href=\"" + Config.URL_PIC_BRANCH + "/" + branch._img + "\" ><img border=0 width=200px height=150px src=\"" + Config.URL_PIC_BRANCH + "/" + branch._img + "\" ></a></td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + branch._branchID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this branch?')) { setVal('actPage','delete');setVal('targetID','" + branch._branchID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"BranchManage.aspx?pg={0}&qsearch={1}\">{0}</a> ", i.ToString(), searchStr)); } } // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected void DoListPaymentByTeacher(string teacherID, string searchStr, bool isNewSearch) { DBManager db; db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); listTeacher = Teacher.LoadListFromDB(db, " WHERE is_active=1 ORDER BY firstname "); if (teacherID == null) { return; } // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) { pg = Int32.Parse(Request["pg"]); } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"", "class=\"td1_grey\"", "class=\"td1_red\"" }, { "class=\"specalt\"", "class=\"alt\"", "class=\"td1_grey\"", "class=\"td1_red\"" } }; string grey = "class=\"thspec_grey\""; string red = "class=\"thspec_red\""; listPayment = new List <Payment>(); AppUser user = (AppUser)Session[SessionVar.USER]; filterPayment = Request["filter_payment"]; if (filterPayment == null) { filterPayment = "0"; // by default } string whereSQL = " pm.course_id=c.course_id AND c.teacher_id=t.teacher_id AND c.room_id = r.room_id "; // only admin can view all payment if (!user.IsAdmin()) { whereSQL = whereSQL + " AND r.branch_id=" + user._branchID; } // filter only payable courses if (filterPayment.Equals("0")) { whereSQL = whereSQL + " AND sum_max_payable<>sum_paid_cost "; } int numRec = db.QueryCount("SELECT Count(*) FROM payment pm, course c, teacher t, room r WHERE " + whereSQL); OdbcDataReader reader = db.Query("SELECT pm.course_id as course_id ,c.bts_course_id as bts_course_id ,c.course_name as course_name, t.paid_group_id as paid_group_id" + ", pm.sum_all_cost as sum_all_cost, pm.sum_max_payable as sum_max_payable, pm.sum_paid_cost as sum_paid_cost " + "FROM payment pm, course c, teacher t, room r WHERE " + whereSQL + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Payment payment = Payment.CreateForm(reader); string chbname = "course" + payment._courseID; int sumPayable = payment._sumMaxPayable - payment._sumPaidCost; int n = 1; if (sumPayable == 0) { n = 2; } else if (sumPayable < 0) { n = 3; } string bgcolor = (sumPayable == 0) ? grey : red; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + (sumPayable > 0 ? bgclass[i % 2, 0] : bgcolor) + ">" + payment._btsCourseID + "</th>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><input type=\"checkbox\" name=\"" + chbname + "\" id=\"" + chbname + "\" />" + "</td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " ><a href=\"CourseManage.aspx?actPage=view&targetID=" + payment._courseID + "\" >" + payment._courseName + "</a></td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center >" + PaidGroup.GetPaidGroupID(payment._paidGroupID) + "</td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><b>" + StringUtil.Int2StrComma(payment._sumAllCost) + "</b></td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><b><font color=blue>" + StringUtil.Int2StrComma(payment._sumMaxPayable) + "</font></b></td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><b><font color=red>" + StringUtil.Int2StrComma(payment._sumPaidCost) + "</font></b></td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><b><font color=green>" + StringUtil.Int2StrComma(sumPayable) + "</font></b></td>"); /* outBuf.Append("<td " + bgclass[i % 2, n] + " align=center>" + payment._lastPaidDate.ToString("dd/MM/yyyy HH:mm", ci) + " </td>"); */ outBuf.Append("<td " + bgclass[i % 2, n] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','view');setVal('targetID','" + payment._courseID + "');doSubmit()\"><img src=\"img/sys/view.gif\" border=0 alt=\"View detail\"></a> "); // outBuf.Append("<a href=\"javascript:if (confirm('Delete this payment?')) { setVal('actPage','delete');setVal('targetID','" + payment._paymentID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"PaymentManage.aspx?pg={0}&filter_payment={1}&qsearch={1}\">{0}</a> ", i.ToString(), filterPayment, searchStr)); } } // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
public static int GetMaxRecord() { DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); OdbcDataReader reader = db.Query("SELECT MAX(teacher_id) FROM teacher"); if (!reader.Read()) return 0; long max = reader.IsDBNull(0) ? -1 : reader.GetInt64(0); db.Close(); return (int)(max+1); }
protected void DoListBranch(string searchStr, bool isNewSearch) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) pg = Int32.Parse(Request["pg"]); string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listBranch = new List<Branch>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); string qSearchSQL = Branch.GetQSearchSQL(searchStr); if (qSearchSQL.Trim().Length > 0) qSearchSQL = " WHERE " + qSearchSQL; int numRec = db.QueryCount("SELECT Count(*) FROM branch " + qSearchSQL); OdbcDataReader reader = db.Query("SELECT * FROM branch " + qSearchSQL + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Branch branch = Branch.CreateForm(reader); string divtxt = Config.URL_PIC_BRANCH + "/" + branch._img; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + " align=center valign=top width=100px>" + Branch.GetBranchID(branch._branchID) + "  </th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>"+branch._branchCode+"</td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left><p><b>สาขา: </b>" + branch._branchName + "</p>"); outBuf.Append("<p><b>ที่ตั้ง: </b>" + branch._address.Replace("\r\n", "<br>") + " </p>"); outBuf.Append("<p><b>เบอร์ติดต่อ: </b>" + branch._tel + " </p>"); outBuf.Append("<p><b>ชื่อผู้ดูแล: </b>" + branch._supervisor + " </p>"); outBuf.Append(" </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center><a href=\"" + Config.URL_PIC_BRANCH + "/" + branch._img + "\" ><img border=0 width=200px height=150px src=\"" + Config.URL_PIC_BRANCH + "/" + branch._img + "\" ></a></td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + branch._branchID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this branch?')) { setVal('actPage','delete');setVal('targetID','" + branch._branchID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"BranchManage.aspx?pg={0}&qsearch={1}\">{0}</a> ", i.ToString(), searchStr)); } } // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected void DoListUser(string searchStr) { // get Page int pg = 1; if (Request["pg"] != null) { pg = Int32.Parse(Request["pg"]); } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listUser = new List <AppUser>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); int numRec = db.QueryCount("SELECT Count(*) FROM user " + GetQSearchSQL(searchStr)); OdbcDataReader reader = db.Query("SELECT * FROM user " + GetQSearchSQL(searchStr) + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { AppUser user = BTS.Entity.AppUser.CreateForm(reader); // byte[] raw = Encoding.Default.GetBytes(user._firstname); // user._firstname = Encoding.GetEncoding("tis-620").GetString(raw); outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + user._userId + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left ><a href=\"#\" >" + user._username + "</a> </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left ><a href=\"#\" >" + user._firstname + " " + user._surname + "</a> </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + GetRoleName(user._roleId) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + GetBranchName(user._branchID) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + user._username + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this user?')) { setVal('actPage','delete');setVal('targetID','" + user._username + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (maxpg % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"Administrator.aspx?pg={0}\">{1}</a> ", i.ToString(), i.ToString())); } } // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected void DoListUser(string searchStr) { // get Page int pg = 1; if (Request["pg"] != null) pg = Int32.Parse(Request["pg"]); string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listUser = new List<AppUser>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); int numRec = db.QueryCount("SELECT Count(*) FROM user " + GetQSearchSQL(searchStr)); OdbcDataReader reader = db.Query("SELECT * FROM user " + GetQSearchSQL(searchStr) + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { AppUser user = BTS.Entity.AppUser.CreateForm(reader); // byte[] raw = Encoding.Default.GetBytes(user._firstname); // user._firstname = Encoding.GetEncoding("tis-620").GetString(raw); outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + user._userId + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left ><a href=\"#\" >" + user._username + "</a> </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left ><a href=\"#\" >" + user._firstname + " " + user._surname + "</a> </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + GetRoleName(user._roleId) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + GetBranchName(user._branchID) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + user._username + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this user?')) { setVal('actPage','delete');setVal('targetID','" + user._username + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (maxpg % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"Administrator.aspx?pg={0}\">{1}</a> ", i.ToString(), i.ToString())); } } // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected string GetRoleName(int role_id) { if (role_id <= 0) return ""; string sql = "SELECT name FROM role WHERE role_id='" + role_id + "'"; string ret = String.Empty; DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); OdbcDataReader reader = db.Query(sql); reader.Read(); ret = reader.GetString(0); db.Close(); return ret; }
protected void DoListStudent(string searchStr, bool isNewSearch) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) { pg = Int32.Parse(Request["pg"]); } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listStudent = new List <Student>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); string qSearchSQL = Student.GetQSearchSQL(searchStr); if (qSearchSQL.Trim().Length > 0) { qSearchSQL = " WHERE " + qSearchSQL; } else // search all { qSearchSQL = " WHERE is_active=1 "; } int numRec = db.QueryCount("SELECT Count(*) FROM student " + qSearchSQL); OdbcDataReader reader = db.Query("SELECT * FROM student " + qSearchSQL + "order by student_id desc LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Student student = Student.CreateForm(reader); // byte[] raw = Encoding.Default.GetBytes(student._firstname); // student._firstname = Encoding.GetEncoding("tis-620").GetString(raw); int age = ((DateTime.Now.Year * 12 + DateTime.Now.Month) - (student._birthday.Year * 12 + student._birthday.Month)) / 12; string divtxt = Config.URL_PIC_STUDENT + "/" + student._img; string studentTxt = "<a href=\"StudentManage.aspx?actPage=view&targetID=" + student._studentID + "\" onmouseover=\"showDiv('" + divtxt + "')\" onmouseout=\"hideDiv()\" >" + student._firstname + " " + student._surname + "(" + student._nickname + ")" + "</a>"; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + Student.GetStudentID(student._studentID) + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + studentTxt + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center > <img width=20 height=24 src=\"" + Config.URL_PIC_SYS + (student._sex.Equals("Male")?"/boy.gif":"/girl.gif") + "\" >"); /* * for (int j = 0; j < ssList[i].skill.Count; j++) * { * outBuf.Append("<LI><a href=\"SkillHandling.aspx#sdid" + ssList[i].skill[j].id + "\" onmouseover=\"showChecklist(" + ssList[i].skill[j].id + ")\" onmouseout=\"hideCheckList()\" >" + ssList[i].skill[j].name + "</a>"); * }*/ outBuf.Append(" </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + age + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + student._school + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + StringUtil.ConvertEducateLevel(student._level) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + student.GetTel() + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + student._email + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + student._studentID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this student?')) { setVal('actPage','delete');setVal('targetID','" + student._studentID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); outBuf2.Append(String.Format("<a href=\"StudentManage.aspx?pg={0}&qsearch={1}\">{2}</a><< ", "1", searchStr, "First")); for (i = pg - 5; i <= pg + 5; i++) { if ((i <= 0) || (i > maxpg)) { continue; } if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"StudentManage.aspx?pg={0}&qsearch={1}\">{0}</a> ", i.ToString(), searchStr)); } } outBuf2.Append(String.Format(" >><a href=\"StudentManage.aspx?pg={0}&qsearch={1}\">{2}</a> ", maxpg.ToString(), searchStr, "Last")); // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected void DoListStudent(string searchStr, bool isNewSearch) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) pg = Int32.Parse(Request["pg"]); string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listStudent = new List<Student>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); string qSearchSQL = Student.GetQSearchSQL(searchStr); if (qSearchSQL.Trim().Length > 0) { qSearchSQL = " WHERE " + qSearchSQL; } else // search all { qSearchSQL = " WHERE is_active=1 "; } int numRec = db.QueryCount("SELECT Count(*) FROM student " + qSearchSQL); OdbcDataReader reader = db.Query("SELECT * FROM student " + qSearchSQL + "order by student_id desc LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Student student = Student.CreateForm(reader); // byte[] raw = Encoding.Default.GetBytes(student._firstname); // student._firstname = Encoding.GetEncoding("tis-620").GetString(raw); int age = ((DateTime.Now.Year * 12 + DateTime.Now.Month) - (student._birthday.Year * 12 + student._birthday.Month)) / 12; string divtxt = Config.URL_PIC_STUDENT + "/" + student._img; string studentTxt = "<a href=\"StudentManage.aspx?actPage=view&targetID="+student._studentID+"\" onmouseover=\"showDiv('"+divtxt+"')\" onmouseout=\"hideDiv()\" >" + student._firstname + " " + student._surname + "("+ student._nickname +")" + "</a>"; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + Student.GetStudentID(student._studentID) + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >"+studentTxt+" </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center > <img width=20 height=24 src=\"" + Config.URL_PIC_SYS + (student._sex.Equals("Male")?"/boy.gif":"/girl.gif") + "\" >" ); /* for (int j = 0; j < ssList[i].skill.Count; j++) { outBuf.Append("<LI><a href=\"SkillHandling.aspx#sdid" + ssList[i].skill[j].id + "\" onmouseover=\"showChecklist(" + ssList[i].skill[j].id + ")\" onmouseout=\"hideCheckList()\" >" + ssList[i].skill[j].name + "</a>"); }*/ outBuf.Append(" </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + age + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + student._school + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + StringUtil.ConvertEducateLevel(student._level) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + student.GetTel() + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + student._email + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + student._studentID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this student?')) { setVal('actPage','delete');setVal('targetID','" + student._studentID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); outBuf2.Append(String.Format("<a href=\"StudentManage.aspx?pg={0}&qsearch={1}\">{2}</a><< ", "1", searchStr, "First")); for (i = pg-5; i <= pg+5; i++) { if ((i <= 0) || (i>maxpg)) { continue; } if (i == pg) { outBuf2.Append("<b>"+i+"</b> "); } else { outBuf2.Append(String.Format("<a href=\"StudentManage.aspx?pg={0}&qsearch={1}\">{0}</a> ", i.ToString(), searchStr)); } } outBuf2.Append(String.Format(" >><a href=\"StudentManage.aspx?pg={0}&qsearch={1}\">{2}</a> ", maxpg.ToString(), searchStr, "Last")); // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected void DoListRegistration(string searchStr, bool isNewSearch) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) { pg = Int32.Parse(Request["pg"]); } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"", "class=\"td1_grey\"" }, { "class=\"specalt\"", "class=\"alt\"", "class=\"td1_grey\"" } }; string grey = "class=\"thspec_grey\""; listRegistration = new List <Registration>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); string qSearchSQL = Registration.GetQSearchSQL(searchStr); if (qSearchSQL.Trim().Length > 0) { qSearchSQL = " WHERE " + qSearchSQL; } // add join condition qSearchSQL = qSearchSQL + ((qSearchSQL.Trim().Length > 0) ? " AND " : " WHERE ") + " rg.student_id=st.student_id AND rg.course_id=c.course_id "; int numRec = db.QueryCount("SELECT Count(*) FROM registration rg, student st, course c " + qSearchSQL); OdbcDataReader reader = db.Query("SELECT rg.*, st.firstname as student_firstname, st.surname as student_surname, c.bts_course_id as bts_course_id, c.course_name FROM registration rg, student st, course c " + qSearchSQL + " ORDER BY regis_id desc " + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; int j = 0; int currentRegisTransactionID = 0; while (reader.Read()) { Registration reg = Registration.CreateForm(reader); if (reg._transactionID != currentRegisTransactionID) { currentRegisTransactionID = reg._transactionID; j++; reg.LoadBranch(db); outBuf.Append("<tr>"); outBuf.Append("<th colspan=9 scope=\"row\" abbr=\"Model\" " + bgclass[j % 2, 0] + "><b>" + reg.GetRegisTransactionID() + "</b></th>"); outBuf.Append("</tr>\n"); } string studentInfo = "<a href=\"StudentManage.aspx?actPage=view&targetID=" + reg._studentID + "\" >" + Student.GetStudentID(reg._studentID) + " " + reg._studentFirstname + " " + reg._studentSurname + "</a>"; string courseInfo = "<a href=\"CourseManage.aspx?actPage=view&targetID=" + reg._courseID + "\" >" + reg._btsCourseID + " " + reg._courseName + "</a>"; string costInfo = StringUtil.Int2StrComma(reg._discountedCost); string statusInfo = Registration.GetStatusText(reg._status); if (reg._status > 0) { costInfo = "<font color=red>" + costInfo + "</font>"; statusInfo = "<font color=red>" + statusInfo + "</font>"; } outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[j % 2, 0] + ">" + Registration.GetRegistrationID(reg._regisID) + "</th>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=center>" + reg._regisdate.ToString("dd/MM/yyyy HH:mm", ci) + " </td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=center>" + reg._paiddate.ToString("dd/MM/yyyy", ci) + " </td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=left>" + courseInfo + "</td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=left>" + studentInfo + "</td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=right>" + costInfo + " </td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=center>" + statusInfo + "</td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=left>" + reg._note + "</td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=center>"); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + reg._regisID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:setVal('actPage','init_print_all');setVal('targetID','" + reg._regisID + "');doSubmit()\"><img src=\"img/sys/print.gif\" border=0 alt=\"พิมพ์ทุกอย่าง\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); outBuf2.Append(String.Format("<a href=\"RegistrationManage.aspx?pg={0}&qsearch={1}\">{2}</a><< ", "1", searchStr, "First")); for (i = pg - 10; i <= pg + 10; i++) { if ((i <= 0) || (i > maxpg)) { continue; } if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"RegistrationManage.aspx?pg={0}&qsearch={1}\">{0}</a> ", i.ToString(), searchStr)); } } outBuf2.Append(String.Format(" >><a href=\"RegistrationManage.aspx?pg={0}&qsearch={1}\">{2}</a> ", maxpg.ToString(), searchStr, "Last")); }
protected void DoListCourse(string searchStr, bool isNewSearch, string filter) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) pg = Int32.Parse(Request["pg"]); if ((filter==null) || (filter.Length==0) || ((!filter.Equals("all")) && (!filter.Equals("only_close")))) { filter = "only_open"; } string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listCourse = new List<Course>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); string qSearchSQL = Course.GetQSearchSQL(searchStr); //filter string curDate = "'"+DateTime.Now.ToString("yyyy-MM-dd", ci)+"'"; // "'2011-05-01'"; string filterSQL = ""; if (filter.Equals("only_open")) { filterSQL = "( end_date > "+ curDate + " or course_type='คอร์ส DVD' )"; } else if (filter.Equals("only_close")) { filterSQL = "( end_date < " + curDate + " or course_type='คอร์ส DVD' )"; } if (filterSQL.Length > 0) { if (qSearchSQL.Trim().Length > 0) { qSearchSQL = qSearchSQL + " AND " + filterSQL; } else { qSearchSQL = filterSQL; } } // Add WHERE if (qSearchSQL.Trim().Length > 0) qSearchSQL = " WHERE " + qSearchSQL; int numRec = db.QueryCount("SELECT Count(*) FROM course c " + qSearchSQL); // add join condition qSearchSQL = qSearchSQL + ((qSearchSQL.Trim().Length > 0)?" AND ":" WHERE ") + " c.teacher_id=t.teacher_id"; String subQuery = " (SELECT count(*) FROM registration r WHERE r.status=0 AND r.course_id=c.course_id) "; OdbcDataReader reader = db.Query("SELECT c.*,t.firstname as teacher_firstname, t.surname as teacher_surname, " + subQuery + " AS num_registered " + " FROM course c, teacher t " + qSearchSQL + " order by bts_course_id desc LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Course course = Course.CreateForm(reader); // byte[] raw = Encoding.Default.GetBytes(course._firstname); // course._firstname = Encoding.GetEncoding("tis-620").GetString(raw); string divtxt = Config.URL_PIC_COURSE + "/" + course._img; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + course._btsCourseID + (course._numRegistered >= course._seatLimit ? "<br><font color=red>[เต็ม]</font>":"") + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " ><a href=\"CourseManage.aspx?actPage=view&targetID=" + course._courseID + "\" >" + "<b>" + course._courseName + "</b></a><br>" + course._courseDesc + "</td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + StringUtil.Int2StrComma(course._cost) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + course._startdate.ToString("dd/MM/yyyy", ci) + " - " + course._enddate.ToString("dd/MM/yyyy", ci) + "<br>" + course._dayOfWeek + " " + course._opentime + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + course._teacher._firstname + " " + course._teacher._surname + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','view');setVal('targetID','" + course._courseID + "');doSubmit()\"><img src=\"img/sys/view.gif\" border=0 alt=\"View detail\"></a> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + course._courseID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this course?')) { setVal('actPage','delete');setVal('targetID','" + course._courseID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); outBuf2.Append(String.Format("<a href=\"CourseManage.aspx?pg={0}&qsearch={1}\">{2}</a><< ", "1", searchStr, "First")); for (i = pg - 5; i <= pg + 5; i++) { if ((i <= 0) || (i > maxpg)) { continue; } if (i == pg) { outBuf2.Append("<b>"+i+"</b> "); } else { outBuf2.Append(String.Format("<a href=\"CourseManage.aspx?pg={0}&qsearch={1}&filter={2}\">{0}</a> ", i.ToString(), searchStr, filter)); } } outBuf2.Append(String.Format(" >><a href=\"CourseManage.aspx?pg={0}&qsearch={1}\">{2}</a> ", maxpg.ToString(), searchStr, "Last")); // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected List<string> GetListUser(string branch_id) { List<string> list = new List<String>(); if (string.IsNullOrEmpty(branch_id)) return list; string sql = "SELECT username,firstname,surname FROM user WHERE branch_id='" + branch_id + "'"; string ret = String.Empty; DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); OdbcDataReader reader = db.Query(sql); int fCount = reader.FieldCount; while (reader.Read()) { string tmp = "[" + reader.GetString(0).ToUpper() + "] " + reader.GetString(1) + " " + reader.GetString(2); list.Add(tmp); } db.Close(); return list; }
protected void DoListRegister(string searchStr) { // get Page int pg = 1; if (Request["pg"] != null) { pg = Int32.Parse(Request["pg"]); } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; // listRegistration = new List<Registration>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); if (searchStr.Trim().Length > 0) { searchStr = " WHERE " + searchStr; } int numRec = db.QueryCount("SELECT Count(*) FROM registration " + searchStr); OdbcDataReader reader = db.Query("SELECT * FROM registration " + searchStr + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Registration regis = Registration.CreateForm(reader); outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + regis._regisID + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._transactionID + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._regisdate.ToString("dd/MM/yyyy", ci) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._studentID + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._courseID + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._fullCost + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._promotionID + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._discountedCost + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + regis._isPaid.ToString() + " </td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (maxpg % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"ReportRegis.aspx?pg={0}\">{1}</a> ", i.ToString(), i.ToString())); } } }
protected void DoListRegistration(string searchStr, bool isNewSearch) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"]!=null)) pg = Int32.Parse(Request["pg"]); string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"", "class=\"td1_grey\"" }, { "class=\"specalt\"", "class=\"alt\"", "class=\"td1_grey\"" } }; string grey = "class=\"thspec_grey\""; listRegistration = new List<Registration>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); string qSearchSQL = Registration.GetQSearchSQL(searchStr); if (qSearchSQL.Trim().Length > 0) qSearchSQL = " WHERE " + qSearchSQL; // add join condition qSearchSQL = qSearchSQL + ((qSearchSQL.Trim().Length > 0) ? " AND " : " WHERE ") + " rg.student_id=st.student_id AND rg.course_id=c.course_id "; int numRec = db.QueryCount("SELECT Count(*) FROM registration rg, student st, course c " + qSearchSQL); OdbcDataReader reader = db.Query("SELECT rg.*, st.firstname as student_firstname, st.surname as student_surname, c.bts_course_id as bts_course_id, c.course_name FROM registration rg, student st, course c " + qSearchSQL + " ORDER BY regis_id desc " + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; int j = 0; int currentRegisTransactionID = 0; while (reader.Read()) { Registration reg = Registration.CreateForm(reader); if (reg._transactionID != currentRegisTransactionID) { currentRegisTransactionID = reg._transactionID; j++; reg.LoadBranch(db); outBuf.Append("<tr>"); outBuf.Append("<th colspan=9 scope=\"row\" abbr=\"Model\" " + bgclass[j % 2, 0] + "><b>" + reg.GetRegisTransactionID() + "</b></th>"); outBuf.Append("</tr>\n"); } string studentInfo = "<a href=\"StudentManage.aspx?actPage=view&targetID="+reg._studentID+"\" >" + Student.GetStudentID(reg._studentID) +" "+ reg._studentFirstname + " " + reg._studentSurname + "</a>"; string courseInfo = "<a href=\"CourseManage.aspx?actPage=view&targetID=" + reg._courseID + "\" >" + reg._btsCourseID + " " + reg._courseName + "</a>"; string costInfo = StringUtil.Int2StrComma(reg._discountedCost); string statusInfo = Registration.GetStatusText(reg._status); if (reg._status > 0) { costInfo = "<font color=red>" + costInfo + "</font>"; statusInfo = "<font color=red>" + statusInfo + "</font>"; } outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[j % 2, 0] + ">" + Registration.GetRegistrationID(reg._regisID) + "</th>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=center>" + reg._regisdate.ToString("dd/MM/yyyy HH:mm", ci) + " </td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=center>" + reg._paiddate.ToString("dd/MM/yyyy", ci) + " </td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=left>" + courseInfo + "</td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=left>" + studentInfo + "</td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=right>" + costInfo + " </td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=center>" + statusInfo + "</td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=left>" + reg._note + "</td>"); outBuf.Append("<td " + bgclass[j % 2, 1] + " align=center>"); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + reg._regisID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:setVal('actPage','init_print_all');setVal('targetID','" + reg._regisID + "');doSubmit()\"><img src=\"img/sys/print.gif\" border=0 alt=\"พิมพ์ทุกอย่าง\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); outBuf2.Append(String.Format("<a href=\"RegistrationManage.aspx?pg={0}&qsearch={1}\">{2}</a><< ", "1", searchStr, "First")); for (i = pg - 10; i <= pg + 10; i++) { if ((i <= 0) || (i > maxpg)) { continue; } if (i == pg) { outBuf2.Append("<b>"+i+"</b> "); } else { outBuf2.Append(String.Format("<a href=\"RegistrationManage.aspx?pg={0}&qsearch={1}\">{0}</a> ", i.ToString(), searchStr)); } } outBuf2.Append(String.Format(" >><a href=\"RegistrationManage.aspx?pg={0}&qsearch={1}\">{2}</a> ", maxpg.ToString(), searchStr, "Last")); }
protected void DoListPaymentByTeacher(string teacherID, string searchStr, bool isNewSearch) { DBManager db; db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); db.Connect(); listTeacher = Teacher.LoadListFromDB(db, " WHERE is_active=1 ORDER BY firstname "); if (teacherID == null) return; // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) pg = Int32.Parse(Request["pg"]); string[,] bgclass = new string[,] { { "class=\"spec\"", "class=\"td1\"", "class=\"td1_grey\"", "class=\"td1_red\"" }, { "class=\"specalt\"", "class=\"alt\"", "class=\"td1_grey\"", "class=\"td1_red\"" } }; string grey = "class=\"thspec_grey\""; string red = "class=\"thspec_red\""; listPayment = new List<Payment>(); AppUser user = (AppUser)Session[SessionVar.USER]; filterPayment = Request["filter_payment"]; if (filterPayment == null) filterPayment = "0"; // by default string whereSQL = " pm.course_id=c.course_id AND c.teacher_id=t.teacher_id AND c.room_id = r.room_id "; // only admin can view all payment if (!user.IsAdmin()) { whereSQL = whereSQL + " AND r.branch_id=" + user._branchID; } // filter only payable courses if (filterPayment.Equals("0")) { whereSQL = whereSQL + " AND sum_max_payable<>sum_paid_cost "; } int numRec = db.QueryCount("SELECT Count(*) FROM payment pm, course c, teacher t, room r WHERE " + whereSQL); OdbcDataReader reader = db.Query("SELECT pm.course_id as course_id ,c.bts_course_id as bts_course_id ,c.course_name as course_name, t.paid_group_id as paid_group_id" + ", pm.sum_all_cost as sum_all_cost, pm.sum_max_payable as sum_max_payable, pm.sum_paid_cost as sum_paid_cost " + "FROM payment pm, course c, teacher t, room r WHERE " + whereSQL + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Payment payment = Payment.CreateForm(reader); string chbname = "course" + payment._courseID; int sumPayable = payment._sumMaxPayable - payment._sumPaidCost; int n = 1; if (sumPayable == 0) n = 2; else if (sumPayable < 0) n = 3; string bgcolor = (sumPayable == 0) ? grey : red; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + (sumPayable > 0 ? bgclass[i % 2, 0] : bgcolor) + ">" + payment._btsCourseID + "</th>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><input type=\"checkbox\" name=\"" + chbname + "\" id=\"" + chbname + "\" />" + "</td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " ><a href=\"CourseManage.aspx?actPage=view&targetID=" + payment._courseID + "\" >" + payment._courseName + "</a></td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center >" + PaidGroup.GetPaidGroupID(payment._paidGroupID) + "</td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><b>" + StringUtil.Int2StrComma(payment._sumAllCost) + "</b></td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><b><font color=blue>" + StringUtil.Int2StrComma(payment._sumMaxPayable) + "</font></b></td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><b><font color=red>" + StringUtil.Int2StrComma(payment._sumPaidCost) + "</font></b></td>"); outBuf.Append("<td " + bgclass[i % 2, n] + " align=center ><b><font color=green>" + StringUtil.Int2StrComma(sumPayable) + "</font></b></td>"); /* outBuf.Append("<td " + bgclass[i % 2, n] + " align=center>" + payment._lastPaidDate.ToString("dd/MM/yyyy HH:mm", ci) + " </td>"); */ outBuf.Append("<td " + bgclass[i % 2, n] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','view');setVal('targetID','" + payment._courseID + "');doSubmit()\"><img src=\"img/sys/view.gif\" border=0 alt=\"View detail\"></a> "); // outBuf.Append("<a href=\"javascript:if (confirm('Delete this payment?')) { setVal('actPage','delete');setVal('targetID','" + payment._paymentID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"PaymentManage.aspx?pg={0}&filter_payment={1}&qsearch={1}\">{0}</a> ", i.ToString(), filterPayment, searchStr)); } } // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected void DoListPaidGroup(string searchStr) { // get Page int pg = 1; if (Request["pg"] != null) { pg = Int32.Parse(Request["pg"]); } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); int numRec = db.QueryCount("SELECT Count(*) FROM paid_group " + GetQSearchSQL(searchStr)); OdbcDataReader reader = db.Query("SELECT * FROM paid_group " + GetQSearchSQL(searchStr) + " LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { PaidGroup group = BTS.Entity.PaidGroup.CreateForm(reader); // teacher member list Teacher[] memberList = group.LoadMemberTeachers(db); StringBuilder memberTxt = new StringBuilder(); for (int j = 0; j < memberList.Length; j++) { String txt = Teacher.GetTeacherID(memberList[j]._teacherID) + " " + memberList[j]._firstname + " " + memberList[j]._surname; memberTxt.Append("<a href=\"TeacherManage.aspx?actPage=view&targetID=" + memberList[j]._teacherID + "\">" + txt + "<br>"); } outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + PaidGroup.GetPaidGroupID(group._paidGroupID) + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + group._name + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + group._rawRateInfo + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left >" + memberTxt + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + group._paidGroupID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this user?')) { setVal('actPage','delete');setVal('targetID','" + group._paidGroupID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (maxpg % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"PaidGroupManage.aspx?pg={0}\">{1}</a> ", i.ToString(), i.ToString())); } } // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected void DoListCourse(string searchStr, bool isNewSearch, string filter) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) { pg = Int32.Parse(Request["pg"]); } if ((filter == null) || (filter.Length == 0) || ((!filter.Equals("all")) && (!filter.Equals("only_close")))) { filter = "only_open"; } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listCourse = new List <Course>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); string qSearchSQL = Course.GetQSearchSQL(searchStr); //filter string curDate = "'" + DateTime.Now.ToString("yyyy-MM-dd", ci) + "'"; // "'2011-05-01'"; string filterSQL = ""; if (filter.Equals("only_open")) { filterSQL = "( end_date > " + curDate + " or course_type='คอร์ส DVD' )"; } else if (filter.Equals("only_close")) { filterSQL = "( end_date < " + curDate + " or course_type='คอร์ส DVD' )"; } if (filterSQL.Length > 0) { if (qSearchSQL.Trim().Length > 0) { qSearchSQL = qSearchSQL + " AND " + filterSQL; } else { qSearchSQL = filterSQL; } } // Add WHERE if (qSearchSQL.Trim().Length > 0) { qSearchSQL = " WHERE " + qSearchSQL; } int numRec = db.QueryCount("SELECT Count(*) FROM course c " + qSearchSQL); // add join condition qSearchSQL = qSearchSQL + ((qSearchSQL.Trim().Length > 0)?" AND ":" WHERE ") + " c.teacher_id=t.teacher_id"; String subQuery = " (SELECT count(*) FROM registration r WHERE r.status=0 AND r.course_id=c.course_id) "; OdbcDataReader reader = db.Query("SELECT c.*,t.firstname as teacher_firstname, t.surname as teacher_surname, " + subQuery + " AS num_registered " + " FROM course c, teacher t " + qSearchSQL + " order by bts_course_id desc LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Course course = Course.CreateForm(reader); // byte[] raw = Encoding.Default.GetBytes(course._firstname); // course._firstname = Encoding.GetEncoding("tis-620").GetString(raw); string divtxt = Config.URL_PIC_COURSE + "/" + course._img; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + ">" + course._btsCourseID + (course._numRegistered >= course._seatLimit ? "<br><font color=red>[เต็ม]</font>":"") + "</th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " ><a href=\"CourseManage.aspx?actPage=view&targetID=" + course._courseID + "\" >" + "<b>" + course._courseName + "</b></a><br>" + course._courseDesc + "</td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + StringUtil.Int2StrComma(course._cost) + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center>" + course._startdate.ToString("dd/MM/yyyy", ci) + " - " + course._enddate.ToString("dd/MM/yyyy", ci) + "<br>" + course._dayOfWeek + " " + course._opentime + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " >" + course._teacher._firstname + " " + course._teacher._surname + " </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','view');setVal('targetID','" + course._courseID + "');doSubmit()\"><img src=\"img/sys/view.gif\" border=0 alt=\"View detail\"></a> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + course._courseID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this course?')) { setVal('actPage','delete');setVal('targetID','" + course._courseID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); outBuf2.Append(String.Format("<a href=\"CourseManage.aspx?pg={0}&qsearch={1}\">{2}</a><< ", "1", searchStr, "First")); for (i = pg - 5; i <= pg + 5; i++) { if ((i <= 0) || (i > maxpg)) { continue; } if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"CourseManage.aspx?pg={0}&qsearch={1}&filter={2}\">{0}</a> ", i.ToString(), searchStr, filter)); } } outBuf2.Append(String.Format(" >><a href=\"CourseManage.aspx?pg={0}&qsearch={1}\">{2}</a> ", maxpg.ToString(), searchStr, "Last")); // <a href="#">1</a> <b>2</b> <a href="#">3</a> <a href="#">4</a> }
protected void DoListRoom(string searchStr, bool isNewSearch) { // get Page int pg = 1; if ((!isNewSearch) && (Request["pg"] != null)) { pg = Int32.Parse(Request["pg"]); } string[,] bgclass = new string[, ] { { "class=\"spec\"", "class=\"td1\"" }, { "class=\"specalt\"", "class=\"alt\"" } }; listRoom = new List <Room>(); DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC); string whereSQL = Room.GetQSearchSQL(searchStr); if (whereSQL.Length > 0) { whereSQL = " WHERE " + whereSQL; } int numRec = db.QueryCount("SELECT Count(*) FROM room " + whereSQL); if (whereSQL.Length > 0) { whereSQL = whereSQL + " AND r.branch_id=b.branch_id "; } else { whereSQL = " WHERE r.branch_id=b.branch_id "; } OdbcDataReader reader = db.Query("SELECT r.*,b.branch_name as branch_name FROM room r, branch b " + whereSQL + "ORDER BY room_id LIMIT " + Config.TBRECORD_PER_PAGE + " OFFSET " + (((pg - 1) * Config.TBRECORD_PER_PAGE))); int i = 0; while (reader.Read()) { Room room = Room.CreateForm(reader); string divtxt = Config.URL_PIC_TEACHER + "/" + room._img; outBuf.Append("<tr>"); outBuf.Append("<th scope=\"row\" abbr=\"Model\" " + bgclass[i % 2, 0] + " align=center valign=top width=100px>" + Room.GetRoomID(room._roomID) + "  </th>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=left><p><b>ห้อง: </b>" + room._name + "</p>"); outBuf.Append("<p><b>สาขา: </b>" + room._branchName + " </p>"); outBuf.Append("<p><b>จำนวนที่นั่ง: </b>" + room._seatNo + " </p>"); outBuf.Append("<p><b>รายละเอียด: </b></p><p>" + room._description.Replace("\r\n", "<br>") + " </p>"); outBuf.Append(" </td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center><a href=\"" + Config.URL_PIC_ROOM + "/" + room._img + "\" ><img border=0 width=200px height=150px src=\"" + Config.URL_PIC_ROOM + "/" + room._img + "\" ></a></td>"); outBuf.Append("<td " + bgclass[i % 2, 1] + " align=center> "); outBuf.Append("<a href=\"javascript:setVal('actPage','edit');setVal('targetID','" + room._roomID + "');doSubmit()\"><img src=\"img/sys/edit.gif\" border=0 alt=\"Edit\"></a> "); outBuf.Append("<a href=\"javascript:if (confirm('Delete this room?')) { setVal('actPage','delete');setVal('targetID','" + room._roomID + "');doSubmit(); }\"><img src=\"img/sys/delete.gif\" border=0 alt=\"Delete\"></a> "); outBuf.Append("</td>"); outBuf.Append("</tr>\n"); i++; } db.Close(); // calculate max page int maxpg = numRec / Config.TBRECORD_PER_PAGE; if (maxpg < 1) { maxpg = 1; } else if (numRec % Config.TBRECORD_PER_PAGE > 0) { maxpg++; } // Generate Page Navi HTML outBuf2.Append("<b>Page</b> "); for (i = 1; i <= maxpg; i++) { if (i == pg) { outBuf2.Append("<b>" + i + "</b> "); } else { outBuf2.Append(String.Format("<a href=\"TeacherManage.aspx?pg={0}&qsearch={1}\">{0}</a> ", i.ToString(), searchStr)); } } }