亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? atm.c

?? 可以實現當前自動取款機的各功能
?? C
?? 第 1 頁 / 共 2 頁
字號:
/****************2創建數據庫*******************/
use master
go

if exists (select * from sysdatabases where name='bankDB')--檢查系統中是否已存在數據庫atm
drop database bankDB --如果存在則刪除

go
exec xp_cmdshell 'mkdir G:\二期學習\SQL Server\bank' ,no_output--調用DOS命令創建文件夾
create database bankDB --新建數據庫
on primary  --主文件
(
name = 'atm_data', --邏輯名稱
filename='G:\二期學習\SQL Server\bank\bankDB_data.mdf', --物理名稱
size=10 , --初始大小
filegrowth=15%  --增長率
)
log on --日志文件
(
name='atm_log', --邏輯名稱
filename='G:\二期學習\SQL Server\bank\bankDB_log.ldf',--物理名稱
size=1 , --初始大小
filegrowth=10% --增長率
)
go

/**********************3建表***********************/
use bankDB
go
-------------------1用戶信息表userInfo------------------
if exists (select * from sysobjects where name='userInfo')
drop table userInfo
go
create table userInfo
(
customerID  int identity(1,1) not null,--顧客編號,自動編號(標識列),從1開始,主鍵
customerName varchar (8) not null ,--開戶名
PID varchar(18) not null,--身份證號,必填,只能是18位或15位,身份證號唯一約束
telephone varchar(18) not null,--聯系電話,必填,格式為xxxx-xxxxxxxx或手機號13位
address varchar(20)--居住地址,可選輸入
)

--------------------2銀行卡信息表cardInfo------------------
if exists (select * from sysobjects where name='cardInfo')
drop table  cardInfo
go

create table cardInfo
(
cardID char (19) not null,--卡號,必填,主健,銀行的卡號規則和電話號碼一樣,一般前8位代表特殊含義 假定該行要求其營業廳的卡號格式為:1010 3576 xxxx xxx開始,每4位號碼后有空格,卡號一般是隨機產生.
curType  char(4) not null, --貨幣種類 
savingType char(8), --存款類型 活期/定活兩便/定期
openDate datetime not null,--開戶日期 
openMoney money not null, --開戶金額 
balance money not null, --余額  
pass int  not null ,--密碼  
IsReportLoss bit  not null, --是否掛失  
customerID int not null --顧客編號 
)
go
------------------3交易信息表transInfo -------------------
if exists (select * from sysobjects where name='transInfo')
drop table  transInfo
go

create table transInfo
(
transDate  datetime not null,--交易日期,必填,默認為系統當前日期
cardID char (19) not null,--卡號,必填,外健,可重復索引
transType  char(8) not null,--交易類型,必填,只能是存入/支取
transMoney money not null,--交易金額,必填,大于0
remark text--備注,可選輸入,其他說明
)
go

/************************4添加約束*****************************/

-----------------------1用戶信息表userInfo 添加約束--------------

--主鍵約束customerID 顧客編號 自動編號(標識列)
if exists (select * from sysobjects where name='pr_customerID')
alter table userInfo
drop constraint pr_customerID
alter table userInfo
add constraint pr_customerID primary key (customerID)

--檢查約束customerID 身份證號 只能是18位或15位
if exists (select * from sysobjects where name='ck_PID')
alter table userInfo
drop constraint ck_PID
alter table userInfo
add constraint ck_PID check (
PID like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
or PID like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9,x]'
)


--唯一約束customerID身份證號 
if exists (select * from sysobjects where name='uq_PID')
alter table userInfo
drop constraint uq_PID
alter table userInfo
add constraint uq_PID  unique(customerID)


--檢查約束telephone電話號碼格式為xxxx-xxxxxxxx或手機號13位
if exists (select * from sysobjects where name='ck_telephone')
alter table userInfo
drop constraint ck_telephone
alter table userInfo
add constraint ck_telephone check 
(telephone like '1[3,5][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' or
telephone like '[0][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' or
telephone like '[0][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' )
--(len(telephone)-13 or telephone like [0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])

 

-----------------2銀行卡信息表cardInfo 添加約束------------------
--主鍵約束 cardID 卡號
if exists (select * from sysobjects where name='pr_cardID')
alter table cardInfo
drop constraint pr_cardID
alter table cardInfo
add constraint pr_cardID primary key (cardID)

--檢查約束 cardID 卡號格式為:1010 3576 xxxx xxx開始
if exists (select * from sysobjects where name='ck_cardID')
alter table cardInfo
drop constraint ck_cardID
alter table cardInfo
add constraint ck_cardID check 
(cardID like '1010 3576 [0-9][0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')

--檢查約束  存款類型 活期/定活兩便/定期
if exists (select * from sysobjects where name='ck_savingType')
alter table cardInfo
drop constraint ck_savingType
alter table cardInfo
add constraint ck_savingType 
check (savingType in('活期','定活兩便','定期'))

--默認約束 curType貨幣種類 默認RMB
if exists (select * from sysobjects where name='df_curType')
alter table cardInfo
drop constraint df_curType
alter table cardInfo
add constraint df_curType 
default ('RMB') for curType 

--默認約束 openDate開戶日期 默認為系統當前日期
if exists (select * from sysobjects where name='df_openDate')
alter table cardInfo
drop constraint df_openDate
alter table cardInfo
add constraint df_openDate 
default (getdate()) for openDate


--檢查約束 openMoney開戶金額 不低于1元
if exists (select * from sysobjects where name='ck_openMoney')
alter table cardInfo
drop constraint ck_openMoney
alter table cardInfo
add constraint ck_openMoney 
check (openMoney>=1)

--檢查約束 balance余額 不低于1元,否則將銷戶
if exists (select * from sysobjects where name='ck_balance')
alter table cardInfo
drop constraint ck_balance
alter table cardInfo
add constraint ck_balance 
check (balance>=1)

--檢查約束 pass密碼為6位
if exists (select * from sysobjects where name='ck_pass')
alter table cardInfo
drop constraint ck_pass
alter table cardInfo
add constraint ck_pass 
check (len(pass)=6)

--默認約束 pass密碼默認888888
if exists (select * from sysobjects where name='df_pass')
alter table cardInfo
drop constraint df_pass
alter table cardInfo
add constraint df_pass 
default (888888) for pass

--默認約束 IsReportLoss 是否掛失  是/否值,默認為”否”
if exists (select * from sysobjects where name='df_IsReportLoss')
alter table cardInfo
drop constraint df_IsReportLoss
alter table cardInfo
add constraint df_IsReportLoss 
default (0) for IsReportLoss 

--檢查約束  IsReportLoss 是否掛失  只能為是/否值 
if exists (select * from sysobjects where name='ck_IsReportLoss')
alter table cardInfo
drop constraint ck_IsReportLoss
alter table cardInfo
add constraint ck_IsReportLoss 
check (IsReportLoss in (1,0))

--外鍵約束 customerID 表示該卡對應的顧客編號,一位顧客允許辦理多張卡號
if exists (select * from sysobjects where name='fr_customerID')
alter table cardInfo
drop constraint fr_customerID
alter table cardInfo
add constraint fr_customerID 
foreign key (customerID) references userInfo(customerID)

 

------------------3交易信息表transInfo 添加約束---------------

--默認約束 transDate交易日期,默認為系統當前日期
if exists (select * from sysobjects where name='df_transDate')
alter table transInfo 
drop constraint df_transDate
alter table transInfo 
add constraint df_transDate 
default (getdate()) for transDate

--外鍵約束 cardID 卡號
if exists (select * from sysobjects where name='pr_cardID2')
alter table transInfo 
drop constraint pr_cardID2
alter table transInfo 
add constraint pr_cardID2
foreign key (cardID) references  cardInfo(cardID)

--檢查約束 transType 交易類型 只能是存入/支取
if exists (select * from sysobjects where name='ck_transType')
alter table transInfo
drop constraint ck_transType
alter table transInfo
add constraint ck_transType 
check (transType in('存入','支取'))

--檢查約束 transMoney 交易金額 大于0
if exists (select * from sysobjects where name='ck_transMoney')
alter table transInfo
drop constraint ck_transMoney
alter table transInfo
add constraint ck_transMoney 
check (transMoney>0)


