示例#1
0
        public void changeDisporder(Int32 nodeAID, Int32 nodeBID)
        {
            isSucces = true;
            string connectionString  = DBSource.ConnectionStringPBox;
            int    nodeAID_Disporder = 0;
            int    nodeBID_Disporder = 0;
            string commandTextA      = "SELECT * FROM FileNode WHERE node_id=" + nodeAID;
            string commandTextB      = "SELECT * FROM FileNode WHERE node_id=" + nodeBID;

            helperPBox = new dBHelper(connectionString);
            if (helperPBox.Load(commandTextA, "node_id") == true)
            {
                foreach (DataRow dr in helperPBox.DataSet.Tables[0].Rows)
                {
                    nodeAID_Disporder = int.Parse(dr["disporder"].ToString());
                }
            }
            if (helperPBox.Load(commandTextB, "node_id") == true)
            {
                foreach (DataRow dr in helperPBox.DataSet.Tables[0].Rows)
                {
                    nodeBID_Disporder = int.Parse(dr["disporder"].ToString());
                }
            }
            string commandTextC1 = "update FileNode set disporder = " + nodeBID_Disporder + " WHERE node_id=" + nodeAID;
            string commandTextC2 = "update FileNode set disporder = " + nodeAID_Disporder + " WHERE node_id=" + nodeBID;

            isSucces = isSucces && helperPBox.ExecuteNonQuery(commandTextC1);
            isSucces = isSucces && helperPBox.ExecuteNonQuery(commandTextC2);
        }
示例#2
0
        public void deleteFileNode(Int32 nodeID)
        {
            isSucces = true;
            string connectionString = DBSource.ConnectionStringPBox;

            helperPBox = new dBHelper(connectionString);
            //1、先删除节点下的所有文件数据
            string commandText = "SELECT * FROM FileMemo WHERE file_nodeid=" + nodeID;

            if (helperPBox.Load(commandText, "file_nodeid") == true)
            {
                foreach (DataRow dr in helperPBox.DataSet.Tables[0].Rows)
                {
                    int curFileID = int.Parse(dr["file_id"].ToString());
                    isSucces = isSucces && deleteFileData(curFileID);
                }
            }
            //2、删除节点下的所有文件描述信息
            commandText = "delete FROM FileMemo WHERE file_nodeid=" + nodeID;
            isSucces    = isSucces && helperPBox.ExecuteNonQuery(commandText);
            //3、再删除节点下所有子节点
            commandText = "SELECT * FROM FileNode WHERE parent_id=" + nodeID;
            if (helperPBox.Load(commandText, "node_id") == true)
            {
                foreach (DataRow dr in helperPBox.DataSet.Tables[0].Rows)
                {
                    int curNodeID = int.Parse(dr["node_id"].ToString());
                    deleteFileNode(curNodeID);
                }
            }
            //4、删除自己
            commandText = "SELECT * FROM FileNode WHERE node_id=" + nodeID;
            if (helperPBox.Load(commandText, "node_id") == true)
            {
                if (helperPBox.DataSet.Tables[0].Rows.Count == 1)
                {
                    helperPBox.DataSet.Tables[0].Rows[0].Delete();
                    try
                    {
                        if (helperPBox.Save() == true)
                        {
                            isSucces = isSucces && true;
                        }
                        else
                        {
                            isSucces = isSucces && false;
                            MessageBox.Show("Delete failed");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }