/// <summary> /// 保存安全问题 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSafeQues_Click(object sender, EventArgs e) { Song.Entities.Teacher obj = Extend.LoginState.Accounts.Teacher; obj = this.EntityFill(obj) as Song.Entities.Teacher; Business.Do <ITeacher>().TeacherSave(obj); this.Alert("操作成功!"); }
protected override void InitPageTemplate(HttpContext context) { if (Request.ServerVariables["REQUEST_METHOD"] == "GET") { Song.Entities.Teacher th = Business.Do <ITeacher>().TeacherSingle(thid); this.Document.SetValue("teacher", th); } //此页面的ajax提交,全部采用了POST方式 if (Request.ServerVariables["REQUEST_METHOD"] == "POST") { int size = WeiSha.Common.Request.Form["size"].Int32 ?? 10; //每页多少条 int index = WeiSha.Common.Request.Form["index"].Int32 ?? 1; //第几页 int sumcount = 0; Song.Entities.TeacherComment[] comments = null; comments = Business.Do <ITeacher>().CommentPager(-1, thid, true, true, size, index, out sumcount); string json = "{\"size\":" + size + ",\"index\":" + index + ",\"sumcount\":" + sumcount + ","; json += "\"items\":["; for (int i = 0; i < comments.Length; i++) { comments[i].Thc_Comment = Server.UrlEncode(comments[i].Thc_Comment); comments[i].Thc_Reply = Server.UrlEncode(comments[i].Thc_Reply); json += comments[i].ToJson() + ","; } if (json.EndsWith(",")) { json = json.Substring(0, json.Length - 1); } json += "]}"; Response.Write(json); Response.End(); } }
/// <summary> /// 修改密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEnter_Click(object sender, EventArgs e) { Song.Entities.Teacher obj = Extend.LoginState.Accounts.Teacher; try { string pw = this.tbOldPw.Text.Trim(); obj = Business.Do <ITeacher>().TeacherSingle(obj.Th_AccName, pw, obj.Org_ID); this.lbShow.Visible = obj == null; if (obj == null) { return; } //员工登录密码,为空 if (tbPw1.Text != "") { string md5 = WeiSha.Common.Request.Controls[tbPw1].MD5; obj.Th_Pw = md5; } Business.Do <ITeacher>().TeacherSave(obj); this.Alert("操作成功!"); } catch (Exception ex) { Message.ExceptionShow(ex); } }
protected void btnEnter_Click(object sender, EventArgs e) { Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher; //将界面中的录入,填充到实体 th = this.EntityFill(th) as Song.Entities.Teacher; Business.Do <ITeacher>().TeacherSave(th); }
protected override void InitPageTemplate(HttpContext context) { //教师 int id = WeiSha.Common.Request.QueryString["id"].Int32 ?? 0; Song.Entities.Teacher th = Business.Do <ITeacher>().TeacherSingle(id); if ((WeiSha.Common.Request.Cookies["Teacher_" + th.Th_ID].Int32 ?? 0) == 0) { th.Th_ViewNum++; Business.Do <ITeacher>().TeacherSave(th); context.Response.Cookies["Teacher_" + th.Th_ID].Value = th.Th_ID.ToString(); } th.Th_Photo = Upload.Get["Teacher"].Virtual + th.Th_Photo; this.Document.Variables.SetValue("th", th); //教师的履历 Song.Entities.TeacherHistory[] history = Business.Do <ITeacher>().HistoryAll(th.Th_ID); this.Document.Variables.SetValue("history", history); //教师的课程 List <Song.Entities.Course> courses = Business.Do <ICourse>().CourseCount(-1, -1, th.Th_ID, -1, null, true, -1); for (int i = 0; i < courses.Count; i++) { Song.Entities.Course c = courses[i]; c.Cou_LogoSmall = Upload.Get["Course"].Virtual + c.Cou_LogoSmall; c.Cou_Logo = Upload.Get["Course"].Virtual + c.Cou_Logo; } this.Document.Variables.SetValue("courses", courses); }
protected override void InitPageTemplate(HttpContext context) { //当前课程信息 int id = WeiSha.Common.Request.QueryString["id"].Int32 ?? 0; Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(id); if (cou == null) { return; } if ((WeiSha.Common.Request.Cookies["Course_" + cou.Cou_ID].Int32 ?? 0) == 0) { cou.Cou_ViewNum++; Business.Do <ICourse>().CourseSave(cou); context.Response.Cookies["Course_" + cou.Cou_ID].Value = cou.Cou_ID.ToString(); } cou.Cou_Logo = Upload.Get["Course"].Virtual + cou.Cou_Logo; cou.Cou_LogoSmall = Upload.Get["Course"].Virtual + cou.Cou_LogoSmall; //是否免费,或是限时免费 if (cou.Cou_IsLimitFree) { DateTime freeEnd = cou.Cou_FreeEnd.AddDays(1).Date; if (!(cou.Cou_FreeStart <= DateTime.Now && freeEnd >= DateTime.Now)) { cou.Cou_IsLimitFree = false; } } this.Document.Variables.SetValue("course", cou); //是否学习当前课程 if (this.Account != null) { //是否购买 isBuy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, cou.Cou_ID); this.Document.Variables.SetValue("isStudy", isBuy); } //课程章节列表 outline = Business.Do <IOutline>().OutlineAll(cou.Cou_ID, true); this.Document.Variables.SetValue("Outline", outline); //树形章节输出 if (outline.Length > 0) { this.Document.Variables.SetValue("olTree", Business.Do <IOutline>().OutlineTree(outline)); } //课程公告 Song.Entities.Guide[] guides = Business.Do <IGuide>().GuideCount(-1, cou.Cou_ID, -1, 20); this.Document.Variables.SetValue("guides", guides); //当前课程的主讲老师 Song.Entities.Teacher teacher = Business.Do <ITeacher>().TeacherSingle(cou.Th_ID); if (teacher != null) { teacher.Th_Photo = string.IsNullOrWhiteSpace(teacher.Th_Photo) ? null : Upload.Get["Teacher"].Virtual + teacher.Th_Photo; this.Document.Variables.SetValue("th", teacher); } //学习该课程的总人数,包括已经过期的 int studyCount = Business.Do <ICourse>().CourseStudentSum(cou.Cou_ID, null); this.Document.Variables.SetValue("studyCount", studyCount); }
private void fill() { Song.Entities.Teacher th = id == 0 ? Extend.LoginState.Accounts.Teacher : Business.Do <ITeacher>().TeacherSingle(id); if (th == null) { return; } this.EntityBind(th); }
/// <summary> /// 接收评价信息 /// </summary> private void submit() { string json = string.Empty; //评分、评价 int num = WeiSha.Common.Request.Form["num"].Int32 ?? 0; string txt = WeiSha.Common.Request.Form["txt"].UrlDecode; //学员ID if (!Extend.LoginState.Accounts.IsLogin) { json = "{\"success\":\"0\",\"msg\":\"学员未登录!\"}"; Response.Write(json); } else { int accid = Extend.LoginState.Accounts.UserID; //每天只允许评价一次 int count = Business.Do <ITeacher>().CommentOfCount(thid, accid, day); if (count > 0) { json = "{\"success\":\"0\",\"msg\":\"每天只能评价一次!\"}"; } else { Song.Entities.TeacherComment cmt = new Entities.TeacherComment(); cmt.Thc_Score = num; cmt.Thc_Comment = txt; cmt.Th_ID = thid; Song.Entities.Teacher th = Business.Do <ITeacher>().TeacherSingle(thid); if (th != null) { cmt.Th_Name = th.Th_Name; } cmt.Ac_ID = accid; cmt.Thc_IsShow = true; cmt.Thc_IsUse = true; try { Business.Do <ITeacher>().CommentAdd(cmt); json = "{\"success\":\"1\"}"; } catch (Exception ex) { string msg = ex.Message.Replace("\r", ""); msg = msg.Replace("\n", ""); json = "{\"success\":\"0\",\"msg\":\"" + msg + "\"}"; } } Response.Write(json); } }
protected override void InitPageTemplate(HttpContext context) { //当前课程信息 int id = WeiSha.Common.Request.QueryString["id"].Int32 ?? 0; Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(id); if (cou == null) { return; } if ((WeiSha.Common.Request.Cookies["Course_" + cou.Cou_ID].Int32 ?? 0) == 0) { cou.Cou_ViewNum++; Business.Do <ICourse>().CourseSave(cou); context.Response.Cookies["Course_" + cou.Cou_ID].Value = cou.Cou_ID.ToString(); } cou.Cou_Logo = Upload.Get["Course"].Virtual + cou.Cou_Logo; cou.Cou_LogoSmall = Upload.Get["Course"].Virtual + cou.Cou_LogoSmall; this.Document.Variables.SetValue("course", cou); //是否学习当前课程 if (this.Account != null) { //是否购买 isBuy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, cou.Cou_ID); this.Document.Variables.SetValue("isStudy", isBuy); //是否在试用中 bool istry = Business.Do <ICourse>().IsTryout(cou.Cou_ID, this.Account.Ac_ID); this.Document.Variables.SetValue("isTry", istry); } //课程章节列表 outline = Business.Do <IOutline>().OutlineAll(cou.Cou_ID, true); this.Document.Variables.SetValue("Outline", outline); //树形章节输出 this.Document.Variables.SetValue("olTree", buildOutlineHtml(outline, 0, 0, "")); //课程公告 Song.Entities.Guide[] guides = Business.Do <IGuide>().GuideCount(-1, cou.Cou_ID, -1, 20); this.Document.Variables.SetValue("guides", guides); //当前课程的主讲老师 Song.Entities.Teacher teacher = Business.Do <ITeacher>().TeacherSingle(cou.Th_ID); if (teacher != null) { teacher.Th_Photo = string.IsNullOrWhiteSpace(teacher.Th_Photo) ? null : Upload.Get["Teacher"].Virtual + teacher.Th_Photo; this.Document.Variables.SetValue("th", teacher); } //学习该课程的总人数,包括已经过期的 int studyCount = Business.Do <ICourse>().CourseStudentSum(cou.Cou_ID, null); this.Document.Variables.SetValue("studyCount", studyCount); }
protected override void InitPageTemplate(HttpContext context) { Song.Entities.Teacher teacher = this.Teacher; if (teacher == null) { context.Response.Redirect("index.ashx"); return; } this.Document.Variables.SetValue("CurrUser", teacher); //是否启用或能过审核 bool isEnable = teacher.Th_IsPass && teacher.Th_IsUse; this.Document.Variables.SetValue("isEnable", isEnable); }
protected override void InitPageTemplate(HttpContext context) { Song.Entities.Course currCourse = Extend.LoginState.Accounts.Course(); if (currCourse == null) { return; } //当前课程主负责老师 Song.Entities.Teacher th = Business.Do <ITeacher>().TeacherSingle(currCourse.Th_ID); if (th != null) { th.Th_Photo = string.IsNullOrWhiteSpace(th.Th_Photo) ? null : Upload.Get[thPath].Virtual + th.Th_Photo; this.Document.SetValue("th", th); } this.Document.RegisterGlobalFunction(this.getCommentScore); //计算教师的平均分 }
private void fill() { Song.Entities.Teacher th = id == 0 ? Extend.LoginState.Accounts.Teacher : Business.Do <ITeacher>().TeacherSingle(id); if (th == null) { return; } this.EntityBind(th); //出生年月 Th_Birthday.Text = th.Th_Birthday < DateTime.Now.AddYears(-100) ? "" : th.Th_Birthday.ToString("yyyy-MM-dd"); //个人照片 if (!string.IsNullOrEmpty(th.Th_Photo) && th.Th_Photo.Trim() != "") { this.imgShow.Src = Upload.Get[_uppath].Virtual + th.Th_Photo; } }
protected override void InitPageTemplate(HttpContext context) { //教师 int id = WeiSha.Common.Request.QueryString["id"].Int32 ?? 0; Song.Entities.Teacher th = Business.Do <ITeacher>().TeacherSingle(id); if (th == null) { return; } if ((WeiSha.Common.Request.Cookies["Teacher_" + th.Th_ID].Int32 ?? 0) == 0) { th.Th_ViewNum++; Business.Do <ITeacher>().TeacherSave(th); context.Response.Cookies["Teacher_" + th.Th_ID].Value = th.Th_ID.ToString(); } th.Th_Photo = Upload.Get["Teacher"].Virtual + th.Th_Photo; this.Document.Variables.SetValue("th", th); //教师的履历 Song.Entities.TeacherHistory[] history = Business.Do <ITeacher>().HistoryAll(th.Th_ID); this.Document.Variables.SetValue("history", history); //教师的课程 List <Song.Entities.Course> courses = Business.Do <ICourse>().CourseCount(-1, -1, th.Th_ID, -1, null, true, -1); for (int i = 0; i < courses.Count; i++) { Song.Entities.Course c = courses[i]; c.Cou_LogoSmall = Upload.Get["Course"].Virtual + c.Cou_LogoSmall; c.Cou_Logo = Upload.Get["Course"].Virtual + c.Cou_Logo; } this.Document.Variables.SetValue("courses", courses); //老师列表 Tag thTag = this.Document.GetChildTagById("teachers"); if (thTag != null) { int thCount = int.Parse(thTag.Attributes.GetValue("count", "10")); Song.Entities.Teacher[] teachers = Business.Do <ITeacher>().TeacherCount(this.Organ.Org_ID, true, thCount); foreach (Song.Entities.Teacher c in teachers) { c.Th_Photo = Upload.Get["Teacher"].Virtual + c.Th_Photo; } this.Document.SetValue("teachers", teachers); } }
protected void btnEnter_Click(object sender, EventArgs e) { Song.Entities.Teacher th = Extend.LoginState.Accounts.Teacher; th = this.EntityFill(th) as Song.Entities.Teacher; if (th.Th_Birthday > DateTime.Now.AddYears(-100)) { th.Th_Age = Convert.ToInt32((DateTime.Now - th.Th_Birthday).TotalDays / 365); //th.Th_Age = DateTime.Now.Year - th.Th_Birthday.Year; } //图片 if (fuLoad.PostedFile.FileName != "") { try { fuLoad.UpPath = _uppath; fuLoad.IsMakeSmall = false; fuLoad.IsConvertJpg = true; fuLoad.SaveAndDeleteOld(th.Th_Photo); fuLoad.File.Server.ChangeSize(150, 200, false); th.Th_Photo = fuLoad.File.Server.FileName; // imgShow.Src = fuLoad.File.Server.VirtualPath; } catch (Exception ex) { this.Alert(ex.Message); } } try { Business.Do <ITeacher>().TeacherSave(th); this.Alert("操作完成"); this.JsFunction("top.setPhoto", imgShow.Src); } catch (Exception ex) { this.Alert(ex.Message); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent(); int sum = 0; Song.Entities.Teacher[] teachers = Business.Do <ITeacher>().TeacherPager(org.Org_ID, -1, true, true, "", size, index, out sum); string tm = "{\"sum\":" + sum + ",\"index\":" + index + ",\"object\":["; for (int i = 0; i < teachers.Length; i++) { Song.Entities.Teacher t = teachers[i]; t.Th_Photo = Upload.Get["Teacher"].Virtual + t.Th_Photo; t.Th_Intro = ""; tm += "" + t.ToJson(); if (i < teachers.Length - 1) { tm += ","; } } tm += "]}"; context.Response.Write(tm); }
protected override void OnInitComplete(EventArgs e) { //插入相应的Javascript脚本; string scriptPath = "~/Manage/CoreScripts/"; scriptPath = this.ResolveUrl(scriptPath); //脚本集 string[] scriptFile = new string[] { "jquery.js", "GridView.js", "Extend.js", "PageExt.js", "Verify.js", "HoldMode.js" }; Page.Header.Controls.Add(new System.Web.UI.LiteralControl("\r\n")); foreach (string file in scriptFile) { Page.Header.Controls.Add(new System.Web.UI.LiteralControl("<script type=\"text/javascript\" src=\"" + scriptPath + file + "?ver=" + version + "\"></script>\r\n")); } //插入对应的css文件与js文件 string name = WeiSha.Common.Request.Page.Name; if (System.IO.File.Exists(WeiSha.Common.Request.Page.PhysicsPath + "styles/public.css")) { Page.Header.Controls.Add(new System.Web.UI.LiteralControl("<link href=\"styles/public.css?ver=" + version + "\" type=\"text/css\" rel=\"stylesheet\" />\r\n")); } //字体库 Page.Header.Controls.Add(new System.Web.UI.LiteralControl("<link href=\"/Utility/iconfont/iconfont.css?ver=" + version + "\" type=\"text/css\" rel=\"stylesheet\" />\r\n")); if (System.IO.File.Exists(WeiSha.Common.Request.Page.PhysicsPath + "styles/" + name + ".css")) { Page.Header.Controls.Add(new System.Web.UI.LiteralControl("<link href=\"styles/" + name + ".css?ver=" + version + "\" type=\"text/css\" rel=\"stylesheet\" />\r\n")); } if (System.IO.File.Exists(WeiSha.Common.Request.Page.PhysicsPath + "scripts/" + name + ".js")) { Page.Header.Controls.Add(new System.Web.UI.LiteralControl("<script type=\"text/javascript\" src=\"scripts/" + name + ".js?ver=" + version + "\"></script>\r\n")); } //Response.Write(Extend.ManageSession.Session.Name); #region 验证是否登录 //如果处于管理登录状态 if (LoginState.Admin.IsLogin) { //重新写入session LoginState.Admin.Write(); //判断权限 LoginState.Admin.VerifyPurview(); //记录操作 if (!this.IsPostBack) { bool isWorkLogs = Business.Do <ISystemPara>()["SysIsWorkLogs"].Boolean ?? true; if (Extend.LoginState.Admin.isForRoot) { if (isWorkLogs) { Business.Do <ILogs>().AddOperateLogs(); } } } } else { //如果处于学员登录状态 if (LoginState.Accounts.IsLogin) { //当前页面所在的功能模块名称;即相对于/Manage文件夹的路径,因为每一个模块在Manage目录下是一个单独目录 string module = WeiSha.Common.Request.Page.Module; if (module.ToLower() != "student") { Song.Entities.Teacher th = LoginState.Accounts.Teacher; if (th == null) { Response.Write("未登录,或不具有操作权限。"); Response.End(); } } } else { Response.Write("未登录,或同一账号在异地登录,当前登录状态被取消。"); Response.End(); } } //catch (System.Data.DataException ex) //{ // Message.ExceptionShow(ex); //} //catch (NBear.Common.ExceptionForNoLogin ex) //{ // Message.ExceptionShow(ex); //} //catch (NBear.Common.ExceptionForLicense ex) //{ // Message.License(ex.Message); //} //catch (Exception ex) //{ // Message.ExceptionShow(ex); //} #endregion //this.Form.Attributes.Add("onsubmit", "this.action=document.location.href"); base.OnInitComplete(e); }
/// <summary> /// 教师注册的验证 /// </summary> private void mobiregister_verify() { string vname = WeiSha.Common.Request.Form["vname"].String; string imgCode = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码 string userCode = WeiSha.Common.Request.Form["vcode"].MD5; //取输入的验证码 string phone = WeiSha.Common.Request.Form["phone"].String; //输入的手机号 string sms = WeiSha.Common.Request.Form["sms"].MD5; //输入的短信验证码 string name = WeiSha.Common.Request.Form["name"].String; //姓名 string email = WeiSha.Common.Request.Form["email"].String; //邮箱 string qq = WeiSha.Common.Request.Form["qq"].String; //qq string idcard = WeiSha.Common.Request.Form["idcard"].String; //身份证号 string intro = WeiSha.Common.Request.Form["intro"].Text; //简介 //验证图片验证码 if (imgCode != userCode) { Response.Write("{\"success\":\"-1\",\"state\":\"1\"}"); //图片验证码不正确 return; } //验证手机号是否存在 Song.Entities.Accounts curr = Extend.LoginState.Accounts.CurrentUser; if (curr == null) { Response.Write("{\"success\":\"-1\",\"state\":\"4\"}"); //当前账号未登录; return; } if (phone != curr.Ac_MobiTel1 && phone != curr.Ac_MobiTel2) { Song.Entities.Accounts acc = Business.Do <IAccounts>().IsAccountsExist(-1, phone, 1); if (acc != null) { Response.Write("{\"success\":\"-1\",\"state\":\"2\"}"); //手机号已经存在 return; } } //验证短信验证码 bool isSmsCode = true; //是否短信验证; string smsCode = WeiSha.Common.Request.Cookies["reg_mobi_" + vname].ParaValue; if (isSmsCode && sms != smsCode) { Response.Write("{\"success\":\"-1\",\"state\":\"3\"}"); //短信验证失败 return; } else { Song.Entities.Accounts tmp = Extend.LoginState.Accounts.CurrentUser; tmp.Ac_IsTeacher = true; //当前账户有了教师身份 tmp.Ac_MobiTel2 = phone; Business.Do <IAccounts>().AccountsSave(tmp); //创建教师账户 Song.Entities.Teacher th = Business.Do <IAccounts>().GetTeacher(curr.Ac_ID, null); if (th == null) { th = new Entities.Teacher(); } th.Ac_ID = tmp.Ac_ID; //关联学员账户 th.Ac_UID = tmp.Ac_UID; th.Th_PhoneMobi = phone; //教师手机号,基本账号中已经有记录,此处再记一次 th.Th_Name = name; //教师的名称 th.Th_IDCardNumber = idcard; //教师的身份证号 th.Th_Email = email; th.Th_Qq = qq; th.Th_Intro = intro; //教师的简介 //如果需要审核通过 WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config); th.Th_IsPass = !(bool)(config["IsVerifyTeahcer"].Value.Boolean ?? true); th.Th_IsUse = th.Th_IsPass; if (th.Th_ID < 1) { int id = Business.Do <ITeacher>().TeacherAdd(th); } else { Business.Do <ITeacher>().TeacherSave(th); } //注册成功,以下为判断是否审核通过 if (th.Th_IsPass) { LoginState.Accounts.Write(tmp); Response.Write("{\"success\":\"1\",\"name\":\"" + th.Th_Name + "\",\"state\":\"1\"}"); } else { //注册成功,但待审核 Response.Write("{\"success\":\"1\",\"name\":\"" + th.Th_Name + "\",\"state\":\"0\"}"); } } }