202 lines
6.2 KiB
C#
202 lines
6.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using EAS.Services;
|
|
using SOH.Entities;
|
|
using EAS.Data.Access;
|
|
using EAS.Data.Linq;
|
|
using SOH.Data;
|
|
|
|
|
|
namespace SOH.BLL
|
|
{
|
|
[ServiceObject("合同分组表")]
|
|
[ServiceBind(typeof(It_htfzb))]
|
|
public class t_htfzbBll : It_htfzb
|
|
{
|
|
/// <summary>
|
|
/// 根据合同编码获取合同分组
|
|
/// </summary>
|
|
/// <param name="htbm"></param>
|
|
/// <returns></returns>
|
|
public List<Entities.t_htfzb> GetListByhtbm(int htbm)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.t_htfzbs.Where(t => t.htbm == htbm).ToList();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据合同编码组获取合同分组
|
|
/// 2023-10-26 xulu
|
|
/// </summary>
|
|
/// <param name="htbm"></param>
|
|
/// <returns></returns>
|
|
public List<Entities.t_htfzb> GetListByhtbm(int[] htbm)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.t_htfzbs.Where(t => htbm.Contains(t.htbm)).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public Data.OperationResult Insert(t_htfzb b, List<t_htxmb> xmb)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
|
|
{
|
|
try
|
|
{
|
|
db.t_htfzbs.Insert(b);
|
|
foreach (t_htxmb b1 in xmb)
|
|
{
|
|
db.t_htxmbs.Insert(b1);
|
|
}
|
|
tan.Commit();
|
|
or.State = 1;
|
|
or.Message = "分组项添加成功!";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
or.State = 2;
|
|
or.Message = "分组项添加失败!请联系管理员。";
|
|
}
|
|
}
|
|
}
|
|
return or;
|
|
}
|
|
|
|
|
|
public OperationResult Update(t_htfzb b, List<t_htxmb> xmb)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
|
|
{
|
|
try
|
|
{
|
|
db.t_htfzbs.Update(b);
|
|
List<t_htxmb> xmbal = db.t_htxmbs.Where(t => t.htfzbm == b.htfzbm).ToList();
|
|
foreach (t_htxmb b1 in xmbal)
|
|
{
|
|
db.t_htxmbs.Delete(b1);
|
|
}
|
|
foreach (t_htxmb b1 in xmb)
|
|
{
|
|
db.t_htxmbs.Insert(b1);
|
|
}
|
|
tan.Commit();
|
|
or.State = 1;
|
|
or.Message = "分组项修改成功!";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
or.State = 2;
|
|
or.Message = "分组项修改失败!请联系管理员。";
|
|
}
|
|
}
|
|
}
|
|
return or;
|
|
}
|
|
|
|
|
|
public OperationResult Delete(t_htfzb b)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
using (DbTransaction tan = db.DataAccessor.CreateTransaction())
|
|
{
|
|
try
|
|
{
|
|
db.t_htfzbs.Delete(b);
|
|
List<t_htxmb> xmblist = (from xmb in db.t_htxmbs where xmb.htfzbm == b.htfzbm select xmb).ToList();
|
|
foreach (t_htxmb xmb in xmblist)
|
|
{
|
|
db.t_htxmbs.Delete(xmb);
|
|
}
|
|
List<t_ttgzb> al = (from gzb in db.t_ttgzbs where gzb.htfzbm == b.htfzbm select gzb).ToList();
|
|
foreach (t_ttgzb gzb in al)
|
|
{
|
|
db.t_ttgzbs.Delete(gzb);
|
|
}
|
|
tan.Commit();
|
|
or.State = 1;
|
|
or.Message = "删除分组成功!";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
or.State = 2;
|
|
or.Message = "删除分组失败!" + ex.ToString();
|
|
}
|
|
}
|
|
}
|
|
return or;
|
|
}
|
|
|
|
public t_htfzb GetModelByfzbm(int fzbm)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data = db.t_htfzbs.Where(t => t.htfzbm == fzbm);
|
|
if (data.Any())
|
|
{
|
|
return data.First();
|
|
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
public List<t_htfzb> GetModelListByfzbm(int fzbm)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data = db.t_htfzbs.Where(t => t.htfzbm == fzbm);
|
|
if (data.Any())
|
|
{
|
|
return data.ToList();
|
|
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据合同编码和合同分组名称查询到改分组是否存在(团检导入)
|
|
/// </summary>
|
|
/// <param name="htbm"></param>
|
|
/// <param name="htfzmc"></param>
|
|
/// <returns></returns>
|
|
public t_htfzb GethtfzbmByhtbmAndhtfzmc(int htbm, string htfzmc)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var b = db.t_htfzbs.Where(t => t.htbm == htbm && t.htfzmc == htfzmc).ToList();
|
|
if (b.Any())
|
|
{
|
|
return b.First();
|
|
}
|
|
else return null;
|
|
}
|
|
}
|
|
}
|
|
}
|