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 { /// /// 根据合同编码获取合同分组 /// /// /// public List GetListByhtbm(int htbm) { using (DbEntities db = new DbEntities()) { return db.t_htfzbs.Where(t => t.htbm == htbm).ToList(); } } /// /// 根据合同编码组获取合同分组 /// 2023-10-26 xulu /// /// /// public List 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 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 xmb) { OperationResult or = new OperationResult(); using (DbEntities db = new DbEntities()) { using (DbTransaction tan = db.DataAccessor.CreateTransaction()) { try { db.t_htfzbs.Update(b); List 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 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 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 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; } } } /// /// 根据合同编码和合同分组名称查询到改分组是否存在(团检导入) /// /// /// /// 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; } } } }