12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using Cksoft.Data;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using DllEapEntity.Rms;
- using System.Linq;
- namespace DllEapDal
- {
- public class ProgramFileParamDal
- {
- private IDatabase CurrDb;
- public ProgramFileParamDal(IDatabase db)
- {
- CurrDb = db;
- }
- public IEnumerable<ProgramFileParams> Get(int start, int length, string order, string sort, string filter, string errorinfo)
- {
- var pros = CurrDb.FindListForCondition<ProgramFileParams>($" {filter} order by {sort} {order} limit {start - 1},{length}", ref errorinfo);
- return pros;
- }
- public int GetCount(string filter)
- {
- string sql = $"select count(1) from programfileparams a where 1=1 {filter}";
- return Convert.ToInt32(CurrDb.FindList<string>(sql).FirstOrDefault() ?? "0");
- }
- public ProgramFileParams Get(int id)
- {
- var pro = CurrDb.FindEntityFor<ProgramFileParams>(id);
- return pro;
- }
- /// <summary>
- /// 添加角色并返回角色Id
- /// </summary>
- /// <param name="role"></param>
- /// <param name="userCode"></param>
- /// <returns></returns>
- public int Add(int programId,IEnumerable<ProgramFileParams>pros, string userCode)
- {
- var sql = $"delete from ProgramFileParams where PreiD={programId}";
- CurrDb.ExecuteBySql(sql);
- if (pros != null && pros.Count() > 0)
- {
- foreach(var item in pros)
- {
- if (CurrDb.Insert(item) < 0)
- {
- return -1;
- }
- }
- }
- return 1;
- }
- public int Update(ProgramParamsDetail role, string userCode)
- {
- if (CurrDb.UpdateFor(role, userCode) < 0)
- {
- return -1;
- }
- return role.ID;
- }
- public int Delete(int id, ref string msg)
- {
- // 判断是否有产品正在使用该程序
- if (CurrDb.DeleteFor<ProgramParamsDetail>(id) < 0)
- {
- msg = "删除失败";
- return -1;
- }
- msg = string.Empty;
- return 1;
- }
- }
- }
|