123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- using System;
- using System.Collections.Generic;
- using WMS.Info;
- using WMS.Util;
- namespace WMS.Core
- {
- public class BaseCustomer
- {
- /// <summary>
- /// 获取列表数据
- /// <summary>
- /// <returns></returns>
- public IEnumerable<BASE_CUSTOMER> GetList(string keyword)
- {
- try
- {
- return SysDbCore.GetDbCtx().Queryable<BASE_CUSTOMER>().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_CUSTOMER> GetPageList(string keyword, Pagination pagination)
- {
- try
- {
- int count = 0;
- var db = SysDbCore.GetDbCtx().Queryable<BASE_CUSTOMER>().Where(it => it.F_ISDELETE == 0).WhereIF(!keyword.IsEmpty(), it => it.F_NO.Contains(keyword) || it.F_NAME.Contains(keyword));
- List<BASE_CUSTOMER> 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_CUSTOMER GetEntity(string keyValue)
- {
- try
- {
- return SysDbCore.GetDbCtx().Queryable<BASE_CUSTOMER>().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_CUSTOMER>().Where(it => it.F_NO == keyValue).ExecuteCommand();
- SysDbCore.GetDbCtx().Updateable<BASE_CUSTOMER>().UpdateColumns(it => new BASE_CUSTOMER { 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_CUSTOMER 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_CUSTOMER>().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_CUSTOMER> GetMap()
- {
- try
- {
- Dictionary<string, BASE_CUSTOMER> dics = new Dictionary<string, BASE_CUSTOMER>();
- SysDbCore.GetDbCtx().Queryable<BASE_CUSTOMER>().ToList().ForEach(it => dics.Add(it.F_NO, it));
- return dics;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public List<TreeModel> GetCheckTree()
- {
- List<BASE_CUSTOMER> list = SysDbCore.GetDbCtx().Queryable<BASE_CUSTOMER>().Where(it => it.F_ISDELETE == 0 && it.F_ISSTOP == 0).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_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();
- }
- }
- }
|