12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using Models;
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DAL
- {
- /// <summary>
- /// 培训费用数据访问层
- /// </summary>
- public class TrainingExpensesService
- {
- List<TrainingExpenses> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<TrainingExpenses>.excuteSql(new TrainingExpenses(), "TrainingExpenses", sql, CommandType.Text, param);
- }
- TrainingExpenses excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<TrainingExpenses> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- {
- //返回null
- return null;
- }
- //返回单个对象
- return hdList[0];
- }
- public List<TrainingExpenses> GetAll()
- {
- return excuteSql(" select * from TrainingExpenses where isdel = 0 ");
- }
- public TrainingExpenses GetByCountry(string country)
- {
- return excuteType(string.Format(" select * from TrainingExpenses where isdel = 0 and country = '{0}' ",country));
- }
- public List<TrainingExpenses> GetLikeByCountry(string country)
- {
- return excuteSql(string.Format(" select * from TrainingExpenses where isdel = 0 and country like '%{0}%' ", country));
- }
- public bool Add(TrainingExpenses TE)
- {
- string sql = "insert into TrainingExpenses values(@continent,@country,@currency,@expense,@operationTime,@operationUser,@Isdel)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@continent",TE.continent),
- new SqlParameter("@country",TE.country),
- new SqlParameter("@currency",TE.currency),
- new SqlParameter("@expense",TE.expense),
- new SqlParameter("@operationTime",TE.operationTime),
- new SqlParameter("@operationUser",TE.operationUser),
- new SqlParameter("@Isdel","0")
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- }
- }
|