您的位置:首页 > 编程语言

使用 Rad Controls 实现 可拖动节点 Tree (源代码可以下载了)

2008-05-02 12:26 666 查看
1 VS2005和.NET 2.0

2 Telerik ASP.NET RAD CONTROLS系列控件,安装后会在VS的工具栏里添加一排RAD CONTROL的控件(AJAX版本也不错)

3 castle activerecord ,具体请看terrylee的贴 卢彦的activerecord as tree

4 MYSQL Connector/Net 5.1( MYSQL5.X版本 )

5 NAVICAT 或者 EMS SQL 或者其他MYSQL GUI管理工具

源代码里附带了程序源文件,MySQL Connector 5.1,Rad 控件和皮肤

最终实现效果如下

以下为MYSQL 的结构和数据文件

-- ----------------------------

-- Table structure for department_info

-- ----------------------------

DROP TABLE IF EXISTS `department_info`;

CREATE TABLE `department_info` (

`Department_SN` int(11) NOT NULL auto_increment COMMENT '部门流水号',

`Department_ID` varchar(50) default NULL COMMENT '部门编号',

`Department_Name` varchar(50) default NULL COMMENT '部门名称',

`Department_Level` int(11) default NULL COMMENT '部门层级',

`Department_UpperSn` int(11) default NULL COMMENT '部门层级',

`Department_BranchStorea` varchar(50) default NULL COMMENT '上级部门',

`Department_Head` varchar(50) default NULL COMMENT '部门总店',

`Department_Secretary` varchar(50) default NULL COMMENT '部门秘书',

`Department_Contact` varchar(50) default NULL COMMENT '部门联系人',

`Department_Address` varchar(50) default NULL COMMENT '部门地址',

`Department_Tel` varchar(50) default NULL COMMENT '部门电话',

`Department_Fax` varchar(50) default NULL COMMENT '部门传真',

`Department_Status` int(11) default NULL COMMENT '部门状态',

`Department_Memo` varchar(500) default NULL COMMENT '部门备注',

`Department_WBS` varchar(20) default NULL COMMENT 'WBS',

PRIMARY KEY (`Department_SN`)

) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8;

-- ----------------------------

-- Records

-- ----------------------------

INSERT INTO `department_info` VALUES ('51', '00104', '管理部', '1', null, '1', '00002', '00002', '00002', '上海市龙漕路', '021-6565656', '021-6565656', '1', '', '1');

INSERT INTO `department_info` VALUES ('52', '123123', '财务部', '2', '51', null, null, null, null, null, null, null, null, null, '1.1');

INSERT INTO `department_info` VALUES ('53', '123123', '外场', '3', '52', null, null, null, null, null, null, null, null, null, '1.1.1');

INSERT INTO `department_info` VALUES ('54', '00107', '仓管', '2', '51', null, null, null, null, null, null, null, null, null, '1.3');

INSERT INTO `department_info` VALUES ('55', '00108', '厨房', '4', '53', null, null, null, null, null, null, null, null, null, '1.1.1.1');

INSERT INTO `department_info` VALUES ('56', '00109', '采购', '2', '51', null, null, null, null, null, null, null, null, null, '1.2');

命名空间wbsbom_mysql

VS2008 新建一个WEB站点。按照castle的配置,

需要一个Global.asax,一个实体类文件department_info.cs

web.config的关键设置 2段activerecord设置是重点

<!--activerecord设置-->

<section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord"/>

<!--activerecord设置-->

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />

<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

</sectionGroup>

</sectionGroup>

</sectionGroup>

</configSections>

<connectionStrings>

<add name="Material_DBConnectionString" connectionString="server=192.168.0.56;uid=sa;pwd=;database=Material_DB" providerName="System.Data.SqlClient"/>

</connectionStrings>

<appSettings/>

<!--activerecord设置-->

<activerecord isWeb="true">

<config>

<add key="hibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver" />

<add key="hibernate.dialect" value="NHibernate.Dialect.MySQLDialect" />

<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />

<add key="hibernate.connection.connection_string" value="ConnectionString = ${Material_DBConnectionString}" />

</config>

</activerecord>

gloabax.asax

<%@ Application Language="C#" %>

<%@ Import Namespace="Castle.ActiveRecord" %>

<%@ Import Namespace="Castle.ActiveRecord.Framework.Config" %>

<script runat="server">

void Application_Start(object sender, EventArgs e)

private static void DeleteHaveNotChildren()

private static department_info DeleteHaveChildren()

private static void Create()

private static void Save()

//新建 和 新建一个部门的名字

department_info new_department_info = new department_info();

new_department_info.Department_Name = "博客园";

department_info new_Childrendepartment_info = new department_info();

new_Childrendepartment_info.Department_Name = "书籍翻译部门";

department_info grand_Childrendepartment_info = new department_info();

grand_Childrendepartment_info.Department_Name = "写书部门";

new_Childrendepartment_info.Children.Add(grand_Childrendepartment_info);

new_department_info.Children.Add(new_Childrendepartment_info);

new_department_info.Create();

//修改 和 修改一个部门的名字

department_info update_department_info = department_info.FindAllByProperty("Department_Name", "博客园")[0];

update_department_info.Department_Name = "博客园_修改";        //

department_info update_Childrendepartment_info = (department_info)update_department_info.Children[0];

update_Childrendepartment_info.Department_Name = "书籍翻译部门_修改";

update_department_info.Save();

//department_info del_department_info = department_info.FindAllByProperty("Department_Name", "博客园_修改")[0];

//del_department_info.Delete();

//department_info delHasntChildren_department_info = department_info.FindAllByProperty("Department_Name", "博客园_修改")[0];

//delHasntChildren_department_info.Children.Clear();

//delHasntChildren_department_info.Delete();

//新建 和 新建一个部门的名字

department_info new_department_info = new department_info();

new_department_info.Department_Name = "博客园";

department_info new_Childrendepartment_info = new department_info();

new_Childrendepartment_info.Department_Name = "书籍翻译部门";

new_department_info.Children.Add(new_Childrendepartment_info);

new_department_info.Create();

//修改 和 修改一个部门的名字

department_info update_department_info = department_info.FindAllByProperty("Department_Name", "博客园")[0];

update_department_info.Department_Name = "博客园_修改";        //

department_info update_Childrendepartment_info = (department_info)update_department_info.Children[0];

update_Childrendepartment_info.Department_Name = "书籍翻译部门_修改";

update_department_info.Save();

//department_info del_department_info = department_info.FindAllByProperty("Department_Name", "博客园_修改")[0];

//del_department_info.Delete();

//department_info delHasntChildren_department_info = department_info.FindAllByProperty("Department_Name", "博客园_修改")[0];

//delHasntChildren_department_info.Children.Clear();

//delHasntChildren_department_info.Delete();

源代码如下

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using Telerik.WebControls;

using System.Collections.Generic;

using System.Collections;

using System.Data.SqlClient;

using wbsbom_mysql;

using MySql.Data.MySqlClient;

public partial class WBSTree_Default2 : System.Web.UI.Page


Future Reading:Rails生成ExtTee
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