コード例 #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 SellNum</returns>
        public IList <BCW.Model.SellNum> GetSellNums(int p_pageIndex, int p_pageSize, string strWhere, out int p_recordCount)
        {
            IList <BCW.Model.SellNum> listSellNums = new List <BCW.Model.SellNum>();
            string sTable     = "tb_SellNum";
            string sPkey      = "id";
            string sField     = "ID,Types,UsID,UsName,BuyUID,Price,State,Mobile,Notes,AddTime,Tags,PayTime";
            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(listSellNums);
                }
                while (reader.Read())
                {
                    BCW.Model.SellNum objSellNum = new BCW.Model.SellNum();
                    objSellNum.ID     = reader.GetInt32(0);
                    objSellNum.Types  = reader.GetInt32(1);
                    objSellNum.UsID   = reader.GetInt32(2);
                    objSellNum.UsName = reader.GetString(3);
                    objSellNum.BuyUID = reader.GetInt32(4);
                    objSellNum.Price  = reader.GetInt64(5);
                    objSellNum.State  = reader.GetByte(6);

                    if (!reader.IsDBNull(7))
                    {
                        objSellNum.Mobile = reader.GetString(7);
                    }
                    if (!reader.IsDBNull(8))
                    {
                        objSellNum.Notes = reader.GetString(8);
                    }

                    objSellNum.AddTime = reader.GetDateTime(9);
                    objSellNum.Tags    = reader.GetInt32(10);
                    if (!reader.IsDBNull(11))
                    {
                        objSellNum.PayTime = reader.GetDateTime(11);
                    }

                    listSellNums.Add(objSellNum);
                }
            }
            return(listSellNums);
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BCW.Model.SellNum GetSellNum(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Types,UsID,UsName,BuyUID,Price,State,Mobile,Notes,AddTime,Tags,PayTime from tb_SellNum ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            BCW.Model.SellNum model = new BCW.Model.SellNum();
            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.BuyUID = reader.GetInt32(4);
                    model.Price  = reader.GetInt64(5);
                    model.State  = reader.GetByte(6);
                    if (!reader.IsDBNull(7))
                    {
                        model.Mobile = reader.GetString(7);
                    }
                    if (!reader.IsDBNull(8))
                    {
                        model.Notes = reader.GetString(8);
                    }

                    model.AddTime = reader.GetDateTime(9);
                    model.Tags    = reader.GetInt32(10);
                    if (!reader.IsDBNull(11))
                    {
                        model.PayTime = reader.GetDateTime(11);
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add2(BCW.Model.SellNum model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_SellNum(");
            strSql.Append("Types,UsID,UsName,BuyUID,Price,State,Mobile,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@Types,@UsID,@UsName,@BuyUID,@Price,@State,@Mobile,@AddTime)");
            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("@BuyUID",  SqlDbType.Int,       4),
                new SqlParameter("@Price",   SqlDbType.BigInt,    8),
                new SqlParameter("@State",   SqlDbType.TinyInt,   1),
                new SqlParameter("@Mobile",  SqlDbType.NVarChar, 50),
                new SqlParameter("@AddTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.Types;
            parameters[1].Value = model.UsID;
            parameters[2].Value = model.UsName;
            parameters[3].Value = model.BuyUID;
            parameters[4].Value = model.Price;
            parameters[5].Value = model.State;
            parameters[6].Value = model.Mobile;
            parameters[7].Value = model.AddTime;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(BCW.Model.SellNum model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_SellNum set ");
            strSql.Append("Types=@Types,");
            strSql.Append("UsID=@UsID,");
            strSql.Append("UsName=@UsName,");
            strSql.Append("BuyUID=@BuyUID,");
            strSql.Append("Price=@Price,");
            strSql.Append("State=@State,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("PayTime=@PayTime");
            strSql.Append(" where ID=@ID ");
            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("@BuyUID",  SqlDbType.Int,        4),
                new SqlParameter("@Price",   SqlDbType.BigInt,     8),
                new SqlParameter("@State",   SqlDbType.TinyInt,    1),
                new SqlParameter("@AddTime", SqlDbType.DateTime),
                new SqlParameter("@PayTime", 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.BuyUID;
            parameters[5].Value = model.Price;
            parameters[6].Value = model.State;
            parameters[7].Value = model.AddTime;
            parameters[8].Value = model.PayTime;

            SqlHelper.ExecuteSql(strSql.ToString(), parameters);
        }