2008년 07월 19일
노기자카 하루카의 비밀OP - [당황스런 비터튠]
# by | 2008/07/19 12:53 | Moe | 트랙백 | 덧글(0)
.NET WebService (SOAP) 이용 제작
-------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundImage="@Embed(source='../img/bg2.png')" width="660" height="450"
borderColor="#FFFFFF" cornerRadius="0" horizontalAlign="left" verticalAlign="top" backgroundAlpha="100" backgroundColor="#FFFFFF"
backgroundGradientAlphas="[0.0, 0.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]" creationComplete="initDate()">
<mx:Script>
<![CDATA[
import mx.events.DateChooserEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.managers.CursorManager;
import mx.rpc.Fault;
import mx.containers.Canvas;
import mx.core.IFlexDisplayObject;
import mx.core.UIComponent;
import mx.collections.ArrayCollection;
import mx.controls.*;
import mx.rpc.http.HTTPService;
import mx.rpc.events.*;
import mx.utils.ArrayUtil;
import flash.external.*;
import flash.events.Event;
import mx.core.IUIComponent;
import mx.rpc.soap.*;
//System.useCodePage = true;
//Security.loadPolicyFile("http://xxx.xxx.xxx.xxx/crossdomain.xml");
//Security.allowDomain("*");
private var gateway:WebService = new WebService();
/*숙박일수 선택하는 기간이 연결되는 부분*/
[Bindable]
public var cards: Array = [ {label:"1박2일", data:1},
{label:"2박3일", data:2}, {label:"3박4일", data:3} ];
[Bindable]
public var selectedItem:Object;
/* 날짜를 계산하는 Module */
private function datelblshow(sd:String, ed:String, count:Number):void
{
var s1:Date = new Date(Number(sd));
var s2:Date = new Date(Number(ed));
//this.day_num.text = '숙박일:' + s1.fullYear+'년'+s1.month+'월'+s1.getDate()+ '일'
// + '~' + s2.fullYear+'년'+s2.month+'월'+s2.getDate()+ '일';
//this.sdateCh.selectedDate = new Date(s1.getFullYear(), s1.getMonth()-1, s1.getDate());
//this.edateCh.selectedDate = new Date(s2.getFullYear(), s2.getMonth()-1, s2.getDate());
}
private function initDate():void
{
var NowDate:Date = new Date();
GetHL(NowDate.getFullYear(),NowDate.month+1);
}
private function GetHL(Year:Number,Month:Number):void
{
gateway.wsdl = "http://xxx.xxx.xxx.xxx/Service.asmx?wsdl";
gateway.loadWSDL();
gateway.GetReservationHLByMonth.addEventListener(ResultEvent.RESULT, GetHLHandler);
gateway.addEventListener(FaultEvent.FAULT, faultHandler);
var SMonth:Date = new Date(Year,Month,1);
var EMonth:Date = new Date(SMonth.getFullYear(),SMonth.month,10);
EMonth.setMonth(EMonth.getMonth()+1);
var STDT:String = SMonth.getFullYear().toString() + "-" + SMonth.getMonth() + "-" + SMonth.getDate();
var EDDT:String = EMonth.getFullYear().toString() + "-" + EMonth.getMonth() + "-10";
gateway.GetReservationHLByMonth(STDT,EDDT);
CursorManager.setBusyCursor();
}
private function GetHLHandler(e:ResultEvent):void
{
CursorManager.removeBusyCursor();
try{
var table:* = e.result.Tables.dt0.Rows;
DateArr = table;
}
catch (err:Error) {
Alert.show(err.message.toString());
}
}
public function faultHandler(e:FaultEvent):void
{
CursorManager.removeBusyCursor();
try{
Alert.show(e.message.toString());
//Alert.show("An unexpected error occurred and has been logged.");
}
catch (err:Error) {
Alert.show(err.message.toString());
}
}
/* DataChooser에서 날짜를 빼오는 부분 */
private var sdate:String;
private var edate:String;
private var count:Number;
private var date1:Date;
public function Calculate():void
{
/* var Room:int = 0;
var OptionTot:int = 0;
var Duration:int = 0;
Duration = add_day.selectedIndex + 1;
Room = 0;
for(var DDay:int = 0;DDay < Duration; DDay++)
{
if (DateArr[dc1.selectedDate.dateUTC].HL.toString()=="H")
}
for(var i:int=0; i<8 ; i++)
{
option_content.text = "";
OptionTot = 0;
if(wall_cb.selected == true) {
option_content.text += "벽난로[10,000] ";
/* count_money(10000); */
}
private function DCCal(e:Event):void
{
//Alert.show(dc1.selectedDate.date.toString());
CalculateCom();
//Alert.show(e.newDate.date.toString());
}
var RoomPriceLow:int = 0;
var RoomPriceMedium:int = 0;
var RoomPriceHigh:int = 0;
var RoomName:String = "";
var StartDate:String = "";
var EndDate:String = "";
var Duration:int = 0;
var TotPrice:int = 0;
var strOption:String = "";
public function PreCalculateCom():void
{
if (RoomName.length>0)
{
try
{
gateway.wsdl = "http://xxx.xxx.xxx.xxx/Service.asmx?wsdl";
gateway.loadWSDL();
gateway.fnCheckReservation.addEventListener(ResultEvent.RESULT, GetReservationInfo);
gateway.addEventListener(FaultEvent.FAULT, faultHandler);
var TempDate:Date = new Date(dc1.selectedDate.getFullYear(),dc1.selectedDate.month,dc1.selectedDate.date);
var Month1:Number = TempDate.month + 1;
var FirstDate:Date = TempDate;
FirstDate.month += 1;
FirstDate.dateUTC += 1;
var strStartDate:String = FirstDate.fullYearUTC + "-" + FirstDate.monthUTC + "-" + FirstDate.dateUTC;
gateway.fnCheckReservation(RoomName, strStartDate, add_day.selectedItem.data);
CursorManager.setBusyCursor();
}
catch(e)
{}
}
}
private function GetReservationInfo(e:ResultEvent)
{
CursorManager.removeBusyCursor();
if (e.result.toString()=="False")
{
Alert.show("이미 예약된 방입니다.");
}
}
public function CalculateCom():void
{
try
{
var Room:int = 0;
var OptionTot:int = 0;
var CalDate:Number = 0;
//var CalTDate:Date = new Date(dc1.selectedDate.fullYear(),dc1.selectedDate.month+1,dc1.selectedDate.date);
Duration = add_day.selectedItem.data;// selectedIndex + 1;
Room = 0;
for(var DDay:int = 0;DDay < Duration; DDay++)
{
CalDate = dc1.selectedDate.dateUTC + DDay;
if (DateArr[CalDate].HL==1)
{
Room = Room + RoomPriceLow;
}
else if (DateArr[CalDate].HL==2)
{
Room = Room + RoomPriceMedium;
}
else if (DateArr[CalDate].HL==3)
{
Room = Room + RoomPriceHigh;
}
}
option_content.text = "";
OptionTot = 0;
strOption = "";
if(wall_cb.selected == true) {
option_content.text += "벽난로[10,000] ";
OptionTot = OptionTot + 10000;
strOption = "벽난로/10000";
}
if(babe_cb.selected == true) {
option_content.text += "바베큐[10,000] " + '\n';
OptionTot = OptionTot + 10000;
strOption = strOption + "|바베큐/10000";
}
if(spa_cb.selected == true) {
option_content.text +="스파[40,000] " + '\n';
OptionTot = OptionTot + 40000;
strOption = strOption + "|스파/40000";
}
if(packa_cb.selected == true) {
option_content.text +="패키지A[50,000] ";
OptionTot = OptionTot + 50000;
strOption = strOption + "|패키지A/50000";
}
if(packb_cb.selected == true) {
option_content.text +="패키지B[100,000] " + '\n';
OptionTot = OptionTot + 100000;
strOption = strOption + "|패키지B/10000";
}
if(cake_cb.selected == true) {
option_content.text +="케익[20,000] ";
OptionTot = OptionTot + 20000;
strOption = strOption + "|케익/20000";
}
if(wine_cb.selected == true) {
option_content.text +="와인[20,000] ";
OptionTot = OptionTot + 20000;
strOption = strOption + "|와인/20000";
}
if(flower_cb.selected == true) {
option_content.text +="꽃다발[30,000] " + '\n';
OptionTot = OptionTot + 30000;
strOption = strOption + "|꽃다발/30000";
}
if(strOption.substr(0,1)=="|")
{
strOption = strOption.substr(1,strOption.length-1);
}
if(strOption.substr(strOption.length-1,1)=="|")
{
strOption = strOption.substr(0,strOption.length-1);
}
var TotCount:int = Room + OptionTot;
TotPrice = TotCount;
total_money.text = '₩' + thousandFormat.format(String(TotCount));
/*
var s1:Date = dc1.selectedDate;
s1.monthUTC += 1;
this.day_num.text = '숙박일:' + s1.fullYearUTC+'년'+s1.monthUTC +'월'+s1.dateUTC+ '일';
var s2:Date = dc1.selectedDate;
//s2.monthUTC += 1;
s2.date += Duration;// .setDate(s2.getDate() + Duration);
this.day_num.text = this.day_num.text + '~' + s2.fullYearUTC +'년'+s2.monthUTC+'월'+s2.dateUTC+ '일';
*/
BtnRes.visible = true;
}
catch(e)
{
Alert.show("날짜와 방을 선택해 주세요");
}
}
public var DateArr:ArrayCollection = new ArrayCollection();
/* ComboBox에서 선택시에 index값을 가져와서 넘겨주는 부분 */
private var totalcount:String;
private var tot_count:int;
/* checkbox를 클릭하였을 때 옵션 추가해 주는 function */
private function add_option():void
{
CalculateCom();
}
private var money_tot:int;
private function count_money(money:int):void
{
}
/* 특정날짜 미리 선택해 놓는 Script */
public function displayDates():void
{
var dateRanges:Array = [];
for (var i:int=0; i<shows.show.length(); i++)
{
var cDate:Date = new Date(shows.show[i].showDate.toString());
var cDateObject:Object = {rangeStart:cDate, rangeEnd:cDate};
dateRanges.push(cDateObject);
}
dc1.selectedRanges = dateRanges;
}
var InfoArr:Array = new Array();
public function InsertReservation():void
{
var strInfo:String = ExternalInterface.call("GetInfo");
//var strInfo:String = "0||LicenseNum|Mobile|Email|Name";
//Alert.show(strInfo);
InfoArr = strInfo.split("|");
gateway.wsdl = "http://xxx.xxx.xxx.xxx/Service.asmx?wsdl";
gateway.loadWSDL();
gateway.InsertReservationData.addEventListener(ResultEvent.RESULT, InsertReservationData);
gateway.addEventListener(FaultEvent.FAULT, faultHandler);
var TempDate:Date = new Date(dc1.selectedDate.getFullYear(),dc1.selectedDate.month,dc1.selectedDate.date);
var Month1:Number = TempDate.month + 1;
var FirstDate:Date = TempDate;
var SecondDate:Date = TempDate;
FirstDate.month += 1;
FirstDate.dateUTC += 1;
StartDate = FirstDate.fullYearUTC + "-" + FirstDate.monthUTC + "-" + FirstDate.dateUTC;
SecondDate.dateUTC += Duration;
EndDate = SecondDate.fullYearUTC + "-" + SecondDate.monthUTC + "-" + SecondDate.dateUTC;
gateway.InsertReservationData(InfoArr[0].toString(), InfoArr[1].toString(), InfoArr[2].toString(), InfoArr[3].toString(), InfoArr[4].toString(), InfoArr[5].toString(), RoomName, StartDate, EndDate, Duration, TotPrice.toString(), strOption);
//Flag, ID, LicenseNum, HP, Email, Name, Room, SDate, EDate, Duration, TotPrice, strOption
CursorManager.setBusyCursor();
reserv_name.text = "예약자 성함 : " + InfoArr[5].toString();
}
private function InsertReservationData(e:ResultEvent):void
{
CursorManager.removeBusyCursor();
Alert.show(e.result.toString());
if (e.result.toString().substr(0,2)!="이미")
{
var request:HTTPService = new HTTPService();
var params:Object = new Object();
params.HP = InfoArr[3].toString();
//params.MSG = InfoArr[5].toString() + "님 "+RoomName+"방 "+StartDate+"일부터 "+Duration+"일간 예약이 완료되었습니다. ";
//params.MSG2 = InfoArr[5].toString() + "님 으로 "+TotPrice+"원 입금바랍니다.";
params.callback = "0000000000";
params.name = InfoArr[5].toString();
params.TotPrice = TotPrice;
params.roomName = RoomName;
params.StartDate = StartDate;
params.Duration = Duration;
params.Flager = "Reservation";
request.useProxy = false;
request.url = "http://xxx.xxx.xxx.xxx/sms_result.asp";
//Alert.show(InfoArr[3].toString()+"/"+"예약이 성공적으로 완료되었습니다.");
request.addEventListener(ResultEvent.RESULT,SuccessSMS);
request.addEventListener(FaultEvent.FAULT,FaultSMS);
request.send(params);
//ExternalInterface.call("CloseWindow");
}
//ExternalInterface.call("SendSMSAndClose",InfoArr[3].toString());
}
private function SuccessSMS(e:ResultEvent):void
{
//Alert.show(e.message.toString());
}
private function FaultSMS(e:FaultEvent):void
{
//Alert.show(e.message.toString());
// ExternalInterface.call("CloseWindow");
}
private function ChangeMonth(e:DateChooserEvent):void
{
var month:Number = e.currentTarget.displayedMonth;
var year:Number = e.currentTarget.displayedYear;
GetHL(year,month+1);
}
public function changeImage(ImagePath:String):void
{
RoomImage.visible = true;
RoomImage.source = ImagePath;
}
//RoomImage
]]>
</mx:Script>
<mx:Style source="../css/miallet.css"/>
<!--2인실 XML DB-->
<mx:XMLList id="Room2">
<room2>
<name>라라</name>
<Low>100000</Low>
<Medium>150000</Medium>
<High>200000</High>
<ImageName>room7.jpg</ImageName>
</room2>
<room2>
<name>안나</name>
<Low>100000</Low>
<Medium>150000</Medium>
<High>200000</High>
<ImageName>room3.jpg</ImageName>
</room2>
<room2>
<name>로테</name>
<Low>100000</Low>
<Medium>150000</Medium>
<High>200000</High>
<ImageName>room9.jpg</ImageName>
</room2>
<room2>
<name>메기</name>
<Low>100000</Low>
<Medium>150000</Medium>
<High>200000</High>
<ImageName>room5.jpg</ImageName>
</room2>
<room2>
<name>마농</name>
<Low>100000</Low>
<Medium>150000</Medium>
<High>200000</High>
<ImageName>room8.jpg</ImageName>
</room2>
<room2>
<name>쟌느</name>
<Low>100000</Low>
<Medium>150000</Medium>
<High>200000</High>
<ImageName>room4.jpg</ImageName>
</room2>
<room2>
<name>앤</name>
<Low>120000</Low>
<Medium>170000</Medium>
<High>220000</High>
<ImageName>room1.jpg</ImageName>
</room2>
<room2>
<name>메리</name>
<Low>80000</Low>
<Medium>130000</Medium>
<High>180000</High>
<ImageName>room5.jpg</ImageName>
</room2>
<room2>
<name>세라</name>
<Low>120000</Low>
<Medium>170000</Medium>
<High>220000</High>
<ImageName>room6.jpg</ImageName>
</room2>
<room2>
<name>죠안나(2)</name>
<Low>150000</Low>
<Medium>200000</Medium>
<High>250000</High>
<ImageName>room10.jpg</ImageName>
</room2>
<room2>
<name>마리아(2)</name>
<Low>150000</Low>
<Medium>200000</Medium>
<High>250000</High>
<ImageName>room11.jpg</ImageName>
</room2>
</mx:XMLList>
<!--4인실 XML DB-->
<mx:XMLList id="Room4">
<room4>
<name>죠안나(2)</name>
<Low>150000</Low>
<Medium>200000</Medium>
<High>250000</High>
<ImageName>room10.jpg</ImageName>
</room4>
<room4>
<name>마리아(2)</name>
<Low>150000</Low>
<Medium>200000</Medium>
<High>250000</High>
<ImageName>room11.jpg</ImageName>
</room4>
<room4>
<name>죠안나(4)</name>
<Low>200000</Low>
<Medium>250000</Medium>
<High>300000</High>
<ImageName>room10.jpg</ImageName>
</room4>
<room4>
<name>마리아(4)</name>
<Low>200000</Low>
<Medium>250000</Medium>
<High>300000</High>
<ImageName>room11.jpg</ImageName>
</room4>
<room4>
<name>알리사(4)</name>
<Low>200000</Low>
<Medium>250000</Medium>
<High>300000</High>
<ImageName>room13.jpg</ImageName>
</room4>
<room4>
<name>에이미(4)</name>
<Low>200000</Low>
<Medium>250000</Medium>
<High>300000</High>
<ImageName>room12.jpg</ImageName>
</room4>
</mx:XMLList>
<mx:XML id="shows" format="e4x">
<!--
<mx:XMLList id="shows">
-->
<data>
<show>
<showID>1</showID>
<showDate>01/01/2008</showDate>
</show>
<show>
<showID>2</showID>
<showDate>02/06/2008</showDate>
</show>
<show>
<showID>3</showID>
<showDate>02/07/2008</showDate>
</show>
<show>
<showID>4</showID>
<showDate>02/08/2008</showDate>
</show>
<show>
<showID>5</showID>
<showDate>03/01/2008</showDate>
</show>
<show>
<showID>6</showID>
<showDate>05/05/2008</showDate>
</show>
<show>
<showID>7</showID>
<showDate>05/12/2008</showDate>
</show>
<show>
<showID>8</showID>
<showDate>06/06/2008</showDate>
</show>
<show>
<showID>9</showID>
<showDate>08/15/2008</showDate>
</show>
<show>
<showID>10</showID>
<showDate>09/13/2008</showDate>
</show>
<show>
<showID>11</showID>
<showDate>09/14/2008</showDate>
</show>
<show>
<showID>12</showID>
<showDate>09/15/2008</showDate>
</show>
<show>
<showID>13</showID>
<showDate>10/03/2008</showDate>
</show>
<show>
<showID>14</showID>
<showDate>12/25/2008</showDate>
</show>
</data>
<!--
</mx:XMLList>
-->
</mx:XML>
<!-- 금액 표시시에 천자리마다 콤마(,)찍어주는 포맷-->
<mx:CurrencyFormatter id="thousandFormat" thousandsSeparatorTo="," currencySymbol=""/>
<!--룸정보 및 예약정보 보여주기-->
<mx:VBox x="25" y="53" width="172" height="210" verticalGap="2">
<mx:Image id="RoomImage" width="170" height="117" visible="false"/>
<mx:Text text="예약자성함 : " id="reserv_name" height="16" fontSize="11" color="#FFFFFF"/>
<mx:Text text="선택객실 : 앤" id="room_name" height="16" fontSize="11" color="#FFFFFF"/>
<!--mx:Text text="숙박일 : " id="day_num" height="16" fontSize="11" color="#FFFFFF"/-->
</mx:VBox>
<!--선택객실 이용후기 보기-->
<mx:LinkButton x="33" y="280" label="선택 객실 이용후기 보기" fontSize="11"
click="navigateToURL(new URLRequest('../04_community/postscript.asp'), '_parent');"/>
<!--옵션사항 확인-->
<mx:Text text="선택 옵션현황" fontWeight="bold" x="29" y="305" fontSize="11"/>
<mx:Text text="옵션을 선택해 주세요." color="#FFFFFF" x="30" y="318" fontSize="10" id="option_content"/>
<!--예약사항 확인 결산-->
<mx:VBox x="27" y="375" width="172" height="50" verticalGap="0">
<mx:Text x="25" y="387.05" text="결제예상금액" fontWeight="bold" fontSize="11"/>
<mx:Text color="#FFFFFF" fontFamily="Arial" fontSize="20" fontWeight="bold" id="total_money"/>
</mx:VBox>
<!--1.날짜선택-->
<mx:DateChooser width="208" height="155" fontFamily="돋움" fontSize="11" x="246" y="53" dayNames="[일,월,화,수,목,금,토]"
yearSymbol="년" monthNames="[1월,2월,3월,4월,5월,6월,7월,8월,9월,10월,11월,12월]"
creationComplete="displayDates()" id="dc1"
change="PreCalculateCom();DCCal(event)" scroll="ChangeMonth(event)"
/>
<!--mx:DateChooser width="208" height="155" fontFamily="돋움" fontSize="11" x="246" y="53" id="dc1"
change="DCCal(event)" scroll="ChangeMonth(event)"/-->
<mx:HRule x="246" y="232" width="208"/>
<!--예약하기 숙박일수 선택 콤보박스-->
<mx:Text x="246" y="242" text="숙박일수선택"/>
<mx:ComboBox x="325" y="236.25" id="add_day" width="100" dataProvider="{cards}"
change="CalculateCom();"></mx:ComboBox>
<!--2.객실선택 부분-->
<mx:DataGrid x="482" y="53" width="70" textAlign="center" fontSize="10" color="#000000" height="181"
dataProvider="{Room2}" id="room2" change="PreCalculateCom();changeImage(room2.selectedItem.ImageName);room_name.text='선택객실 : ' + String(room2.selectedItem.name); RoomName = String(room2.selectedItem.name);
RoomPriceLow = int(room2.selectedItem.Low);RoomPriceMedium = int(room2.selectedItem.Medium);RoomPriceHigh = int(room2.selectedItem.High);CalculateCom();">
<mx:columns>
<mx:DataGridColumn headerText="2인실" dataField="name"/>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid x="556" y="53" width="70" textAlign="center" fontSize="10" color="#000000" height="181"
dataProvider="{Room4}" id="room4" change="PreCalculateCom();changeImage(room4.selectedItem.ImageName);room_name.text='선택객실 : ' + String(room4.selectedItem.name); RoomName = String(room4.selectedItem.name);
RoomPriceLow = int(room4.selectedItem.Low);RoomPriceMedium = int(room4.selectedItem.Medium);RoomPriceHigh = int(room4.selectedItem.High);CalculateCom();">
<mx:columns>
<mx:DataGridColumn headerText="4인실" dataField="name"/>
</mx:columns>
</mx:DataGrid>
<!--3.옵션선택 부분-->
<mx:VBox x="246" y="330" height="95" width="380" verticalGap="0">
<mx:CheckBox label="벽난로 사용 : 사용료 1만원추가" id="wall_cb" click="add_option()"/>
<mx:CheckBox label="바베큐 숯불사용 : 사용료 1만원 추가" id="babe_cb" click="add_option()"/>
<mx:CheckBox label="스파사용 : 사용료 4만원추가" id="spa_cb" click="add_option()"/>
<mx:CheckBox label="이벤트 패키지A-풍선(꽃+나비)+헬륨10개+테이블=5만원" id="packa_cb" click="add_option()"/>
<mx:CheckBox label="이벤트 패키지B-풍선(꽃+나비+바닥30개)+헬륨20개+테이블+케익+와인=10만원" id="packb_cb" click="add_option()"/>
<mx:CheckBox label="별도주문-케익=2만원" id="cake_cb" click="add_option()"/>
<mx:CheckBox label="별도주문-와인=2만원" id="wine_cb" click="add_option()"/>
<mx:CheckBox label="별도주문-꽃다발=3만원" id="flower_cb" click="add_option()"/>
</mx:VBox>
<mx:Button label="예약" x="147" y="393" id="BtnRes" visible="false" click="InsertReservation()"/>
</mx:Application>
# by | 2008/05/17 23:04 | Flex | 트랙백 | 덧글(0)

# by | 2008/05/17 22:58 | 트랙백 | 덧글(0)
# by | 2008/02/05 20:20 | 트랙백 | 덧글(0)
◀ 이전 페이지 다음 페이지 ▶