//查询航班 private void button1_Click(object sender, EventArgs e) { //发送到PID端判断城市、日期的正确性 string strResult = ""; if (PublicClass.SendCommand(textBox1.Text.Trim() + "|" + textBox2.Text.Trim() + "|" + dateTimePicker1.Value.ToString("yyyy-MM-dd"), 2, ref strResult)) { if (strResult.IndexOf("|") == -1) { MessageBox.Show(strResult); return; } else { string[] sl = strResult.Split('|'); fromcitycode = sl[0]; fromcityname = sl[1]; tocitycode = sl[2]; tocityname = sl[3]; FlightDate = dateTimePicker1.Value.ToString("yyyy-MM-dd"); //调用IBE接口查询航班 IBEServices.WebService1SoapClient ibe = new IBEServices.WebService1SoapClient(); avResult = ibe.getIBEAVData(fromcitycode, tocitycode, dateTimePicker1.Value.ToString("yyyy-MM-dd"), "00:00:00"); //2014-01-15,11:30,14:10,3U,8885,F2A2YABATA*9,CTU,PEK,330,0,1,1,False,,T1T3^ //2014-01-15,11:55,14:20,HU,7148,FAZ6A6YABAS1*9,CTU,PEK,333,0,1,1,False,,T2T1^ //2014-01-15,12:00,14:40,ZH,1406,YABASAUA*9,CTU,PEK,330,0,1,1,True,,T2T3^ //2014-01-15,12:00,14:40,CA,1406,YABASAN1UA*9,CTU,PEK,330,0,1,1,False,,T2T3^ //2014-01-15,12:15,14:45,CZ,6162,F7W7S7YAB7*9,CTU,PEK,321,0,1,1,False,,T2T2^ //2014-01-15,13:00,15:35,CA,421,C4YABASANAU2*9,CTU,PEK,320,0,1,1,False,,T2T3^ //2014-01-15,13:30,16:10,3U,8887,FAA7YABATA*9,CTU,PEK,330,0,1,1,False,,T1T3^ //2014-01-15,13:50,16:25,ZH,1416,F1YABASAUA*9,CTU,PEK,330,0,1,1,True,,T2T3^ //2014-01-15,13:50,16:25,CA,1416,F1YABASAUA*9,CTU,PEK,330,0,1,1,False,,T2T3^2014-01-15,14:00,16:40,CA,4103,F2YABASAN2UA*9,CTU,PEK,321,0,1,1,False,,T2T3^2014-01-15,14:00,16:40,ZH,4103,F2YABASAUA*9,CTU,PEK,321,0,0,1,True,,T2T3^2014-01-15,15:00,17:30,CA,4109,F8A3O1W5YAUA*9,CTU,PEK,333,0,1,1,False,,T2T3^2014-01-15,15:00,17:30,ZH,4109,F8YAUA*9,CTU,PEK,333,0,0,1,True,,T2T3^2014-01-15,15:30,18:05,3U,8893,F4YABATA*9,CTU,PEK,330,0,1,1,False,,T1T3^2014-01-15,16:00,18:35,CA,4105,F1CADAZ4R1*9,CTU,PEK,340,0,1,1,False,,T2T3^2014-01-15,16:00,18:35,ZH,4105,F1CA*9,CTU,PEK,340,0,1,1,True,,T2T3^2014-01-15,16:30,19:15,3U,8889,F1YABATA*9,CTU,PEK,321,0,1,1,False,,T1T3^2014-01-15,17:00,19:25,ZH,4117,F7YABASAUA*9,CTU,PEK,321,0,1,1,True,,T2T3^2014-01-15,17:00,19:25,CA,4117,F7A5YABASAN1UA*9,CTU,PEK,321,0,1,1,False,,T2T3^2014-01-15,18:00,20:40,CA,4119,FAA6YASAN1UA*9,CTU,PEK,33A,0,1,1,False,,T2T3^2014-01-15,18:00,20:40,ZH,4119,FAYASAUA*9,CTU,PEK,33A,0,1,1,True,,T2T3^2014-01-15,18:45,21:30,CA,4197,F8A6O3YABASAN3UA*9,CTU,PEK,319,0,1,1,False,,T2T3^2014-01-15,18:45,21:30,ZH,4197,F8YABASAUA*9,CTU,PEK,319,0,1,1,True,,T2T3^2014-01-15,19:00,21:45,CA,4111,YASAN2UA*9,CTU,PEK,319,0,1,1,False,,T2T3^2014-01-15,19:00,21:45,ZH,4111,YASAUA*9,CTU,PEK,319,0,1,1,True,,T2T3^2014-01-15,19:30,22:10,3U,8891,F2A2YABATA*9,CTU,PEK,321,0,1,1,False,,T1T3^2014-01-15,20:30,23:10,3U,8895,F1A1Y7B5T7*9,CTU,PEK,320,0,1,1,False,,T1T3^2014-01-15,20:55,23:25,HU,7142,FAZ1A1YABAKAS5*9,CTU,PEK,787,0,0,1,False,,T2T1^2014-01-15,21:00,23:50,ZH,1426,F5YABASAUA*9,CTU,PEK,738,0,1,1,True,,T2T3^2014-01-15,21:00,23:50,CA,1426,F5A2YABASAN2UA*9,CTU,PEK,738,0,1,1,False,,T2T3^2014-01-15,21:10,23:45,CZ,3904,A4FAP1WAS1YABAUAQARA*9,CTU,PEK,333,0,1,1,False,P11,T2T2^2014-01-15,21:30,00:05,3U,8547,F6A6YABATA*9,CTU,PEK,320,0,1,1,False,,T1T3 //解析IBE返回航班信息 dataGridView1.DataSource = GetUserData(avResult); } } else { MessageBox.Show("与服务器通讯异常!"); return; } }
//发送指令 private string SendCommandAndGetResult() { //获取待发送指令 string cmd = GetSendCommand(); //预处理指令 string ErrorMessage = ""; string precmd = PrepareCommand.DuelCommand(cmd, ref ErrorMessage); if (precmd == "") { if (ErrorMessage != "") { richTextBox1.AppendText("\n" + ErrorMessage); } richTextBox1.AppendText("\n>"); richTextBox1.SelectionStart = richTextBox1.TextLength; } else { string strResult = ""; if (PublicClass.SendCommand(precmd, 1, ref strResult)) { //格式化返回结果(主要处理AVH返回) strResult = PublicClass.FormatResult(precmd, strResult); richTextBox1.AppendText("\n" + strResult + "\n>"); richTextBox1.SelectionStart = richTextBox1.TextLength; //分析返回结果 PrepareCommand.AnalyseCommandResult(precmd, strResult); } else { MessageBox.Show(strResult); } } return(cmd); }
private void button1_Click(object sender, EventArgs e) { int count = int.Parse(cmbPassengerCount.Text); bool flag = true;//信息是否合法 //判断乘机人信息录入是否完整 //判断证件号码信息录入是否完整 switch (count) { case 1: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "") { flag = false; } break; case 2: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "" || txtPassenger2.Text.Trim() == "" || txtCard2.Text.Trim() == "") { flag = false; } break; case 3: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "" || txtPassenger2.Text.Trim() == "" || txtCard2.Text.Trim() == "" || txtPassenger3.Text.Trim() == "" || txtCard3.Text.Trim() == "") { flag = false; } break; case 4: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "" || txtPassenger2.Text.Trim() == "" || txtCard2.Text.Trim() == "" || txtPassenger3.Text.Trim() == "" || txtCard3.Text.Trim() == "" || txtPassenger4.Text.Trim() == "" || txtCard4.Text.Trim() == "") { flag = false; } break; case 5: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "" || txtPassenger2.Text.Trim() == "" || txtCard2.Text.Trim() == "" || txtPassenger3.Text.Trim() == "" || txtCard3.Text.Trim() == "" || txtPassenger4.Text.Trim() == "" || txtCard4.Text.Trim() == "" || txtPassenger5.Text.Trim() == "" || txtCard5.Text.Trim() == "") { flag = false; } break; case 6: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "" || txtPassenger2.Text.Trim() == "" || txtCard2.Text.Trim() == "" || txtPassenger3.Text.Trim() == "" || txtCard3.Text.Trim() == "" || txtPassenger4.Text.Trim() == "" || txtCard4.Text.Trim() == "" || txtPassenger5.Text.Trim() == "" || txtCard5.Text.Trim() == "" || txtPassenger6.Text.Trim() == "" || txtCard6.Text.Trim() == "") { flag = false; } break; case 7: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "" || txtPassenger2.Text.Trim() == "" || txtCard2.Text.Trim() == "" || txtPassenger3.Text.Trim() == "" || txtCard3.Text.Trim() == "" || txtPassenger4.Text.Trim() == "" || txtCard4.Text.Trim() == "" || txtPassenger5.Text.Trim() == "" || txtCard5.Text.Trim() == "" || txtPassenger6.Text.Trim() == "" || txtCard6.Text.Trim() == "" || txtPassenger7.Text.Trim() == "" || txtCard7.Text.Trim() == "") { flag = false; } break; case 8: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "" || txtPassenger2.Text.Trim() == "" || txtCard2.Text.Trim() == "" || txtPassenger3.Text.Trim() == "" || txtCard3.Text.Trim() == "" || txtPassenger4.Text.Trim() == "" || txtCard4.Text.Trim() == "" || txtPassenger5.Text.Trim() == "" || txtCard5.Text.Trim() == "" || txtPassenger6.Text.Trim() == "" || txtCard6.Text.Trim() == "" || txtPassenger7.Text.Trim() == "" || txtCard7.Text.Trim() == "" || txtPassenger8.Text.Trim() == "" || txtCard8.Text.Trim() == "") { flag = false; } break; case 9: if (txtPassenger1.Text.Trim() == "" || txtCard1.Text.Trim() == "" || txtPassenger2.Text.Trim() == "" || txtCard2.Text.Trim() == "" || txtPassenger3.Text.Trim() == "" || txtCard3.Text.Trim() == "" || txtPassenger4.Text.Trim() == "" || txtCard4.Text.Trim() == "" || txtPassenger5.Text.Trim() == "" || txtCard5.Text.Trim() == "" || txtPassenger6.Text.Trim() == "" || txtCard6.Text.Trim() == "" || txtPassenger7.Text.Trim() == "" || txtCard7.Text.Trim() == "" || txtPassenger8.Text.Trim() == "" || txtCard8.Text.Trim() == "" || txtPassenger9.Text.Trim() == "" || txtCard9.Text.Trim() == "") { flag = false; } break; } if (!flag) { MessageBox.Show("乘客姓名和证件号码信息不能为空!"); return; } //判断联系人信息是否完整 if (txtLinkMan.Text.Trim() == "" || txtLinkPhone.Text.Trim() == "") { MessageBox.Show("联系人和联系电话不能为空!"); return; } //2014-01-15,11:30,14:10,3U,8885,F2A2YABATA*9,CTU,PEK,330,0,1,1,False,,T1T3 string[] sl = selectFlight.Split(','); //组织订座指令 string cmd = "nm"; //ss hu7742 t 21jan14 kweszx 1 string ssInfo = "^ss " + sl[3] + sl[4] + " " + cmbClassList.Text.Substring(0, 1) + " " + getEtermDate(sl[0]) + " " + fromcitycode + tocitycode + " " + cmbPassengerCount.Text; string cardInfo = ""; string ctInfo = "^ct" + txtLinkPhone.Text.Trim(); //osi hu ctct 13688514890 string osiInfo = "^osi " + sl[3] + " ctct " + txtLinkPhone.Text; DateTime tmpdate = DateTime.Parse(sl[0] + " " + sl[1]).AddHours(-1); string tktlInfo = "^tktl/" + tmpdate.ToString("HHmm") + "/" + getEtermDate(tmpdate.ToString("yyyy-MM-dd")) + "/" + PublicClass.curOfficeCode; switch (count) { case 1: cmd += "1" + txtPassenger1.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1"; break; case 2: cmd += "1" + txtPassenger1.Text + "1" + txtPassenger2.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1" + "^ssr foid " + sl[3] + " hk/ni" + txtCard2.Text + "/P2"; break; case 3: cmd += "1" + txtPassenger1.Text + "1" + txtPassenger2.Text + "1" + txtPassenger3.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1" + "^ssr foid " + sl[3] + " hk/ni" + txtCard2.Text + "/P2" + "^ssr foid " + sl[3] + " hk/ni" + txtCard3.Text + "/P3"; break; case 4: cmd += "1" + txtPassenger1.Text + "1" + txtPassenger2.Text + "1" + txtPassenger3.Text + "1" + txtPassenger4.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1" + "^ssr foid " + sl[3] + " hk/ni" + txtCard2.Text + "/P2" + "^ssr foid " + sl[3] + " hk/ni" + txtCard3.Text + "/P3" + "^ssr foid " + sl[3] + " hk/ni" + txtCard4.Text + "/P4"; break; case 5: cmd += "1" + txtPassenger1.Text + "1" + txtPassenger2.Text + "1" + txtPassenger3.Text + "1" + txtPassenger4.Text + "1" + txtPassenger5.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1" + "^ssr foid " + sl[3] + " hk/ni" + txtCard2.Text + "/P2" + "^ssr foid " + sl[3] + " hk/ni" + txtCard3.Text + "/P3" + "^ssr foid " + sl[3] + " hk/ni" + txtCard4.Text + "/P4" + "^ssr foid " + sl[3] + " hk/ni" + txtCard5.Text + "/P5"; break; case 6: cmd += "1" + txtPassenger1.Text + "1" + txtPassenger2.Text + "1" + txtPassenger3.Text + "1" + txtPassenger4.Text + "1" + txtPassenger5.Text + "1" + txtPassenger6.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1" + "^ssr foid " + sl[3] + " hk/ni" + txtCard2.Text + "/P2" + "^ssr foid " + sl[3] + " hk/ni" + txtCard3.Text + "/P3" + "^ssr foid " + sl[3] + " hk/ni" + txtCard4.Text + "/P4" + "^ssr foid " + sl[3] + " hk/ni" + txtCard5.Text + "/P5" + "^ssr foid " + sl[3] + " hk/ni" + txtCard6.Text + "/P6"; break; case 7: cmd += "1" + txtPassenger1.Text + "1" + txtPassenger2.Text + "1" + txtPassenger3.Text + "1" + txtPassenger4.Text + "1" + txtPassenger5.Text + "1" + txtPassenger6.Text + "1" + txtPassenger7.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1" + "^ssr foid " + sl[3] + " hk/ni" + txtCard2.Text + "/P2" + "^ssr foid " + sl[3] + " hk/ni" + txtCard3.Text + "/P3" + "^ssr foid " + sl[3] + " hk/ni" + txtCard4.Text + "/P4" + "^ssr foid " + sl[3] + " hk/ni" + txtCard5.Text + "/P5" + "^ssr foid " + sl[3] + " hk/ni" + txtCard6.Text + "/P6" + "^ssr foid " + sl[3] + " hk/ni" + txtCard7.Text + "/P7"; break; case 8: cmd += "1" + txtPassenger1.Text + "1" + txtPassenger2.Text + "1" + txtPassenger3.Text + "1" + txtPassenger4.Text + "1" + txtPassenger5.Text + "1" + txtPassenger6.Text + "1" + txtPassenger7.Text + "1" + txtPassenger8.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1" + "^ssr foid " + sl[3] + " hk/ni" + txtCard2.Text + "/P2" + "^ssr foid " + sl[3] + " hk/ni" + txtCard3.Text + "/P3" + "^ssr foid " + sl[3] + " hk/ni" + txtCard4.Text + "/P4" + "^ssr foid " + sl[3] + " hk/ni" + txtCard5.Text + "/P5" + "^ssr foid " + sl[3] + " hk/ni" + txtCard6.Text + "/P6" + "^ssr foid " + sl[3] + " hk/ni" + txtCard7.Text + "/P7" + "^ssr foid " + sl[3] + " hk/ni" + txtCard8.Text + "/P8"; break; case 9: cmd += "1" + txtPassenger1.Text + "1" + txtPassenger2.Text + "1" + txtPassenger3.Text + "1" + txtPassenger4.Text + "1" + txtPassenger5.Text + "1" + txtPassenger6.Text + "1" + txtPassenger7.Text + "1" + txtPassenger8.Text + "1" + txtPassenger9.Text; cardInfo += "^ssr foid " + sl[3] + " hk/ni" + txtCard1.Text + "/P1" + "^ssr foid " + sl[3] + " hk/ni" + txtCard2.Text + "/P2" + "^ssr foid " + sl[3] + " hk/ni" + txtCard3.Text + "/P3" + "^ssr foid " + sl[3] + " hk/ni" + txtCard4.Text + "/P4" + "^ssr foid " + sl[3] + " hk/ni" + txtCard5.Text + "/P5" + "^ssr foid " + sl[3] + " hk/ni" + txtCard6.Text + "/P6" + "^ssr foid " + sl[3] + " hk/ni" + txtCard7.Text + "/P7" + "^ssr foid " + sl[3] + " hk/ni" + txtCard8.Text + "/P8" + "^ssr foid " + sl[3] + " hk/ni" + txtCard9.Text + "/P9"; break; } //nm1吴俊^ss hu7742 t 21jan14 kweszx 1^ct0851-8651569^ssr foid hu hk/ni512923197410241294/p1^ //osi hu ctct 13688514890^tktl/0825/21jan/kwe140^@ cmd += ssInfo + ctInfo + cardInfo + osiInfo + tktlInfo + "^@"; //预订座位 string strResult = ""; if (PublicClass.SendCommand(cmd, 1, ref strResult)) { //分析PNR string PNR = PublicClass.GetPNRCodeByYuDingResult(strResult); //复制到粘贴板 Clipboard.SetText(PNR); MessageBox.Show("预订PNR结果:" + PNR); return; } else { MessageBox.Show(strResult); return; } }