/// <summary> /// 添加试卷 /// </summary> public ServiceInvokeDTO AddPaper(Paper paper) { log.Debug(Constant.DEBUG_START); ServiceInvokeDTO result = null; try { // Check user name //Paper dbPaper = paperDAL.GetByID(); //if (dbPaper == null) //{ // teacher.Password = SecurityUtil.MD5(teacher.Password + Constant.TEACHER_SALT_KEY); // teacherDAL.Insert(teacher); // result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS); //} //else //{ // result = new ServiceInvokeDTO(InvokeCode.ACCOUNT_TEACHER_ACCOUNT_EXIST_ERROR); //} } catch (Exception ex) { log.Error(ex); throw ex; } log.Debug(Constant.DEBUG_END); return result; }
/// <summary> /// 添加实体信息,返回添加成功后的主键ID /// </summary> public int Insert(Paper paper) { int id = 0; const string sql = @"INSERT INTO Paper(CourseID, PaperType, Name, Duration, AddPerson) VALUES (@CourseID, @PaperType, @Name, @Duration, @AddPerson); SELECT LAST_INSERT_ID();"; using (DbConnection connection = ConnectionManager.OpenConnection) { id = connection.Query<int>(sql, paper).SingleOrDefault<int>(); } return id; }
/// <summary> /// 更新实体信息 /// </summary> public void Update(Paper paper) { const string sql = @"UPDATE Paper SET PaperType = @PaperType, Name= @Name, Duration= @Duration WHERE IsDeleted = 0 AND ID = @ID"; using (DbConnection connection = ConnectionManager.OpenConnection) { connection.Execute(sql, paper); } }