using Learun.Util; using Learun.Util.SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Learun.Application.Organization { /// /// 版 本 PIT-ADMS V7.0.3 敏捷开发框架 /// Copyright (c) 2013-2018 Hexagon PPM /// 创建人:研发部 /// 日 期:2017.04.17 /// 描 述:公司管理 /// public class CompanyService { #region 仓储 Repository _companyRepository => new Repository(); #endregion #region 构造函数和属性 private string fieldSql; public CompanyService() { fieldSql = @" t.F_CompanyId, t.F_Category, t.F_ParentId, t.F_EnCode, t.F_ShortName, t.F_FullName, t.F_Nature, t.F_OuterPhone, t.F_InnerPhone, t.F_Fax, t.F_Postalcode, t.F_Email, t.F_Manager, t.F_ProvinceId, t.F_CityId, t.F_CountyId, t.F_Address, t.F_WebAddress, t.F_FoundedTime, t.F_BusinessScope, t.F_SortCode, t.F_DeleteMark, t.F_EnabledMark, t.F_Description, t.F_CreateDate, t.F_CreateUserId, t.F_CreateUserName, t.F_ModifyDate, t.F_ModifyUserId, t.F_ModifyUserName "; } #endregion #region 获取数据 /// /// 获取公司列表信息(全部) /// /// public List GetList() { try { //var strSql = new StringBuilder(); //strSql.Append("SELECT "); //strSql.Append(fieldSql); //strSql.Append(" FROM LR_Base_Company t WHERE t.F_EnabledMark = 1 AND t.F_DeleteMark = 0 ORDER BY t.F_ParentId,t.F_EnCode "); //return this.BaseRepository().FindList(strSql.ToString()); var res = _companyRepository.GetList().Where(x => x.F_EnabledMark == 1 && x.F_DeleteMark == 0). OrderBy(x => x.F_ParentId).OrderBy(x => x.F_EnCode); return res.ToList(); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion #region 提交数据 /// /// 虚拟删除公司 /// /// 主键 public void VirtualDelete(string keyValue) { try { CompanyEntity entity = new CompanyEntity() { F_CompanyId = keyValue, F_DeleteMark = 1 }; _companyRepository.Update(entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 保存公司表单(新增、修改) /// /// 主键值 /// 公司实体 /// public void SaveEntity(string keyValue, CompanyEntity companyEntity) { try { if (!string.IsNullOrEmpty(keyValue)) { companyEntity.Modify(keyValue); _companyRepository.Update(companyEntity); } else { companyEntity.Create(); _companyRepository.Insert(companyEntity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion } }