public List <StudentClassHistoryEntity> GetSearch(string sort, string order, int offset, int pageSize, out int total) { int pageCount = 0; string querySql = string.Format("select * from StudentClassHistory(nolock) where valid = 'T'"); DataTable dt = SplitPage.SqlSplitPage(querySql, string.Format("order by {0} {1}", sort, order), null, offset / pageSize, pageSize, out pageCount, out total); List <StudentClassHistoryEntity> list = new List <StudentClassHistoryEntity>(); foreach (DataRow dr in dt.Rows) { StudentClassHistoryEntity entity = new StudentClassHistoryEntity(); entity.ID = Ext.ToInt(dr["ID"]); entity.StudentID = Ext.ToInt(dr["StudentID"]); entity.ArrangeClassID = Ext.ToInt(dr["ArrangeClassID"]); entity.StartTime = Ext.ToDateOrNull(dr["StartTime"]); entity.EndTime = Ext.ToDateOrNull(dr["EndTime"]); entity.Score = Ext.ToIntOrNull(dr["Score"]); entity.IsAttend = Ext.ToString(dr["IsAttend"]); entity.IsPass = Ext.ToString(dr["IsPass"]); entity.Remark = Ext.ToString(dr["Remark"]); entity.Valid = Ext.ToString(dr["Valid"]); entity.CreateTime = Ext.ToDate(dr["CreateTime"]); entity.CreateBy = Ext.ToString(dr["CreateBy"]); entity.UpdateTime = Ext.ToDate(dr["UpdateTime"]); entity.UpdateBy = Ext.ToString(dr["UpdateBy"]); list.Add(entity); } return(list); }
public void Update(StudentClassHistoryEntity entity) { entity.UpdateTime = DateTime.Now; IDbSession session = SessionFactory.CreateSession(); try { session.BeginTrans(); Repository.Update <StudentClassHistoryEntity>(session.Connection, entity, session.Transaction); session.Commit(); } catch (System.Exception) { session.Rollback(); throw; } finally { session.Dispose(); } }
public string PostStudentClassHistory(StudentClassHistoryEntity entity) { try { if (entity == null || entity.ArrangeClassID <= 0 || entity.StudentID <= 0) { return("error"); } StudentClassHistoryManager manager = new StudentClassHistoryManager(); entity.CreateTime = DateTime.Now; entity.CreateTime = DateTime.Now; manager.Insert(entity); return("success"); } catch (Exception e) { return(e.ToString()); } }
public string PutStudentClassHistory(StudentClassHistoryEntity entity) { try { if (entity == null) { return("error"); } StudentClassHistoryManager manager = new StudentClassHistoryManager(); entity.CreateTime = DateTime.Now; entity.CreateTime = DateTime.Now; manager.Update(entity); return("success"); } catch (Exception e) { return(e.ToString()); } }
public string DeleteStudentClassHistory(int id) { try { StudentClassHistoryManager manager = new StudentClassHistoryManager(); StudentClassHistoryEntity entity = manager.GetStudentClassHistoryByID(id); if (entity != null) { entity.Valid = "F"; entity.CreateTime = DateTime.Now; entity.CreateTime = DateTime.Now; manager.Update(entity); } return("success"); } catch (Exception e) { return(e.ToString()); } }