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

/BaliEnterpriseSystems/BaliEnterpriseSystems/StudentsInfo.aspx.cs

https://github.com/sirivedula/BEST
C# | 170 lines | 156 code | 14 blank | 0 comment | 20 complexity | 6e7c98eb49a99e3ea3441a542ecb4a32 MD5 | raw file
  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. using System.Xml.Linq;
  13. using BaliEnterpriseSystems.BestObjects;
  14. using System.Text;
  15. using System.Collections.Generic;
  16. namespace BaliEnterpriseSystems
  17. {
  18. public partial class StudentsPageInfo : System.Web.UI.Page
  19. {
  20. protected void Page_LoadComplete(object sender, EventArgs e)
  21. {
  22. if (HttpContext.Current.Session["CurrentUser"] == null)
  23. {
  24. Response.Redirect("Logout.aspx");
  25. }
  26. ltrSubMenu.Text = UtilMenu.StudentMenu("studentinfo");
  27. if (!Utils.User.UserRoleByName("Student - Information").allowView)
  28. {
  29. ltrGrid.Text = "You do not have rights to view.";
  30. return;
  31. }
  32. string ms = Request.QueryString["ms"];
  33. ltrMScript.Text = Utils.MenuSelectScript(ms);
  34. BestCenters bcs = new BestCenters();
  35. bcs.LoadRows();
  36. StringBuilder sbc = new StringBuilder();
  37. sbc.Append("<option value=\"\"></option>");
  38. for (int rnum = 0; rnum < bcs.TableRows.Count; rnum++)
  39. {
  40. string cid = bcs.TableRows[rnum].Fields["CenterId"].fieldValue;
  41. sbc.Append("<option value=\"" + HttpUtility.HtmlEncode(cid) + "\">" + HttpUtility.HtmlEncode(cid) + "</option>");
  42. }
  43. this.ltrCenters.Text = sbc.ToString();
  44. StringBuilder jsbp = new StringBuilder();
  45. jsbp.Append("jsProg=[");
  46. StringBuilder sbp = new StringBuilder();
  47. sbp.Append("<option value=\"\"></option>");
  48. BestPrograms bps = new BestPrograms();
  49. bps.LoadRows();
  50. for (int rnum = 0; rnum < bps.TableRows.Count; rnum++)
  51. {
  52. string optext = bps.TableRows[rnum].Fields["programName"].fieldValue + ":" + bps.TableRows[rnum].Fields["programType"].fieldValue + ": Per " + bps.TableRows[rnum].Fields["amountType"].fieldValue;
  53. string optval = bps.TableRows[rnum].Fields["guidfield"].fieldValue;
  54. sbp.Append("<option value=\"" + HttpUtility.HtmlEncode(optval) + "\">" + HttpUtility.HtmlEncode(optext) + "</option>");
  55. jsbp.Append("{\"guid\":\"" + optval + "\",\"amount\":\"" + bps.TableRows[rnum].Fields["amount"].fieldValue + "\",\"amountType\":\"" + bps.TableRows[rnum].Fields["amountType"].fieldValue + "\"}");
  56. if (rnum < bps.TableRows.Count - 1) jsbp.Append(",");
  57. }
  58. jsbp.Append("]");
  59. this.ltrProgScript.Text = "<script type=\"text/javascript\">" + jsbp.ToString() + "</script>";
  60. this.ltrPrograms.Text = sbp.ToString();
  61. this.ltrStateOpts.Text = Utils.StateOptions();
  62. if (IsPostBack)
  63. {
  64. BestStudents bs = new BestStudents();
  65. string isnew = Request.Form["isnew"];
  66. bool cansave = true;
  67. if (string.IsNullOrEmpty(isnew))
  68. {
  69. List<BestField> bparams = new List<BestField>();
  70. BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
  71. guid.fieldValue = Request.Form["guidfield"];
  72. bparams.Add(guid);
  73. if (!string.IsNullOrEmpty(guid.fieldValue))
  74. {
  75. bs.LoadRows("guidfield=?", bparams);
  76. }
  77. else
  78. {
  79. string delguid = Request.Form["deleteguid"];
  80. if (!string.IsNullOrEmpty(delguid))
  81. {
  82. bparams[0].fieldValue = delguid;
  83. bs.LoadRows("guidfield=?", bparams);
  84. bs.CurrentRow.IsDelete = true;
  85. bs.CurrentRow.Save();
  86. }
  87. cansave = false;
  88. }
  89. }
  90. if (cansave)
  91. {
  92. bs.StudentId = Request.Form["g_StudentId"];
  93. bs.CenterId = Request.Form["g_CenterId"];
  94. bs.firstName = Request.Form["g_firstName"];
  95. bs.lastName = Request.Form["g_lastName"];
  96. if (string.IsNullOrEmpty(bs.StudentId))
  97. {
  98. ltrValidateMsg.Text = Utils.WarningMessage("Student Id is Required.");
  99. cansave = false;
  100. }
  101. if (string.IsNullOrEmpty(bs.CenterId))
  102. {
  103. ltrValidateMsg.Text = Utils.WarningMessage("Center Id is Required.");
  104. cansave = false;
  105. }
  106. if (string.IsNullOrEmpty(bs.firstName) && string.IsNullOrEmpty(bs.lastName))
  107. {
  108. ltrValidateMsg.Text = Utils.WarningMessage("First Name or Last Name is required");
  109. cansave = false;
  110. }
  111. if (cansave)
  112. {
  113. bs.middleName = Request.Form["g_middleName"];
  114. bs.parentName = Request.Form["g_parentName"];
  115. if(!string.IsNullOrEmpty(Request.Form["g_programGuid"]))
  116. bs.programGuid = new Guid(Request.Form["g_programGuid"]);
  117. bs.address1 = Request.Form["g_address1"];
  118. bs.address2 = Request.Form["g_address2"];
  119. bs.city = Request.Form["g_city"];
  120. bs.state = Request.Form["g_state"];
  121. bs.zip = Request.Form["g_zip"];
  122. bs.cellPhone = Request.Form["g_cellPhone"];
  123. bs.workPhone = Request.Form["g_workPhone"];
  124. bs.homePhone = Request.Form["g_homePhone"];
  125. bs.emailId = Request.Form["g_emailId"];
  126. bs.gender = Request.Form["g_gender"];
  127. bs.Hours = Request.Form["g_Hours"];
  128. bs.hourType = Request.Form["g_hourType"];
  129. bs.amountType = Request.Form["g_amountType"];
  130. bs.Amount = Request.Form["g_Amount"];
  131. string joinDate = Request.Form["g_joinDate"];
  132. if (!string.IsNullOrEmpty(joinDate))
  133. {
  134. bs.joinDate = Convert.ToDateTime(joinDate);
  135. }
  136. string birthDate = Request.Form["g_birthDate"];
  137. if (!string.IsNullOrEmpty(birthDate))
  138. {
  139. bs.joinDate = Convert.ToDateTime(birthDate);
  140. }
  141. if (!bs.CurrentRow.Save())
  142. {
  143. ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
  144. }
  145. }
  146. }
  147. }
  148. BestGrid bsGrid = new BestGrid();
  149. bsGrid.PageRequest = Page.Request;
  150. bsGrid.Title = "Students Information";
  151. bsGrid.GridTable = new BestStudents();
  152. bsGrid.securityPage = "Student - Information";
  153. ltrGrid.Text = bsGrid.ToHTML();
  154. }
  155. }
  156. }