示例#1
0
        public BestTutorNotes()
        {
            this.TableName = "BestTutorNotes";
            this.SecurityPage = "Tutor - Notes";

            TableFields.Add(new BestField() { fieldName = "guidfield", fieldHeader = "guid", displayField = false, fieldSize = 40, IsRequired = true, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid });
            TableFields.Add(new BestField() { fieldName = "lastChange", fieldHeader = "Last Change", displayField = false, fieldSize = 20, IsRequired = true, fieldType = "System.DateTime", paramOledbType = System.Data.OleDb.OleDbType.DBTimeStamp });
            TableFields.Add(new BestField() { fieldName = "lastChangeUser", fieldHeader = "Last Change User", displayField = false, fieldSize = 128, IsRequired = true, fieldType = "System.String", paramOledbType = System.Data.OleDb.OleDbType.VarChar });

            TableFields.Add(new BestField()
            {
                fieldName = "tutorGuid",
                fieldHeader = "Tutor Name",
                displayField = true,
                fieldSize = 40,
                IsRequired = false,
                fieldType = "System.Guid",
                paramOledbType = System.Data.OleDb.OleDbType.Guid,
                displayFormatFunc = new Func<BestRow, object>((obj) =>
                {
                    BestRow bstd = (BestRow)obj;
                    List<BestField> bparams = new List<BestField>();
                    BestField guid = new BestField() { fieldName = "tutorGuid", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
                    guid.fieldValue = bstd.Fields["tutorGuid"].fieldValue;
                    bparams.Add(guid);
                    BestTutors bpstd = new BestTutors();
                    bpstd.LoadRows("guidfield=?", bparams);
                    return bpstd.firstName + " " + bpstd.lastName;
                })
            });

            TableFields.Add(new BestField() { fieldName = "noteDate", fieldHeader = "Note Date", displayField = true, fieldSize = 20, IsRequired = true, fieldType = "System.DateTime", paramOledbType = System.Data.OleDb.OleDbType.DBTimeStamp });
            TableFields.Add(new BestField() { fieldName = "notes", fieldHeader = "Notes", displayField = true, fieldSize = 9000, IsRequired = true, fieldType = "System.String", paramOledbType = System.Data.OleDb.OleDbType.VarChar });
            TableFields.Add(new BestField()
            {
                fieldName = "CenterId",
                fieldSize = 50,
                fieldType = "System.String",
                paramOledbType = System.Data.OleDb.OleDbType.VarChar,
                IsRequired = true
            });
        }
示例#2
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["CurrentUser"] == null)
            {
                Response.Redirect("Logout.aspx");
            }
            ltrSubMenu.Text = UtilMenu.TutorMenu("tutorinfo");

            string ms = Request.QueryString["ms"];
            ltrMScript.Text = Utils.MenuSelectScript(ms);

            if (!Utils.User.UserRoleByName("Tutor - Information").allowView)
            {
                ltrGrid.Text = "You do not have rights to view.";
                return;
            }
            this.ltrStateOpts.Text = Utils.StateOptions();
            BestCenters bcs = new BestCenters();
            bcs.LoadRows();
            for (int rnum = 0; rnum < bcs.TableRows.Count; rnum++)
            {
                string cid = bcs.TableRows[rnum].Fields["CenterId"].fieldValue;
                if (cid.Equals(Utils.User.CenterId))
                {
                    this.CenterId.Items.Add(cid);
                }
            }

            string saveClicked = Request.Form["SaveClicked"] ?? "";
            if (IsPostBack && saveClicked.Equals("1"))
            {
                BestTutors bs = new BestTutors();
                string isnew = Request.Form["isnew"];
                bool cansave = true;
                if (string.IsNullOrEmpty(isnew))
                {
                    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 = Request.Form["guidfield"];
                    bparams.Add(guid);

                    if (!string.IsNullOrEmpty(guid.fieldValue))
                    {
                        bs.LoadRows("guidfield=?", bparams);
                    }
                    else
                    {
                        string delguid = Request.Form["deleteguid"];
                        if (!string.IsNullOrEmpty(delguid))
                        {
                            bparams[0].fieldValue = delguid;
                            bs.LoadRows("guidfield=?", bparams);
                            bs.CurrentRow.IsDelete = true;
                            bs.CurrentRow.Save();
                        }
                        cansave = false;
                    }
                }

                if (cansave)
                {
                    bs.TutorId = Request.Form["g_TutorId"];
                    bs.firstName = Request.Form["g_firstName"];
                    bs.lastName = Request.Form["g_lastName"];
                    bs.CenterId = this.CenterId.Value;

                    if (string.IsNullOrEmpty(bs.TutorId))
                    {
                        ltrValidateMsg.Text = Utils.WarningMessage("Tutor Id is Required.");
                        cansave = false;
                    }
                    if (string.IsNullOrEmpty(bs.firstName) && string.IsNullOrEmpty(bs.lastName))
                    {
                        ltrValidateMsg.Text = Utils.WarningMessage("First Name or Last Name is required");
                        cansave = false;
                    }

                    if (cansave)
                    {
                        bs.middleName = Request.Form["g_middleName"];
                        bs.address1 = Request.Form["g_address1"];
                        bs.address2 = Request.Form["g_address2"];
                        bs.city = Request.Form["g_city"];
                        bs.state = Request.Form["g_state"];
                        bs.zip = Request.Form["g_zip"];
                        bs.cellPhone = Request.Form["g_cellPhone"];
                        bs.workPhone = Request.Form["g_workPhone"];
                        bs.homePhone = Request.Form["g_homePhone"];
                        bs.emailId = Request.Form["g_emailId"];
                        bs.gender = Request.Form["g_gender"];
                        bs.School = Request.Form["g_school"];
                        bs.yearGraduated = Request.Form["g_yearGraduated"];
                        bs.GPA = Request.Form["g_GPA"];
                        bs.Major = Request.Form["g_Major"];
                        bs.Expertise = Request.Form["g_Expertise"];
                        bs.learningStyle = Request.Form["g_learningStyle"];
                        bs.Matchup = Request.Form["g_Matchup"];
                        bs.gradeLevels = Request.Form["g_gradeLevels"];
                        bs.otherSkill = Request.Form["g_otherSkill"];
                        bs.programStyle = Request.Form["g_programStyle"];
                        string salary = Request.Form["g_salary"];
                        string perhour = Request.Form["g_perhour"];
                        if (!string.IsNullOrEmpty(salary))
                        {
                            bs.Salary = Convert.ToDecimal(salary);
                        }
                        if (!string.IsNullOrEmpty(perhour))
                        {
                            bs.PerHour = Convert.ToDecimal(perhour);
                        }
                        if (!string.IsNullOrEmpty(Request.Form["g_joinDate"]))
                        {
                            bs.joinDate = Convert.ToDateTime(Request.Form["g_joinDate"]);
                        }

                        if (!bs.CurrentRow.Save())
                        {
                            ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
                        }
                    }
                }
            }

            BestDatabase db = new BestDatabase();
            OleDbCommand myCmd = db.dbCmd;
            myCmd.CommandText = "Best_GetNextTutorId";
            OleDbParameter p1 = new OleDbParameter("@makehigherthan", OleDbType.VarChar, 10);
            p1.Value = "T0";
            myCmd.Parameters.Add(p1);
            myCmd.CommandType = System.Data.CommandType.StoredProcedure;
            OleDbDataReader read = myCmd.ExecuteReader();
            string tutorid = "";
            if (read.Read())
            {
                tutorid = read.GetValue(0).ToString();
            }
            ltrLoadScript.Text = "<script type=\"text/javascript\">\n newtutorid='" + tutorid + "'\n</script>\n";

            BestGrid bsGrid = new BestGrid();
            bsGrid.PageRequest = Page.Request;
            bsGrid.Title = "Tutuor Information";
            bsGrid.GridTable = new BestTutors();
            bsGrid.securityPage = "Tutor - Information";
            ltrGrid.Text = bsGrid.ToHTML();
        }
