123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using Cksoft.Data;
- using DllEapEntity;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace DllEapDal
- {
- public class PartMachineDal
- {
- private IDatabase CurrDb = null;
- private string commonFilter = null;
- public PartMachineDal(IDatabase db)
- {
- CurrDb = db;
- }
- public PartMachineDal(IDatabase db, string userCode)
- {
- CurrDb = db;
- //var smDal = new StaffMachineDal(CurrDb);
- //string errorinfo = string.Empty;
- //var idFilter = smDal.GetFilter(userCode, ref errorinfo);
- //commonFilter = idFilter;
- }
- public IEnumerable<PartMachine> Get(int start, int length, string order, string sort, string filter, string errorinfo)
- {
- var pros = CurrDb.FindListForCondition<PartMachine>($" {commonFilter + filter} order by {sort} {order} limit {start - 1},{length}", ref errorinfo);
- return pros;
- }
- public int GetCount(string filter)
- {
- string errorinfo = string.Empty;
- //string sql = $"select count(1) from ProgramRule a where 1=1 {filter}";
- var entities = CurrDb.FindListForCondition<PartMachine>(commonFilter + filter, ref errorinfo);
- if (entities != null)
- {
- return entities.Count();
- }
- return 0;
- }
- public PartMachine Get(int id)
- {
- var pro = CurrDb.FindEntityFor<PartMachine>(id);
- return pro;
- }
- public int DeleteMac(IEnumerable<int> funcIds, int roleId)
- {
- var sql = $"delete from PartMachine where partID={roleId} ";
- if (CurrDb.ExecuteBySql(sql) < 0)
- return -1;
- return 1;
- }
- public int Add(IEnumerable<int> funcIds, int macID, string[] pros, string[] employs, string[] qtypes, string usercode)
- {
- if (funcIds == null || funcIds.Count() <= 0)
- {
- return 1;
- }
- int count = 0;
- foreach (var item in funcIds)
- {
- var res = CurrDb.InsertFor<PartMachine>(new PartMachine()
- {
- machineID = item,
- partID = macID,
- programName = pros[count],
- employNum = employs[count],
- qtype = qtypes[count],
- RecTime = DateTime.Now,
- ModTime = DateTime.Now,
- ModCode = usercode,
- RecCode = usercode,
- }, usercode);
- if (res < 0)
- return -1;
- count++;
- }
- return 1;
- }
- }
- }
|