123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.CommonLogic.ChargeManage;
- using EMIS.CommonLogic;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.ChargeManage.ChargeSituation;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using System.Text.RegularExpressions;
- using EMIS.DataLogic.ChargeManage.ChargeSituation;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- namespace EMIS.CommonLogic.ChargeManage.ChargeSituation
- {
- public class ChargeProjectServices : BaseServices, IChargeProjectServices
- {
- public ChargeProjectDAL ChargeProjectDAL { get; set; }
- /// <summary>
- /// 查询收费项目信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ChargeProjectView> GetChargeProjectViewGrid(ConfiguretView configuretView,
- int pageIndex, int pageSize)
- {
- Expression<Func<EC_ChargeProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = ChargeProjectDAL.GetChargeProjectViewQueryAble(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.ChrageProjectName)
- .ToGridResultSet<ChargeProjectView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询收费项目信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <returns></returns>
- public List<ChargeProjectView> GetChargeProjectViewList(ConfiguretView configuretView)
- {
- Expression<Func<EC_ChargeProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = ChargeProjectDAL.GetChargeProjectViewQueryAble(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- string conditionValue = string.Empty;
- Regex rg = new Regex(@"^[0-9]*$");
- if (rg.IsMatch(configuretView.ConditionValue))
- {
- conditionValue = Convert.ToInt32(configuretView.ConditionValue).ToString();
- }
- else
- {
- conditionValue = configuretView.ConditionValue;
- }
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, conditionValue);
- }
- return query.OrderBy(x => x.ChrageProjectName).ToList();
- }
- /// <summary>
- /// 查询收费项目实体
- /// </summary>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- public EC_ChargeProject GetChargeProject(Guid? chargeProjectID)
- {
- try
- {
- Expression<Func<EC_ChargeProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.ChargeProjectID == chargeProjectID);
- return ChargeProjectDAL.chargeProjectRepository.GetSingle(exp);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询收费项目View
- /// </summary>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- public ChargeProjectView GetChargeProjectView(Guid? chargeProjectID)
- {
- try
- {
- Expression<Func<EC_ChargeProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.ChargeProjectID == chargeProjectID);
- var query = ChargeProjectDAL.GetChargeProjectViewQueryAble(exp);
- return query.SingleOrDefault();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询收费项目明细View
- /// </summary>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- public ChargeProjectView GetChargeProjectDetailsView(Guid? chargeProjectID)
- {
- try
- {
- Expression<Func<EC_ChargeProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.ChargeProjectID == chargeProjectID);
- var query = ChargeProjectDAL.GetChargeProjectViewQueryAble(exp);
- return query.SingleOrDefault();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="chargeProjectView"></param>
- public void ChargeProjectAdd(ChargeProjectView chargeProjectView)
- {
- try
- {
- //查询数据库进行验证(需排除自己)
- var chargeProject = ChargeProjectDAL.chargeProjectRepository
- .GetList(x => x.ChargeProjectID != chargeProjectView.ChargeProjectID
- && x.Name == chargeProjectView.ChrageProjectName).FirstOrDefault();
- if (chargeProject == null)
- {
- //数据有误验证
- if (chargeProjectView.ChargeProjectID != null && chargeProjectView.ChargeProjectID != Guid.Empty)
- {
- chargeProject = ChargeProjectDAL.chargeProjectRepository
- .GetList(x => x.ChargeProjectID == chargeProjectView.ChargeProjectID).SingleOrDefault();
- if (chargeProject == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- chargeProject.Name = chargeProjectView.ChrageProjectName;
- chargeProject.Remark = chargeProjectView.Remark;
- SetModifyStatus(chargeProject);
- }
- }
- else
- {
- EC_ChargeProject newChargeProject = new EC_ChargeProject();
- newChargeProject.ChargeProjectID = Guid.NewGuid();
- newChargeProject.Name = chargeProjectView.ChrageProjectName;
- newChargeProject.Remark = chargeProjectView.Remark;
- SetNewStatus(newChargeProject);
- UnitOfWork.Add(newChargeProject);
- }
- }
- else
- {
- throw new Exception("已存在相同的收费项目");
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="chargeProjectIDs"></param>
- /// <returns></returns>
- public bool ChargeProjectDelete(List<Guid> chargeProjectIDs)
- {
- try
- {
- UnitOfWork.Delete<EC_ChargeProject>(x => chargeProjectIDs.Contains(x.ChargeProjectID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 验证
- /// </summary>
- /// <param name="chargeProjectID"></param>
- /// <param name="chrageProjectName"></param>
- /// <returns></returns>
- public string GetVerification(Guid? chargeProjectID, string chrageProjectName)
- {
- //查询数据库进行验证(需排除自己)
- var chargeProject = ChargeProjectDAL.chargeProjectRepository.GetList(x => x.ChargeProjectID != chargeProjectID
- && x.Name == chrageProjectName).FirstOrDefault();
- if (chargeProject == null)
- {
- //数据有误验证
- if (chargeProjectID.HasValue && chargeProjectID != Guid.Empty)
- {
- chargeProject = ChargeProjectDAL.chargeProjectRepository
- .GetList(x => x.ChargeProjectID == chargeProjectID).SingleOrDefault();
- if (chargeProject == null)
- {
- return "数据有误,请核查";
- }
- else
- {
- return "成功";
- }
- }
- else
- {
- return "成功";
- }
- }
- else
- {
- return "已存在相同的收费项目";
- }
- }
- }
- }
|