using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.Common; using System.Linq; using System.IO; using System.Xml; using WeiSha.Data; using WeiSha.Common; using Song.Entities; using Song.ServiceInterfaces; using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; namespace Song.ServiceImpls { public class TeacherCom : ITeacher { #region 教师管理 public int TeacherAdd(Teacher entity) { entity.Th_CrtTime = DateTime.Now; entity.Th_IsUse = true; Song.Entities.Organization org = Business.Do().OrganCurrent(); if (org != null) { entity.Org_ID = org.Org_ID; entity.Org_Name = org.Org_Name; } //如果账号为空 if (string.IsNullOrWhiteSpace(entity.Th_AccName)) { if (!string.IsNullOrWhiteSpace(entity.Th_PhoneMobi)) { entity.Th_AccName = entity.Th_PhoneMobi; } else { entity.Th_AccName = WeiSha.Common.Request.UniqueID(); } } //如果密码不为空 if (!string.IsNullOrWhiteSpace(entity.Th_Pw)) entity.Th_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(entity.Th_Pw).MD5; return Gateway.Default.Save(entity); } public void TeacherSave(Teacher entity){ //如果密码不为空 //if (string.IsNullOrWhiteSpace(entity.Th_Pw)) // entity.Th_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(entity.Th_Pw).MD5; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save(entity); //同步课程表中的教师名称 tran.Update(new Field[] { Course._.Th_Name }, new object[] { entity.Th_Name }, Course._.Th_ID == entity.Th_ID); //同步教师评价中的名称 tran.Update(new Field[] { TeacherComment._.Th_Name }, new object[] { entity.Th_Name }, TeacherComment._.Th_ID == entity.Th_ID); tran.Update(new Field[] { Accounts._.Ac_Sex, Accounts._.Ac_Birthday, Accounts._.Ac_IDCardNumber, Accounts._.Ac_Nation, Accounts._.Ac_Native }, new object[] { entity.Th_Sex, entity.Th_Birthday, entity.Th_IDCardNumber, entity.Th_Nation, entity.Th_Native }, Accounts._.Ac_ID == entity.Ac_ID); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } } public void TeacherDelete(int identify) { Song.Entities.Teacher th = this.TeacherSingle(identify); if (th == null) return; this.TeacherDelete(th); } public void TeacherDelete(string accname, int orgid) { Song.Entities.Teacher th = this.TeacherSingle(accname, orgid); if (th == null) return; this.TeacherDelete(th); } public void TeacherDelete(Teacher entity) { using (DbTrans tran = Gateway.Default.BeginTrans()) { TeacherDelete(entity, tran); } } public void TeacherDelete(Teacher entity, DbTrans tran) { if (tran == null) tran = Gateway.Default.BeginTrans(); try { tran.Delete(Teacher._.Th_ID == entity.Th_ID); tran.Delete(TeacherHistory._.Th_ID == entity.Th_ID); tran.Update(new Field[] { Accounts._.Ac_IsTeacher }, new object[] { false }, Accounts._.Ac_ID == entity.Ac_ID); tran.Commit(); if (!string.IsNullOrWhiteSpace(entity.Th_Photo)) WeiSha.WebControl.FileUpload.Delete("Teacher", entity.Th_Photo); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); tran.Dispose(); } Extend.LoginState.Accounts.Refresh(entity.Ac_ID); } public Teacher TeacherSingle(int identify) { return Gateway.Default.From().Where(Teacher._.Th_ID == identify).ToFirst(); } public Teacher TeacherSingle(string accname, int orgid) { WhereClip wc = new WhereClip(); if (orgid > 0) wc &= Teacher._.Org_ID == orgid; wc.And(Teacher._.Th_AccName == accname); return Gateway.Default.From().Where(wc).ToFirst(); } public Teacher TeacherSingle(string accname, string pw, int orgid) { pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(pw).MD5; WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(Teacher._.Org_ID == orgid); wc.And(Teacher._.Th_AccName == accname || Teacher._.Th_IDCardNumber == accname); wc.And(Teacher._.Th_Pw == pw); return Gateway.Default.From().Where(wc).ToFirst(); } /// /// 教师登录 /// /// 账号,或身份证,或手机 /// 密码 /// /// public Teacher TeacherLogin(string acc, string pw, int orgid) { WhereClip wc = Teacher._.Org_ID == orgid && Teacher._.Th_IsUse == true && Teacher._.Th_IsPass == true; wc.And(Teacher._.Th_Pw == new WeiSha.Common.Param.Method.ConvertToAnyValue(pw).MD5); Song.Entities.Teacher entity = null; if (entity == null) entity = Gateway.Default.From().Where(wc && Teacher._.Th_AccName == acc).ToFirst(); if (entity == null) entity = Gateway.Default.From().Where(wc && Teacher._.Th_PhoneMobi == acc).ToFirst(); if (entity == null) entity = Gateway.Default.From().Where(wc && Teacher._.Th_IDCardNumber == acc).ToFirst(); return entity; } public bool IsTeacherExist(int orgid, string accname) { Teacher mm = Gateway.Default.From() .Where(Teacher._.Org_ID == orgid && Teacher._.Th_AccName == accname).ToFirst(); if (mm == null) return false; //如果是一个已经存在的对象,则不匹配自己 mm = Gateway.Default.From() .Where(Teacher._.Org_ID == orgid && Teacher._.Th_AccName == accname && Teacher._.Th_ID != mm.Th_ID) .ToFirst(); return mm != null; } public bool IsTeacherExist(int orgid, Teacher entity) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(Teacher._.Org_ID == orgid); wc &= Teacher._.Th_ID != entity.Th_ID; wc.And(Teacher._.Th_AccName == entity.Th_AccName); int obj = Gateway.Default.Count(wc); return obj > 0; } public Teacher[] TeacherAll(int orgid, bool? isUse) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(Teacher._.Org_ID == orgid); if (isUse != null) wc.And(Teacher._.Th_IsUse == isUse); return Gateway.Default.From().Where(wc).OrderBy(Teacher._.Th_RegTime.Desc).ToArray(); } public Teacher[] TeacherCount(int orgid, bool? isUse, int count) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(Teacher._.Org_ID == orgid); if (isUse != null) wc.And(Teacher._.Th_IsUse == isUse); count = count > 0 ? count : int.MaxValue; return Gateway.Default.From().Where(wc).OrderBy(Teacher._.Th_RegTime.Desc).ToArray(count); } public int TeacherOfCount(int orgid, bool? isUse) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(Teacher._.Org_ID == orgid); if (isUse != null) wc.And(Teacher._.Th_IsUse == isUse); return Gateway.Default.Count(wc); } /// /// 导出Excel格式的教师信息 /// /// 导出文件的路径(服务器端) /// 机构id /// 教师分组id,小于0为全部 /// public string TeacherExport4Excel(string path, int orgid, int sortid) { HSSFWorkbook hssfworkbook = new HSSFWorkbook(); //xml配置文件 XmlDocument xmldoc = new XmlDocument(); string confing = WeiSha.Common.App.Get["ExcelInputConfig"].VirtualPath + "教师信息.xml"; xmldoc.Load(WeiSha.Common.Server.MapPath(confing)); XmlNodeList nodes = xmldoc.GetElementsByTagName("item"); //创建工作簿对象 ISheet sheet = hssfworkbook.CreateSheet("教师信息"); //sheet.DefaultColumnWidth = 30; //创建数据行对象 IRow rowHead = sheet.CreateRow(0); for (int i = 0; i < nodes.Count; i++) { string exExport = nodes[i].Attributes["export"] != null ? nodes[i].Attributes["export"].Value : ""; //是否导出 if (exExport.ToLower() == "false") continue; rowHead.CreateCell(i).SetCellValue(nodes[i].Attributes["Column"].Value); } //生成数据行 ICellStyle style_size = hssfworkbook.CreateCellStyle(); style_size.WrapText = true; WhereClip wc = Teacher._.Org_ID == orgid; if (sortid >= 0) wc.And(Teacher._.Ths_ID == sortid); Teacher[] Teachers = Gateway.Default.From().Where(wc).OrderBy(Teacher._.Th_RegTime.Desc).ToArray(); for (int i = 0; i < Teachers.Length; i++) Teachers[i].Th_Intro = WeiSha.Common.HTML.ClearTag(Teachers[i].Th_Intro); for (int i = 0; i < Teachers.Length; i++) { IRow row = sheet.CreateRow(i + 1); for (int j = 0; j < nodes.Count; j++) { Type type = Teachers[i].GetType(); System.Reflection.PropertyInfo propertyInfo = type.GetProperty(nodes[j].Attributes["Field"].Value); //获取指定名称的属性 object obj = propertyInfo.GetValue(Teachers[i], null); if (obj != null) { string exExport = nodes[j].Attributes["export"] != null ? nodes[j].Attributes["export"].Value : ""; //是否导出 if (exExport.ToLower() == "false") continue; string format = nodes[j].Attributes["Format"] != null ? nodes[j].Attributes["Format"].Value : ""; string datatype = nodes[j].Attributes["DataType"] != null ? nodes[j].Attributes["DataType"].Value : ""; string defvalue = nodes[j].Attributes["DefautValue"] != null ? nodes[j].Attributes["DefautValue"].Value : ""; string value = ""; switch (datatype) { case "date": DateTime tm = Convert.ToDateTime(obj); value = tm > DateTime.Now.AddYears(-100) ? tm.ToString(format) : ""; break; default: value = obj.ToString(); break; } if (defvalue.Trim() != "") { foreach (string s in defvalue.Split('|')) { string h = s.Substring(0, s.IndexOf("=")); string f = s.Substring(s.LastIndexOf("=") + 1); if (value == h) value = f; } } row.CreateCell(j).SetCellValue(value); } } } FileStream file = new FileStream(path, FileMode.Create); hssfworkbook.Write(file); file.Close(); return path; } public Teacher[] TeacherPager(int orgid, int size, int index, out int countSum) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(Teacher._.Org_ID == orgid); countSum = Gateway.Default.Count(wc); index = index > 0 ? index : 1; return Gateway.Default.From().Where(wc).OrderBy(Teacher._.Th_CrtTime.Desc).ToArray(size, (index - 1) * size); } public Teacher[] TeacherPager(int orgid, int thsid, bool? isUse, bool? isShow, string searName, int size, int index, out int countSum) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(Teacher._.Org_ID == orgid); if (thsid > 0) wc.And(Teacher._.Ths_ID == thsid); if (isUse != null) wc.And(Teacher._.Th_IsUse == (bool)isUse); if (isShow != null) wc.And(Teacher._.Th_IsShow == (bool)isShow); if (!string.IsNullOrWhiteSpace(searName) && searName.Trim() != "") wc.And(Teacher._.Th_Name.Like("%" + searName + "%")); countSum = Gateway.Default.Count(wc); index = index > 0 ? index : 1; return Gateway.Default.From().Where(wc).OrderBy(Teacher._.Th_CrtTime.Desc).ToArray(size, (index - 1) * size); } #endregion #region 教师分类 public void SortAdd(TeacherSort entity) { Song.Entities.Organization org = Business.Do().OrganCurrent(); if (org != null) { entity.Org_ID = org.Org_ID; entity.Org_Name = org.Org_Name; } //添加对象,并设置排序号 object obj = Gateway.Default.Max(TeacherSort._.Ths_Tax, TeacherSort._.Org_ID == org.Org_ID); entity.Ths_Tax = obj is int ? (int)obj + 1 : 0; Gateway.Default.Save(entity); } public void SortSave(TeacherSort entity) { using (DbTrans tran = Gateway.Default.BeginTrans()) { try { if (entity.Ths_IsDefault) { tran.Update(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { false }, TeacherSort._.Ths_ID != entity.Ths_ID && TeacherSort._.Org_ID == entity.Org_ID); } tran.Save(entity); tran.Update(new Field[] { Teacher._.Ths_Name }, new object[] { entity.Ths_Name }, Teacher._.Ths_ID == entity.Ths_ID); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } } public int SortDelete(int identify) { Teacher st = Gateway.Default.From().Where(Teacher._.Ths_ID == identify).ToFirst(); if (st != null) throw new WeiSha.Common.ExceptionForAlert("请先删除其所属的教师信息"); return Gateway.Default.Delete(TeacherSort._.Ths_ID == identify); } public TeacherSort SortSingle(int identify) { return Gateway.Default.From().Where(TeacherSort._.Ths_ID == identify).ToFirst(); } public TeacherSort SortDefault(int orgid) { return Gateway.Default.From().Where(TeacherSort._.Org_ID == orgid && TeacherSort._.Ths_IsDefault == true).ToFirst(); } public void SortSetDefault(int orgid, int identify) { using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Update(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { false }, TeacherSort._.Org_ID == orgid); tran.Update(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { true }, TeacherSort._.Ths_ID == identify); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } } public TeacherSort[] SortAll(int orgid, bool? isUse) { WhereClip wc = TeacherSort._.Org_ID == orgid; if (isUse != null) wc.And(TeacherSort._.Ths_IsUse == isUse); return Gateway.Default.From().Where(wc).OrderBy(TeacherSort._.Ths_Tax.Asc).ToArray(); } public TeacherSort[] SortCount(int orgid, bool? isUse, int count) { WhereClip wc = TeacherSort._.Org_ID == orgid; if (isUse != null) wc.And(TeacherSort._.Ths_IsUse == isUse); count = count > 0 ? count : int.MaxValue; return Gateway.Default.From().Where(wc).ToArray(count); } public TeacherSort Sort4Teacher(int studentId) { Teacher st = this.TeacherSingle(studentId); if (st == null) return null; return Gateway.Default.From().Where(TeacherSort._.Ths_ID == st.Ths_ID).ToFirst(); } public Teacher[] Teacher4Sort(int sortid, bool? isUse) { WhereClip wc = Teacher._.Ths_ID == sortid; if (isUse != null) wc.And(Teacher._.Th_IsUse == isUse); return Gateway.Default.From().Where(wc).ToArray(); } public bool SortIsExist(TeacherSort entity) { //如果是一个已经存在的对象,则不匹配自己 TeacherSort mm = Gateway.Default.From() .Where(TeacherSort._.Org_ID == entity.Org_ID && TeacherSort._.Ths_Name == entity.Ths_Name && TeacherSort._.Ths_ID != entity.Ths_ID) .ToFirst(); return mm != null; } public bool SortRemoveUp(int orgid, int id) { //当前对象 TeacherSort current = Gateway.Default.From().Where(TeacherSort._.Ths_ID == id).ToFirst(); //当前对象排序号 int orderValue = (int)current.Ths_Tax; ; //上一个对象,即兄长对象; TeacherSort up = Gateway.Default.From() .Where(TeacherSort._.Org_ID == orgid && TeacherSort._.Ths_Tax < orderValue) .OrderBy(TeacherSort._.Ths_Tax.Desc).ToFirst(); if (up == null) return false; //交换排序号 current.Ths_Tax = up.Ths_Tax; up.Ths_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save(current); tran.Save(up); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } return true; } public bool SortRemoveDown(int orgid, int id) { //当前对象 TeacherSort current = Gateway.Default.From().Where(TeacherSort._.Ths_ID == id).ToFirst(); //当前对象排序号 int orderValue = (int)current.Ths_Tax; //下一个对象,即弟弟对象; TeacherSort down = Gateway.Default.From() .Where(TeacherSort._.Org_ID == orgid && TeacherSort._.Ths_Tax > orderValue) .OrderBy(TeacherSort._.Ths_Tax.Asc).ToFirst(); if (down == null) return false; //交换排序号 current.Ths_Tax = down.Ths_Tax; down.Ths_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save(current); tran.Save(down); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } return true; } #endregion #region 教师履历管理 /// /// 添加教师 /// /// 业务实体 /// 如果已经存在该教师,则返回-1 public int HistoryAdd(TeacherHistory entity) { entity.Thh_CrtTime = DateTime.Now; return Gateway.Default.Save(entity); } /// /// 修改教师 /// /// 业务实体 public void HistorySave(TeacherHistory entity) { Gateway.Default.Save(entity); } /// /// 删除,按主键ID; /// /// 实体的主键 public void HistoryDelete(int identify) { Gateway.Default.Delete(TeacherHistory._.Thh_ID==identify); } /// /// 获取单一实体对象,按主键ID; /// /// 实体的主键 /// public TeacherHistory HistorySingle(int identify) { return Gateway.Default.From().Where(TeacherHistory._.Thh_ID == identify).ToFirst(); } /// /// 获取对象;即所有网站教师; /// /// public TeacherHistory[] HistoryAll(int thid) { WhereClip wc = TeacherHistory._.Th_ID == thid; return Gateway.Default.From().Where(wc).OrderBy(TeacherHistory._.Thh_StartTime.Asc).ToArray(); } /// /// 获取教师 /// /// 机构id /// /// /// public TeacherHistory[] HistoryCount(int thid, int count) { if (count < 1) return this.HistoryAll(thid); WhereClip wc = TeacherHistory._.Th_ID == thid; return Gateway.Default.From().Where(wc).OrderBy(TeacherHistory._.Thh_StartTime.Asc).ToArray(count); } #endregion #region 教师评价管理 /// /// 添加教师评价 /// /// 业务实体 /// public int CommentAdd(TeacherComment entity) { if (entity.Org_ID < 1) { Song.Entities.Organization org = Business.Do().OrganCurrent(); entity.Org_ID = org.Org_ID; } entity.Thc_CrtTime = DateTime.Now; entity.Thc_IP = WeiSha.Common.Request.IP.IPAddress; entity.Thc_Device = WeiSha.Common.Browser.IsMobile ? "Mobi" : "PC"; return Gateway.Default.Save(entity); } /// /// 修改教师评价信息 /// /// 业务实体 public void CommentSave(TeacherComment entity) { Gateway.Default.Save(entity); } /// /// 删除,按主键ID; /// /// 实体的主键 public void CommentDelete(int identify) { Gateway.Default.Delete(TeacherComment._.Thc_ID == identify); } /// /// 获取单一实体对象,按主键ID; /// /// 实体的主键 /// public TeacherComment CommentSingle(int identify) { return Gateway.Default.From().Where(TeacherComment._.Thc_ID == identify).ToFirst(); } /// /// 某天内,最近一次学员给教师的评价 /// /// 教师id /// 学员id /// 当前天数 /// public TeacherComment CommentSingle(int thid, int accid, int day) { WhereClip wc = new WhereClip(); if (thid > 0) wc.And(TeacherComment._.Th_ID == thid); if (accid > 0) wc.And(TeacherComment._.Ac_ID == accid); if (day > 0) { DateTime start = DateTime.Now.AddDays(-day); wc.And(TeacherComment._.Thc_CrtTime >= start); } return Gateway.Default.From().Where(wc).OrderBy(TeacherComment._.Thc_CrtTime.Desc).ToFirst(); } /// /// 计算教师的评分,从当前日期之前的多少天内 /// /// 评分教师的id /// 从当前日期之前的多少天内,小于或等于0表示取所有 /// public double CommentScore(int thid, int day) { DateTime end = DateTime.Now; DateTime start = end.AddDays(-day); return CommentScore(thid, start, end); } /// /// 计算教师的评分,通过起始时间 /// /// 评分教师的id /// 开始时间 /// 结束时间 /// public double CommentScore(int thid, DateTime? start, DateTime? end) { WhereClip wc = new WhereClip(); wc.And(TeacherComment._.Thc_IsUse == true); if (thid > 0) wc.And(TeacherComment._.Th_ID == thid); if (start != null) wc.And(TeacherComment._.Thc_CrtTime > (DateTime)start); if (end != null) wc.And(TeacherComment._.Thc_CrtTime <= (DateTime)end); // object obj = Gateway.Default.Avg(TeacherComment._.Thc_Score, wc); if (obj == null) return 0; double avg = 0; double.TryParse(obj.ToString(), out avg); return avg; } /// /// 获取教师的评价 /// /// 教师id /// /// /// public TeacherComment[] CommentCount(int thid, bool? isUse, bool? isShow, int count) { WhereClip wc = new WhereClip(); if (thid > 0) wc.And(TeacherComment._.Th_ID == thid); if (isUse != null) wc.And(TeacherComment._.Thc_IsUse == (bool)isUse); if (isShow != null) wc.And(TeacherComment._.Thc_IsShow == (bool)isShow); return Gateway.Default.From().Where(wc).OrderBy(TeacherComment._.Thc_CrtTime.Desc).ToArray(count); } /// /// 教师评分排行 /// /// /// /// /// 获取个数 /// public TeacherComment[] CommentOrder(int orgid, bool? isUse, bool? isShow, int day, int count) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(TeacherComment._.Org_ID == orgid); if (isUse != null) wc.And(TeacherComment._.Thc_IsUse == (bool)isUse); if (isShow != null) wc.And(TeacherComment._.Thc_IsShow == (bool)isShow); //时间区间 if (day > 0) { DateTime end = DateTime.Now; DateTime start = end.AddDays(-day); if (start != null) wc.And(TeacherComment._.Thc_CrtTime > (DateTime)start); if (end != null) wc.And(TeacherComment._.Thc_CrtTime <= (DateTime)end); } TeacherComment[] tcs=Gateway.Default.From() .Select(TeacherComment._.Th_Name, TeacherComment._.Thc_Score.Avg()) .GroupBy(TeacherComment._.Th_Name.Group).Where(wc).OrderBy(new OrderByClip("Thc_Score desc")).ToArray(count); foreach (TeacherComment t in tcs) { t.Thc_Score = Math.Round(t.Thc_Score * 100) / 100; } return tcs; } /// /// 某天内,学员给教师的评价数 /// /// 教师id /// 学员id /// 当前天数 /// public int CommentOfCount(int thid, int accid, int day) { WhereClip wc = new WhereClip(); if (thid > 0) wc.And(TeacherComment._.Th_ID == thid); if (accid > 0) wc.And(TeacherComment._.Ac_ID == accid); if (day > 0) { DateTime start = DateTime.Now.AddDays(-day); wc.And(TeacherComment._.Thc_CrtTime >= start); } return Gateway.Default.Count(wc); } public TeacherComment[] CommentPager(int orgid, bool? isUse, bool? isShow, int size, int index, out int countSum) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(TeacherComment._.Org_ID == orgid); if (isUse != null) wc.And(TeacherComment._.Thc_IsUse == (bool)isUse); if (isShow != null) wc.And(TeacherComment._.Thc_IsShow == (bool)isShow); countSum = Gateway.Default.Count(wc); index = index > 0 ? index : 1; return Gateway.Default.From().Where(wc).OrderBy(TeacherComment._.Thc_CrtTime.Desc).ToArray(size, (index - 1) * size); } /// /// 当前机构下某个教师的评价信息 /// /// /// 教师id /// /// /// /// /// /// public TeacherComment[] CommentPager(int orgid, int thid, bool? isUse, bool? isShow, int size, int index, out int countSum) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(TeacherComment._.Org_ID == orgid); if (thid > 0) wc.And(TeacherComment._.Th_ID == thid); if (isUse != null) wc.And(TeacherComment._.Thc_IsUse == (bool)isUse); if (isShow != null) wc.And(TeacherComment._.Thc_IsShow == (bool)isShow); countSum = Gateway.Default.Count(wc); index = index > 0 ? index : 1; return Gateway.Default.From().Where(wc).OrderBy(TeacherComment._.Thc_CrtTime.Desc).ToArray(size, (index - 1) * size); } /// /// 当前机构下某个教师的评价信息 /// /// /// 教师姓名 /// /// /// /// /// /// public TeacherComment[] CommentPager(int orgid, string thname, bool? isUse, bool? isShow, int size, int index, out int countSum) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(TeacherComment._.Org_ID == orgid); if (!string.IsNullOrWhiteSpace(thname)) wc.And(TeacherComment._.Th_Name == thname); if (isUse != null) wc.And(TeacherComment._.Thc_IsUse == (bool)isUse); if (isShow != null) wc.And(TeacherComment._.Thc_IsShow == (bool)isShow); countSum = Gateway.Default.Count(wc); index = index > 0 ? index : 1; return Gateway.Default.From().Where(wc).OrderBy(TeacherComment._.Thc_CrtTime.Desc).ToArray(size, (index - 1) * size); } #endregion } }