PageRenderTime 53ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/StudentForm.aspx.cs

https://github.com/sirivedula/BEST
C# | 624 lines | 568 code | 40 blank | 16 comment | 81 complexity | dfd7518b0eb8d2043614818dca4c9f5d 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. using System.Data.OleDb;
  10. namespace BaliEnterpriseSystems
  11. {
  12. public partial class StudentForm : System.Web.UI.Page
  13. {
  14. protected void Page_LoadComplete(object sender, EventArgs e)
  15. {
  16. if (HttpContext.Current.Session["CurrentUser"] == null)
  17. {
  18. Response.Redirect("Logout.aspx");
  19. }
  20. ltrSubMenu.Text = UtilMenu.StudentMenu("studentinfo");
  21. string ms = Request.QueryString["ms"];
  22. ltrMScript.Text = Utils.MenuSelectScript(ms);
  23. string submitMode = Request["submitMode"];
  24. if (IsPostBack)
  25. {
  26. if (!string.IsNullOrEmpty(submitMode))
  27. {
  28. if (submitMode.Equals("add"))
  29. {
  30. if (!Utils.User.UserRoleByName("Student - Information").allowAdd)
  31. {
  32. Response.Write("You do not have rights to add.");
  33. return;
  34. }
  35. }
  36. if (submitMode.Equals("edit"))
  37. {
  38. if (!Utils.User.UserRoleByName("Student - Information").allowEdit)
  39. {
  40. Response.Write("You do not have rights to edit.");
  41. return;
  42. }
  43. }
  44. }
  45. }
  46. BestCenters bcs = new BestCenters();
  47. bcs.LoadRows();
  48. StringBuilder sbc = new StringBuilder();
  49. sbc.Append("<option value=\"\"></option>");
  50. for (int rnum = 0; rnum < bcs.TableRows.Count; rnum++)
  51. {
  52. string cid = bcs.TableRows[rnum].Fields["CenterId"].fieldValue;
  53. if (cid.Equals(Utils.User.CenterId))
  54. {
  55. this.CenterId.Items.Add(cid);
  56. }
  57. //sbc.Append("<option value=\"" + HttpUtility.HtmlEncode(cid) + "\">" + HttpUtility.HtmlEncode(cid) + "</option>");
  58. }
  59. //this.ltrCenters.Text = sbc.ToString();
  60. this.ltrState.Text = Utils.StateOptions();
  61. StringBuilder jsbp = new StringBuilder();
  62. jsbp.Append("jsProg=[");
  63. StringBuilder sbp = new StringBuilder();
  64. sbp.Append("<option value=\"\"></option>");
  65. BestPrograms bps = new BestPrograms();
  66. bps.LoadRows();
  67. ListItem ltItem = new ListItem("", "");
  68. this.proposedProg.Items.Add(ltItem);
  69. for (int rnum = 0; rnum < bps.TableRows.Count; rnum++)
  70. {
  71. string optext = bps.TableRows[rnum].Fields["programName"].fieldValue + ":" + bps.TableRows[rnum].Fields["programType"].fieldValue + ": Per " + bps.TableRows[rnum].Fields["amountType"].fieldValue;
  72. string optval = bps.TableRows[rnum].Fields["guidfield"].fieldValue;
  73. sbp.Append("<option value=\"" + HttpUtility.HtmlEncode(optval) + "\">" + HttpUtility.HtmlEncode(optext) + "</option>");
  74. jsbp.Append("{\"guid\":\"" + optval + "\",\"amount\":\"" + bps.TableRows[rnum].Fields["amount"].fieldValue + "\",\"amountType\":\"" + bps.TableRows[rnum].Fields["amountType"].fieldValue + "\"}");
  75. if (rnum < bps.TableRows.Count - 1) jsbp.Append(",");
  76. ltItem = new ListItem(optext, optval);
  77. this.proposedProg.Items.Add(ltItem);
  78. }
  79. jsbp.Append("]");
  80. this.ltrprog1.Text = sbp.ToString();
  81. this.ltrRelation.Text = Utils.RelationshipOptions();
  82. if (!string.IsNullOrEmpty(submitMode) && submitMode.Equals("add") && !IsPostBack)
  83. {
  84. /* Get New Next Student ID */
  85. BestDatabase db = new BestDatabase();
  86. OleDbCommand myCmd = db.dbCmd;
  87. myCmd.CommandText = "Best_GetNextStudentId";
  88. this.CenterId.SelectedIndex = 0;
  89. OleDbParameter p1 = new OleDbParameter("@xcenterid", OleDbType.VarChar, 10);
  90. p1.Value = this.CenterId.Items[0].Value;
  91. myCmd.Parameters.Add(p1);
  92. myCmd.CommandType = System.Data.CommandType.StoredProcedure;
  93. OleDbDataReader read = myCmd.ExecuteReader();
  94. if (read.Read())
  95. {
  96. string studentid = read.GetValue(0).ToString();
  97. this.StudentId.Value = studentid;
  98. }
  99. }
  100. string studentguid = Request.QueryString["studentguid"];
  101. Guid studentGuid = Guid.NewGuid();
  102. if (!string.IsNullOrEmpty(studentguid))
  103. {
  104. studentGuid = new Guid(studentguid);
  105. }
  106. StringBuilder jstdProg = new StringBuilder();
  107. StringBuilder jstdPick = new StringBuilder();
  108. StringBuilder jstdGPA = new StringBuilder();
  109. jstdProg.AppendLine("");
  110. jstdProg.Append("studentProg = [");
  111. jstdPick.AppendLine("");
  112. jstdPick.Append("pickupInfo = [");
  113. string jsSelState = "";
  114. jstdGPA.AppendLine("");
  115. jstdGPA.Append("studentGPA = [");
  116. if (submitMode.Equals("edit"))
  117. {
  118. /* Load Student Master */
  119. try
  120. {
  121. List<BestField> bparams = new List<BestField>();
  122. BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
  123. guid.fieldValue = studentguid;
  124. bparams.Add(guid);
  125. bstdMast.LoadRows("guidfield=?", bparams);
  126. bstdPic.LoadRows("studentguid=?", bparams);
  127. bstdPay.LoadRows("studentguid=?", bparams);
  128. bstdRef.LoadRows("studentguid=?", bparams);
  129. bstdProg.LoadRows("studentguid=?", bparams);
  130. bstdPickup.LoadRows("studentguid=?", bparams);
  131. bstdGPA.LoadRows("studentguid=?", bparams);
  132. jsSelState = bstdMast.state;
  133. }
  134. catch (Exception ex)
  135. {
  136. Response.Write("Error:" + HttpUtility.HtmlEncode(ex.Message));
  137. return;
  138. }
  139. if (!IsPostBack)
  140. {
  141. LoadForm(studentguid);
  142. }
  143. }
  144. if (IsPostBack)
  145. {
  146. doSave(studentGuid);
  147. }
  148. jstdProg.AppendLine(getStudentProgJS());
  149. jstdPick.AppendLine(getStudentPickupJS());
  150. jstdGPA.AppendLine(getStudentGPAJS());
  151. jstdProg.Append("]");
  152. jstdPick.Append("]");
  153. jstdGPA.Append("]");
  154. StringBuilder jsDateEvents = new StringBuilder();
  155. jsDateEvents.AppendLine("");
  156. jsDateEvents.AppendLine("$(document).ready(function(){");
  157. jsDateEvents.AppendLine("$('#" + this.cellPhone.ClientID + ",#" + this.homePhone.ClientID + ",#" + this.workPhone.ClientID + ",#contact0').mask('(999) 999-9999')");
  158. jsDateEvents.AppendLine("$('#" + this.joinDate.ClientID + ",#" + this.birthDate.ClientID + "').mask('99/99/9999');");
  159. jsDateEvents.AppendLine("$('#" + this.joinDate.ClientID + ",#" + this.birthDate.ClientID + "').datepicker({ showOn: 'button', buttonImage: 'images/date.png', buttonImageOnly: true, changeYear: true, changeMonth: true });");
  160. if (!string.IsNullOrEmpty(jsSelState))
  161. {
  162. jsDateEvents.AppendLine("$('#selState').val('" + jsSelState + "');");
  163. }
  164. jsDateEvents.AppendLine("$('#+" + this.firstName.ClientID + "').focus();");
  165. jsDateEvents.AppendLine("});");
  166. jsDateEvents.AppendLine("parentNameId = '" + this.parentName.ClientID + "';");
  167. jsDateEvents.AppendLine("payeenameId = '" + this.paymentname1.ClientID + "';");
  168. this.ltrProgScript.Text = "<script type=\"text/javascript\">" + jsbp.ToString() + jstdProg.ToString() + jstdPick.ToString() + jstdGPA.ToString() + jsDateEvents.ToString() + "</script>";
  169. if (submitMode.Equals("edit"))
  170. {
  171. this.ltrPhoto.Text = "<a href=\"UploadPhoto.aspx?sid=" + HttpUtility.UrlEncode(this.StudentId.Value) + "&cid=" + HttpUtility.UrlEncode(this.CenterId.Value) + "\" target=\"_blank\">Choose Photo</a>";
  172. }
  173. this.photoDisplay.Text = "<img id=\"empPhoto\" alt=\"Employee Photo\" src=\"getPhoto.aspx?sid=" + Server.UrlEncode(this.StudentId.Value) + "&cid=" + Server.UrlEncode(this.CenterId.Value) + "\" />";
  174. }
  175. private string getStudentProgJS()
  176. {
  177. StringBuilder sb = new StringBuilder();
  178. if (bstdProg.TableRows.Count == 0)
  179. {
  180. sb.Append("{ guid: \"newguid\", progGuid: \"\", isDeleted: false, Index:0 }");
  181. }
  182. else
  183. {
  184. for (int i = 0; i < bstdProg.TableRows.Count; i++)
  185. {
  186. bstdProg.currentRowId = i;
  187. BestRow trow = bstdProg.TableRows[i];
  188. sb.Append("{guid:\"" + bstdProg.guidfield.ToString() + "\", progGuid:\"" + bstdProg.programguid.ToString() + "\", idDeleted:false, Index:" + i.ToString() + ",Amount:\"" + bstdProg.Amount.ToString("0.00") + "\"}");
  189. if (i < bstdProg.TableRows.Count - 1) sb.Append(",");
  190. }
  191. }
  192. return sb.ToString();
  193. }
  194. private string getStudentPickupJS()
  195. {
  196. StringBuilder sb = new StringBuilder();
  197. if (bstdPickup.TableRows.Count == 0)
  198. {
  199. sb.Append("{ guid: \"newguid\", contactName: \"\", contactPhone:\"\", relationShip:\"\", isDeleted: false, Index:0 }");
  200. }
  201. else
  202. {
  203. for (int i = 0; i < bstdPickup.TableRows.Count; i++)
  204. {
  205. BestRow trow = bstdPickup.TableRows[i];
  206. sb.Append("{guid:\"" + trow.Fields["guidfield"].fieldValue + "\", contactName:\"" + trow.Fields["contactName"].fieldValue + "\", contactPhone:\"" + trow.Fields["contactPhone"].fieldValue + "\", relationShip:\"" + trow.Fields["relationShip"].fieldValue + "\", idDeleted:false, Index:" + i.ToString() + "}");
  207. if (i < bstdPickup.TableRows.Count - 1) sb.Append(",");
  208. }
  209. }
  210. return sb.ToString();
  211. }
  212. private string getStudentGPAJS()
  213. {
  214. StringBuilder sb = new StringBuilder();
  215. if (bstdGPA.TableRows.Count == 0)
  216. {
  217. sb.Append("{guid:\"newguid\", AssessDate:\"\", GradeAvg:\"\", AssessLevel:\"\", isDeleted:false, Index: 0}");
  218. }
  219. else
  220. {
  221. for (int i = 0; i < bstdGPA.TableRows.Count; i++)
  222. {
  223. BestRow trow = bstdGPA.TableRows[i];
  224. sb.Append("{guid:\"" + trow.Fields["guidfield"].fieldValue + "\", AssessDate:\"" + trow.Fields["assessmentdate"].fieldValue.Replace(" 12:00:00 AM","") + "\", GradeAvg:\"" + trow.Fields["assessmentGPA"].fieldValue + "\", AssessLevel:\"" + trow.Fields["assessmentLevel"].fieldValue + "\", isDeleted:false, Index:" + i.ToString() + "}");
  225. if (i < bstdGPA.TableRows.Count - 1) sb.Append(",");
  226. }
  227. }
  228. return sb.ToString();
  229. }
  230. private BestStudents _bstdMast;
  231. private BestStudents bstdMast
  232. {
  233. get
  234. {
  235. if (_bstdMast == null)
  236. {
  237. _bstdMast = new BestStudents();
  238. }
  239. return _bstdMast;
  240. }
  241. }
  242. private BestStudentPrograms _bstdProg;
  243. public BestStudentPrograms bstdProg
  244. {
  245. get
  246. {
  247. if (_bstdProg == null)
  248. {
  249. _bstdProg = new BestStudentPrograms();
  250. }
  251. return _bstdProg;
  252. }
  253. }
  254. private BestStudentPicture _bstdPic;
  255. private BestStudentPicture bstdPic
  256. {
  257. get
  258. {
  259. if (_bstdPic == null)
  260. {
  261. _bstdPic = new BestStudentPicture();
  262. }
  263. return _bstdPic;
  264. }
  265. }
  266. private BestStudentPickup _bstdPickup;
  267. private BestStudentPickup bstdPickup
  268. {
  269. get
  270. {
  271. if (_bstdPickup == null)
  272. {
  273. _bstdPickup = new BestStudentPickup();
  274. }
  275. return _bstdPickup;
  276. }
  277. }
  278. private BestStudentReference _bstdRef;
  279. private BestStudentReference bstdRef
  280. {
  281. get
  282. {
  283. if (_bstdRef == null)
  284. {
  285. _bstdRef = new BestStudentReference();
  286. }
  287. return _bstdRef;
  288. }
  289. }
  290. private BestStudentPayment _bstdPay;
  291. private BestStudentPayment bstdPay
  292. {
  293. get
  294. {
  295. if (_bstdPay == null)
  296. {
  297. _bstdPay = new BestStudentPayment();
  298. }
  299. return _bstdPay;
  300. }
  301. }
  302. private BestStudentGPA _bstdGPA;
  303. private BestStudentGPA bstdGPA
  304. {
  305. get
  306. {
  307. if (_bstdGPA == null)
  308. {
  309. _bstdGPA = new BestStudentGPA();
  310. }
  311. return _bstdGPA;
  312. }
  313. }
  314. private void LoadForm(string studentguid)
  315. {
  316. this.CenterId.Value = bstdMast.CenterId;
  317. this.StudentId.Value = bstdMast.StudentId;
  318. this.firstName.Value = bstdMast.firstName;
  319. this.lastName.Value = bstdMast.lastName;
  320. this.middleName.Value = bstdMast.middleName;
  321. this.parentName.Value = bstdMast.parentName;
  322. if (bstdMast.joinDate > DateTime.MinValue)
  323. this.joinDate.Value = bstdMast.joinDate.ToString("MM/dd/yyyy");
  324. if (bstdMast.birthDate > DateTime.MinValue)
  325. this.birthDate.Value = bstdMast.birthDate.ToString("MM/dd/yyyy");
  326. this.address1.Value = bstdMast.address1;
  327. this.address2.Value = bstdMast.address2;
  328. this.city.Value = bstdMast.city;
  329. this.zip.Value = bstdMast.zip;
  330. this.cellPhone.Value = bstdMast.cellPhone;
  331. this.workPhone.Value = bstdMast.workPhone;
  332. this.homePhone.Value = bstdMast.homePhone;
  333. this.emailId.Value = bstdMast.emailId;
  334. this.guardianName.Value = bstdMast.guardianName;
  335. this.Hours.Value = bstdMast.Hours;
  336. this.hourType.Value = bstdMast.hourType;
  337. this.gender.Value = bstdMast.gender;
  338. this.School.Value = bstdMast.School;
  339. this.Grade.Value = bstdMast.Grade;
  340. /* Save Student Picture & Hibbies */
  341. this.goals.Value = bstdPic.goals;
  342. this.hobbies.Value = bstdPic.hobbies;
  343. this.personality.Value = bstdPic.personality;
  344. this.tutorprefs.Value = bstdPic.tutorpreference;
  345. //referencedby, expectedDuration, blcRecommend, proposedProg, proposedHour, parentComments, parentExpects, emergName, emergPhone
  346. this.referencedby.Value = bstdRef.referencedby;
  347. this.attenduration.Value = bstdRef.expectedDuration;
  348. this.blcplan.Value = bstdRef.blcRecommend;
  349. this.proposedProg.Value = bstdRef.proposedProg;
  350. this.proposedHours.Value = bstdRef.proposedHour;
  351. this.parentComments.Value = bstdRef.parentComments;
  352. this.parentExpects.Value = bstdRef.parentExpects;
  353. this.emergName.Value = bstdRef.emergName;
  354. this.emergPhone.Value = bstdRef.emergPhone;
  355. this.healthConditions.Value = bstdRef.healthConditions;
  356. this.parentemail.Value = bstdPay.parentEmail;
  357. this.paymentname1.Value = bstdPay.Name;
  358. this.paymentmethod.Value = bstdPay.payMethod;
  359. }
  360. private void SavePrograms(Guid studentGuid)
  361. {
  362. string programsData = Request.Form["programsData"];
  363. if (!string.IsNullOrEmpty(programsData))
  364. {
  365. string[] aryProgs = programsData.Split('\n');
  366. for (int i = 0; i < aryProgs.Length; i++)
  367. {
  368. string[] aryFields = aryProgs[i].Split('\t');
  369. Decimal ddamt;
  370. if (aryFields[0].Length > 16)
  371. {
  372. /* Edit or Delete */
  373. BestStudentPrograms bstdProg = new BestStudentPrograms();
  374. List<BestField> bparams = new List<BestField>();
  375. BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
  376. guid.fieldValue = aryFields[0];
  377. bparams.Add(guid);
  378. if (!string.IsNullOrEmpty(guid.fieldValue))
  379. {
  380. bstdProg.LoadRows("guidfield=?", bparams);
  381. }
  382. bstdProg.programguid = (Guid)Utils.getNullableGuid(aryFields[1]);
  383. Decimal.TryParse(aryFields[2], out ddamt);
  384. bstdProg.Amount = ddamt;
  385. bstdProg.CurrentRow.IsDelete = aryFields[3].Equals("true\r");
  386. bstdProg.CurrentRow.Save();
  387. }
  388. else if(aryFields[0].Length != 0)
  389. {
  390. /* Add */
  391. Guid? programguid = Utils.getNullableGuid(aryFields[1]);
  392. if (programguid != null)
  393. {
  394. BestStudentPrograms bstdProg = new BestStudentPrograms();
  395. bstdProg.studentGuid = studentGuid;
  396. bstdProg.programguid = new Guid(aryFields[1]);
  397. Decimal.TryParse(aryFields[2], out ddamt);
  398. bstdProg.Amount = ddamt;
  399. bstdProg.StudentId = this.StudentId.Value;
  400. bstdProg.CenterId = this.CenterId.Value;
  401. bstdProg.CurrentRow.Save();
  402. }
  403. }
  404. }
  405. }
  406. }
  407. private void SavePickupInfo(Guid studentGuid)
  408. {
  409. string pickupData = Request.Form["pickupInfoData"];
  410. if (!string.IsNullOrEmpty(pickupData))
  411. {
  412. string[] aryPick = pickupData.Split('\n');
  413. for (int i = 0; i < aryPick.Length; i++)
  414. {
  415. string[] aryFields = aryPick[i].Split('\t');
  416. if (aryFields[0].Length > 16)
  417. {
  418. /* Edit or Delete */
  419. BestStudentPickup bstdPickup = new BestStudentPickup();
  420. List<BestField> bparams = new List<BestField>();
  421. BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
  422. guid.fieldValue = aryFields[0];
  423. bparams.Add(guid);
  424. if (!string.IsNullOrEmpty(guid.fieldValue))
  425. {
  426. bstdPickup.LoadRows("guidfield=?", bparams);
  427. }
  428. bstdPickup.contactName = aryFields[1];
  429. bstdPickup.contactPhone = aryFields[2];
  430. bstdPickup.relationship = aryFields[3];
  431. bstdPickup.CurrentRow.IsDelete = aryFields[4].Equals("true\r");
  432. bstdPickup.CurrentRow.Save();
  433. }
  434. else if (aryFields[0].Length != 0)
  435. {
  436. /* Add */
  437. BestStudentPickup bstdPick = new BestStudentPickup();
  438. bstdPick.CenterId = this.CenterId.Value;
  439. bstdPick.studentGuid = studentGuid;
  440. bstdPick.StudentId = this.StudentId.Value;
  441. bstdPick.contactName = aryFields[1];
  442. bstdPick.contactPhone = aryFields[2];
  443. bstdPick.relationship = aryFields[3];
  444. bstdPick.CurrentRow.Save();
  445. }
  446. }
  447. }
  448. }
  449. private void SaveGPA(Guid studentGuid)
  450. {
  451. string assessmentData = Request.Form["assessmentData"];
  452. if (!string.IsNullOrEmpty(assessmentData))
  453. {
  454. string[] aryGPA = assessmentData.Split('\n');
  455. for (int i = 0; i < aryGPA.Length; i++)
  456. {
  457. string[] aryFields = aryGPA[i].Split('\t');
  458. if (aryFields[0].Length > 16)
  459. {
  460. /* Edit or Delete */
  461. BestStudentGPA bstudGPA = new BestStudentGPA();
  462. List<BestField> bparams = new List<BestField>();
  463. BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
  464. guid.fieldValue = aryFields[0];
  465. bparams.Add(guid);
  466. if (!string.IsNullOrEmpty(guid.fieldValue))
  467. {
  468. bstudGPA.LoadRows("guidfield=?", bparams);
  469. }
  470. if (!string.IsNullOrEmpty(aryFields[1]))
  471. bstudGPA.assessmentDate = Convert.ToDateTime(aryFields[1]);
  472. bstudGPA.assessmentGPA = aryFields[2];
  473. bstudGPA.assessmentLevel = aryFields[3];
  474. bstudGPA.CurrentRow.IsDelete = aryFields[4].Equals("true\r");
  475. bstudGPA.CurrentRow.Save();
  476. }
  477. else if (aryFields[0].Length != 0)
  478. {
  479. /* Add */
  480. BestStudentGPA bstudGPA = new BestStudentGPA();
  481. bstudGPA.studentGuid = studentGuid;
  482. if(!string.IsNullOrEmpty( aryFields[1]))
  483. bstudGPA.assessmentDate = Convert.ToDateTime(aryFields[1]);
  484. bstudGPA.assessmentGPA = aryFields[2];
  485. bstudGPA.assessmentLevel = aryFields[3];
  486. bstudGPA.StudentId = this.StudentId.Value;
  487. bstudGPA.CenterId = this.CenterId.Value;
  488. bstudGPA.CurrentRow.Save();
  489. }
  490. }
  491. }
  492. }
  493. private void doSave(Guid studentGuid)
  494. {
  495. /* Saving New or Edit */
  496. string doSave = Request["doSave"];
  497. if (!string.IsNullOrEmpty(doSave) && doSave.Equals("1"))
  498. {
  499. /* Save Student Information */
  500. string centerid = this.CenterId.Items[this.CenterId.SelectedIndex].Value;
  501. bstdMast.guidfield = studentGuid;
  502. bstdMast.StudentId = this.StudentId.Value;
  503. bstdMast.CenterId = centerid;
  504. bstdMast.firstName = this.firstName.Value;
  505. bstdMast.lastName = this.lastName.Value;
  506. bstdMast.middleName = this.middleName.Value;
  507. bstdMast.parentName = this.parentName.Value;
  508. if (!string.IsNullOrEmpty(this.joinDate.Value))
  509. {
  510. bstdMast.joinDate = Convert.ToDateTime(this.joinDate.Value);
  511. }
  512. if (!string.IsNullOrEmpty(this.birthDate.Value))
  513. {
  514. bstdMast.birthDate = Convert.ToDateTime(this.birthDate.Value);
  515. }
  516. bstdMast.address1 = this.address1.Value;
  517. bstdMast.address2 = this.address2.Value;
  518. bstdMast.city = this.city.Value;
  519. bstdMast.state = Request.Form["selState"] ?? "";
  520. bstdMast.zip = this.zip.Value;
  521. bstdMast.cellPhone = this.cellPhone.Value;
  522. bstdMast.workPhone = this.workPhone.Value;
  523. bstdMast.homePhone = this.homePhone.Value;
  524. bstdMast.emailId = this.emailId.Value;
  525. bstdMast.guardianName = this.guardianName.Value;
  526. bstdMast.Hours = this.Hours.Value;
  527. bstdMast.hourType = this.hourType.Value;
  528. bstdMast.gender = this.gender.Value;
  529. bstdMast.School = this.School.Value;
  530. bstdMast.Grade = this.Grade.Value;
  531. /* Save Student Picture & Hibbies */
  532. bstdPic.studentGuid = studentGuid;
  533. bstdPic.StudentId = this.StudentId.Value;
  534. bstdPic.CenterId = centerid;
  535. bstdPic.goals = this.goals.Value;
  536. bstdPic.hobbies = this.hobbies.Value;
  537. bstdPic.personality = this.personality.Value;
  538. bstdPic.tutorpreference = this.tutorprefs.Value;
  539. //referencedby, expectedDuration, blcRecommend, proposedProg, proposedHour, parentComments, parentExpects, emergName, emergPhone
  540. bstdRef.referencedby = this.referencedby.Value;
  541. bstdRef.expectedDuration = this.attenduration.Value;
  542. bstdRef.blcRecommend = this.blcplan.Value;
  543. bstdRef.proposedProg = this.proposedProg.Value;
  544. bstdRef.proposedHour = this.proposedHours.Value;
  545. bstdRef.parentComments = this.parentComments.Value;
  546. bstdRef.parentExpects = this.parentExpects.Value;
  547. bstdRef.emergName = this.emergName.Value;
  548. bstdRef.emergPhone = this.emergPhone.Value;
  549. bstdRef.CenterId = centerid;
  550. bstdRef.studentGuid = studentGuid;
  551. bstdRef.StudentId = this.StudentId.Value;
  552. bstdRef.healthConditions = this.healthConditions.Value;
  553. bstdPay.CenterId = centerid;
  554. bstdPay.StudentId = this.StudentId.Value;
  555. bstdPay.studentGuid = studentGuid;
  556. bstdPay.parentEmail = this.parentemail.Value;
  557. bstdPay.Name = this.paymentname1.Value;
  558. bstdPay.payMethod = this.paymentmethod.Value;
  559. string errorMsg = "";
  560. if (bstdMast.CurrentRow.Save())
  561. {
  562. SavePrograms(studentGuid);
  563. SavePickupInfo(studentGuid);
  564. SaveGPA(studentGuid);
  565. bstdPay.CurrentRow.Save();
  566. errorMsg = bstdPay.CurrentRow.lastError;
  567. bstdPic.CurrentRow.Save();
  568. errorMsg += bstdPic.CurrentRow.lastError;
  569. bstdRef.CurrentRow.Save();
  570. errorMsg += bstdRef.CurrentRow.lastError;
  571. if (errorMsg.Length > 0)
  572. {
  573. OleDbCommand myCmd = bstdMast.dbCmd;
  574. myCmd.CommandText = "insert into BestLogs (message) values (?)";
  575. OleDbParameter p1 = new OleDbParameter("msg", OleDbType.VarChar, 9999999);
  576. p1.Value = errorMsg;
  577. myCmd.ExecuteNonQuery();
  578. }
  579. Response.Redirect("StudentsInfo.aspx?ms=3");
  580. }
  581. }
  582. }
  583. }
  584. }