PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/BestTutorPlan.aspx.cs

https://github.com/sirivedula/BEST
C# | 99 lines | 95 code | 4 blank | 0 comment | 10 complexity | e2d86584232758c4f905523c23e023a7 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Text;
  8. using BaliEnterpriseSystems.BestObjects;
  9. namespace BaliEnterpriseSystems
  10. {
  11. public partial class BestTutorPlan : System.Web.UI.Page
  12. {
  13. protected void Page_LoadComplete(object sender, EventArgs e)
  14. {
  15. if (HttpContext.Current.Session["CurrentUser"] == null)
  16. {
  17. Response.Redirect("Logout.aspx");
  18. }
  19. ltrSubMenu.Text = UtilMenu.TutorMenu("tutorplanner");
  20. if (!Utils.User.UserRoleByName("Tutor - Planner").allowView)
  21. {
  22. ltrValidateMsg.Text = "You do not have rights to view.";
  23. return;
  24. }
  25. string ms = Request.QueryString["ms"];
  26. this.ltrMScript.Text = Utils.MenuSelectScript(ms);
  27. BestTutors bstd = new BestTutors();
  28. string tutorLoginScript = "";
  29. if (Utils.User.BestUser.userType.Equals("Tutor"))
  30. {
  31. List<BestField> bparam = new List<BestField>();
  32. bparam.Add(new BestField() { fieldName = "tutorGuid", fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldSize = 40 });
  33. bparam[0].fieldValue = Utils.User.BestUser.tutorGuid.ToString();
  34. bstd.LoadRows("guidfield=?", bparam);
  35. tutorLoginScript = "$('#tblStudentSel').css('display','none');";
  36. }
  37. else
  38. {
  39. bstd.LoadRows("CenterId=?", Utils.User.CIdParam);
  40. }
  41. string selstudent = Request.Form["selTutor"];
  42. StringBuilder sb = new StringBuilder();
  43. string selName = "";
  44. for (int i = 0; i < bstd.TableRows.Count; i++)
  45. {
  46. string sname = bstd.TableRows[i].Fields["firstname"].fieldValue + " " + bstd.TableRows[i].Fields["lastname"].fieldValue;
  47. string sguid = bstd.TableRows[i].Fields["guidfield"].fieldValue;
  48. sb.Append("<option value=\"" + HttpUtility.HtmlEncode(sguid) + "\"");
  49. if (string.IsNullOrEmpty(selstudent))
  50. {
  51. selstudent = sguid;
  52. }
  53. if (sguid.Equals(selstudent))
  54. {
  55. selName = sname;
  56. sb.Append(" selected ");
  57. }
  58. sb.Append(">" + HttpUtility.HtmlEncode(sname) + "</option>");
  59. }
  60. ltrTutorOpts.Text = sb.ToString();
  61. StringBuilder sbInfo = new StringBuilder();
  62. sbInfo.Append("[");
  63. if (!string.IsNullOrEmpty(selstudent))
  64. {
  65. BestSTPlan bstPlan = new BestSTPlan();
  66. BestField bfield = new BestField() { fieldName = "tutorguid", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldType = "System.Guid" };
  67. bfield.fieldValue = selstudent;
  68. List<BestField> bparams = new List<BestField>();
  69. bparams.Add(bfield);
  70. bparams.Add(Utils.User.CenterIdField);
  71. bstPlan.LoadRows("tutorguid=? and isdeleted=0 and centerid=?", bparams);
  72. string stplanInfo = "{guidfield:\"[paramguid]\",tutGuid:\"[paramstuGuid]\",schDay:\"[paramschDay]\",schFrom:\"[paramschFrom]\",schTo:\"[paramschTo]\"}";
  73. for (int i = 0; i < bstPlan.TableRows.Count; i++)
  74. {
  75. string result = stplanInfo;
  76. bstPlan.currentRowId = i;
  77. result = result.Replace("[paramguid]", bstPlan.guidfield.ToString());
  78. result = result.Replace("[paramstuGuid]", bstPlan.tutorguid.ToString());
  79. result = result.Replace("[paramschDay]", bstPlan.schDay);
  80. result = result.Replace("[paramschFrom]", bstPlan.schFrom);
  81. result = result.Replace("paramschTo]", bstPlan.schTo);
  82. sbInfo.Append(result);
  83. if (i < bstPlan.TableRows.Count - 1)
  84. sbInfo.Append(",");
  85. }
  86. }
  87. sbInfo.Append("]");
  88. ltrStdScript.Text = @"<script type=""text/javascript"">" + tutorLoginScript + @" g_nameOnScheduler = " + Utils.EnquoteJS(selName) + @";
  89. g_curSTGuid = " + Utils.EnquoteJS(selstudent) + @";
  90. g_IsStudent = false;
  91. STPlanInfo = " + sbInfo.ToString() + @"
  92. </script>";
  93. }
  94. }
  95. }