示例#1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public long Add(JY.Model.Collection model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",             SqlDbType.BigInt,     8),
                new SqlParameter("@ProductId",      SqlDbType.Int,        4),
                new SqlParameter("@ProductName",    SqlDbType.NVarChar,  50),
                new SqlParameter("@MemberId",       SqlDbType.Int,        4),
                new SqlParameter("@MemberName",     SqlDbType.NVarChar,  50),
                new SqlParameter("@CollectionDate", SqlDbType.DateTime),
                new SqlParameter("@Sort",           SqlDbType.Int,        4),
                new SqlParameter("@IsDelete",       SqlDbType.Bit, 1)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.ProductId;
            parameters[2].Value     = model.ProductName;
            parameters[3].Value     = model.MemberId;
            parameters[4].Value     = model.MemberName;
            parameters[5].Value     = model.CollectionDate;
            parameters[6].Value     = model.Sort;
            parameters[7].Value     = model.IsDelete;

            DbHelperSQL.RunProcedure("Collection_ADD", parameters, out rowsAffected);
            return((long)parameters[0].Value);
        }
示例#2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(JY.Model.Collection model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",             SqlDbType.BigInt,     8),
                new SqlParameter("@ProductId",      SqlDbType.Int,        4),
                new SqlParameter("@ProductName",    SqlDbType.NVarChar,  50),
                new SqlParameter("@MemberId",       SqlDbType.Int,        4),
                new SqlParameter("@MemberName",     SqlDbType.NVarChar,  50),
                new SqlParameter("@CollectionDate", SqlDbType.DateTime),
                new SqlParameter("@Sort",           SqlDbType.Int,        4),
                new SqlParameter("@IsDelete",       SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.ProductId;
            parameters[2].Value = model.ProductName;
            parameters[3].Value = model.MemberId;
            parameters[4].Value = model.MemberName;
            parameters[5].Value = model.CollectionDate;
            parameters[6].Value = model.Sort;
            parameters[7].Value = model.IsDelete;

            DbHelperSQL.RunProcedure("Collection_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JY.Model.Collection GetModel(long ID)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;

            JY.Model.Collection model = new JY.Model.Collection();
            DataSet             ds    = DbHelperSQL.RunProcedure("Collection_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductId"] != null && ds.Tables[0].Rows[0]["ProductId"].ToString() != "")
                {
                    model.ProductId = int.Parse(ds.Tables[0].Rows[0]["ProductId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductName"] != null && ds.Tables[0].Rows[0]["ProductName"].ToString() != "")
                {
                    model.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MemberId"] != null && ds.Tables[0].Rows[0]["MemberId"].ToString() != "")
                {
                    model.MemberId = int.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MemberName"] != null && ds.Tables[0].Rows[0]["MemberName"].ToString() != "")
                {
                    model.MemberName = ds.Tables[0].Rows[0]["MemberName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CollectionDate"] != null && ds.Tables[0].Rows[0]["CollectionDate"].ToString() != "")
                {
                    model.CollectionDate = DateTime.Parse(ds.Tables[0].Rows[0]["CollectionDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sort"] != null && ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                {
                    model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsDelete"] != null && ds.Tables[0].Rows[0]["IsDelete"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsDelete"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDelete"].ToString().ToLower() == "true"))
                    {
                        model.IsDelete = true;
                    }
                    else
                    {
                        model.IsDelete = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }