123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using Cksoft.Data;
- using DllEapEntity;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace DllEapDal
- {
- public class MachinetestmarkingDal
- {
- private IDatabase CurrDb = null;
- private string commonFilter = null;
- public MachinetestmarkingDal(IDatabase db)
- {
- CurrDb = db;
- }
- public MachinetestmarkingDal(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<MachineTestMarking> Get(int start, int length, string order, string sort, string filter, string errorinfo)
- {
- var pros = CurrDb.FindListForCondition<MachineTestMarking>($" {commonFilter + filter} order by {sort} {order} limit {start - 1},{length}", ref errorinfo);
- return pros;
- }
-
- public List<string> getParts(string filter, string errorinfo)
- {
- var pros = CurrDb.FindListForCondition<MachineTestMarking>($"{ filter}", ref errorinfo);
- List<string> list = new List<string>();
- foreach (MachineTestMarking item in pros)
- {
- list.Add(item.ParentFCode);
- }
- return list;
- }
- 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<MachineTestMarking>(commonFilter + filter, ref errorinfo);
- if (entities != null)
- {
- return entities.Count();
- }
- return 0;
- }
- public MachineTestMarking Get(int id)
- {
- var pro = CurrDb.FindEntityFor<MachineTestMarking>(id);
- return pro;
- }
- public int Delete(int id, ref string msg)
- {
- var sql = $"delete from Machinetestmarking where macID={id}";
- if (CurrDb.ExecuteBySql(sql) < 0)
- {
- msg = "删除已绑定该机台的相关员工数据时发生错误";
- return -1;
- }
- msg = string.Empty;
- return 1;
- }
- public int DeleteMac(IEnumerable<int> funcIds, int roleId)
- {
- var sql = $"delete from Machinetestmarking where macID={roleId} ";
- if (CurrDb.ExecuteBySql(sql) < 0)
- return -1;
- return 1;
- }
- public int Add(IEnumerable<int> funcIds, int macID, string usercode)
- {
- if (funcIds == null || funcIds.Count() <= 0)
- {
- return 1;
- }
- int count = 0;
- foreach (var item in funcIds)
- {
- var res = CurrDb.InsertFor<MachineTestMarking>(new MachineTestMarking()
- {
- parentID = item,
- macID = 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;
- }
- }
- }
|