java中Jcombobox的用法? 100
如何使用JcomboBox组件来实现级联效果,例如:总公司有多个子公司,公司1,公司2...;公司1有多个部门:采购,生产部,销售部...;公司2有多个部门:行政,采购,...
如何使用JcomboBox组件来实现级联效果,例如:总公司有多个子公司,公司1,公司2...;公司1有多个部门:采购,生产部,销售部...;公司2有多个部门:行政,采购,生产,销售...。使用MSSQL数据库,Company表存储公司信息,有三个字段:id(主键),name(公司名称),upper(上级公司编号);department存储部门信息,有四个字段,id(主键),name(部门名称),upper(上级部门编号),ssgs(所属公司)。SQL脚本为:if exists (select 1
from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('department') and o.name = 'FK_DEPARTME_REFERENCE_COMPANY')
alter table department
drop constraint FK_DEPARTME_REFERENCE_COMPANY
go
if exists (select 1
from sysobjects
where id = object_id('Company')
and type = 'U')
drop table Company
go
if exists (select 1
from sysobjects
where id = object_id('department')
and type = 'U')
drop table department
go
create table Company (
id varchar(8) not null,
name varchar(15) null,
upper varchar(8) null,
constraint PK_COMPANY primary key (id)
)
go
create table department (
id varchar(8) not null,
name varchar(15) null,
upper varchar(8) null,
ssgs varchar(8) null,
constraint PK_DEPARTMENT primary key (id)
)
go
alter table department
add constraint FK_DEPARTME_REFERENCE_COMPANY foreign key (ssgs)
references Company (id)
go
我想使用两个JcomboBox选择来查找数据,第一个为公司选择,第二个为所选公司的部门。请问有高手给我出代码吗? 展开
from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('department') and o.name = 'FK_DEPARTME_REFERENCE_COMPANY')
alter table department
drop constraint FK_DEPARTME_REFERENCE_COMPANY
go
if exists (select 1
from sysobjects
where id = object_id('Company')
and type = 'U')
drop table Company
go
if exists (select 1
from sysobjects
where id = object_id('department')
and type = 'U')
drop table department
go
create table Company (
id varchar(8) not null,
name varchar(15) null,
upper varchar(8) null,
constraint PK_COMPANY primary key (id)
)
go
create table department (
id varchar(8) not null,
name varchar(15) null,
upper varchar(8) null,
ssgs varchar(8) null,
constraint PK_DEPARTMENT primary key (id)
)
go
alter table department
add constraint FK_DEPARTME_REFERENCE_COMPANY foreign key (ssgs)
references Company (id)
go
我想使用两个JcomboBox选择来查找数据,第一个为公司选择,第二个为所选公司的部门。请问有高手给我出代码吗? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询