/*********************5插入數據*******************************/
---------------1測試 插入 userInfo 用戶信息表 和 cardInfo銀行卡信息表 數據------
insert userInfo (customerName, PID ,telephone, address)
values  ( '張三','123456789012345','010-67898978','北京海淀' )
insert cardInfo (cardID ,savingType ,openMoney,balance,customerID)
values ('1010 3576 1234 5678','活期',1000,1000,@@identity)

insert userInfo (customerName, PID ,telephone)
values('李四','321245678912345678','0478-44443333')
insert cardInfo (cardID ,savingType ,openMoney,balance,customerID)
values ('1010 3576 1212 1134','定期',1 ,1 ,@@identity)


-- delete  from cardInfo  delete  from userInfo 

-----------------2測試 手動取款交易 插入交易信息表transInfo數據--------------
--測試1 手動添加交易表信息,更新卡號信息表中的數據
declare @cardid  char(19)--定義變量 @cardid 卡號

select @cardid=cardid from cardInfo --從userInfo用戶表中獲取客戶為 張三 的卡號cardid
where customerID=(select customerID from userInfo where customername='張三')

insert into transinfo (transtype,cardid,transmoney)
values ('支取',@cardid,900)--向交易信息表transInfo插入數據:張三 支取 900元 卡號為@cardid 

update cardinfo set balance =balance-900 --更改 cardInfo銀行卡信息表 張三 余額balance 減去900
where customerID =(select customerID from userInfo where customername='張三')

--測試2  手動添加交易表信息,更新卡號信息表中的數據
declare @cardid2  char(19)--定義變量 @cardid 卡號

select @cardid2=cardid from cardInfo  --從userInfo用戶表中獲取客戶為 李四 的卡號cardid
where customerID=(select customerID from userInfo where customername='李四')

insert into transinfo (transtype,cardid,transmoney)
values ('存入',@cardid2,5000)--向交易信息表transInfo插入數據:李四 存入 5000元 卡號為@cardid2 

update cardinfo set balance =balance+5000 --更改 cardInfo銀行卡信息表 李四 余額balance 增加5000
where customerID =(select customerID from userInfo where customername='李四')

 

/******************************6常規業務模擬***************************/

----------------------6.1修改密碼--------------------------
--說明*修改張三(卡號為 1010 3576 1234 5678) 銀行卡號密碼為123456
update  cardInfo set pass=123456 
where customerid=(select customerid from userInfo where customername='張三')

--說明*修改李四(卡號為 1010 3567 1212 1134) 銀行卡號密碼為123123
update  cardInfo set pass=123123
where customerid=(select customerid from userInfo where customername='李四')
 
select * from cardInfo--2銀行卡信息表:cardInfo 

------------------------6.2掛失帳號----------------------------
--說明*李四 (卡號為1010 3567 1212 1134) 因銀行卡丟失,申請掛失
--說明*修改張三(卡號為 1010 3576 1234 5678) 銀行卡號密碼為123456
update  cardInfo set pass=123456 
where customerid=(select customerid from userInfo where customername='張三')

--說明*修改李四(卡號為 1010 3567 1212 1134) 銀行卡號密碼為123123
update  cardInfo set pass=123123
where customerid=(select customerid from userInfo where customername='李四')select * from cardInfo--2銀行卡信息表:cardInfo 

------------------------6.3統計銀行的支金流通余額和盈利結算----------
--說明*存入 代表資金流入,支取 代表資金流出

--declare @inMoney money
--select @inMoney- sum(transMoney) from transInfo where (transType-'存入')-sum(transMoney) from transinfo where transType-'支取')--錯誤不要了

declare @inMoney money--定義變量 總存入量
,@outMoney money--定義變量 總支取量
select @inMoney= sum(transMoney) from transInfo where (transType='存入')--從銀行卡信息表 獲取總存入量
select @outMoney=sum(transMoney) from transInfo where (transType='支取')--從銀行卡信息表 獲取總存入量

--資金流通金額-總存入量-總支取量
print '銀行流通余額總計為'+convert(varchar(20),@inMoney-@outMoney)+'RMB'
--盈利結算-總支取量*0.008-總存入量*0.003
print '盈利結算為'+left(convert(varchar(10),@outMoney*0.008-@inMoney*0.003),4)+'RMB'
 

--------------------------6.4查詢本周開戶的卡號-----------------------
/*declare @xtday datetime
set @xtday- datepart(dw,getdate())

declare @a datetime 
select  @a-openDate from cardInfo where cardID-'1010 3576 1212 1134'
print datediff (weekday,@a,getdate())
print datediff (dd,@a,getdate())
print @xtday 
print datepart(dw,getdate())-1*/

--print '本周開戶的卡號信息如下:'--錯誤的
--select cardID from cardInfo 
--where datediff(day,datepart(weekday,opendate),datepart(weekday,getdate()))<7--錯了
--where datename(dw,opendate)-datename(dw,getdate()) and month(openDate)-month(getdate())and year(openDate)-year(getdate())--同一天的

--顯示樣式1
print '本周開戶的卡號信息如下:'
select cardID from cardInfo 
where datediff (dd,opendate,getdate())<-(datepart(dw,getdate())-1)
select * from cardInfo 
--顯示樣式2
print '本周開戶的卡號信息如下:'
declare @temp int 
select 客戶姓名=customerName,聯系電話=telephone ,開戶金額=openMoney,
開戶日期=opendate from userInfo inner
join cardinfo on  userinfo.customerID=cardinfo.customerID 
where datediff(dd,opendate,getdate())<=(datepart(dw,getdate())-1)
select * from cardinfo

select datepart(dw,getdate())-1  --求出當前周幾
select datediff(dd,opendate,getdate()) from cardinfo
--函數第1個參數放天數,第2個參數填寫列中字段,第3個是當前日期(求出2個日期之間的差值) 

 


