Example #1
0
        public void autoEtdz(string pnr, bool isPatOperation)
        {
            string prestring = "EEEEEEEEEE    ";

            try
            {
                if (!isPatOperation)
                {
                    EagleAPI.LogWrite(prestring + "开始进行自动出票:");
                }
                Options.ibe.ibeInterface ib = new Options.ibe.ibeInterface();
                string            rtXml     = ib.rt2(pnr);
                Options.ibe.IbeRt rtResult  = new Options.ibe.IbeRt(rtXml);
                //注:自动出票不检查身份证项,请在出票前输好身份证
                //0.检查PNR是否存在
                if (!isPatOperation)
                {
                    EagleAPI.LogWrite("检查PNR是否存在:");
                }
                if (rtXml == "")
                {
                    throw new Exception("终止出票,原因:PNR不存在!");
                }

                //1.检查是否有票号
                if (!isPatOperation)
                {
                    EagleAPI.LogWrite("检查是否有票号:");
                }
                if (rtResult.getpeopleinfo(2)[0] != "")
                {
                    throw new Exception("终止出票,原因:已经存在票号");
                }

                //2.根据出发城市,找到对应配置,此步骤以后增加。暂时使用当前配置
                string startCity = rtResult.getflightsegsinfo()[0].Split('~')[2].Substring(0, 3);
                //todo: 找配置,并切换配置……

                //3.检验配置是否切换成功,若成功,则应该在返回变量中,处理后面的步骤。
                //todo:EagleAPI.EagleSendOneCmd("qt");

                //4.根据PNR信息及配置定制指令串
                if (!isPatOperation)
                {
                    EagleAPI.LogWrite("开始生成指令串");
                }
                List <string> cmdString = new List <string>();
                cmdString.Add("rt" + pnr);
                //      I.根据人数及航段,指定RR项
                int pCount = rtResult.getpeopleinfo(0).Length;
                { this.nPeople.Value = pCount; Application.DoEvents(); }                                        //置控件
                int fCount = rtResult.getflightsegsinfo().Length;
                { this.nSegment.Value = fCount; Application.DoEvents(); }                                       //置控件
                for (int i = 0; i < fCount; i++)
                {
                    cmdString.Add(string.Format("{0}RR", pCount + i + 1));
                }
                //      II.根据航空公司及配置,指定AT/WUH项
                int    no     = pCount + fCount + 3;
                string atItem = no.ToString() + "aT/" + startCity + "YY";
                cmdString.Add(atItem);
                { tbLocalCity.Text = startCity + "YY"; tbATWUH.Text = atItem; Application.DoEvents(); }         //置控件

                //      III.检查舱位是否为特价舱。来决定PAT项
                string[] fInfo           = rtResult.getflightsegsinfo();
                int      normalBunkCount = 0;
                for (int i = 0; i < fInfo.Length; i++)
                {
                    if (EagleAPI.isNormalBunk(fInfo[i].Split('~')[0].Substring(0, 2), fInfo[i].Split('~')[1]))
                    {
                        normalBunkCount++;
                    }
                }
                bRtBotton = false;
                EagleAPI.CLEARCMDLIST(3);
                if (btAutoETDZ.Focused)//原一键出票
                {
                    if (cbAutoPat.Checked)
                    {
                        EagleAPI.LogWrite("发送相应的PAT指令");
                        if (normalBunkCount == fInfo.Length)//全部航段为正常舱位
                        {
                            if (fCount == 1)
                            {
                                if (isPatOperation)
                                {
                                    EagleAPI.EagleSendOneCmd("i~rT" + tbPnr.Text.Trim() + "~pat:");
                                    return;
                                }
                                cmdString.Add("pat:");
                            }
                            else
                            {
                                switch (fInfo[0].Split('~')[0].Substring(0, 2))
                                {
                                case "CZ":
                                    if (isPatOperation)
                                    {
                                        EagleAPI.EagleSendOneCmd("i~rT" + tbPnr.Text.Trim() + "~pat:#yzzs");
                                        return;
                                    }
                                    cmdString.Add("pat:#yzzs");
                                    break;

                                case "MU":
                                    if (isPatOperation)
                                    {
                                        EagleAPI.EagleSendOneCmd("i~rT" + tbPnr.Text.Trim() + "~pat:#muytr");
                                        return;
                                    }
                                    cmdString.Add("pat:#muytr");
                                    break;

                                case "3U":
                                    if (isPatOperation)
                                    {
                                        EagleAPI.EagleSendOneCmd("i~rT" + tbPnr.Text.Trim() + "~pat:#3UZZ");
                                        return;
                                    }
                                    cmdString.Add("pat:#3UZZ");
                                    break;

                                default:
                                    if (isPatOperation)
                                    {
                                        EagleAPI.EagleSendOneCmd("i~rT" + tbPnr.Text.Trim() + "~pat:");
                                        return;
                                    }
                                    cmdString.Add("pat:");
                                    break;
                                }
                            }
                        }
                        else if (normalBunkCount == 0)//全部为特价舱
                        {
                            if (isPatOperation)
                            {
                                EagleAPI.EagleSendOneCmd("i~rT" + tbPnr.Text.Trim() + "~pat:a");
                                return;
                            }
                            cmdString.Add("pat:a");
                        }
                        else//其中一部分为特价舱
                        {
                            throw new Exception("终止出票,原因:包含正常舱位和特殊舱位!不知道如何PAT!");
                        }

                        if (!isPatOperation)
                        {
                            cmdString.Add(GlobalVar.strPatItem);
                        }
                        DialogResult dr = MessageBox.Show("PAT指令:    " + cmdString[cmdString.Count - 1] + "\r\n" +
                                                          "票价组:   " + cmdString[cmdString.Count - 1] + "\r\n\r\n是否继续出票?", "注意", MessageBoxButtons.YesNo);
                        if (dr == DialogResult.No)
                        {
                            return;
                        }
                    }
                }
                else if (button1.Focused)//2008-7-21  一键出票
                {
                    if (!isPATed.Checked)
                    {
                        string patStr = "";
                        if (radioButton1.Checked)
                        {
                            patStr = "pat:";
                        }
                        if (radioButton2.Checked)
                        {
                            patStr = "pat:A";
                        }
                        if (radioButton3.Checked)
                        {
                            patStr = "pat:*ch";
                        }
                        if (radioButton4.Checked)
                        {
                            patStr = "pat:#yzzs";
                        }
                        if (radioButton5.Checked)
                        {
                            patStr = "pat:#muytr";
                        }
                        if (radioButton6.Checked)
                        {
                            patStr = "pat:#3UZZ";
                        }
                        if (!isPatOperation)
                        {
                            cmdString.Add(GlobalVar.strPatItem);
                        }
                        if (isPatOperation)
                        {
                            EagleAPI.EagleSendOneCmd("i~rT" + tbPnr.Text.Trim() + "~" + patStr);
                            return;
                        }
                        cmdString.Add(patStr);
                        DialogResult dr = MessageBox.Show("PAT指令:    " + cmdString[cmdString.Count - 1] + "\r\n" +
                                                          "票价组:   " + cmdString[cmdString.Count - 1] + "\r\n\r\n是否继续出票?", "注意", MessageBoxButtons.YesNo);
                        if (dr == DialogResult.No)
                        {
                            return;
                        }
                    }
                }
                //      IV. 签注EI项
                int bunkindex = 0;
                for (int i = 0; i < fInfo.Length; i++)
                {
                    int index = EagleAPI.IndexOfBunk(fInfo[i].Split('~')[0].Substring(0, 2), fInfo[i].Split('~')[1]);
                    if (index > bunkindex)
                    {
                        bunkindex = index;
                    }
                }
                if (bunkindex < 3)
                {
                    cbRestrictions.Text = "";
                }
                else if (bunkindex < 6)
                {
                    cmdString.Add("EI:不得签转");
                    cbRestrictions.Text = cmdString[cmdString.Count - 1].Substring(3);      //置控件
                }
                else if (bunkindex < 16)
                {
                    cmdString.Add("EI:不得签转更改");
                    cbRestrictions.Text = cmdString[cmdString.Count - 1].Substring(3);      //置控件
                }
                else
                {
                    cmdString.Add("EI:不得签转更改退票");
                    cbRestrictions.Text = cmdString[cmdString.Count - 1].Substring(3);      //置控件
                }
                Application.DoEvents();
                //      V.出票ETDZ项
                int pn = CreateETicket.GetPrinterNumber(GlobalVar.officeNumberCurrent);
                cmdString.Add("ETDZ:" + pn.ToString());
                tbETDZ.Text = "ETDZ:" + pn.ToString();                              //置控件
                Application.DoEvents();
                if (pn == 0)
                {
                    throw new Exception("终止出票,原因:未选择配置!");
                }
                string cmd = "i";
                for (int i = 0; i < cmdString.Count; i++)
                {
                    cmd += "~" + cmdString[i];
                }
                EagleAPI.LogWrite(prestring + "得到指令并发送:" + cmd);
                EagleAPI.EagleSendOneCmd(cmd);
            }
            catch (Exception ex)
            {
                EagleAPI.LogWrite(prestring + ex.Message);
                //控件值。
                this.tbPAT.Text = ex.Message;                                           //置控件
            }
        }