public string SaveCurriculum(string jsonString, string action) { try { CurriculumInfoEntity entity = JsonConvert.DeserializeObject <CurriculumInfoEntity>(jsonString); CurriculumInfoManager manager = new CurriculumInfoManager(); if (action == "add") { manager.Insert(entity); } else { CurriculumInfoEntity oldEntity = manager.GetCurriculumInfoByCode(entity.Code); oldEntity.Name = entity.Name; oldEntity.Type = entity.Type; oldEntity.UpdateBy = SessionHelper.CurrentUser.Code; manager.Update(oldEntity); } return("success"); } catch (Exception e) { return(e.ToString()); } }
public List <CurriculumInfoEntity> GetSearch(string keyString, string sort, string order, int offset, int pageSize, out int total) { int pageCount = 0; string querySql = string.Format("select * from CurriculumInfo(nolock) where valid = 'T' and (code like '%{0}%' or name like '%{0}%')", keyString); DataTable dt = SplitPage.SqlSplitPage(querySql, string.Format("order by {0} {1}", sort, order), null, offset / pageSize, pageSize, out pageCount, out total); List <CurriculumInfoEntity> list = new List <CurriculumInfoEntity>(); foreach (DataRow dr in dt.Rows) { CurriculumInfoEntity entity = new CurriculumInfoEntity(); entity.CurriculumID = Ext.ToInt(dr["CurriculumID"]); entity.Code = Ext.ToString(dr["Code"]); entity.Name = Ext.ToString(dr["Name"]); entity.Type = Ext.ToString(dr["Type"]); entity.Score = Ext.ToIntOrNull(dr["Score"]); entity.StartTime = Ext.ToDateOrNull(dr["StartTime"]); entity.EndTime = Ext.ToDateOrNull(dr["EndTime"]); 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(CurriculumInfoEntity entity) { entity.UpdateTime = DateTime.Now; IDbSession session = SessionFactory.CreateSession(); try { session.BeginTrans(); Repository.Update <CurriculumInfoEntity>(session.Connection, entity, session.Transaction); session.Commit(); } catch (System.Exception) { session.Rollback(); throw; } finally { session.Dispose(); } }
public string PutCurriculumInfo(CurriculumInfoEntity entity) { try { if (entity == null) { return("error"); } CurriculumInfoManager manager = new CurriculumInfoManager(); entity.CreateTime = DateTime.Now; entity.CreateTime = DateTime.Now; manager.Update(entity); return("success"); } catch (Exception e) { return(e.ToString()); } }
public string DeleteCurriculumInfo(int id) { try { CurriculumInfoManager manager = new CurriculumInfoManager(); CurriculumInfoEntity entity = manager.GetCurriculumInfoByID(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()); } }