Ejemplo n.º 1
0
 /// <summary>
 /// 是否存在该记录
 /// </summary>
 /// <returns></returns>
 public bool ExistsViewEntity(Expression<Func<VSysDepartment , bool>> predicate)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
        bool status= db.VSysDepartments.Any(predicate);
        return status;
     }
 }
Ejemplo n.º 2
0
	    /// <summary>
        /// 获取所有的数据
	    /// </summary>
	    /// <returns>返回所有数据列表</returns>
        public List<TFunTag> GetList() 
        {
          using (teaCRMDBContext db=new teaCRMDBContext())
            {
             var models= db.TFunTags.ToList();
			 return models;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 是否存在该记录
 /// </summary>
 /// <returns></returns>
 public bool ExistsViewEntity(Expression<Func<VCompanyUser , bool>> predicate)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
        bool status= db.VCompanyUsers.Any(predicate);
        return status;
     }
 }
Ejemplo n.º 4
0
		/// <summary>
        /// 获取指定的单个实体
        /// 如果不存在则返回null
        /// 如果存在多个则抛异常
        /// </summary>
        /// <param name="predicate">Lamda表达式</param>
        /// <returns>Entity</returns>
        public TFunTag GetEntity(Expression<Func<TFunTag, bool>> predicate) 
        {
            using (teaCRMDBContext db=new teaCRMDBContext())
            {
                var model =db.TFunTags.Where<TFunTag>(predicate).SingleOrDefault();
                return model;
		    }
        }
Ejemplo n.º 5
0
	    /// <summary>
        /// 获取所有的数据
	    /// </summary>
	    /// <returns>返回所有数据列表</returns>
        public List<VMyappCompany> GetViewList() 
        {
          using (teaCRMDBContext db=new teaCRMDBContext())
            {
             var models= db.VMyappCompanies;
			  var sqlText = models.GetProperty("SqlText");
             LogHelper.Debug(sqlText.ToString());
			 return models.ToList();
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 获取指定的单个实体
 /// 如果不存在则返回null
 /// 如果存在多个则抛异常
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 /// <returns>Entity</returns>
 public VMyappCompany GetViewEntity(Expression<Func<VMyappCompany, bool>> predicate)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
         var model =db.VMyappCompanies.Where<VMyappCompany>(predicate);
         var sqlText = model.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return model.SingleOrDefault();
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 获取数据总数
 /// </summary>
 /// <returns>返回所有数据总数</returns>
 public int GetCount()
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         var models = db.TSysPowers;
         var sqlText = models.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return models.Count();
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取所有的数据
        /// </summary>
        /// <param name="predicate">Lamda表达式</param>
        /// <returns>返回所有数据列表</returns>
       public List<VMyappCompany> GetViewList(Expression<Func<VMyappCompany, bool>> predicate)
        {
             using (teaCRMDBContext db=new teaCRMDBContext())
            {
             var models= db.VMyappCompanies.Where<VMyappCompany>(predicate);
			   var sqlText = models.GetProperty("SqlText");
             LogHelper.Debug(sqlText.ToString());
			 return models.ToList();
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 获取所有的数据
 /// </summary>
 /// <returns>返回所有数据列表</returns>
 public List<TCusLog> GetList()
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         var models = db.TCusLogs;
         var sqlText = models.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return models.ToList();
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 获取所有的数据
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 /// <returns>返回所有数据列表</returns>
 public List<TCusLog> GetList(Expression<Func<TCusLog, bool>> predicate)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         var models = db.TCusLogs.Where<TCusLog>(predicate);
         var sqlText = models.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return models.ToList();
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 获取指定的单个实体
 /// 如果不存在则返回null
 /// 如果存在多个则抛异常
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 /// <returns>Entity</returns>
 public VSysDepartment GetViewEntity(Expression<Func<VSysDepartment, bool>> predicate)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
         var model =db.VSysDepartments.Where<VSysDepartment>(predicate);
         var sqlText = model.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return model.SingleOrDefault();
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 获取数据总数
 /// </summary>
 /// <returns>返回所有数据总数</returns>
 public int GetViewCount()
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         var models = db.VAppCompanies;
         var sqlText = models.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return models.Count();
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 获取数据总数
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 /// <returns>返回所有数据总数</returns>
 public int GetCount(Expression<Func<TSysPower, bool>> predicate)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         var models = db.TSysPowers.Where<TSysPower>(predicate);
         var sqlText = models.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return models.Count();
     }
 }
Ejemplo n.º 14
0
		  /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体对象</param>
        public bool InsertEntity(TFunTag entity)
        {
            using (teaCRMDBContext db=new teaCRMDBContext())
            {
              int rows=  db.TFunTags.Insert(entity);
				 if (rows > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 执行Sql
 /// </summary>
 /// <param name="sql">Sql语句</param>
 /// <param name="namedParameters">查询字符串</param>
 /// <returns></returns>
 public bool ExecuteSql(string sql, dynamic namedParameters = null)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
      {
          var rows = db.DbHelper.ExecuteNonQuery(sql, namedParameters);
          if (rows > 0)
          {
              return true;
          }
          else
          {
              return false;
          }
      }
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 删除实体
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 public bool DeleteEntity(Expression<Func<TSysUser , bool>> predicate)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
         TSysUser  entity = db.TSysUsers.Where(predicate).First();
         int rows=db.TSysUsers.Delete(entity);
          if (rows > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 批量删除
 /// </summary>
 /// <param name="list">实体集合</param>
 public bool DeletesEntity(List<TSysUser> list)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
         //var tran = db.Connection.BeginTransaction();
         try
         {
             foreach (var item in list)
             {
                 db.TSysUsers.Delete(item);
             }
             //tran.Commit();
             return true;
         }
         catch (Exception ex)
         {
             //tran.Rollback();
             return false;
             throw new Exception(ex.Message);
         }
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 获取所有的数据
 /// </summary>
 /// <returns>返回所有数据列表</returns>
 public List<VSysDepartment> GetViewList()
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
      var models= db.VSysDepartments;
       var sqlText = models.GetProperty("SqlText");
      LogHelper.Debug(sqlText.ToString());
      return models.ToList();
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public bool UpadateEntity(TSysUser entity)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
        int rows= db.TSysUsers.Update(entity);
        if (rows > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Ejemplo n.º 20
0
 //查询分页
 public IPagination<TSysUser> GetListByPage(int pageIndex, int pageSize, out int rowCount,
     IDictionary<string, teaCRM.Entity.teaCRMEnums.OrderEmum> orders,
     Expression<Func<TSysUser, bool>> predicate)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         var roles = db.TSysUsers.Where(predicate);
         rowCount = roles.Count();
         var prevCount = (pageIndex - 1)*pageSize;
         var models = roles
             .Skip(prevCount)
             .Take(pageSize);
         foreach (var order in orders)
         {
             models = models.OrderBy(String.Format("{0} {1}", order.Key, order.Value));
         }
         var sqlText = models.GetProperty("SqlText");
         LogHelper.Debug("ELINQ Paging:<br/>" + sqlText.ToString());
         return models.ToPagination(pageSize, pageSize, rowCount);
     }
 }
Ejemplo n.º 21
0
 //以下是原生Sql方法==============================================================
 //===========================================================================
 /// <summary>
 /// 用SQL语句查询
 /// </summary>
 /// <param name="sql">sql语句</param>
 /// <param name="namedParameters">sql参数</param>
 /// <returns>集合</returns>
 public IEnumerable<TSysUser> GetListBySql(string sql, dynamic namedParameters)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
        return db.DbHelper.ExecuteDataTable(sql,namedParameters).ToList<TSysUser>();
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 获取指定的单个实体
 /// 如果不存在则返回null
 /// 如果存在多个则抛异常
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 /// <returns>Entity</returns>
 public TSysUser GetEntity(Expression<Func<TSysUser, bool>> predicate)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
         var model =db.TSysUsers.Where<TSysUser>(predicate);
         var sqlText = model.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return model.SingleOrDefault();
     }
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 根据条件查询某些字段(LINQ 动态查询)
 /// </summary>
 /// <param name="selector">要查询的字段(格式:new(ID,Name))</param>
 /// <param name="predicate">筛选条件(id=0)</param>
 /// <returns></returns>
 public IQueryable<Object> GetFields(string selector, string predicate)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
         var model = db.TSysUsers.Where(predicate).Select(selector);
         var sqlText = model.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return (IQueryable<object>) model;
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// 检测该公司下的账号名是否重复
 /// </summary>
 /// <param name="UserLName"></param>
 /// <param name="compNum"></param>
 /// <returns></returns>
 public bool ExistsUser(string UserLName, string compNum)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         var exists = db.TSysUsers.Any(u => u.CompNum == compNum && u.UserLname == UserLName);
         return !exists;
     }
 }
Ejemplo n.º 25
0
 /// <summary>
 /// 是否存在该记录
 /// </summary>
 /// <returns></returns>
 public bool ExistsEntity(Expression<Func<TCusLog , bool>> predicate)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
        bool status= db.TCusLogs.Any(predicate);
        return status;
     }
 }
Ejemplo n.º 26
0
		 //查询分页
    public  List<TFunTag> GetListByPage(int pageIndex, int pageSize, Expression<Func<TFunTag , bool>> predicate)
	  {
	   using (teaCRMDBContext db=new teaCRMDBContext())
            {
             var models= db.TFunTags.ToList();
			 return models;
            }
	  }
Ejemplo n.º 27
0
         /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="entity">实体对象</param>
        public bool UpadateEntity(TFunAppCompany entity)
        {
            using (teaCRMDBContext db=new teaCRMDBContext())
            {
               int rows= db.TFunAppCompanies.Update(entity);
			   if (rows > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
Ejemplo n.º 28
0
		   /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <returns></returns>
       public   bool ExistsEntity(Expression<Func<TFunAppCompany , bool>> predicate)
	   {
            using (teaCRMDBContext db=new teaCRMDBContext())
            {
               bool status= db.TFunAppCompanies.Any(predicate);
               return status;
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 批量改状态
        /// </summary>
        /// <param name="con_ids">The con_ids.</param>
        /// <param name="op">操作(0 1)</param>
        /// <param name="field">字段</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool UpdateStatusMoreContact(string con_ids, int op, string field)
        {
            using (teaCRMDBContext db = new teaCRMDBContext())
            {
                if (db.Connection.State != ConnectionState.Open)
                {
                    db.Connection.Open();
                }
                var tran = db.Connection.BeginTransaction();
                try
                {
                    int[] conIdArray = Utils.StringToIntArray(con_ids, ',');
                    foreach (var cusId in conIdArray)
                    {
                        string strSet = String.Format("{0}={1}", field, op);
                        string strWhere = String.Format("id={0}", cusId);

                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("UPDATE T_cus_con SET ");
                        strSql.Append(strSet);
                        strSql.Append(" WHERE ");
                        strSql.Append(strWhere);
                        LogHelper.Debug(strSql.ToString());

                        db.DbHelper.ExecuteNonQuery(strSql.ToString());
                    }
                    LogHelper.Debug("联系人状态事务执行成功!");
                    tran.Commit();
                    return true;
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    LogHelper.Error("联系人状态事务执行失败:", ex);
                    return false;
                }

                finally
                {
                    if (db.Connection.State != ConnectionState.Closed)
                    {
                        db.Connection.Close();
                    }
                }
            }
        }
Ejemplo n.º 30
0
	  //以下是原生Sql方法==============================================================
	  //===========================================================================
	   /// <summary>
        /// 用SQL语句查询
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="namedParameters">sql参数</param>
        /// <returns>集合</returns>
        public IEnumerable<VMyappCompany> GetViewListBySql(string sql, dynamic namedParameters)
        {
          using (teaCRMDBContext db=new teaCRMDBContext())
            {
               return db.DbHelper.ExecuteDataTable(sql,namedParameters).ToList<VMyappCompany>();
            }
          
        }