Ejemplo n.º 1
0
        /// <summary>
        /// 分页
        /// </summary>
        public List <crm_com_platform> GetPage(string orderName, string order, int offset, int pageSize, string stime, string etime, string search, out int total)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  Id,ComPlatformValue,Type,IsSelected,UTime,CTime  ");
            strSql.Append("  from crm_com_platform ");

            strSql.Append($" where  UTime>='{stime}' AND UTime<'{etime}' ");
            strSql.Append($"  ORDER BY {orderName} {order} LIMIT {offset},{pageSize}; ");

            StringBuilder strSqlCount = new StringBuilder();

            strSqlCount.Append("  SELECT COUNT(1) FROM crm_com_platform ");

            strSqlCount.Append($" where  UTime>='{stime}' AND UTime<'{etime}' ");

            _reader = MySqlHelper.ExecuteReader(BasicConfig.ConnectionString, CommandType.Text, strSql.ToString());

            List <crm_com_platform> list = new List <crm_com_platform>();

            while (_reader.Read())
            {
                list.Add(new crm_com_platform {
                    Id = _reader["Id"].ToInt_V(),
                    ComPlatformValue = _reader["ComPlatformValue"].ToDouble_V(),
                    Type             = _reader["Type"].ToInt_V(),
                    IsSelected       = _reader["IsSelected"].ToInt_V(),
                    UTime            = _reader["UTime"].ToDateTime_V(),
                    CTime            = _reader["CTime"].ToDateTime_V()
                });
            }
            total = int.Parse(MySqlHelper.ExecuteScalar(MySqlHelper.ConnectionString, CommandType.Text, strSqlCount.ToString()).ToString());;
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 判断是否存在
        /// </summary>
        public bool Exists(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from crm_com_platform");
            strSql.Append(" where Id=@Id");

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Id", MySqlDbType.Int32, 11)
            };

            parameters[0].Value = Id;

            return(int.Parse(MySqlHelper.ExecuteScalar(BasicConfig.ConnectionString, CommandType.Text, strSql.ToString(), parameters).ToString()) > 0 ? true : false);
        }