温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:酒店管理系统(ExtJs)源码
当前文件:
MyHotelManager/HotelUI/Js/AddRoom.js,打开代码结构图
MyHotelManager/HotelUI/Js/AddRoom.js,打开代码结构图1//添加酒店客房 2
function AddRoom() 3
{ 4
//获得房间类型 5
var strType=new Ext.data.Store 6
( 7
{ 8
proxy: new Ext.data.HttpProxy 9
( 10
{ 11
url:'/HotelUI/Json/GetAllRoomType.aspx' 12
} 13
), 14
//读取Json 15
reader: new Ext.data.JsonReader 16
( 17
{root:'data'}, 18
[ 19
{name:'TypeId',type:'string'}, 20
{name:'TypeName',type:'string'} 21
] 22
) 23
} 24
); 25
strType.load(); 26
27
//获得房间状态 28
var strState = new Ext.data.Store 29
( 30
{ 31
proxy: new Ext.data.HttpProxy 32
( 33
{ 34
url:'/HotelUI/Json/GetAllRoomState.aspx' 35
} 36
), 37
//读取Json 38
reader: new Ext.data.JsonReader 39
( 40
{root:'data'}, 41
[ 42
{name:'StateId',type:'string'}, 43
{name:'StateName',type:'string'} 44
] 45
) 46
} 47
); 48
strState.load(); 49
50
Ext.QuickTips.init(); 51
Ext.form.Field.prototype.msgTarget = 'side'; 52
var addRoom = new Ext.FormPanel 53
( 54
{ 55
labelWidth:75, 56
frame : true, 57
title : '请仔细填写表单', 58
width : 580, 59
waitMsgTarget : true, 60
items: 61
[ 62
{ 63
layout:'column', 64
border:false, 65
items: 66
[ 67
{ 68
columnWidth:.5, 69
layout: 'form', 70
border:false, 71
items: 72
[ 73
{ 74
xtype:'textfield', 75
fieldLabel: ' 房间编号', 76
labelStyle: 'width:100px', 77
width:150, 78
name: 'Number', 79
allowBlank:false, 80
blankText: '请输入编号' 81
}, 82
{ 83
xtype:'textfield', 84
fieldLabel: ' 房间床位数', 85
labelStyle: 'width:100px', 86
width:80, 87
name: 'BedNumber', 88
allowBlank:false, 89
blankText: '请输入床位数' 90
} 91
] 92
}, 93
{ 94
columnWidth:.5, 95
layout: 'form', 96
border:false, 97
items: 98
[ 99
new Ext.form.ComboBox 100
( 101
{ 102
fieldLabel: ' 选择房间类型', 103
labelStyle: 'width:100px', 104
width:100, 105
editable: false, //不允许输入 106
name: 'TypeName', 107
store:strType, 108
emptyText:'--请选择--', 109
allowBlank:false, //不允许为空 110
blankText:'请选择类型', //错误提示信息 111
displayField:'TypeName', 112
valueField: 'TypeId', 113
hiddenName:'TypeId', 114
mode: 'client', 115
triggerAction: 'all', 116
selectOnFocus:true 117
} 118
), 119
new Ext.form.ComboBox 120
( 121
{ 122
fieldLabel: ' 选择房间状态', 123
labelStyle: 'width:100px', 124
width:100, 125
editable: false, //不允许输入 126
name: 'StateName', 127
store:strState, 128
emptyText:'--请选择--', 129
allowBlank:false, //不允许为空 130
blankText:'请选择状态', //错误提示信息 131
displayField:'StateName', 132
valueField: 'StateId', 133
hiddenName:'StateId', 134
mode: 'client', 135
triggerAction: 'all', 136
selectOnFocus:true 137
} 138
) 139
] 140
} 141
] 142
}, 143
{ 144
xtype:'textarea', 145
name:'remark', 146
fieldLabel:' 备注', 147
labelStyle: 'width:100px', 148
height:120, 149
width:380 150
} 151
], 152
buttons: 153
[ 154
{ 155
id:'btnOk', 156
text:'确 定', 157
handler:function() 158
{ 159
//如果验证合法 160
if (addRoom.form.isValid()) 161
{ 162
//弹出效果 163
Ext.MessageBox.show 164
( 165
{ 166
msg: '正在保存,请稍等...', 167
progressText: 'Saving...', 168
width:300, 169
wait:true, 170
waitConfig: {interval:200}, 171
icon:'download', 172
animEl: 'saving' 173
} 174
); 175
setTimeout(function(){}, 10000); 176
//提交到服务器 177
addRoom.form.submit 178
( 179
{ 180
url:'/HotelUI/Form/AddRoom.aspx', //提交的页面路径 181
method:'post',//提交方式为post 182
//提交成功的回调函数 183
success:function(form,action) 184
{ 185
var flage = action.result.success; 186
//如果服务器端传过来的数据为true则表示登录成功 187
if (flage == true) 188
{ 189
Ext.MessageBox.alert('恭喜','添加房间成功!'); 190
newWin.hide(); 191
} 192
}, 193
//提交失败的回调函数 194
failure:function() 195
{ 196
Ext.Msg.alert('错误','服务器出现错误请稍后再试!'); 197
} 198
} 199
); 200
} 201
} 202
}, 203
{ 204
text:'取 消', 205
handler:function() 206
{ 207
newWin.hide(); 208
} 209
} 210
] 211
} 212
); 213
//定义窗体 214
newWin = new Ext.Window 215
( 216
{ 217
layout : 'fit', 218
width : 540, 219
height : 300, 220
collapsible:true, //允许缩放条 221
closeAction : 'hide', 222
closable:true, 223
plain : true, 224
modal: 'true', 225
title : '添加酒店房间', 226
items : addRoom 227
} 228
) 229
//显示窗体 230
newWin.show(); 231
} 232
233
234
235





}
}