123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using WMS.Info;
- using WMS.Util;
- namespace WMS.Core
- {
- public class BaseSupplier
- {
- /// <summary>
- /// 获取列表数据
- /// <summary>
- /// <returns></returns>
- public IEnumerable<BASE_SUPPLIER> GetList(string keyword)
- {
- try
- {
- return SysDbCore.GetDbCtx().Queryable<BASE_SUPPLIER>().Where(it => it.F_ISDELETE == 0).WhereIF(!keyword.IsEmpty(), it => it.F_NO.Contains(keyword) || it.F_NAME.Contains(keyword)).ToList();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取列表数据
- /// <summary>
- /// <returns></returns>
- public IEnumerable<BASE_SUPPLIER> GetListByNo(ViewParams queryJson)
- {
- SqlSugarClient client = null;
- try
- {
- client = SysDbCore.GetDbCtx();
- var db = client.Queryable<BASE_SUPPLIER>().Where(it => it.F_ISDELETE == 0);
- if (queryJson != null)
- {
- if (!string.IsNullOrEmpty(queryJson.txt_Supper))
- {
- db.Where(v => v.F_NO.Contains(queryJson.txt_Supper));
- }
- }
- return db.ToList();
-
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally { client.Dispose(); }
- }
- /// <summary>
- /// 获取分页数据
- /// <summary>
- /// <returns></returns>
- public IEnumerable<BASE_SUPPLIER> GetPageList(string keyword, Pagination pagination)
- {
- try
- {
- int count = 0;
- var db = SysDbCore.GetDbCtx().Queryable<BASE_SUPPLIER>().Where(it => it.F_ISDELETE == 0).WhereIF(!keyword.IsEmpty(), it => it.F_NO.Contains(keyword) || it.F_NAME.Contains(keyword));
- List<BASE_SUPPLIER> list = null;
- if (pagination.sord.ToUpper() == "ASC")
- {
- list = db.OrderBy(pagination.sidx).ToPageList(pagination.page, pagination.rows, ref count);
- }
- else
- {
- string orderstr = pagination.sidx + " desc";
- list = db.OrderBy(orderstr).ToPageList(pagination.page, pagination.rows, ref count);
- }
- pagination.records = count;
- return list;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public BASE_SUPPLIER GetEntity(string keyValue)
- {
- try
- {
- return SysDbCore.GetDbCtx().Queryable<BASE_SUPPLIER>().Where(it => it.F_ISDELETE == 0 && it.F_NO == keyValue).First();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DeleteEntity(string keyValue)
- {
- try
- {
- //SysDbCore.GetDbCtx().Deleteable<BASE_SUPPLIER>().Where(it => it.F_NO == keyValue).ExecuteCommand();
- SysDbCore.GetDbCtx().Updateable<BASE_SUPPLIER>().UpdateColumns(it => new BASE_SUPPLIER { F_ISDELETE = 1 }).Where(it => it.F_NO == keyValue).ExecuteCommand();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void SaveEntity(LoginUserInfo loginUserInfo, string keyValue, BASE_SUPPLIER entity)
- {
- try
- {
- if (entity == null)
- {
- throw SysExCore.ThrowFailException("输入数据为空。");
- }
- if (string.IsNullOrWhiteSpace(entity.F_NO))
- {
- throw SysExCore.ThrowFailException("编码为空。");
- }
- if (string.IsNullOrWhiteSpace(entity.F_NAME))
- {
- throw SysExCore.ThrowFailException("名称为空。");
- }
- entity.F_EDITTIME = DateTime.Now;
- entity.F_EDITUSERNO = loginUserInfo.UserNo;
- if (string.IsNullOrEmpty(keyValue))
- {
- var item = SysDbCore.GetDbCtx().Queryable<BASE_SUPPLIER>().First(v => v.F_NO == entity.F_NO);
- if (item != null)
- {
- throw SysExCore.ThrowFailException("供应商编号不能重复。");
- }
- entity.F_ADDTIME = DateTime.Now;
- entity.F_ADDUSERNO = loginUserInfo.UserNo;
- entity.F_ISDELETE = 0;
- //entity.F_ISSTOP = 0;
- SysDbCore.GetDbCtx().Insertable(entity).ExecuteCommand();
- }
- else
- {
- SysDbCore.GetDbCtx().Updateable(entity).IgnoreColumns(it => new { it.F_ADDTIME, it.F_ADDUSERNO }).Where(it => it.F_NO == keyValue).ExecuteCommand();
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public Dictionary<string, BASE_SUPPLIER> GetMap()
- {
- try
- {
- Dictionary<string, BASE_SUPPLIER> dics = new Dictionary<string, BASE_SUPPLIER>();
- SysDbCore.GetDbCtx().Queryable<BASE_SUPPLIER>().ToList().ForEach(it => dics.Add(it.F_NO, it));
- return dics;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取按钮列表树形数据(基于供应商模块)
- /// </summary>
- /// <returns></returns>
- public List<TreeModel> GetCheckTree()
- {
- List<BASE_SUPPLIER> list = SysDbCore.GetDbCtx().Queryable<BASE_SUPPLIER>().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0).OrderBy(v=>v.F_NO).ToList();
- List<TreeModel> treeList = new List<TreeModel>();
- //{
- // TreeModel node = new TreeModel();
- // node.id = ACLAuthorize.ALLAuthorize;
- // node.text = "授权所有";
- // node.value = ACLAuthorize.ALLAuthorize;
- // node.showcheck = true;
- // node.checkstate = 0;
- // node.isexpand = true;
- // node.icon = ACLAuthorize.IcoAuthorize;
- // node.parentId = "";
- // treeList.Add(node);
- //}
- foreach (var item in list)
- {
- TreeModel node = new TreeModel();
- node.id = item.F_NO;
- node.text = item.F_NO+"_"+item.F_NAME;
- node.value = item.F_NO;
- node.showcheck = true;
- node.checkstate = 0;
- node.isexpand = true;
- node.icon = ACLAuthorize.IcoAuthorize;
- node.parentId = "";
- treeList.Add(node);
- }
- return treeList.ToTree();
- }
- }
- }
|