示例#3
0
        private string TutorOptions()
        {
            StringBuilder sb = new StringBuilder();
            string tutorguid = Request.Form["TutorGuid"] ?? "";
            sb.Append("<option value=\"\"></option>");
            BestTutors bs = new BestTutors();
            bs.LoadRows("CenterId=?", "centerid", Utils.User.CenterId, "firstname");
            sb.Append(string.Join("", bs.TableRows.Rows.Select(x => "<option value=\"" + Server.HtmlEncode(x.Fields["guidfield"].fieldValue) + "\" " + (tutorguid.Equals(x.Fields["guidfield"].fieldValue) ? "selected" : "") + " >" + Server.HtmlEncode(x.Fields["firstname"].fieldValue + " " + x.Fields["lastname"].fieldValue) + "</option>").ToArray()));

            return sb.ToString();
        }
示例#4
0
        private void SendEMails()
        {
            /* Send EMails */
            string strRows = Request.Form["rowcount"];
            int rowCount;
            int.TryParse(strRows, out rowCount);
            List<BestField> bparams = new List<BestField>();
            string paramQs = "";
            for (int i = 0; i < rowCount; i++)
            {
                string chkStr = Request.Form["chk_" + i.ToString()]??"";
                if (chkStr.Equals("on"))
                {
                    BestField bsf = new BestField() { fieldName = "guidfield", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldType = "System.Guid" };
                    bsf.fieldValue = Request.Form["guid" + i.ToString()];
                    bparams.Add(bsf);
                    paramQs += "?,";
                }
            }
            paramQs = (paramQs.Length > 0) ? paramQs.Substring(0, paramQs.Length - 1) : "";
            string selWho = Request.Form["selWho"];
            if (bparams.Count > 0)
            {
                Dictionary<string, BMails> nvc = new Dictionary<string, BMails>();
                string emailBody = getEMailBody();

                if (selWho.Equals("Student"))
                {
                    BestStudents bs = new BestStudents();
                    bs.LoadRows("guidfield in (" + paramQs + ")", bparams);
                    for (int i = 0; i < bs.TableRows.Count; i++)
                    {
                        bs.currentRowId = i;
                        BMails bm = new BMails();
                        bm.emailbody = ReplaceParams(bs, emailBody);
                        bm.emailToName = bs.firstName + " " + bs.lastName;
                        nvc.Add(bs.emailId, bm);
                    }
                }
                else if (selWho.Equals("Tutor"))
                {
                    BestTutors bt = new BestTutors();
                    bt.LoadRows("guidfield in (" + paramQs + ")", bparams);
                    for (int i = 0; i < bt.TableRows.Count; i++)
                    {
                        bt.currentRowId = i;
                        BMails bm = new BMails();
                        bm.emailbody = ReplaceParams(bt, emailBody);
                        bm.emailToName = bt.firstName + " " + bt.lastName;
                        nvc.Add(bt.emailId, bm);
                    }
                }

                string emailSubject = Request.Form["emailSubject"] ?? "";
                string message = "Send EMail To:\n";
                foreach (string key in nvc.Keys)
                {
                    BMails bm = (BMails)nvc[key];
                    if (Utils.User.emailUtil.Send(key, emailSubject, bm.emailbody, bm.emailToName))
                    {
                        message += key + " " + bm.emailToName + "\n";
                    }
                }
                ltrValidateMsg.Text = Utils.InfoMessage(message);
            }
        }
