public List <T_CGD> GetPageInfo <S>(Expression <Func <T_CGD, bool> > where, Func <T_CGD, S> order, bool desc, int pageIndex, int pageSize, int?cpId, int?supId, int?cusId, out int pageCount, out int totalRecord) { totalRecord = 0; pageCount = 0; List <T_CGD> list = new List <T_CGD>(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { Expression <Func <T_CGMX, bool> > whereCGMX = PredicateBuilder.True <T_CGMX>(); var isContain = false; if (cpId != null && cpId != 0) { whereCGMX = whereCGMX.And(p => p.CPID == cpId); isContain = true; } if (supId != null && supId != 0) { whereCGMX = whereCGMX.And(p => p.SupID == supId); isContain = true; } if (cusId != null && cusId != 0) { whereCGMX = whereCGMX.And(p => p.CPSCQYID == cusId); isContain = true; } if (isContain) { var dbchild = hContext1.Set <T_CGMX>().Where(whereCGMX.Compile()); var lst = dbchild.Select(p => p.CGID); if (lst != null) { where = where.And(p => lst.Contains(p.CGID)); } } DbSet <T_CGD> db = hContext1.Set <T_CGD>(); //DbQuery<T_CGD> dbq = db.Include("T_WhsQY"); totalRecord = db.Where(where.Compile()).Count(); if (totalRecord > 0) { pageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(totalRecord / pageSize))) + 1; if (desc) { list = db.Where(where.Compile()).OrderByDescending <T_CGD, S>(order).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } else { list = db.Where(where.Compile()).OrderBy <T_CGD, S>(order).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } } } catch (Exception ex) { return(null); } return(list); } }
public override List <T_XSMX> GetPageInfo <S>(Expression <Func <T_XSMX, bool> > where, Func <T_XSMX, S> order, bool desc, int pageIndex, int pageSize, out int pageCount, out int totalRecord) { totalRecord = 0; pageCount = 0; List <T_XSMX> list = new List <T_XSMX>(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T_XSMX> db = hContext1.Set <T_XSMX>(); DbQuery <T_XSMX> dbq = db.Include("T_XSD").Include("T_YLCP").Include("T_YLCP.T_SupQY").Include("T_YLCP.T_SupQY1").Include("T_XSD.T_CusQY"); totalRecord = db.Where(where.Compile()).Count(); if (totalRecord > 0) { pageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(totalRecord / pageSize))) + 1; if (desc) { list = dbq.Where(where.Compile()).OrderByDescending <T_XSMX, string>(p => p.T_XSD.XSDH).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } else { list = dbq.Where(where.Compile()).OrderBy <T_XSMX, string>(p => p.T_XSD.XSDH).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } } } catch (Exception ex) { return(null); } return(list); } }
public int Delete(int id) { int result = 0; using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { var dbchild = hContext1.Set <T_RKMX>(); var lst = dbchild.Where(p => p.RKID == id); if (lst != null && lst.Count() > 0) { dbchild.RemoveRange(lst); } var db = hContext1.Set <T_RKD>(); var model = db.Find(id); db.Remove(model); hContext1.SaveChanges(); result = 1; } catch (Exception ex) { } } return(result); }
public int SaveTPrice(int id, double tPrice, string dhid) { int result = 0; using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { if (id == 0) { var model = hContext1.Set <T_CGD>().Where(p => p.CGDH == dhid).FirstOrDefault(); if (model.CGID != 0) { model.CGTotalPrice = tPrice; } } else { var model = hContext1.Set <T_CGD>().Find(id); model.CGTotalPrice = tPrice; } hContext1.SaveChanges(); result = 1; } catch (Exception ex) { } } return(result); }
public int DeleteModelByGuid(string guid) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T_SHMX> db = hContext1.Set <T_SHMX>(); T_SHMX model = db.Where(p => p.GUID == guid).FirstOrDefault(); #region //对原库存数据进行修改 //DbSet<T_KC> kcdb = hContext1.Set<T_KC>(); //var oldkc = kcdb.Where(p => p.CPID == model.CPID && p.CPPH == model.CPPH && p.CKID == model.CKID).FirstOrDefault(); //if (oldkc != null) //{ // oldkc.CPNUM = oldkc.CPNUM + Convert.ToInt32(model.CPNUM); //} #endregion var parentModel = hContext1.Set <T_SHD>().Find(model.SHID); parentModel.ISSH = 0; db.Remove(model); return(hContext1.SaveChanges()); } catch (Exception) { return(0); } } }
public int AddModelByCkdh(T_SHMX model, string SHDH) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { var parentModel = hContext1.Set <T_SHD>().Where(p => p.SHDH == SHDH).FirstOrDefault(); parentModel.ISSH = 0; model.SHID = parentModel.SHID; #region //对新库存数据进行修改 //DbSet<T_KC> kcdb = hContext1.Set<T_KC>(); //var kc = kcdb.Where(p => p.CPID == model.CPID && p.CPPH == model.CPPH && p.CKID == model.CKID).FirstOrDefault(); //if (kc == null) //{ // return 0; //} //kc.CPNUM = kc.CPNUM - Convert.ToInt32(model.CPNUM); #endregion model.CPTPRICE = (model.CPPRICE ?? 0) * (model.CPNUM ?? 0); hContext1.Set <T_SHMX>().Add(model); return(hContext1.SaveChanges()); } catch (Exception ex) { return(0); } } }
/// <summary> /// 登陆 /// </summary> /// <param name="用户ID"></param> /// <param name="密码"></param> /// <returns></returns> public string Login(string userAccount, string password, out SysUser user) { string result = ""; user = null; using (MedicalApparatusManageEntities gContext = new MedicalApparatusManageEntities()) { try { var list = gContext.SysUser.Where(p => p.UserAccount == userAccount && p.UserPassword == password); if (list.Count() > 0) { var liststate = gContext.SysUser.Where(p => p.UserAccount == userAccount && p.UserPassword == password && p.UserState == 1); if (liststate.Count() > 0) { result = "success"; user = list.FirstOrDefault(); } else { result = "该用户已禁用!"; } } else { result = "请检查用户名和密码是否正确!"; } } catch (Exception ex) { result = ex.Message; } } return(result); }
public int UpdateList(List <T_BJDate> list) { var result = 0; using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { foreach (var item in list) { var temp = hContext1.Set <T_BJDate>().Find(item.ID); if (temp != null) { temp.BJDATE = item.BJDATE; } } hContext1.SaveChanges(); result = 1; } catch (Exception) { } } return(result); }
public virtual List <T> GetPageInfo <S>(Expression <Func <T, bool> > where, Func <T, S> order, bool desc, int pageIndex, int pageSize, out int pageCount, out int totalRecord) { totalRecord = 0; pageCount = 0; List <T> list = new List <T>(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T> db = hContext1.Set <T>(); totalRecord = db.Where(where.Compile()).Count(); if (totalRecord > 0) { pageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(totalRecord / pageSize))) + 1; if (desc) { list = db.Where(where.Compile()).OrderByDescending <T, S>(order).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } else { list = db.Where(where.Compile()).OrderBy <T, S>(order).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } } } catch (Exception ex) { int a = 0; } return(list); } }
public virtual int UpdateModel(T model, params object[] keyValues) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T> db = hContext1.Set <T>(); T oldModel = db.Find(keyValues); foreach (var item in model.GetType().GetProperties()) { item.SetValue(oldModel, item.GetValue(model, null), null); } hContext1.SaveChanges(); return(1); } catch (DbEntityValidationException dbEx) { return(0); } catch (Exception ex) { return(0); } } }
public T_SJZDFL GetModeByName(string name) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { List <T_SJZDFL> list = null; Expression <Func <T_SJZDFL, bool> > where = PredicateBuilder.True <T_SJZDFL>(); if (!string.IsNullOrEmpty(name)) { where.And(p => p.FLMC == name); } DbSet <T_SJZDFL> db = hContext1.Set <T_SJZDFL>(); list = db.Where(where.Compile()).ToList(); if (list.Count > 0) { return(list[0]); } } catch (Exception ex) { } } return(null); }
public List<T_CusPerson> GetPageInfo<S>(Expression<Func<T_CusPerson, bool>> where, Func<T_CusPerson, S> order, bool desc, int pageIndex, int pageSize, out int pageCount, out int totalRecord) { totalRecord = 0; pageCount = 0; List<T_CusPerson> list = new List<T_CusPerson>(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet<T_CusPerson> db = hContext1.Set<T_CusPerson>(); DbQuery<T_CusPerson> dbq = db.Include("T_CusQY"); totalRecord = db.Where(where.Compile()).Count(); if (totalRecord > 0) { pageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(totalRecord / pageSize))) + 1; if (desc) { list = dbq.Where(where.Compile()).OrderByDescending<T_CusPerson, S>(order).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } else { list = dbq.Where(where.Compile()).OrderBy<T_CusPerson, S>(order).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } } } catch (Exception) { return null; } return list; } }
public int SaveTPrice(int id, string dh, double tPrice) { int result = 0; using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { if (id != 0) { var model = hContext1.Set <T_XSD>().Find(id); model.XSJE = tPrice; } else { var model = hContext1.Set <T_XSD>().Where(p => p.XSDH == dh).FirstOrDefault(); model.XSJE = tPrice; } hContext1.SaveChanges(); result = 1; } catch (Exception ex) { } } return(result); }
public T_YLCP GetCpDetailsById(int cpid) { T_YLCP cp = new T_YLCP(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { cp = base.GetModelById(cpid); if (cp != null) { if (cp.CPSCQYID.HasValue) { cp.T_SupQY1 = hContext1.Set <T_SupQY>().Find(cp.CPSCQYID); } if (cp.CPGYSID.HasValue) { cp.T_SupQY = hContext1.Set <T_SupQY>().Find(cp.CPGYSID); } } } catch (Exception ex) { } } return(cp); }
public int AddModelByCkdh(T_CKMX model, string CKDH) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { int ckid = hContext1.Set <T_CKD>().Where(p => p.CKDH == CKDH).FirstOrDefault().CKID; model.CKDID = ckid; //对新库存数据进行修改 DbSet <T_KC> kcdb = hContext1.Set <T_KC>(); var kc = kcdb.Where(p => p.CPID == model.CPID && p.CPPH == model.CPPH && p.CKID == model.CKID).FirstOrDefault(); if (kc == null) { return(0); } kc.CPNUM = kc.CPNUM - Convert.ToInt32(model.CPNUM); hContext1.Set <T_CKMX>().Add(model); return(hContext1.SaveChanges()); } catch (Exception ex) { return(0); } } }
public static void ExecProc() { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { hContext1.proc_get_bjd(); } catch (Exception ex) { } } }
public virtual T GetModelById(params object[] keyValues) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { return(hContext1.Set <T>().Find(keyValues)); } catch (Exception) { return(new T()); } } }
public int GetRoleByUserId(int userId) { int roleId = 0; using (MedicalApparatusManageEntities gContext = new MedicalApparatusManageEntities()) { var role = gContext.Set <SysUserRole>().Where(p => p.UserId == userId).FirstOrDefault(); if (role != null) { roleId = role.RoleId.Value; } } return(roleId); }
public List <T_YSD> GetYSDByCondition(string hflag, int?cpId, int?supId, string cpph) { Expression <Func <T_YSD, bool> > where = PredicateBuilder.True <T_YSD>(); if (!String.IsNullOrEmpty(hflag)) { where = where.And(p => p.YSFLAG == hflag); } List <T_YSD> list = new List <T_YSD>(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { Expression <Func <T_YSMX, bool> > whereMX = PredicateBuilder.True <T_YSMX>(); var isContain = false; if (cpId != null && cpId != 0) { whereMX = whereMX.And(p => p.CPID == cpId); isContain = true; } if (supId != null && supId != 0) { whereMX = whereMX.And(p => p.SupID == supId); isContain = true; } if (!String.IsNullOrEmpty(cpph)) { whereMX = whereMX.And(p => !string.IsNullOrEmpty(p.CPPH) && p.CPPH.Contains(cpph)); isContain = true; } if (isContain) { var dbchild = hContext1.Set <T_YSMX>().Where(whereMX.Compile()); var lst = dbchild.Select(p => p.YSID); if (lst != null) { where = where.And(p => lst.Contains(p.YSID)); } } DbSet <T_YSD> db = hContext1.Set <T_YSD>(); list = db.Where(where.Compile()).OrderByDescending(p => p.YSDH).ToList(); } catch (Exception ex) { return(null); } return(list); } }
public List <T_RKD> GetListModelById(Int32 id) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T_RKD> db = hContext1.Set <T_RKD>(); return(db.Where(p => p.RKID == id).ToList()); } catch (Exception) { return(new List <T_RKD>()); } } }
public int AddModelByRkdh(T_RKMX model, string RKDH) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { var parentModel = hContext1.Set <T_RKD>().Where(p => p.RKDH == RKDH).FirstOrDefault(); parentModel.ISSH = 0; var rkid = parentModel.RKID; model.RKID = rkid; hContext1.Set <T_RKMX>().Add(model); #region //对新库存数据进行修改 //DbSet<T_KC> kcdb = hContext1.Set<T_KC>(); //var newkc = kcdb.Where(p => p.CPID == model.CPID && p.CPPH == model.CPPH && p.CKID == model.CKID).FirstOrDefault(); //if (newkc == null) //{ // T_KC newKc = new T_KC() // { // CPID = model.CPID, // CKID = model.CKID, // CPNUM = Convert.ToInt32(model.CPNUM), // FlAG = 1, // CPPH = model.CPPH, // CPSCRQ = model.CPSCRQ, // CPYXQ = model.CPYXQ, // SupID = model.SupID, // ScqyID = model.ScqyID // }; // kcdb.Add(newKc); //} //else //{ // newkc.CPNUM = newkc.CPNUM + Convert.ToInt32(model.CPNUM); // newkc.CPYXQ = model.CPYXQ; // newkc.CPSCRQ = model.CPSCRQ; //} #endregion return(hContext1.SaveChanges()); } catch (Exception ex) { return(0); } } }
public List <T_CKD> GetListModelById(Int32 id) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T_CKD> db = hContext1.Set <T_CKD>(); DbQuery <T_CKD> dbq = db.Include("T_XSD"); return(dbq.Where(p => p.CKID == id).ToList()); } catch (Exception) { return(new List <T_CKD>()); } } }
public List <T_QYZZ> GetQYZZByQyid(int qyid) { List <T_QYZZ> list = new List <T_QYZZ>(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { list = hContext1.Set <T_QYZZ>().Where(p => p.QYID == qyid).ToList(); } catch (Exception) { } } return(list); }
public T_BJDate GetFirstBJDate() { T_BJDate model = new T_BJDate(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { model = hContext1.Set <T_BJDate>().FirstOrDefault() ?? new T_BJDate(); } catch (Exception) { } } return(model); }
public List <T_YLCPZZ> GetCPZZByCpid(int cpid) { List <T_YLCPZZ> list = new List <T_YLCPZZ>(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { list = hContext1.Set <T_YLCPZZ>().Where(p => p.CPID == cpid).ToList(); } catch (Exception) { } } return(list); }
/// <summary> /// 获取快捷菜单列表 /// </summary> /// <param name="用户ID"></param> /// <returns></returns> public List <SysFavorite> GetFavoriteList(int userid) { List <SysFavorite> list = new List <SysFavorite>(); string sql = string.Format(@"SELECT * FROM SysFavorite WHERE UserID = {0}", userid); using (MedicalApparatusManageEntities gContext = new MedicalApparatusManageEntities()) { try { list = gContext.Database.SqlQuery <SysFavorite>(sql).ToList(); } catch (Exception) { } } return(list); }
public int DeleteModelByGuid(string guid) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T_YSMX> db = hContext1.Set <T_YSMX>(); T_YSMX model = db.Where(p => p.GUID == guid).FirstOrDefault(); db.Remove(model); return(hContext1.SaveChanges()); } catch (Exception) { return(0); } } }
public int GetCount() { int count = 0; using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T_BJD> db = hContext1.Set <T_BJD>(); count = db.Count(); } catch (Exception) { } return(count); } }
public virtual int DeleteModelById(params object[] keyValues) { using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T> db = hContext1.Set <T>(); T model = db.Find(keyValues); db.Remove(model); return(hContext1.SaveChanges()); } catch (Exception ex) { return(0); } } }
public virtual List <T> GetAllModels <S>(Expression <Func <T, bool> > where) { List <T> list = new List <T>(); using (MedicalApparatusManageEntities hContext1 = new MedicalApparatusManageEntities()) { try { DbSet <T> db = hContext1.Set <T>(); list = db.Where(where.Compile()).ToList(); } catch (Exception) { } return(list); } }