コード例 #1
0
ファイル: FavoriteDB.cs プロジェクト: godsayyou/Mes-1
        public int LoadFavoriteByUserID_PrivilegeID(Favorite obj)
        {
            string     sql = @"SELECT [UserID]
				, [PrivilegeID]
                FROM [BE_Favorite] WITH(NOLOCK) WHERE [UserID]=@UserID AND [PrivilegeID]=@PrivilegeID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pUserID = new SqlParameter("UserID", Convert2DBnull(obj.UserID));

            pUserID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pUserID);

            SqlParameter pPrivilegeID = new SqlParameter("PrivilegeID", Convert2DBnull(obj.PrivilegeID));

            pPrivilegeID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pPrivilegeID);

            int           ret = 0;
            SqlDataReader dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    if (!Convert.IsDBNull(dr["UserID"]))
                    {
                        obj.UserID = (Guid)dr["UserID"];
                    }
                    if (!Convert.IsDBNull(dr["PrivilegeID"]))
                    {
                        obj.PrivilegeID = (Guid)dr["PrivilegeID"];
                    }
                    ret += 1;
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
コード例 #2
0
ファイル: FavoriteDB.cs プロジェクト: godsayyou/Mes-1
        public int InsertFavorite(Favorite obj)
        {
            string     sql = @"INSERT INTO[BE_Favorite]([UserID]
				, [PrivilegeID]
				) VALUES(@UserID
				, @PrivilegeID
				)"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pUserID = new SqlParameter("UserID", Convert2DBnull(obj.UserID));

            pUserID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pUserID);

            SqlParameter pPrivilegeID = new SqlParameter("PrivilegeID", Convert2DBnull(obj.PrivilegeID));

            pPrivilegeID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pPrivilegeID);

            return(cmd.ExecuteNonQuery());
        }
コード例 #3
0
ファイル: FavoriteDB.cs プロジェクト: godsayyou/Mes-1
        public List <Favorite> LoadFavoritesByPrivilegeID(Guid privilegeID)
        {
            string     sql = @"SELECT [UserID]
				, [PrivilegeID]
				 FROM [BE_Favorite] WHERE [PrivilegeID]=@PrivilegeID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pPrivilegeID = new SqlParameter("PrivilegeID", privilegeID);

            pPrivilegeID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pPrivilegeID);

            List <Favorite> ret = new List <Favorite>();
            SqlDataReader   dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    Favorite iret = new Favorite();
                    if (!Convert.IsDBNull(dr["UserID"]))
                    {
                        iret.UserID = (Guid)dr["UserID"];
                    }
                    if (!Convert.IsDBNull(dr["PrivilegeID"]))
                    {
                        iret.PrivilegeID = (Guid)dr["PrivilegeID"];
                    }
                    ret.Add(iret);
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }