PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/TutorsInfo.aspx.cs

https://github.com/sirivedula/BEST
C# | 168 lines | 157 code | 11 blank | 0 comment | 20 complexity | a6f203dbf35a5ec31cdc7c59dc799de6 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.Collections.Generic;
  15. using System.Data.OleDb;
  16. using System.Text;
  17. namespace BaliEnterpriseSystems
  18. {
  19. public partial class TutorsPageInfo : System.Web.UI.Page
  20. {
  21. protected void Page_LoadComplete(object sender, EventArgs e)
  22. {
  23. if (HttpContext.Current.Session["CurrentUser"] == null)
  24. {
  25. Response.Redirect("Logout.aspx");
  26. }
  27. ltrSubMenu.Text = UtilMenu.TutorMenu("tutorinfo");
  28. string ms = Request.QueryString["ms"];
  29. ltrMScript.Text = Utils.MenuSelectScript(ms);
  30. if (!Utils.User.UserRoleByName("Tutor - Information").allowView)
  31. {
  32. ltrGrid.Text = "You do not have rights to view.";
  33. return;
  34. }
  35. this.ltrStateOpts.Text = Utils.StateOptions();
  36. BestCenters bcs = new BestCenters();
  37. bcs.LoadRows();
  38. for (int rnum = 0; rnum < bcs.TableRows.Count; rnum++)
  39. {
  40. string cid = bcs.TableRows[rnum].Fields["CenterId"].fieldValue;
  41. if (cid.Equals(Utils.User.CenterId))
  42. {
  43. this.CenterId.Items.Add(cid);
  44. }
  45. }
  46. string saveClicked = Request.Form["SaveClicked"] ?? "";
  47. if (IsPostBack && saveClicked.Equals("1"))
  48. {
  49. BestTutors bs = new BestTutors();
  50. string isnew = Request.Form["isnew"];
  51. bool cansave = true;
  52. if (string.IsNullOrEmpty(isnew))
  53. {
  54. List<BestField> bparams = new List<BestField>();
  55. BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
  56. guid.fieldValue = Request.Form["guidfield"];
  57. bparams.Add(guid);
  58. if (!string.IsNullOrEmpty(guid.fieldValue))
  59. {
  60. bs.LoadRows("guidfield=?", bparams);
  61. }
  62. else
  63. {
  64. string delguid = Request.Form["deleteguid"];
  65. if (!string.IsNullOrEmpty(delguid))
  66. {
  67. bparams[0].fieldValue = delguid;
  68. bs.LoadRows("guidfield=?", bparams);
  69. bs.CurrentRow.IsDelete = true;
  70. bs.CurrentRow.Save();
  71. }
  72. cansave = false;
  73. }
  74. }
  75. if (cansave)
  76. {
  77. bs.TutorId = Request.Form["g_TutorId"];
  78. bs.firstName = Request.Form["g_firstName"];
  79. bs.lastName = Request.Form["g_lastName"];
  80. bs.CenterId = this.CenterId.Value;
  81. if (string.IsNullOrEmpty(bs.TutorId))
  82. {
  83. ltrValidateMsg.Text = Utils.WarningMessage("Tutor Id is Required.");
  84. cansave = false;
  85. }
  86. if (string.IsNullOrEmpty(bs.firstName) && string.IsNullOrEmpty(bs.lastName))
  87. {
  88. ltrValidateMsg.Text = Utils.WarningMessage("First Name or Last Name is required");
  89. cansave = false;
  90. }
  91. if (cansave)
  92. {
  93. bs.middleName = Request.Form["g_middleName"];
  94. bs.address1 = Request.Form["g_address1"];
  95. bs.address2 = Request.Form["g_address2"];
  96. bs.city = Request.Form["g_city"];
  97. bs.state = Request.Form["g_state"];
  98. bs.zip = Request.Form["g_zip"];
  99. bs.cellPhone = Request.Form["g_cellPhone"];
  100. bs.workPhone = Request.Form["g_workPhone"];
  101. bs.homePhone = Request.Form["g_homePhone"];
  102. bs.emailId = Request.Form["g_emailId"];
  103. bs.gender = Request.Form["g_gender"];
  104. bs.School = Request.Form["g_school"];
  105. bs.yearGraduated = Request.Form["g_yearGraduated"];
  106. bs.GPA = Request.Form["g_GPA"];
  107. bs.Major = Request.Form["g_Major"];
  108. bs.Expertise = Request.Form["g_Expertise"];
  109. bs.learningStyle = Request.Form["g_learningStyle"];
  110. bs.Matchup = Request.Form["g_Matchup"];
  111. bs.gradeLevels = Request.Form["g_gradeLevels"];
  112. bs.otherSkill = Request.Form["g_otherSkill"];
  113. bs.programStyle = Request.Form["g_programStyle"];
  114. string salary = Request.Form["g_salary"];
  115. string perhour = Request.Form["g_perhour"];
  116. if (!string.IsNullOrEmpty(salary))
  117. {
  118. bs.Salary = Convert.ToDecimal(salary);
  119. }
  120. if (!string.IsNullOrEmpty(perhour))
  121. {
  122. bs.PerHour = Convert.ToDecimal(perhour);
  123. }
  124. if (!string.IsNullOrEmpty(Request.Form["g_joinDate"]))
  125. {
  126. bs.joinDate = Convert.ToDateTime(Request.Form["g_joinDate"]);
  127. }
  128. if (!bs.CurrentRow.Save())
  129. {
  130. ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
  131. }
  132. }
  133. }
  134. }
  135. BestDatabase db = new BestDatabase();
  136. OleDbCommand myCmd = db.dbCmd;
  137. myCmd.CommandText = "Best_GetNextTutorId";
  138. OleDbParameter p1 = new OleDbParameter("@makehigherthan", OleDbType.VarChar, 10);
  139. p1.Value = "T0";
  140. myCmd.Parameters.Add(p1);
  141. myCmd.CommandType = System.Data.CommandType.StoredProcedure;
  142. OleDbDataReader read = myCmd.ExecuteReader();
  143. string tutorid = "";
  144. if (read.Read())
  145. {
  146. tutorid = read.GetValue(0).ToString();
  147. }
  148. ltrLoadScript.Text = "<script type=\"text/javascript\">\n newtutorid='" + tutorid + "'\n</script>\n";
  149. BestGrid bsGrid = new BestGrid();
  150. bsGrid.PageRequest = Page.Request;
  151. bsGrid.Title = "Tutuor Information";
  152. bsGrid.GridTable = new BestTutors();
  153. bsGrid.securityPage = "Tutor - Information";
  154. ltrGrid.Text = bsGrid.ToHTML();
  155. }
  156. }
  157. }