示例#5
0
 private string EMailTargetHTML(string studTutor, string filter, string filterval)
 {
     StringBuilder result = new StringBuilder();
     result.Append("<table id=\"available\" class=\"bestgrid\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:80%;\"><tr><th><input type=\"checkbox\" id=\"checkAll\" onclick=\"ToggleCheck();\" /></th><th>Id</th><th>First Name</th><th>Last Name</th><th>EMail Address</th></tr>");
     int rowcount = 0;
     if (studTutor.Equals("Student"))
     {
         BestStudents bs = new BestStudents();
         if (!string.IsNullOrEmpty(filter) && !string.IsNullOrEmpty(filterval))
         {
             BestField bfld = new BestField() { fieldName = "filterparam", paramOledbType = System.Data.OleDb.OleDbType.VarChar, fieldSize = 50, fieldType = "System.String" };
             bfld.fieldValue = filterval;
             List<BestField> bparam = new List<BestField>();
             bparam.Add(bfld);
             bparam.Add(Utils.User.CenterIdField);
             if (filter.Equals("School"))
             {
                 bs.LoadRows("school = ? and CenterId=?", bparam,"firstname,lastname");
             }
             else if (filter.Equals("Grade"))
             {
                 bs.LoadRows("grade = ? and CenterId=?", bparam, "firstname,lastname");
             }
         }
         else
         {
             bs.LoadRows("CenterId=?",Utils.User.CIdParam,"firstname, lastname");
         }
         rowcount = bs.TableRows.Count;
         for (int row = 0; row < bs.TableRows.Count; row++)
         {
             bs.currentRowId = row;
             string trclass = (row % 2 == 0) ? "" : " class=\"gridodd\" ";
             result.Append("<tr" + trclass + ">");
             if (!string.IsNullOrEmpty(bs.emailId))
             {
                 result.Append("<td><input type=\"checkbox\" id=\"chk_" + row.ToString() + "\" name=\"chk_" + row.ToString() + "\" /><input type=\"hidden\" id=\"guid" + row.ToString() + "\" name=\"guid" + row.ToString() + "\" value=\"" + HttpUtility.HtmlEncode(bs.guidfield.ToString()) + "\" /></td>");
             }
             else
             {
                 result.Append("<td>&nbsp;</td>");
             }
             result.Append("<td>" + HttpUtility.HtmlEncode(bs.StudentId) + "</td><td>" + HttpUtility.HtmlEncode(bs.firstName) + "</td><td>" + HttpUtility.HtmlEncode(bs.lastName) + "</td><td>" + HttpUtility.HtmlEncode(bs.emailId) + "</td></tr>");
         }
     }
     else if (studTutor.Equals("Tutor"))
     {
         BestTutors bt = new BestTutors();
         bt.LoadRows("CenterId=?", Utils.User.CIdParam, "firstname,lastname");
         rowcount = bt.TableRows.Count;
         for (int row = 0; row < bt.TableRows.Count; row++)
         {
             bt.currentRowId = row;
             string trclass = (row % 2 == 0) ? "" : " class=\"gridodd\" ";
             result.Append("<tr" + trclass + ">");
             if (!string.IsNullOrEmpty(bt.emailId))
             {
                 result.Append("<td><input type=\"checkbox\" id=\"chk_" + row.ToString() + "\" name=\"chk_" + row.ToString() + "\" /><input type=\"hidden\" id=\"guid" + row.ToString() + "\" name=\"guid" + row.ToString() + "\" value=\"" + HttpUtility.HtmlEncode(bt.guidfield.ToString()) + "\" /></td>");
             }
             else
             {
                 result.Append("<td>&nbsp;</td>");
             }
             result.Append("<td>" + HttpUtility.HtmlEncode(bt.TutorId) + "</td><td>" + HttpUtility.HtmlEncode(bt.firstName) + "</td><td>" + HttpUtility.HtmlEncode(bt.lastName) + "</td><td>" + HttpUtility.HtmlEncode(bt.emailId) + "</td></tr>");
         }
     }
     result.Append("<input type=\"hidden\" id=\"rowcount\" name=\"rowcount\" value=\"" + rowcount.ToString() + "\" />");
     result.Append("</table>");
     return result.ToString();
 }
