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

184 lines
7.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SOH.Entities;
using EAS.Services;
namespace SOH.BLL
{
[ServiceObject("合同表")]
[ServiceBind(typeof(It_ht))]
public class t_htBll : It_ht
{
public List<Entities.t_ht> GetListByparam(string param)
{
using (DbEntities db = new DbEntities())
{
//var data = db.t_hts.Where(t => t.khbianma.zjm.Contains(param) || t.khbianma.khmc.Contains(param));
var data = db.t_khs.Where(t => t.zjm.Contains(param) || t.khmc.Contains(param)).Join(db.t_hts, t => t.khbm, p => p.khbm, (t, p) => p);
return data.ToList();
}
}
public List<Entities.t_ht> GetListByxsy(string xsy, string param)
{
using (DbEntities db = new DbEntities())
{
if (xsy == "")
{
var data = db.t_hts.Where(t => t.khbianma.khmc.Contains(param) || t.khbianma.zjm.Contains(param)).OrderByDescending(t => t.htqsrq);
return data.ToList();
}
else
{
var data = db.t_hts.Where(t => t.ywdbdm == xsy && (t.khbianma.khmc.Contains(param) || t.khbianma.zjm.Contains(param))).OrderByDescending(t => t.htqsrq);
return data.ToList();
}
}
}
//public DataTable GetJbtjByTmNew(int tmh)
//{
// using (var db = new DbEntities())
// {
// string sql1 = @"select t_jbtj.fddm,advice.Name,t_jcxm.xb,advice.Description from t_jbtj,itemindexresulttemplet,advice,t_jcxm
// where t_jbtj.jbbm=itemindexresulttemplet.ID and
// t_jbtj.upflag=t_jcxm.jcxmbm and
// itemindexresulttemplet.AdviceID=advice.ID and advice.Name not like '%放弃%' and
// advice.Name not like '%其%' and advice.Name!='' and t_jbtj.tm=" + tmh;
// DataTable dt = db.DataAccessor.QueryDataTable(sql1);
// return dt;
// }
//}
public string GetListByxsy2(string xsy, string param)
{
using (DbEntities db = new DbEntities())
{
var data = from kh in db.t_khs
join ht in db.t_hts on kh.khbm equals ht.khbm
select new
{
= kh.khbm,
= kh.khmc,
= ht.htbm,
= ht.nd,
= ht.htbj,
= ht.yjtjrs,
= ht.htqsrq.ToString("yyyy-MM-dd"),
= ht.htjzrq.ToString("yyyy-MM-dd"),
= kh.khgddh,
= kh.khlxr,
= ht.ywdbdm
};
var data1 = data.ToList();
if (!string.IsNullOrEmpty(xsy))
{
if (xsy != "admin")
{
data1 = data.Where(t => t..Equals(xsy)).ToList();
}
}
if (!string.IsNullOrEmpty(param))
{
data1 = data.Where(t => t..Contains(param)).ToList();
}
return Newtonsoft.Json.JsonConvert.SerializeObject(data1);
}
}
public string GetListByxsyWjrs(string xsy, string param)
{
using (DbEntities db = new DbEntities())
{
var data = from kh in db.t_khs
join ht in db.t_hts on kh.khbm equals ht.khbm
join tt in db.t_ttgzbs on ht.htbm equals tt.htbm
select new
{
= kh.khbm,
= kh.khmc,
= ht.htbm,
= ht.nd,
= ht.htbj,
= ht.yjtjrs,
= ht.htqsrq.ToString("yyyy-MM-dd"),
= ht.htjzrq.ToString("yyyy-MM-dd"),
= kh.khgddh,
= kh.khlxr,
= ht.ywdbdm ,
tmztz = tt.tmztz,
sjje=tt.tjzje
}
into k
group k by new { k., k., k., k., k., k., k.,
k.,k.,k.,k.
} into t
select new
{
= t.Key.,
= t.Key.,
= t.Key.,
= t.Key.,
= t.Key.,
= t.Key.,
= t.Key.,
= t.Key.,
= t.Key.,
= t.Key.,
= t.Key.,
= t.Where(e => e.tmztz == 0).Count(),
//未检金额 = ((t.Where(e => e.tmztz == 0)).Sum(e => e.sjje)/100).ToString("0.00"),
= (t.Where(e => e.tmztz == 0)).Sum(e => e.sjje) / 100,
= t.Where(e => e.tmztz != 22).Count(),
= t.Where(e => e.tmztz != 0).Count(),
= (t.Where(e => e.tmztz != 0)).Sum(e => e.sjje) / 100
};
var data1 = data.ToList();
if (!string.IsNullOrEmpty(xsy))
{
if (xsy != "admin")
{
data1 = data.Where(t => t..Equals(xsy)).ToList();
}
}
if (!string.IsNullOrEmpty(param))
{
data1 = data.Where(t => t..Contains(param)).ToList();
}
return Newtonsoft.Json.JsonConvert.SerializeObject(data1);
}
}
public string GetTitleByHtbm(int htbm)
{
using (DbEntities db = new DbEntities())
{
var data = from a in db.t_hts
join b in db.t_khs
on a.khbm equals b.khbm
where a.htbm == htbm
select b.khmc + a.nd + "年度团检合同结算";
if (data.Any())
{
return data.FirstOrDefault();
}
else
{
return "";
}
}
}
}
}