/*
         * 初始化文件文件夹树
         */
        private void StorageGif_InitFolder()
        {
            //1.初始化页面树
            StorageGifFolder storageGifFolder = storageGifFolderBll.get(1);

            if (storageGifFolder == null)
            {
                return;
            }

            TreeViewItem firstItem = new TreeViewItem();

            firstItem.IsExpanded = true;
            firstItem.Header     = storageGifFolder.name;
            firstItem.Tag        = storageGifFolder.id;
            firstItem.Padding    = new Thickness(5);

            StorageGif_GetTreeViewItemChildren(firstItem);

            //添加单击、右键事件
            folderTreeColumn.MouseLeftButtonUp += (object sender, MouseButtonEventArgs e) => StorageGif_TreeView_MouseLeftButtonUp(sender, e);

            folderTreeColumn.Items.Clear();
            folderTreeColumn.Items.Add(firstItem);
        }
コード例 #2
0
        /*
         * 获取最后一个文件夹
         */
        public StorageGifFolder getLastFolder()
        {
            String sql = "select * from storageGifFolder order by id desc limit 0,1";

            SQLiteParameter[] parameters =
            {
            };
            DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters);

            StorageGifFolder entity = DataToEntity <StorageGifFolder> .FillModel(dt.Rows[0]);

            return(entity);
        }
コード例 #3
0
        /*
         * 获取父栏目中最大的排序号
         */
        public StorageGifFolder getMaxIdxByParentId(int parentId)
        {
            String sql = "select max(idx) as idx from storageGifFolder where parentId=@parentId";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@parentId", DbType.Int32, 4)
            };
            parameters[0].Value = parentId;

            DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters);

            StorageGifFolder entity = DataToEntity <StorageGifFolder> .FillModel(dt.Rows[0]);

            return(entity);
        }
コード例 #4
0
        /*
         * 插入子文件夹
         */
        public StorageGifFolder insertChild(StorageGifFolder tmp)
        {
            //补充idx,createTime两个参数
            StorageGifFolder maxFolder = getMaxIdxByParentId(tmp.parentId);

            if (maxFolder == null)
            {
                tmp.idx = 1;
            }
            else
            {
                tmp.idx = maxFolder.idx + 1;
            }

            return(storageGifFolderDal.insert(tmp));
        }
コード例 #5
0
        /*
         * 是否存在同名文件夹
         */
        public int hasSameName(StorageGifFolder entity)
        {
            string sql = "select count(*) from storageGifFolder where name=@name and id!=@id";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@name", DbType.String, 30),
                new SQLiteParameter("@id",   DbType.Int32, 4)
            };
            parameters[0].Value = entity.name;
            parameters[1].Value = entity.id;

            object obj = Common.SQLiteHelper.ExecuteScalar(sql, parameters);

            int result = int.Parse(obj.ToString());

            return(result);
        }
コード例 #6
0
        /*
         * 插入一个文件夹
         */
        public StorageGifFolder insert(StorageGifFolder entity)
        {
            String sql = "insert into storageGifFolder(name,parentId,idx) values(@name,@parentId,@idx);select last_insert_rowid();";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@name",     DbType.String, 100),
                new SQLiteParameter("@parentId", DbType.Int32,    4),
                new SQLiteParameter("@idx",      DbType.Int32, 4)
            };
            parameters[0].Value = entity.name;
            parameters[1].Value = entity.parentId;
            parameters[2].Value = entity.idx;

            DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters);
            int       id = DataType.ToInt32(dt.Rows[0]["last_insert_rowid()"].ToString());

            entity.id = id;
            return(entity);
        }
コード例 #7
0
        /*
         * 更新
         */
        public int update(StorageGifFolder entity)
        {
            string sql = "update storageGifFolder set name=@name,parentId=@parentId,idx=@idx"
                         + "  where id=@id";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@name",     DbType.String, 100),
                new SQLiteParameter("@parentId", DbType.Int32,    4),
                new SQLiteParameter("@idx",      DbType.Int32,    4),
                new SQLiteParameter("@id",       DbType.Int32, 4)
            };
            parameters[0].Value = entity.name;
            parameters[1].Value = entity.parentId;
            parameters[2].Value = entity.idx;
            parameters[3].Value = entity.id;

            int result = Common.SQLiteHelper.ExecuteNonQuery(sql, parameters);

            return(result);
        }
コード例 #8
0
        /*
         * 获取文件夹
         */
        public StorageGifFolder get(int id)
        {
            String sql = "select * from storageGifFolder where id=@id";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@id", DbType.Int32, 4)
            };
            parameters[0].Value = id;

            DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(null);
            }

            StorageGifFolder storageGifFolder = DataToEntity <StorageGifFolder> .FillModel(dt.Rows[0]);

            return(storageGifFolder);
        }
コード例 #9
0
        /*
         * 是否存在同名文件夹
         */
        public bool hasSameName(StorageGifFolder storageGifFolder)
        {
            int rows = storageGifFolderDal.hasSameName(storageGifFolder);

            return(rows > 0 ? true : false);
        }
コード例 #10
0
        /*
         * 更新
         */
        public StorageGifFolder update(StorageGifFolder storageGifFolder)
        {
            int rows = storageGifFolderDal.update(storageGifFolder);

            return(storageGifFolder);
        }