示例#6
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["CurrentUser"] == null)
            {
                Response.Redirect("Logout.aspx");
            }
            ltrSubMenu.Text = UtilMenu.TutorMenu("tutorusers");
            if (!Utils.User.UserRoleByName("Tutor - Users").allowView)
            {
                ltrGrid.Text = "You do not have rights to view.";
                return;
            }

            string ms = Request.QueryString["ms"];
            this.ltrMScript.Text = Utils.MenuSelectScript(ms);

            string saveClicked = Request.Form["SaveClicked"] ?? "";
            if (IsPostBack && saveClicked.Equals("1"))
            {
                BestField fld = new BestField() { fieldName = "guidfield", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldType = "System.Guid" };
                List<BestField> bparam = new List<BestField>();
                string delguid = Request.Form["deleteguid"];
                if (!string.IsNullOrEmpty(delguid))
                {
                    BestUser bsduser = new BestUser();
                    fld.fieldValue = delguid;
                    bparam.Add(fld);
                    bsduser.LoadRows("guidfield=?", bparam);
                    bsduser.CurrentRow.IsDelete = true;
                    if (!bsduser.CurrentRow.Save())
                    {
                        ltrValidateMsg.Text = Utils.WarningMessage(bsduser.CurrentRow.lastError);
                    }
                }
                else
                {
                    string tutorGud = Request.Form["tutorTag0"];
                    if (!string.IsNullOrEmpty(tutorGud))
                    {
                        fld.fieldValue = tutorGud;
                        bparam.Add(fld);
                        BestTutors bstutor = new BestTutors();
                        bstutor.LoadRows("guidfield=?", bparam);
                        if (!bstutor.CurrentRow.IsNew)
                        {
                            if (string.IsNullOrEmpty(bstutor.emailId))
                            {
                                ltrValidateMsg.Text = Utils.WarningMessage("Tutor E-Mail Address is Required.");
                            }
                            else
                            {
                                BestUser bstuser = new BestUser();
                                bstuser.userName = bstutor.emailId;
                                bstuser.firstName = bstutor.firstName;
                                bstuser.lastName = bstutor.lastName;
                                bstuser.address1 = bstutor.address1;
                                bstuser.address2 = bstutor.address2;
                                bstuser.city = bstutor.city;
                                bstuser.state = bstutor.state;
                                bstuser.zip = bstutor.zip;
                                bstuser.cellPhone = bstutor.cellPhone;
                                bstuser.workPhone = bstutor.workPhone;
                                bstuser.homePhone = bstutor.homePhone;
                                bstuser.tutorGuid = bstutor.guidfield;
                                bstuser.Centers = bstutor.CenterId;

                                bstuser.emailId = bstutor.emailId;
                                bstuser.userType = "Tutor";
                                string randPwd = RandomString(8);
                                bstuser.password = Utils.GetMD5Hash(randPwd);
                                bstuser.passwordExpiration = DateTime.Today.AddDays(3);
                                if (bstuser.CurrentRow.Save())
                                {
                                    Utils.User.emailUtil.Send(bstuser.emailId, "BLC Login Information", @"<h2>Welcome to Bali Learning Center!</h2><br><h3>Your login information is enclosed.</h3>

            <b>Accessing Your Account</b><br>
            Step 1:<br>
            Click the link below or enter the URL below into your web browser<br>
            Address:	<a href=""http://best.vasbal.com"">Bali Learning Center Login</a><br><br>

            Step 2:<br>
            Enter the following user name and temporary password.<br>
            User Name: <b>" + bstuser.userName + @"</b><br>
            Password:   <b>" + randPwd + @"</b><br><br>

            <h3>This temporary password expires in 24 hours.</h3><br><br>

            You will be prompted to change your user name and password during your initial log in as well as answer a few security related questions. <br>
            <br>

            <br>
            <br>
            Thank you,<br>
            Bali Learning Center", bstuser.firstName + " " + bstuser.lastName);

                                    /* Create Tutor - Personal Role  */
                                    List<BestField> bparams = new List<BestField>();
                                    BestField paramUName = new BestField() { fieldName = "username", fieldSize = 80, fieldType = "System.String", paramOledbType = System.Data.OleDb.OleDbType.VarChar, displayField = false };
                                    paramUName.fieldValue = bstuser.userName;
                                    BestField service = new BestField() { fieldName = "service", fieldSize = 80, fieldType = "System.String", paramOledbType = System.Data.OleDb.OleDbType.VarChar, displayField = false };
                                    bparams.Add(paramUName);
                                    bparams.Add(service);

                                    string[] aryRoles = { "3.Tutors", "Tutor - Personal", "Tutor - Planner" };
                                    for (int i = 0; i < aryRoles.Length; i++)
                                    {
                                        UserRoles urole = new UserRoles();
                                        bparams[1].fieldValue = aryRoles[i];
                                        urole.LoadRows("username = ? and service=?", bparams);
                                        if (urole.TableRows.Count == 0)
                                        {
                                            urole.Service = aryRoles[i];
                                            urole.UserName = bstuser.userName;
                                            urole.allowView = "1";
                                            urole.CurrentRow.Save();
                                        }
                                    }
                                }
                                else
                                {
                                    ltrValidateMsg.Text =  Utils.WarningMessage( bstuser.CurrentRow.lastError);
                                }
                            }
                        }
                    }
                }
            }

            BestGrid bsGrid = new BestGrid();
            bsGrid.PageRequest = Page.Request;
            bsGrid.Title = "Tutor Users";
            bsGrid.securityPage = "Tutor - Users";
            BestUser bsuser = new BestUser();
            bsuser.overrideAdd = Utils.User.UserRoleByName("Tutor - Users").allowAdd;
            bsuser.overrideDelete = Utils.User.UserRoleByName("Tutor - Users").allowDelete;
            bsuser.overrideEdit = false;

            bsuser.TableFields["address1"].displayField = false;
            bsuser.TableFields["address2"].displayField = false;
            bsuser.TableFields["city"].displayField = false;
            bsuser.TableFields["zip"].displayField = false;
            bsuser.TableFields["state"].displayField = false;
            bsuser.TableFields["Centers"].displayField = false;
            bsGrid.GridTable = bsuser;
            bsGrid.whereClause = "usertype in ('Tutor')";
            ltrGrid.Text = bsGrid.ToHTML();

            /* Auto Tutors */
            StringBuilder sb = new StringBuilder();
            string autoSample = "{value:\"[paramValue]\", label:[paramLabel]}";
            sb.AppendLine("<script type=\"text/javascript\">");
            sb.AppendLine("autoTutors = [");
            BestTutors bstd = new BestTutors();
            bstd.LoadRows();
            for (int s = 0; s < bstd.TableRows.Count; s++)
            {
                string result = autoSample;
                result = result.Replace("[paramValue]", bstd.TableRows[s].Fields["guidfield"].fieldValue);
                result = result.Replace("[paramLabel]", Utils.EnquoteJS((bstd.TableRows[s].Fields["firstName"].fieldValue ?? "") + " " +
                    (bstd.TableRows[s].Fields["lastName"].fieldValue ?? "")));
                sb.Append(result);
                if (s < bstd.TableRows.Count - 1) sb.AppendLine(",");
            }
            sb.AppendLine("];");
            sb.AppendLine("</script>");
            this.ltrScript.Text = sb.ToString();
        }
示例#7
0
        private string StudentAndTutors()
        {
            StringBuilder jsSb = new StringBuilder();

            string autoSample = "{value:\"[paramValue]\", label:[paramLabel]}";
            jsSb.AppendLine("autoStudents = [");
            BestStudents bstd = new BestStudents();
            bstd.LoadRows("CenterId=?", Utils.User.CIdParam, "firstname");
            for (int s = 0; s < bstd.TableRows.Count; s++)
            {
                string result = autoSample;
                bstd.currentRowId = s;
                result = result.Replace("[paramValue]", bstd.guidfield.ToString());
                result = result.Replace("[paramLabel]", Utils.EnquoteJS((bstd.firstName ?? "") + " " +
                    (bstd.lastName ?? "")));
                jsSb.Append(result);
                if (s < bstd.TableRows.Count - 1) jsSb.AppendLine(",");
            }
            jsSb.AppendLine("];");

            BestTutors bstut = new BestTutors();
            bstut.LoadRows("CenterId=?", Utils.User.CIdParam,"firstname");
            jsSb.AppendLine("autoTutors = [");
            for (int s = 0; s < bstut.TableRows.Count; s++)
            {
                string result = autoSample;
                bstut.currentRowId = s;
                result = result.Replace("[paramValue]", bstut.guidfield.ToString());
                result = result.Replace("[paramLabel]", Utils.EnquoteJS((bstut.firstName ?? "") + " " + (bstut.lastName ?? "").Substring(0, 1) + "-" + bstut.TutorId));
                jsSb.Append(result);
                if (s < bstut.TableRows.Count - 1) jsSb.AppendLine(",");
            }
            jsSb.AppendLine("];");

            string studentSample = "{\"firstName\":[paramFirst], \"lastName\":[paramLast], \"guid\":\"[paramGuid]\"}";
            jsSb.AppendLine("StudentInfo = [");
            for (int s = 0; s < bstd.TableRows.Count; s++)
            {
                string result = studentSample;
                bstd.currentRowId = s;
                result = result.Replace("[paramGuid]", bstd.guidfield.ToString());
                result = result.Replace("[paramFirst]", Utils.EnquoteJS(bstd.firstName?? ""));
                result = result.Replace("[paramLast]", Utils.EnquoteJS(bstd.lastName?? ""));
                jsSb.Append(result);
                if (s < bstd.TableRows.Count - 1) jsSb.AppendLine(",");
            }

            jsSb.AppendLine("];");
            string tutorSample = "{\"Name\":[paramName], \"Id\":\"[paramId]\",\"guid\":\"[paramGuid]\"}";
            jsSb.AppendLine("TutorInfo = [");
            for (int s = 0; s < bstut.TableRows.Count; s++)
            {
                string result = tutorSample;
                bstut.currentRowId = s;
                result = result.Replace("[paramGuid]", bstut.guidfield.ToString());
                result = result.Replace("[paramName]", Utils.EnquoteJS((bstut.firstName?? "") + " " + (bstut.lastName?? "").Substring(0,1) + "-" + bstut.TutorId));
                result = result.Replace("[paramId]", bstut.TutorId);
                jsSb.Append(result);
                if (s < bstut.TableRows.Count - 1) jsSb.AppendLine(",");
            }
            jsSb.AppendLine("];");

            return jsSb.ToString();
        }
示例#8
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["CurrentUser"] == null)
            {
                Response.Redirect("Logout.aspx");
            }
            ltrSubMenu.Text = UtilMenu.TutorMenu("tutorplanner");
            if (!Utils.User.UserRoleByName("Tutor - Planner").allowView)
            {
                ltrValidateMsg.Text = "You do not have rights to view.";
                return;
            }

            string ms = Request.QueryString["ms"];
            this.ltrMScript.Text = Utils.MenuSelectScript(ms);
            BestTutors bstd = new BestTutors();
            string tutorLoginScript = "";
            if (Utils.User.BestUser.userType.Equals("Tutor"))
            {
                List<BestField> bparam = new List<BestField>();
                bparam.Add(new BestField() { fieldName = "tutorGuid", fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, fieldSize = 40 });
                bparam[0].fieldValue = Utils.User.BestUser.tutorGuid.ToString();
                bstd.LoadRows("guidfield=?", bparam);
                tutorLoginScript = "$('#tblStudentSel').css('display','none');";
            }
            else
            {
                bstd.LoadRows("CenterId=?", Utils.User.CIdParam);
            }
            string selstudent = Request.Form["selTutor"];
            StringBuilder sb = new StringBuilder();
            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>");
            }
            ltrTutorOpts.Text = sb.ToString();
            StringBuilder sbInfo = new StringBuilder();
            sbInfo.Append("[");
            if (!string.IsNullOrEmpty(selstudent))
            {
                BestSTPlan bstPlan = new BestSTPlan();
                BestField bfield = new BestField() { fieldName = "tutorguid", 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("tutorguid=? and isdeleted=0 and centerid=?", bparams);
                string stplanInfo = "{guidfield:\"[paramguid]\",tutGuid:\"[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.tutorguid.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"">" + tutorLoginScript + @" g_nameOnScheduler = " + Utils.EnquoteJS(selName) + @";
            g_curSTGuid = " + Utils.EnquoteJS(selstudent) + @";
            g_IsStudent = false;
            STPlanInfo = " + sbInfo.ToString() + @"
            </script>";
        }
示例#9
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["CurrentUser"] == null)
            {
                Response.Redirect("Logout.aspx");
            }
            ltrSubMenu.Text = UtilMenu.TutorMenu("tutornotes");
            if (!Utils.User.UserRoleByName("Tutor - Notes").allowView)
            {
                ltrGrid.Text = "You do not have rights to view.";
                return;
            }

            string ms = Request.QueryString["ms"];
            this.ltrMScript.Text = Utils.MenuSelectScript(ms);

            string saveClicked = Request.Form["SaveClicked"] ?? "";
            if (IsPostBack && saveClicked.Equals("1"))
            {
                BestTutorNotes bs = new BestTutorNotes();
                string isnew = Request.Form["isnew"];
                bool cansave = true;
                if (string.IsNullOrEmpty(isnew))
                {
                    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 = Request.Form["guidfield"];
                    bparams.Add(guid);

                    if (!string.IsNullOrEmpty(guid.fieldValue))
                    {
                        bs.LoadRows("guidfield=?", bparams);
                    }
                    else
                    {
                        string delguid = Request.Form["deleteguid"];
                        if (!string.IsNullOrEmpty(delguid))
                        {
                            bparams[0].fieldValue = delguid;
                            bs.LoadRows("guidfield=?", bparams);
                            bs.CurrentRow.IsDelete = true;
                            bs.CurrentRow.Save();
                        }
                        cansave = false;
                    }
                }

                if (cansave)
                {
                    if (!string.IsNullOrEmpty(isnew))
                    {
                        string guid = Request.Form["g_tutorGuid"];
                        if (string.IsNullOrEmpty(guid))
                        {
                            ltrValidateMsg.Text = Utils.WarningMessage("Tutor Name is Required.");
                            cansave = false;
                        }
                        bs.tutorGuid = new Guid(guid);
                    }
                    if (cansave)
                    {
                        string notedate = Request.Form["g_noteDate"];
                        if (!string.IsNullOrEmpty(notedate))
                        {
                            bs.noteDate = Convert.ToDateTime(notedate);
                        }
                        bs.notes = Request.Form["g_notes"];
                        bs.CenterId = Utils.User.CenterId;

                        if (!bs.CurrentRow.Save())
                        {
                            ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
                        }
                    }
                }
            }

            /* Auto Student */
            string autoSample = "{value:\"[paramValue]\", label:[paramLabel]}";
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("autoTutors = [");
            BestTutors bstd = new BestTutors();
            bstd.LoadRows("CenterId=?", Utils.User.CIdParam);
            for (int s = 0; s < bstd.TableRows.Count; s++)
            {
                string result = autoSample;
                result = result.Replace("[paramValue]", bstd.TableRows[s].Fields["guidfield"].fieldValue);
                result = result.Replace("[paramLabel]", Utils.EnquoteJS((bstd.TableRows[s].Fields["firstName"].fieldValue ?? "") + " " +
                    (bstd.TableRows[s].Fields["lastName"].fieldValue ?? "")));
                sb.Append(result);
                if (s < bstd.TableRows.Count - 1) sb.AppendLine(",");
            }
            sb.AppendLine("];");
            ltrScript.Text = @"<script type=""text/javascript"">
            $(document).ready(function(){ " + sb.ToString() + @"
            $('#tutorTag1').autocomplete( { source:autoTutors, delay: 0, select : function( event, ui){
            $('#tutorGuid').val( ui.item.value );
            $( this ).val( ui.item.label );
            return false;
            } } ); }); </script>";

            BestGrid bsGrid = new BestGrid();
            bsGrid.PageRequest = Page.Request;
            bsGrid.Title = "Tutor Notes";
            bsGrid.GridTable = new BestTutorNotes();
            bsGrid.securityPage = "Tutor - Notes";
            ltrGrid.Text = bsGrid.ToHTML();
        }
