PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/BestStudentPlan.aspx.cs

https://github.com/sirivedula/BEST
C# | 101 lines | 97 code | 4 blank | 0 comment | 10 complexity | faa128ddb774376e0921d5a78c137748 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 BaliEnterpriseSystems.BestObjects;
  8. using System.Text;
  9. namespace BaliEnterpriseSystems
  10. {
  11. public partial class BestStudentPlan : 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.StudentMenu("studentplanner");
  20. if (!Utils.User.UserRoleByName("Student - 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. BestStudents bstd = new BestStudents();
  28. string studentLoginScript = "";
  29. if (Utils.User.BestUser.userType.Equals("Student"))
  30. {
  31. List<BestField> bparam = new List<BestField>();
  32. bparam.Add(new BestField() { fieldName = "studentGuid", fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldSize = 40 });
  33. bparam[0].fieldValue = Utils.User.BestUser.studentGuid.ToString();
  34. bstd.LoadRows("guidfield=?", bparam);
  35. studentLoginScript = "$('#tblStudentSel').css('display','none');";
  36. }
  37. else
  38. {
  39. bstd.LoadRows("CenterId=?", Utils.User.CIdParam);
  40. }
  41. string selstudent = Request.Form["selStudent"];
  42. StringBuilder sb = new StringBuilder();
  43. sb.Append("");
  44. string selName = "";
  45. for (int i = 0; i < bstd.TableRows.Count; i++)
  46. {
  47. string sname = bstd.TableRows[i].Fields["firstname"].fieldValue + " " + bstd.TableRows[i].Fields["lastname"].fieldValue;
  48. string sguid = bstd.TableRows[i].Fields["guidfield"].fieldValue;
  49. sb.Append("<option value=\"" + HttpUtility.HtmlEncode(sguid) + "\"");
  50. if (string.IsNullOrEmpty(selstudent))
  51. {
  52. selstudent = sguid;
  53. }
  54. if (sguid.Equals(selstudent))
  55. {
  56. selName = sname;
  57. sb.Append(" selected ");
  58. }
  59. sb.Append(">" + HttpUtility.HtmlEncode(sname) + "</option>");
  60. }
  61. ltrStudentOpts.Text = sb.ToString();
  62. StringBuilder sbInfo = new StringBuilder();
  63. sbInfo.Append("[");
  64. if (!string.IsNullOrEmpty(selstudent))
  65. {
  66. BestSTPlan bstPlan = new BestSTPlan();
  67. BestField bfield = new BestField() { fieldName = "studentguid", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldType = "System.Guid" };
  68. bfield.fieldValue = selstudent;
  69. List<BestField> bparams = new List<BestField>();
  70. bparams.Add(bfield);
  71. bparams.Add(Utils.User.CenterIdField);
  72. bstPlan.LoadRows("studentguid=? and isdeleted=0 and centerid=?", bparams);
  73. string stplanInfo = "{guidfield:\"[paramguid]\",stuGuid:\"[paramstuGuid]\",schDay:\"[paramschDay]\",schFrom:\"[paramschFrom]\",schTo:\"[paramschTo]\"}";
  74. for (int i = 0; i < bstPlan.TableRows.Count; i++)
  75. {
  76. string result = stplanInfo;
  77. bstPlan.currentRowId = i;
  78. result = result.Replace("[paramguid]", bstPlan.guidfield.ToString());
  79. result = result.Replace("[paramstuGuid]", bstPlan.studentGuid.ToString());
  80. result = result.Replace("[paramschDay]", bstPlan.schDay);
  81. result = result.Replace("[paramschFrom]", bstPlan.schFrom);
  82. result = result.Replace("paramschTo]", bstPlan.schTo);
  83. sbInfo.Append(result);
  84. if (i < bstPlan.TableRows.Count - 1)
  85. sbInfo.Append(",");
  86. }
  87. }
  88. sbInfo.Append("]");
  89. ltrStdScript.Text = @"<script type=""text/javascript""> " + studentLoginScript + @"
  90. g_nameOnScheduler = " + Utils.EnquoteJS(selName) + @";
  91. g_curSTGuid = " + Utils.EnquoteJS(selstudent) + @";
  92. g_IsStudent = true;
  93. STPlanInfo = " + sbInfo.ToString() + @"
  94. </script>";
  95. }
  96. }
  97. }