protected void Page_LoadComplete(object sender, EventArgs e) { if (HttpContext.Current.Session["CurrentUser"] == null) { Response.Redirect("Logout.aspx"); } ltrSubMenu.Text = UtilMenu.StudentMenu("studentplanner"); if (!Utils.User.UserRoleByName("Student - Planner").allowView) { ltrValidateMsg.Text = "You do not have rights to view."; return; } string ms = Request.QueryString["ms"]; this.ltrMScript.Text = Utils.MenuSelectScript(ms); BestStudents bstd = new BestStudents(); string studentLoginScript = ""; if (Utils.User.BestUser.userType.Equals("Student")) { List<BestField> bparam = new List<BestField>(); bparam.Add(new BestField() { fieldName = "studentGuid", fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldSize = 40 }); bparam[0].fieldValue = Utils.User.BestUser.studentGuid.ToString(); bstd.LoadRows("guidfield=?", bparam); studentLoginScript = "$('#tblStudentSel').css('display','none');"; } else { bstd.LoadRows("CenterId=?", Utils.User.CIdParam); } string selstudent = Request.Form["selStudent"]; StringBuilder sb = new StringBuilder(); sb.Append(""); string selName = ""; for (int i = 0; i < bstd.TableRows.Count; i++) { string sname = bstd.TableRows[i].Fields["firstname"].fieldValue + " " + bstd.TableRows[i].Fields["lastname"].fieldValue; string sguid = bstd.TableRows[i].Fields["guidfield"].fieldValue; sb.Append("<option value=\"" + HttpUtility.HtmlEncode(sguid) + "\""); if (string.IsNullOrEmpty(selstudent)) { selstudent = sguid; } if (sguid.Equals(selstudent)) { selName = sname; sb.Append(" selected "); } sb.Append(">" + HttpUtility.HtmlEncode(sname) + "</option>"); } ltrStudentOpts.Text = sb.ToString(); StringBuilder sbInfo = new StringBuilder(); sbInfo.Append("["); if (!string.IsNullOrEmpty(selstudent)) { BestSTPlan bstPlan = new BestSTPlan(); BestField bfield = new BestField() { fieldName = "studentguid", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldType = "System.Guid" }; bfield.fieldValue = selstudent; List<BestField> bparams = new List<BestField>(); bparams.Add(bfield); bparams.Add(Utils.User.CenterIdField); bstPlan.LoadRows("studentguid=? and isdeleted=0 and centerid=?", bparams); string stplanInfo = "{guidfield:\"[paramguid]\",stuGuid:\"[paramstuGuid]\",schDay:\"[paramschDay]\",schFrom:\"[paramschFrom]\",schTo:\"[paramschTo]\"}"; for (int i = 0; i < bstPlan.TableRows.Count; i++) { string result = stplanInfo; bstPlan.currentRowId = i; result = result.Replace("[paramguid]", bstPlan.guidfield.ToString()); result = result.Replace("[paramstuGuid]", bstPlan.studentGuid.ToString()); result = result.Replace("[paramschDay]", bstPlan.schDay); result = result.Replace("[paramschFrom]", bstPlan.schFrom); result = result.Replace("paramschTo]", bstPlan.schTo); sbInfo.Append(result); if (i < bstPlan.TableRows.Count - 1) sbInfo.Append(","); } } sbInfo.Append("]"); ltrStdScript.Text = @"<script type=""text/javascript""> " + studentLoginScript + @" g_nameOnScheduler = " + Utils.EnquoteJS(selName) + @"; g_curSTGuid = " + Utils.EnquoteJS(selstudent) + @"; g_IsStudent = true; STPlanInfo = " + sbInfo.ToString() + @" </script>"; }
protected void Page_LoadComplete(object sender, EventArgs e) { if (HttpContext.Current.Session["CurrentUser"] == null) { Response.Redirect("Logout.aspx"); } string schType = Request.Form["schType"]; string schGuid = Request.Form["guidfield"]; if (!string.IsNullOrEmpty(schType)) { string tutGuid = Request.Form["tutGuid"]; string stuGuid = Request.Form["stuGuid"]; string schDay = Request.Form["schDay"]; string schFrom = Request.Form["schFrom"]; string schTo = Request.Form["schTo"]; string isdelete = Request.Form["isDel"]; BestSTPlan bstp = new BestSTPlan(); if (Utils.IsGuid(schGuid)) { if (schType.Equals("Student") && !(Utils.User.UserRoleByName("Student - Planner").allowEdit)) { Response.Write("{result:false,Message:'You do not have rights to edit.'}"); return; } if (schType.Equals("Tutor") && !(Utils.User.UserRoleByName("Tutor - Planner").allowEdit)) { Response.Write("{result:false,Message:'You do not have rights to edit.'}"); return; } List<BestField> bparams = new List<BestField>(); BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false }; guid.fieldValue = schGuid; bparams.Add(guid); bstp.LoadRows("guidfield = ?", bparams); if (bstp.TableRows.Count > 0) { bstp.schDay = schDay; bstp.schFrom = schFrom; bstp.schTo = schTo; bstp.CenterId = Utils.User.CenterId; if (Utils.IsGuid(tutGuid)) bstp.tutorguid= new Guid(tutGuid); if (Utils.IsGuid(stuGuid)) bstp.studentGuid = new Guid(stuGuid); bstp.CurrentRow.Save(); } } else { if (schType.Equals("Student") && !(Utils.User.UserRoleByName("Student - Planner").allowAdd)) { Response.Write("{result:false,Message:'You do not have rights to edit.'}"); return; } if (schType.Equals("Tutor") && !(Utils.User.UserRoleByName("Tutor - Planner").allowAdd)) { Response.Write("{result:false,Message:'You do not have rights to edit.'}"); return; } bstp.guidfield = Guid.NewGuid(); bstp.schDay = schDay; bstp.schFrom = schFrom; bstp.schTo = schTo; bstp.CenterId = Utils.User.CenterId; if (Utils.IsGuid(tutGuid)) bstp.tutorguid = new Guid(tutGuid); if (Utils.IsGuid(stuGuid)) bstp.studentGuid = new Guid(stuGuid); } bstp.isDeleted = isdelete; if (bstp.CurrentRow.Save()) { Response.Write("{result:true,guid:'" + bstp.CurrentRow.Fields["guidfield"].fieldValue + "'}"); } else { Response.Write("{result:false,Message:'" + Utils.EnquoteJS(bstp.CurrentRow.lastError) + "'}"); } } }