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 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 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 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 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 al = data.OrderBy(t => t.xssx).ToList(); return al; } } public List 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(); } } /// /// 根据合同分组编码获取组合项目列表 /// /// /// public List 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 al = data.OrderBy(t => t.xssx).ToList(); return al; } } /// /// 根据助记符查询组合项目 /// /// /// /// public List 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 ldz = data.ToList(); return ldz; } else { return null; } } } /// /// 根据分店代码查询所有未注销的组合项目 /// /// /// public List 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 ldz = data.ToList(); return ldz; } else { return null; } } } public List 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 ldz = data.ToList(); return ldz; } else { return null; } } } } }