예제 #1
0
파일: FrmMain.cs 프로젝트: tinshen/pidDev
 private void Exit_ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //释放资源
     PublicClass.Free();
     Application.ExitThread();
 }
예제 #2
0
        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;
            }
        }