示例#10
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["CurrentUser"] == null)
            {
                Response.Redirect("Logout.aspx");
            }
            ltrSubMenu.Text = UtilMenu.TutorMenu("tutorschedule");
            if (!Utils.User.UserRoleByName("Tutor - Schedule").allowView)
            {
                ltrValidateMsg.Text = "You do not have rights to view.";
                return;
            }

            string ms = Request.QueryString["ms"];
            this.ltrMScript.Text = Utils.MenuSelectScript(ms);
            BestTutors bstd = new BestTutors();
            bstd.LoadRows("CenterId=?", Utils.User.CIdParam,"firstname");
            string selstudent = Request.Form["selTutor"];
            StringBuilder sb = new StringBuilder();
            string selName = "";
            string emailaddress = "";
            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;
                    emailaddress = bstd.TableRows[i].Fields["emailId"].fieldValue;
                    sb.Append(" selected ");
                }
                sb.Append(">" + HttpUtility.HtmlEncode(sname) + "</option>");
            }
            ltrTutorOpts.Text = sb.ToString();
            string fromdate = Request.Form["fromdate"] ?? "";
            string todate = Request.Form["todate"] ?? "";
            DateTime today = DateTime.Today;
            int curweek = ((int)today.DayOfWeek) * -1;
            if (string.IsNullOrEmpty(fromdate))
            {
                fromdate = today.AddDays(curweek).ToString("MM/dd/yyyy");
            }
            if (string.IsNullOrEmpty(todate))
            {
                todate = today.AddDays(curweek).AddDays(7).ToString("MM/dd/yyyy");
            }
            ltrLoadScript.Text = "<script type=\"text/javascript\">$(document).ready(function(){$('#fromdate').val('" + fromdate + "'); $('#todate').val('" + todate + @"');
            }); </script>";
            if (!string.IsNullOrEmpty(selstudent))
            {
                string tsql = "select Date, [Sunday], [Monday], [Tuesday], [Wednesday], [Thursday], [Friday], [Saturday],stud1name,stud2name,stud3name,stud4name,stud5name from VBestSchedules where ";
                tsql += "(tutGuid='" + selstudent + "') and convert(datetime,date) between '" + fromdate + @"' and '" + todate + @"' order by convert(datetime, date), convert(numeric, schfrom)";

                StringBuilder sbSchd = new StringBuilder();
                BestDatabase db = new BestDatabase();
                OleDbCommand myCmd = db.dbCmd;
                myCmd.CommandText = tsql;
                OleDbDataReader tblReader = myCmd.ExecuteReader(CommandBehavior.KeyInfo);
                //Retrieve column schema into a DataTable.
                DataTable schemaTable = tblReader.GetSchemaTable();

                sbSchd.Append("<table cellpadding=\"0\" style=\"padding:1px;font-family:Tahoma;font-size:12px;border:1px solid #999;background-color:#A11117\"><tr>");
                //For each field in the table...
                int fieldCnt = 0;
                foreach (DataRow myField in schemaTable.Rows)
                {
                    fieldCnt++; if (fieldCnt > 8) break;
                    sbSchd.Append("<th style=\"color:#000;background-color:#E9BA15;padding:2px;\">" + myField[0] + "</th>");
                }
                sbSchd.Append("</tr>");

                int cnt = 0;
                while (tblReader.Read())
                {
                    string name = " " + tblReader[8].ToString();
                    name += !string.IsNullOrEmpty(tblReader[9].ToString()) ? ", "+tblReader[9].ToString() : "";
                    name += !string.IsNullOrEmpty(tblReader[10].ToString()) ? ", "+tblReader[10].ToString() : "";
                    name += !string.IsNullOrEmpty(tblReader[11].ToString()) ? ", "+tblReader[11].ToString() : "";
                    name += !string.IsNullOrEmpty(tblReader[12].ToString()) ? ", "+tblReader[12].ToString() : "";
                    string trclass = (cnt % 2 == 0) ? "" : "trordd";
                    sbSchd.Append("<tr style=\"font-family:Tahoma;color:#FFF;font-size:12px;\"><td>" + (tblReader[0].ToString()) + "</td>");
                    sbSchd.Append("<td>" + Utils.ToTimeFormat(tblReader[1].ToString()) + (!string.IsNullOrEmpty(tblReader[1].ToString())?name:"") +  "</td>");
                    sbSchd.Append("<td>" + Utils.ToTimeFormat(tblReader[2].ToString()) + (!string.IsNullOrEmpty(tblReader[2].ToString())?name:"") +"</td>");
                    sbSchd.Append("<td>" + Utils.ToTimeFormat(tblReader[3].ToString()) + (!string.IsNullOrEmpty(tblReader[3].ToString())?name:"") +"</td>");
                    sbSchd.Append("<td>" + Utils.ToTimeFormat(tblReader[4].ToString()) + (!string.IsNullOrEmpty(tblReader[4].ToString())?name:"") +"</td>");
                    sbSchd.Append("<td>" + Utils.ToTimeFormat(tblReader[5].ToString()) + (!string.IsNullOrEmpty(tblReader[5].ToString())?name:"") +"</td>");
                    sbSchd.Append("<td>" + Utils.ToTimeFormat(tblReader[6].ToString()) + (!string.IsNullOrEmpty(tblReader[6].ToString())?name:"") +"</td>");
                    sbSchd.Append("<td>" + Utils.ToTimeFormat(tblReader[7].ToString()) + (!string.IsNullOrEmpty(tblReader[7].ToString())?name:"") +"</td></tr>");
                    cnt++;
                }
                tblReader.Close();

                sbSchd.Append("</table>");
                ltrTutorSchedule.Text = sbSchd.ToString();
                string sendEClick = Request.Form["sendEMailClick"] ?? "";
                if (!string.IsNullOrEmpty(sendEClick) && sendEClick.Equals("1") && emailaddress.Length > 0)
                {
                    string emailbody = "Dear " + selName + "<br />Following is your Schedule from " + fromdate + " to " + todate + ":<br />" + sbSchd.ToString() + "<br />Thank you<br />Bali Learning";
                    if (Utils.User.emailUtil.Send(emailaddress, "Schedule Info", emailbody, selName))
                    {
                        ltrEMessage.Text = "EMail Sent To: " + Server.HtmlEncode(emailaddress);
                    }
                }
            }
        }