数据库
use master
if exists (select * from sysdatabases where name='bond')
drop database bond
create database bond
on PRIMARY
(
name='bond_data',
FILENAME='F:\asp\理财代销\management\bond.mdf',
filegrowth=20%,
size=10MB
)
LOG ON
(
name='bond_log',
FILENAME='F:\asp\理财代销\management\bond_log.ldf',
size=3MB,
MAXSIZE=20MB
)
use bond
--基金类型表(左用)
if exists (select * from sys.objects where name='jjlx')
drop table jjlx
create table jjlx
(
id int primary key identity(1,1), --id
jjlx varchar(50) not null --基金类型
)
--基金类型表增加存储过程
if exists(select * from sys.objects where name='jjlx_add')
drop procedure jjlx_add
go
create proc jjlx_add
@jjlx varchar(50)
as
insert into jjlx values (@jjlx)
go
--基金类型表查询存储过程
if exists(select * from sys.objects where name='p_jjlx')
drop procedure p_jjlx
go
create proc p_jjlx
as
select * from jjlx
go
--基金类型表修改存储过程
if exists(select * from sys.objects where name='jjlx_gai')
drop procedure jjlx_gai
go
create proc jjlx_gai
@id int,
@jjlx varchar(50)
as
UPDATE jjlx SET jjlx=@jjlx where id=@id
go
--基金类型表删除存储过程
if exists(select * from sys.objects where name='jjlx_delete')
drop procedure jjlx_delete
go
create proc jjlx_delete
@id int,
@jjlx varchar(50)
as
delete from jjlx where id=@id and jjlx=@jjlx
go
链接数据库
Web.config
<connectionStrings>
<add name="conn" connectionString="server=.;database=bond;integrated security=true" />
</connectionStrings>
Model层
managementModel类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace managementModel
{
public class jjlxs//基金类型表
{
public int id { set; get; }//id
public string jjlx { set; get; } //基金类型
}
}
DAL层
添加引用 Model层
添加程序集引用 using System.Configuration;
managementDAL类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using managementModel;
namespace managementDAL
{
public class jjlxdal
{
DBHelper db