tijian_jichuang/Code/SOH.BLL.Host/t_zhxmBll.cs
2025-02-20 11:54:48 +08:00

238 lines
7.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EAS.Services;
using SOH.Entities;
using SOH.Data;
using System.Data;
namespace SOH.BLL
{
[ServiceObject("分店维护模块")]
[ServiceBind(typeof(It_zhxm))]
public class t_zhxmBll : It_zhxm
{
public List<Entities.t_zhxm> GetzhxmByks(int ksbm,int fddm)
{
using (DbEntities db = new DbEntities())
{
if (ksbm == -1)
{
return db.t_zhxms.Where(t => t.fddm == fddm && t.zhuxiao == "0").ToList();
}
else return db.t_zhxms.Where(t => t.ksbm == ksbm && t.fddm == fddm && t.zhuxiao == "0").ToList();
}
}
public List<Entities.t_zhxm> GetzhxmByksAll(int ksbm, int fddm)
{
using (DbEntities db = new DbEntities())
{
if (ksbm == -1)
{
return db.t_zhxms.ToList();
}
else return db.t_zhxms.Where(t => t.ksbm == ksbm && t.fddm == fddm).ToList();
}
}
public List<Entities.t_zhxm> GetzhxmByks1(int ksbm, int fddm)
{
using (DbEntities db = new DbEntities())
{
if (ksbm == -1)
{
return db.t_zhxms.ToList();
}
else return db.t_zhxms.Where(t => t.ksbm == ksbm && t.fddm == fddm&& t.zhuxiao=="0").ToList();
}
}
public Data.OperationResult Update(t_zhxm zhxm)
{
OperationResult or = new OperationResult();
using (DbEntities db = new DbEntities())
{
try
{
db.OrmAccessor.Update(zhxm);
}
catch (Exception ex)
{
or.State = 0;
or.Message = ex.Message;
}
}
or.State = 1;
or.Message = "修改成功";
//or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(zhxm);
return or;
}
public Data.OperationResult Insert(t_zhxm zhxm)
{
using (DbEntities db = new DbEntities())
{
//zhxm.ddxmb = null;
db.t_zhxms.OrmAccessor.Insert(zhxm);
}
OperationResult or = new OperationResult();
or.State = 1;
or.Message = "添加成功";
//or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(zhxm);
return or;
}
public List<Entities.t_zhxm> GetzhxmByddfzbm(int ddfzbm)
{
using (DbEntities db = new DbEntities())
{
var data = from d in db.t_zhxms
join ddxm in db.ts_ddxmbs on d.zhbm equals ddxm.zhbm
where ddxm.ddfzbm == ddfzbm
select d;
List<t_zhxm> al = data.OrderBy(t => t.xssx).ToList();
return al;
}
}
public List<t_zhxm> GetzhxmByzjm(string zjm)
{
using (DbEntities db = new DbEntities())
{
if (zjm == "")
{
return db.t_zhxms.ToList();
}
else return db.t_zhxms.Where(t => t.zjm.Contains(zjm)).ToList();
}
}
/// <summary>
/// 根据合同分组编码获取组合项目列表
/// </summary>
/// <param name="htfzbm"></param>
/// <returns></returns>
public List<t_zhxm> GetzhxmByhtfzbm(int htfzbm)
{
using (DbEntities db = new DbEntities())
{
var data = from d in db.t_zhxms
join htxm in db.t_htxmbs on d.zhbm equals htxm.zhbm
where htxm.htfzbm == htfzbm
select d;
List<t_zhxm> al = data.OrderBy(t => t.xssx).ToList();
return al;
}
}
/// <summary>
/// 根据助记符查询组合项目
/// </summary>
/// <param name="zjf"></param>
/// <param name="fddm"></param>
/// <returns></returns>
public List<Entities.DTO.dto_zhxm> GetZhxmByZjf(string zjf, short fddm,short xb,short hyzk)
{
using (DbEntities db=new DbEntities())
{
var data = from t in db.t_zhxms
join k in db.t_kss on t.ksbm equals k.ksbm
where t.fddm == fddm && t.zhuxiao == "0" && (xb == 2 ? true : (t.xb == 2 || t.xb == xb))&&(hyzk==2?true:(t.hyzk==2||t.hyzk==hyzk)) && ((zjf==null||zjf=="")?true:t.zjm.Contains(zjf))
select new SOH.Entities.DTO.dto_zhxm
{
zhbm=t.zhbm,
zhmc=t.zhmc,
ksmc=k.ksmc,
jg=t.jg_v,
mzjg=t.mzjg_v
};
if (data.Any())
{
List<SOH.Entities.DTO.dto_zhxm> ldz = data.ToList<SOH.Entities.DTO.dto_zhxm>();
return ldz;
}
else
{
return null;
}
}
}
/// <summary>
/// 根据分店代码查询所有未注销的组合项目
/// </summary>
/// <param name="fddm"></param>
/// <returns></returns>
public List<Entities.DTO.dto_zhxm> GetZhxm(short fddm)
{
using (DbEntities db = new DbEntities())
{
var data = from t in db.t_zhxms
join k in db.t_kss on t.ksbm equals k.ksbm
where t.fddm == fddm && t.zhuxiao == "0" && k.zhuxiao==0
select new SOH.Entities.DTO.dto_zhxm
{
zhbm = t.zhbm,
zhmc = t.zhmc,
ksbm=t.ksbm,
ksmc = k.ksmc,
jg = t.jg_v,
mzjg = t.mzjg_v,
xb=t.xb,
hyzk=t.hyzk,
zjm=t.zjm
};
if (data.Any())
{
List<SOH.Entities.DTO.dto_zhxm> ldz = data.ToList();
return ldz;
}
else
{
return null;
}
}
}
public List<Entities.DTO.dto_zhxm> GetZhxmBytcbm(short tcbm)
{
using (DbEntities db = new DbEntities())
{
var data = from t in db.t_zhxms
join c in db.t_tcxmmxs on t.zhbm equals c.zhbm
join k in db.t_kss on t.ksbm equals k.ksbm
where t.zhuxiao == "0" && c.tcbm == tcbm
select new SOH.Entities.DTO.dto_zhxm
{
zhbm = t.zhbm,
zhmc = t.zhmc,
ksbm = t.ksbm,
ksmc = k.ksmc,
jg = t.jg_v,
mzjg = t.mzjg_v,
xb = t.xb,
hyzk = t.hyzk,
zjm = t.zjm
};
if (data.Any())
{
List<SOH.Entities.DTO.dto_zhxm> ldz = data.ToList();
return ldz;
}
else
{
return null;
}
}
}
}
}