Ejemplo n.º 1
0
        /// <summary>
        /// 取得每页记录
        /// </summary>
        /// <param name="p_pageIndex">当前页</param>
        /// <param name="p_pageSize">分页大小</param>
        /// <param name="p_recordCount">返回总记录数</param>
        /// <param name="strWhere">查询条件</param>
        /// <returns>IList GiftFlows</returns>
        public IList <BCW.Model.Game.GiftFlows> GetGiftFlowss(int p_pageIndex, int p_pageSize, string strWhere, out int p_recordCount)
        {
            IList <BCW.Model.Game.GiftFlows> listGiftFlowss = new List <BCW.Model.Game.GiftFlows>();
            string sTable     = "tb_GiftFlows";
            string sPkey      = "id";
            string sField     = "ID,Types,UsID,UsName,Total,Totall";
            string sCondition = strWhere;
            string sOrder     = "ID Desc";
            int    iSCounts   = 0;

            using (SqlDataReader reader = SqlHelper.RunProcedureMe(sTable, sPkey, sField, p_pageIndex, p_pageSize, sCondition, sOrder, iSCounts, out p_recordCount))
            {
                //计算总页数
                if (p_recordCount > 0)
                {
                    int pageCount = BasePage.CalcPageCount(p_recordCount, p_pageSize, ref p_pageIndex);
                }
                else
                {
                    return(listGiftFlowss);
                }
                while (reader.Read())
                {
                    BCW.Model.Game.GiftFlows objGiftFlows = new BCW.Model.Game.GiftFlows();
                    objGiftFlows.ID     = reader.GetInt32(0);
                    objGiftFlows.Types  = reader.GetInt32(1);
                    objGiftFlows.UsID   = reader.GetInt32(2);
                    objGiftFlows.UsName = reader.GetString(3);
                    objGiftFlows.Total  = reader.GetInt32(4);
                    objGiftFlows.Totall = reader.GetInt32(5);
                    listGiftFlowss.Add(objGiftFlows);
                }
            }
            return(listGiftFlowss);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(BCW.Model.Game.GiftFlows model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_GiftFlows set ");
            strSql.Append("UsName=@UsName,");
            strSql.Append("Total=Total+@Total,");
            strSql.Append("Totall=Totall+@Totall,");
            strSql.Append("AddTime=@AddTime");
            strSql.Append(" where Types=@Types and UsID=@UsID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",      SqlDbType.Int,       4),
                new SqlParameter("@Types",   SqlDbType.Int,       4),
                new SqlParameter("@UsID",    SqlDbType.Int,       4),
                new SqlParameter("@UsName",  SqlDbType.NVarChar, 50),
                new SqlParameter("@Total",   SqlDbType.Int,       4),
                new SqlParameter("@Totall",  SqlDbType.Int,       4),
                new SqlParameter("@AddTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Types;
            parameters[2].Value = model.UsID;
            parameters[3].Value = model.UsName;
            parameters[4].Value = model.Total;
            parameters[5].Value = model.Totall;
            parameters[6].Value = DateTime.Now;

            SqlHelper.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BCW.Model.Game.GiftFlows GetGiftFlows(int Types, int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Types,UsID,UsName,Total,Totall from tb_GiftFlows ");
            strSql.Append(" where Types=@Types and ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Types", SqlDbType.Int, 4),
                new SqlParameter("@ID",    SqlDbType.Int, 4)
            };
            parameters[0].Value = Types;
            parameters[1].Value = ID;

            BCW.Model.Game.GiftFlows model = new BCW.Model.Game.GiftFlows();
            using (SqlDataReader reader = SqlHelper.ExecuteReader(strSql.ToString(), parameters))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    model.ID     = reader.GetInt32(0);
                    model.Types  = reader.GetInt32(1);
                    model.UsID   = reader.GetInt32(2);
                    model.UsName = reader.GetString(3);
                    model.Total  = reader.GetInt32(4);
                    model.Totall = reader.GetInt32(5);
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 取到排行榜
        /// </summary>
        /// <param name="p_pageIndex">当前页</param>
        /// <param name="p_pageSize">每页显示记录数</param>
        /// <param name="p_recordCount">返回总记录数</param>
        /// <param name="strWhere">查询条件</param>
        /// <returns>List</returns>
        public IList <BCW.Model.Game.GiftFlows> GetGiftFlowssTop2(int p_pageIndex, int p_pageSize, string strWhere, out int p_recordCount)
        {
            IList <BCW.Model.Game.GiftFlows> listGiftFlows = new List <BCW.Model.Game.GiftFlows>();

            string strWhe = "";

            if (strWhere != "")
            {
                strWhe = " where " + strWhere + "";
            }

            // 计算记录数
            string countString = "SELECT COUNT(DISTINCT Types) FROM tb_GiftFlows " + strWhe + "";

            p_recordCount = Convert.ToInt32(SqlHelper.GetSingle(countString));
            if (p_recordCount > 0)
            {
                int pageCount = BasePage.CalcPageCount(p_recordCount, p_pageSize, ref p_pageIndex);
                if (pageCount > 50)
                {
                    pageCount = 50;
                }
            }
            else
            {
                return(listGiftFlows);
            }

            // 取出相关记录

            string queryString = "SELECT Types, Sum(Total) as Total, Sum(Totall) as Totall FROM tb_GiftFlows " + strWhe + " GROUP BY Types ORDER BY Sum(Total) DESC";

            using (SqlDataReader reader = SqlHelper.ExecuteReader(queryString))
            {
                int stratIndex = (p_pageIndex - 1) * p_pageSize;
                int endIndex   = p_pageIndex * p_pageSize;
                int k          = 0;
                while (reader.Read())
                {
                    if (k >= stratIndex && k < endIndex)
                    {
                        BCW.Model.Game.GiftFlows objGiftFlows = new BCW.Model.Game.GiftFlows();
                        objGiftFlows.Types  = reader.GetInt32(0);
                        objGiftFlows.Total  = reader.GetInt32(1);
                        objGiftFlows.Totall = reader.GetInt32(2);
                        listGiftFlows.Add(objGiftFlows);
                    }

                    if (k == endIndex)
                    {
                        break;
                    }

                    k++;
                }
            }

            return(listGiftFlows);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BCW.Model.Game.GiftFlows model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_GiftFlows(");
            strSql.Append("Types,UsID,UsName,Total,Totall,AddTime,UsIP)");
            strSql.Append(" values (");
            strSql.Append("@Types,@UsID,@UsName,@Total,@Totall,@AddTime,@UsIP)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Types",   SqlDbType.Int,        4),
                new SqlParameter("@UsID",    SqlDbType.Int,        4),
                new SqlParameter("@UsName",  SqlDbType.NVarChar,  50),
                new SqlParameter("@Total",   SqlDbType.Int,        4),
                new SqlParameter("@Totall",  SqlDbType.Int,        4),
                new SqlParameter("@AddTime", SqlDbType.DateTime),
                new SqlParameter("@UsIP",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Types;
            parameters[1].Value = model.UsID;
            parameters[2].Value = model.UsName;
            parameters[3].Value = model.Total;
            parameters[4].Value = model.Totall;
            parameters[5].Value = DateTime.Now;
            parameters[6].Value = Utils.GetUsIP();

            object obj = SqlHelper.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }