数据库.sql 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. create database HotelManage
  2. go
  3. use HotelManage
  4. go
  5. -----------------------顾客信息表---------------------
  6. create table GuestInfo(
  7. Gid int primary key identity(1,1)not null, --顾客ID
  8. Gname varchar(10) not null, --顾客姓名
  9. GTid int not null, --顾客类型
  10. Sex char(5), --性别
  11. Mobile varchar(30), --电话号码
  12. ChargeSum int ,--消费总金额
  13. Pid varchar(20) --身份证号码
  14. )
  15. --drop table GuestInfo
  16. insert into GuestInfo values('黄宽',4,'男','13657168500',2400,'420984199310135520')
  17. insert into GuestInfo values('小强',4,'男','15322141125',5200,'498541459310135520')
  18. insert into GuestInfo values('刘瑞',4,'男','15322141125',5200,'498541459310135520')
  19. insert into GuestInfo values('彭铭',4,'男','15322141125',5200,'498541459310135520')
  20. insert into GuestInfo values('张三',1,'男','13800000000',1200,'420576199310134430')
  21. insert into GuestInfo values('李四',2,'男','13652114521',800,'420999999310134430')
  22. insert into GuestInfo values('王五',3,'女','15233214415',760,'420888899310134430')
  23. insert into GuestInfo values('赵六',4,'女','18688888888',2400,'420984197777734430')
  24. --select * from GuestInfo,GuestType where GuestType.GTid=GuestInfo.GTid and gid =1
  25. select * from GuestInfo --顾客信息表
  26. --select * from GuestInfo,GuestType where GuestType.GTid=GuestInfo.GTid
  27. --update GuestInfo set gname='张三asd',Gtid=1,Sex='男',mobile='13800000000',Chargesum='1200',pid='420576199310134430' where gid=5
  28. --------------------顾客类别表------------------------
  29. create table GuestType(
  30. GTid int primary key identity(1,1) not null, --类别ID
  31. Tname varchar(10) not null, --类别名称
  32. Trate float not null,--折扣
  33. )
  34. --drop table GuestType
  35. insert into GuestType values('普通会员',1)
  36. insert into GuestType values('高级会员',0.95)
  37. insert into GuestType values('黄金会员',0.90)
  38. insert into GuestType values('钻石会员',0.85)
  39. select * from GuestType --顾客类型表
  40. -------------------入住信息记录表---------------------
  41. create table Record(
  42. REid int primary key identity(1,1) not null, --入住编号
  43. Gid int not null, --顾客编号
  44. RoomId int not null ,--房间编号
  45. InTime datetime ,--入住时间
  46. OutTime datetime,--离开时间
  47. FactTime varchar(50) default '暂未离开',--实际离开时间
  48. daynum int,--入住天数
  49. Charge int default 0--交付押金
  50. )
  51. --update record set inttime='{0}',outtime='{1}',daynum=daynum+{2},charge={3} where roomid={4} and facttime='暂未离开'
  52. --select * from Record,guestinfo where record.gid=guestinfo.gid
  53. --drop table Record
  54. insert into Record values(1,3,'2014-10-13 10:10:32','2015-5-8 10:10:32',default,5,2200)
  55. insert into Record values(2,5,'2015-4-17 10:10:32','2015-5-5 10:10:32',default,5,2200)
  56. insert into Record values(3,13,'2015-4-13 10:10:32','2015-5-1 10:10:32',default,5,5600)
  57. insert into Record values(4,23,'2015-4-8 10:10:32','2015-6-1 10:10:32',default,5,2200)
  58. --------------------房间预定信息表-------------------------
  59. create table Reserve(
  60. Yid int identity(1,1) primary key,--预定记录表编号
  61. Gid int not null, --顾客编号
  62. RoomId int not null ,--房间编号
  63. InTime datetime ,--入住时间
  64. OutTime datetime,--离开时间
  65. FactTime varchar(50) default '暂未入住',--实际离开时间
  66. daynum int,--入住天数
  67. Charge int, --预付金额
  68. actCharge int
  69. )
  70. insert into reserve values(1,26,'2015-4-26 21:12:12','2015-5-15 21:12:12','暂未入住',19,2360,2360)
  71. insert into reserve values(1,34,'2015-4-26 21:12:12','2015-5-15 21:12:12','暂未入住',19,2360,0)
  72. select * from reserve
  73. --update record set facttime='暂未离开',daynum=1,charge=100 where reid = 1
  74. --select datediff(day,'2015-4-13 10:10:32',getdate()) 'daynum'
  75. --select * ,(outtime-Intime)'day'from record,roominfo where record.roomid=roominfo.roomid order by day asc
  76. --update set reserve facttime='已取消' where roomid= and facttime='暂未离开'
  77. select * from Record --入住信息记录表
  78. --select * from reserve,guestinfo,roominfo,guesttype,FloorInfo,roomtype where guestinfo.gid=reserve.gid and roominfo. roomid=reserve.roomid and reserve.roomid=26 and guestinfo.gtid=guesttype.gtid and FloorInfo.fid=RoomInfo.fid and roomtype.rtid=roominfo.rtid and(rsid=2 or rsid = 1) and facttime='暂未入住'
  79. ------------------------楼层信息表------------------------
  80. create table FloorInfo(
  81. Fid int primary key identity(1,1) not null, --楼层ID
  82. Fname varchar(20) --楼层名称
  83. )
  84. --drop table FloorInfo
  85. insert into FloorInfo values('A栋')
  86. insert into FloorInfo values('B栋')
  87. insert into FloorInfo values('C栋')
  88. --select * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid and roomid=38
  89. select * from FloorInfo --楼层信息表
  90. --select * from roominfo where rtid=1 and rsid=3
  91. ------------------------操作员表-------------------------
  92. create table OPInfo(
  93. OId int primary key identity(1,1) not null,--操作员ID
  94. OName varchar(20) not null,--操作员姓名
  95. Pwd varchar(20) not null--操作员密码
  96. )
  97. --drop table OPInfo
  98. insert into OPInfo values('huangkuan','123')
  99. insert into OPInfo values('akuan','123')
  100. select * from OPInfo --操作员信息表
  101. ----------------------房间信息表--------------------------
  102. create table RoomInfo(
  103. RoomId int primary key identity(1,1) not null, --房间编号
  104. Number varchar(20) not null ,--房间号
  105. RTid int ,--房间类型ID
  106. RSid int ,--房间状态编号
  107. Fid int , --楼层编号
  108. Mark varchar(225),--房间备注信息
  109. )
  110. select * from roominfo
  111. --select top 36 * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid and roominfo.RTid=1
  112. --drop table RoomInfo
  113. insert into RoomInfo values('A001',1,3,1,'暂无备注')
  114. insert into RoomInfo values('A002',1,3,1,'暂无备注')
  115. insert into RoomInfo values('A003',1,2,1,'暂无备注')
  116. insert into RoomInfo values('A004',1,3,1,'暂无备注')
  117. insert into RoomInfo values('A005',1,2,1,'暂无备注')
  118. insert into RoomInfo values('A006',1,3,1,'暂无备注')
  119. insert into RoomInfo values('B001',2,3,1,'暂无备注')
  120. insert into RoomInfo values('B002',2,3,1,'暂无备注')
  121. insert into RoomInfo values('B003',2,3,1,'暂无备注')
  122. insert into RoomInfo values('B004',2,3,1,'暂无备注')
  123. insert into RoomInfo values('B005',2,3,1,'暂无备注')
  124. insert into RoomInfo values('B006',2,3,1,'暂无备注')
  125. insert into RoomInfo values('C001',3,2,2,'暂无备注')
  126. insert into RoomInfo values('C002',3,3,2,'暂无备注')
  127. insert into RoomInfo values('C003',3,4,2,'暂无备注')
  128. insert into RoomInfo values('C004',3,3,2,'暂无备注')
  129. insert into RoomInfo values('C005',3,3,2,'暂无备注')
  130. insert into RoomInfo values('C006',3,3,2,'暂无备注')
  131. insert into RoomInfo values('D001',4,3,2,'暂无备注')
  132. insert into RoomInfo values('D002',4,3,2,'暂无备注')
  133. insert into RoomInfo values('D003',4,3,2,'暂无备注')
  134. insert into RoomInfo values('D004',4,3,2,'暂无备注')
  135. insert into RoomInfo values('D005',4,2,2,'暂无备注')
  136. insert into RoomInfo values('D006',4,3,2,'暂无备注')
  137. insert into RoomInfo values('E001',5,3,3,'暂无备注')
  138. insert into RoomInfo values('E002',5,1,3,'暂无备注')
  139. insert into RoomInfo values('E003',5,3,3,'暂无备注')
  140. insert into RoomInfo values('E004',5,3,3,'暂无备注')
  141. insert into RoomInfo values('E005',5,3,3,'暂无备注')
  142. insert into RoomInfo values('E006',5,4,3,'暂无备注')
  143. insert into RoomInfo values('F001',6,3,3,'暂无备注')
  144. insert into RoomInfo values('F002',6,3,3,'暂无备注')
  145. insert into RoomInfo values('F003',6,3,3,'暂无备注')
  146. insert into RoomInfo values('F004',6,1,3,'暂无备注')
  147. insert into RoomInfo values('F005',6,3,3,'暂无备注')
  148. insert into RoomInfo values('F006',6,3,3,'暂无备注')
  149. insert into RoomInfo values('A007',1,3,1,'暂无备注')
  150. insert into RoomInfo values('A008',1,3,1,'暂无备注')
  151. insert into RoomInfo values('A009',1,3,1,'暂无备注')
  152. insert into RoomInfo values('A010',1,3,1,'暂无备注')
  153. insert into RoomInfo values('A011',1,3,1,'暂无备注')
  154. insert into RoomInfo values('A012',1,3,1,'暂无备注')
  155. insert into RoomInfo values('B007',2,3,1,'暂无备注')
  156. insert into RoomInfo values('B008',2,3,1,'暂无备注')
  157. insert into RoomInfo values('B009',2,3,1,'暂无备注')
  158. insert into RoomInfo values('B010',2,3,1,'暂无备注')
  159. insert into RoomInfo values('B011',2,3,1,'暂无备注')
  160. insert into RoomInfo values('B012',2,3,1,'暂无备注')
  161. insert into RoomInfo values('C007',3,3,2,'暂无备注')
  162. insert into RoomInfo values('C008',3,3,2,'暂无备注')
  163. insert into RoomInfo values('C009',3,3,2,'暂无备注')
  164. insert into RoomInfo values('C010',3,3,2,'暂无备注')
  165. insert into RoomInfo values('C011',3,3,2,'暂无备注')
  166. insert into RoomInfo values('C012',3,3,2,'暂无备注')
  167. insert into RoomInfo values('D007',4,3,2,'暂无备注')
  168. insert into RoomInfo values('D008',4,3,2,'暂无备注')
  169. insert into RoomInfo values('D009',4,3,2,'暂无备注')
  170. insert into RoomInfo values('D010',4,3,2,'暂无备注')
  171. insert into RoomInfo values('D011',4,3,2,'暂无备注')
  172. insert into RoomInfo values('D012',4,3,2,'暂无备注')
  173. insert into RoomInfo values('E007',5,3,3,'暂无备注')
  174. insert into RoomInfo values('E008',5,3,3,'暂无备注')
  175. insert into RoomInfo values('E009',5,3,3,'暂无备注')
  176. insert into RoomInfo values('E010',5,3,3,'暂无备注')
  177. insert into RoomInfo values('E011',5,3,3,'暂无备注')
  178. insert into RoomInfo values('E012',5,3,3,'暂无备注')
  179. insert into RoomInfo values('F007',6,3,3,'暂无备注')
  180. insert into RoomInfo values('F008',6,3,3,'暂无备注')
  181. insert into RoomInfo values('F009',6,3,3,'暂无备注')
  182. insert into RoomInfo values('F010',6,3,3,'暂无备注')
  183. insert into RoomInfo values('F011',6,3,3,'暂无备注')
  184. insert into RoomInfo values('F012',6,3,3,'暂无备注')
  185. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  186. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  187. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  188. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  189. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  190. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  191. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  192. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  193. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  194. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  195. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  196. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  197. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  198. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  199. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  200. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  201. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  202. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  203. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  204. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  205. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  206. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  207. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  208. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  209. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  210. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  211. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  212. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  213. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  214. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  215. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  216. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  217. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  218. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  219. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  220. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  221. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  222. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  223. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  224. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  225. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  226. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  227. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  228. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  229. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  230. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  231. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  232. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  233. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  234. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  235. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  236. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  237. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  238. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  239. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  240. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  241. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  242. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  243. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  244. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  245. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  246. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  247. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  248. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  249. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  250. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  251. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  252. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  253. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  254. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  255. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  256. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  257. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  258. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  259. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  260. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  261. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  262. insert into RoomInfo values('未开通',1,6,1,'暂无备注')
  263. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  264. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  265. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  266. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  267. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  268. insert into RoomInfo values('未开通',2,6,1,'暂无备注')
  269. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  270. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  271. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  272. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  273. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  274. insert into RoomInfo values('未开通',3,6,2,'暂无备注')
  275. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  276. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  277. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  278. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  279. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  280. insert into RoomInfo values('未开通',4,6,2,'暂无备注')
  281. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  282. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  283. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  284. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  285. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  286. insert into RoomInfo values('未开通',5,6,3,'暂无备注')
  287. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  288. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  289. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  290. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  291. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  292. insert into RoomInfo values('未开通',6,6,3,'暂无备注')
  293. --select * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid
  294. --select top 36 * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid and roomid not in(select top 36 roomid from roominfo) order by roomid asc
  295. --select * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid and roomid=1
  296. --select * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid--房间信息表
  297. --select * from record,guestinfo,roominfo,guesttype,FloorInfo,roomtype where guestinfo.gid=record.gid and roominfo. roomid=record.roomid and record.roomid=1 and guestinfo.gtid=guesttype.gtid and FloorInfo.fid=RoomInfo.fid and roomtype.rtid=roominfo.rtid and(rsid=2 or rsid = 1)
  298. --------------------房间状态信息表-----------------------------
  299. create table RoomState(
  300. StateId int primary key identity(1,1) not null,--房间状态编号
  301. StateName varchar(20) not null
  302. )
  303. --drop table RoomState
  304. insert into RoomState values('已预定')
  305. insert into RoomState values('已入住')
  306. insert into RoomState values('未入住')
  307. insert into RoomState values('维修中')
  308. insert into RoomState values('清扫中')
  309. insert into RoomState values('未开通')
  310. select * from RoomState --房间状态表
  311. --update reserve set facttime='已转正入住' where roomid=26 and facttime='暂未入住'
  312. -----------------------房间类型表----------------------------
  313. create table RoomType(
  314. RTid int primary key identity(1,1),--房间类型编号
  315. RTname varchar(50) not null,--类型名称
  316. RTprice money not null, --类型价格
  317. AddBedPrice money not null,--加床价格
  318. IsAddBed bit ,--是否允许加床
  319. Remark varchar(255), --备注信息
  320. )
  321. --drop table RoomType
  322. insert into RoomType values('普通单人间(220/天)',220,0,0,'暂无备注')
  323. insert into RoomType values('豪华单人间(280/天)',280,0,0,'暂无备注')
  324. insert into RoomType values('普通双人间(380/天)',380,0,0,'暂无备注')
  325. insert into RoomType values('豪华双人间(480/天)',480,0,0,'暂无备注')
  326. insert into RoomType values('贵宾套房(580/天)',580,120,1,'暂无备注')
  327. insert into RoomType values('总统套房(1280/天)',1280,600,1,'暂无备注')
  328. --select * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid and roomid=1
  329. select * from RoomType --房间信息表
  330. --select * from roomtype where rtid=1
  331. -----------------用户在线预约信息表-----------------------
  332. create table UserInfo(
  333. UId int primary key identity(1,1)not null, --顾客ID
  334. Uname varchar(10) not null, --用户姓名
  335. Upwd varchar(30) not null, --用户密码
  336. Tid int default 1, --用户类型
  337. Sex char(5), --性别
  338. Mobile varchar(30), --电话号码
  339. Pid varchar(20) --身份证号码
  340. )
  341. --drop table UserInfo
  342. insert into UserInfo values('birui','123',default,'男','13657168500','420984199310134430')
  343. insert into UserInfo values('biqiang','123',default,'男','13657168500','420984199310134430')
  344. insert into UserInfo values('biming','123',default,'男','13657168500','420984199310134430')
  345. select * from UserInfo --用户在线预约信息表
  346. --------------营业额统计---------------------------------
  347. create table ChargeCount(
  348. date datetime,
  349. Charge float
  350. )
  351. --drop table chargecount
  352. --select * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid
  353. --select * from record,guestinfo,roominfo,guesttype,FloorInfo,roomtype where guestinfo.gid=record.gid and roominfo. roomid=record.roomid and record.roomid=1and guestinfo.gtid=guesttype.gtid and FloorInfo.fid=RoomInfo.fid and roomtype.rtid=roominfo.rtid and(rsid=2 or rsid = 1) and facttime='暂未离开'
  354. insert into chargecount values('2013-1-2 10:11:12',20000)
  355. insert into chargecount values('2013-2-2 10:11:12',17000)
  356. insert into chargecount values('2013-3-27 10:11:12',50000)
  357. insert into chargecount values('2013-4-28 10:11:12',38000)
  358. insert into chargecount values('2013-5-2 10:11:12',20000)
  359. insert into chargecount values('2013-6-2 10:11:12',36000)
  360. insert into chargecount values('2013-7-27 10:11:12',70000)
  361. insert into chargecount values('2013-8-28 10:11:12',38000)
  362. insert into chargecount values('2013-9-27 10:11:12',62000)
  363. insert into chargecount values('2013-10-28 10:11:12',38000)
  364. insert into chargecount values('2013-11-27 10:11:12',45000)
  365. insert into chargecount values('2013-12-28 10:11:12',38000)
  366. insert into chargecount values('2014-1-2 10:11:12',17000)
  367. insert into chargecount values('2014-2-2 10:11:12',25000)
  368. insert into chargecount values('2014-3-27 10:11:12',46000)
  369. insert into chargecount values('2014-4-28 10:11:12',52000)
  370. insert into chargecount values('2014-5-2 10:11:12',70000)
  371. insert into chargecount values('2014-6-2 10:11:12',42000)
  372. insert into chargecount values('2014-7-27 10:11:12',40000)
  373. insert into chargecount values('2014-8-28 10:11:12',12000)
  374. insert into chargecount values('2014-9-27 10:11:12',25000)
  375. insert into chargecount values('2014-10-28 10:11:12',51000)
  376. insert into chargecount values('2014-11-27 10:11:12',66000)
  377. insert into chargecount values('2014-12-28 10:11:12',42000)
  378. insert into chargecount values('2015-1-27 10:11:12',70000)
  379. insert into chargecount values('2015-2-28 10:11:12',38000)
  380. insert into chargecount values('2015-3-27 10:11:12',62000)
  381. insert into chargecount values('2015-4-28 10:11:12',38000)
  382. insert into chargecount values('2015-5-27 10:11:12',45000)
  383. insert into chargecount values('2015-6-27 10:11:12',70000)
  384. insert into chargecount values('2015-7-28 10:11:12',38000)
  385. insert into chargecount values('2015-8-27 10:11:12',62000)
  386. insert into chargecount values('2015-9-28 10:11:12',38000)
  387. insert into chargecount values('2015-10-27 10:11:12',45000)
  388. --elect year(date) from chargecount group by year(date)
  389. --select * from chargecount
  390. --drop table chargecount
  391. --insert into chargecount values('2015-4-2 10:11:12',200)
  392. --select datediff(day,'2015-4-13 10:10:32',getdate()) 'daynum'
  393. --select sum(charge) from chargecount where (select datediff(day,date,getdate()))=0
  394. --select * from record,guestinfo,roominfo,guesttype,FloorInfo,roomtype where guestinfo.gid=record.gid and roominfo. roomid=record.roomid and record.roomid=1 and guestinfo.gtid=guesttype.gtid and FloorInfo.fid=RoomInfo.fid and roomtype.rtid=roominfo.rtid and(rsid=2 or rsid = 1) and facttime='暂未离开'
  395. --select * from RoomInfo,RoomState,FloorInfo,RoomType where RoomState.Stateid=Roominfo.Rsid and RoomInfo.FId=FloorInfo.fid and RoomInfo.RTid=RoomType.Rtid
  396. ------------换房原因------------------------
  397. create table Trans(
  398. transid int identity(1,1) primary key,
  399. reason varchar(50),
  400. addmoney int
  401. )
  402. --drop table trans
  403. insert into trans values('房间损坏维修',0)
  404. insert into trans values('客房升级',20)
  405. insert into trans values('客房降级',20)
  406. insert into trans values('其他因素',20)
  407. insert into trans values('噪音等外界干扰',0)
  408. select * from trans
  409. -----------------------------------------------------------
  410. select * from GuestInfo --顾客信息表
  411. select * from GuestType --顾客类型表
  412. select * from Record --入住信息记录表
  413. select * from FloorInfo --楼层信息表
  414. select * from OPInfo --操作员信息表
  415. select * from RoomInfo --房间信息表
  416. select * from RoomState --房间状态表
  417. select * from RoomType --房间信息表
  418. select * from UserInfo --用户在线预约信息表