------------------------6.5查詢本月交易金額最高的卡號-----------------
print '本月交易金額最高的卡號'
select distinct cardID from transinfo 
where transMoney=(select  max(transMoney) from transinfo) --交易金額最高
and datediff(Month,transDate,getdate())=0--本月

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩日日夜夜| 国产欧美日韩久久| 日韩影院在线观看| 午夜精品国产更新| 日本欧美在线看| 久草精品在线观看| 久久91精品国产91久久小草| 麻豆精品视频在线观看视频| 日本欧美韩国一区三区| 蜜臀av一区二区在线观看| 日本怡春院一区二区| 免费不卡在线视频| 国产在线播放一区二区三区| 国产伦精品一区二区三区视频青涩| 狠狠久久亚洲欧美| 高清国产一区二区| 99国产麻豆精品| 成人国产免费视频| 不卡视频一二三| 日本高清不卡视频| 欧美嫩在线观看| 精品卡一卡二卡三卡四在线| 国产午夜精品一区二区| 国产精品久久久久久久久果冻传媒 | 一区二区三区资源| 婷婷综合另类小说色区| 精久久久久久久久久久| 国产宾馆实践打屁股91| www.综合网.com| 欧美午夜精品一区| 精品久久一区二区三区| 欧美国产97人人爽人人喊| 亚洲精品免费看| 免费高清在线一区| 99视频精品免费视频| 欧美日韩在线精品一区二区三区激情| 欧美xxxxxxxxx| 日韩伦理电影网| 奇米888四色在线精品| 成人自拍视频在线观看| 欧美视频一区在线| 久久久亚洲综合| 一区av在线播放| 九九九久久久精品| 日本二三区不卡| 精品嫩草影院久久| 一区二区在线观看视频| 久久国产乱子精品免费女| 成人av在线播放网站| 欧美一区日韩一区| 亚洲欧洲精品成人久久奇米网| 亚洲成人午夜电影| 夫妻av一区二区| 3d动漫精品啪啪一区二区竹菊| 中文字幕av免费专区久久| 日日摸夜夜添夜夜添国产精品| 成人免费视频免费观看| 制服.丝袜.亚洲.另类.中文| 国产精品久久久久久久裸模| 美女在线视频一区| 色狠狠一区二区| 国产欧美va欧美不卡在线| 日本伊人精品一区二区三区观看方式| jizzjizzjizz欧美| 精品福利av导航| 婷婷丁香久久五月婷婷| 99re视频这里只有精品| 久久久久久免费毛片精品| 亚洲成av人片在线| 色综合久久99| 国产精品嫩草影院av蜜臀| 在线免费一区三区| 国产精品久久久久影院| 国产在线精品一区二区三区不卡| 欧美日韩一区高清| 亚洲品质自拍视频| 丁香六月综合激情| 2023国产精品视频| 日本欧美大码aⅴ在线播放| 欧美日精品一区视频| 亚洲天堂精品在线观看| 国产99久久久久久免费看农村| 欧美一级艳片视频免费观看| 亚洲一区二区三区小说| 99re成人在线| 日韩美女啊v在线免费观看| 国产成人精品免费| 国产午夜精品在线观看| 精品一区二区三区欧美| 日韩女优av电影| 日本伊人色综合网| 欧美一区二区三区在线观看| 肉肉av福利一精品导航| 欧美唯美清纯偷拍| 一区二区成人在线视频| 色婷婷久久综合| 亚洲蜜桃精久久久久久久| 成人禁用看黄a在线| 国产精品污www在线观看| 成人永久aaa| 中文字幕在线不卡一区二区三区 | 制服丝袜国产精品| 日韩av一二三| 日韩欧美电影一区| 国产在线视频一区二区| 久久久久久久网| 国产成人在线电影| 久久精品人人爽人人爽| 成人午夜免费视频| 亚洲人快播电影网| 91福利视频久久久久| 亚洲成人综合在线| 日韩片之四级片| 韩国av一区二区三区在线观看| 久久久美女毛片| 成人免费看黄yyy456| 亚洲欧洲av色图| 欧美日韩精品综合在线| 免费观看日韩电影| 国产日韩欧美电影| 91在线免费看| 午夜精品久久久久久久久久| 91精品国产色综合久久ai换脸| 久久99精品国产麻豆不卡| 国产亚洲一区二区三区在线观看| 成人精品在线视频观看| 亚洲乱码国产乱码精品精的特点| 欧美色大人视频| 蜜乳av一区二区| 中文字幕精品一区二区精品绿巨人 | www.日韩精品| 亚洲第一成年网| 久久综合色婷婷| 91亚洲国产成人精品一区二区三| 一区二区三区视频在线看| 欧美丰满少妇xxxxx高潮对白 | 91黄色免费看| 91国内精品野花午夜精品| 人人精品人人爱| 欧美国产欧美综合| 精品视频1区2区| 久久精品国产一区二区三| 久久久亚洲欧洲日产国码αv| 99久久免费视频.com| 天堂久久一区二区三区| 国产喷白浆一区二区三区| 色婷婷综合久色| 免费不卡在线视频| 国产精品久久二区二区| 欧美精品久久一区二区三区| 国产成人综合自拍| 五月天精品一区二区三区| 国产欧美精品一区二区三区四区| 欧美在线观看一二区| 国产福利一区二区三区视频在线 | 亚洲国产一区在线观看| 精品精品国产高清一毛片一天堂| 播五月开心婷婷综合| 日韩精品国产精品| 亚洲图片激情小说| 久久―日本道色综合久久| 欧美在线短视频| 成人性生交大合| 老司机一区二区| 亚洲大片一区二区三区| 国产精品久久久久精k8| 欧美mv和日韩mv国产网站| 在线亚洲精品福利网址导航| 国产精品夜夜嗨| 日一区二区三区| 亚洲自拍欧美精品| 国产精品美女久久久久av爽李琼| 日韩一级二级三级精品视频| 色综合天天综合色综合av| 国产91清纯白嫩初高中在线观看| 日韩中文字幕区一区有砖一区| 国产综合一区二区| 亚洲日本在线天堂| 中文天堂在线一区| 欧美mv日韩mv国产网站| 911国产精品| 精品视频1区2区| 欧美最猛性xxxxx直播| 精品日韩在线观看| 91精品国产综合久久久久久久| 91年精品国产| 成人国产在线观看| 粉嫩一区二区三区在线看| 国产一区二区按摩在线观看| 美女网站色91| 美女脱光内衣内裤视频久久网站 | 亚洲综合图片区| 国产精品久久久久久久久免费丝袜 | 国产精品成人在线观看| 国产亚洲一二三区| 久久青草欧美一区二区三区| 日韩一级欧美一级| 日韩午夜电影在线观看| 日韩三级电影网址| 日韩一二三四区|