コード例 #1
0
    protected void cyxlb_Click(object sender, EventArgs e)
    {
        IOpenClient           client = new DefaultOpenClient(BMEshenghuo.serverUrl, BMEshenghuo.appKey, BMEshenghuo.appSecret);
        TrainLinesListRequest req    = new TrainLinesListRequest();

        req.From = qdz.SelectedValue;
        req.To   = zdz.SelectedValue;
        //req.ItemId = mc.SelectedValue;
        req.Date = txtBeginTime.Text;
        TrainLinesListResponse response = client.Execute(req, BMEshenghuo.accessToken);

        if (!response.IsError)
        {
            //hxxz.DataSource = response;
            //hxxz.DataTextField = "TrainNumber" + "TrainTypeName" + "SeatPrice" + "SeatName" + "RemainderTrainTickets" + "StartTime";
            //hxxz.DataValueField = "TrainNumber" + "StartTime";
            //hxxz.DataBind();
            //lab.Text = parPrice.Value;
            if (response.Trainlines == null)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("010488", "没有查到火车票请重新输入条件") + "');</script>", false);
                return;
            }
            List <Qianmi.Api.Domain.Elife.Trainline> alist = response.Trainlines;
            foreach (Qianmi.Api.Domain.Elife.Trainline item in alist)
            {
                List <Qianmi.Api.Domain.Elife.TrainSeat> ss = item.TrainSeats;
                hxxz.Items.Clear();
                for (int j = 0; j < response.Trainlines.Count; j++)
                {
                    if (ss != null)
                    {
                        for (int k = 0; k < ss.Count; k++)
                        {
                            hxxz.Items.Insert(j, alist[j].TrainNumber.ToString() + alist[j].TrainTypeName.ToString() + GetTran("010469", ".时间:") + alist[j].StartTime.ToString() + ss[k].SeatName.ToString() + GetTran("010470", ".票价:") + ss[k].SeatPrice.ToString() + GetTran("010489", ".余票:") + ss[k].RemainderTrainTickets.ToString());
                            hxxz.Items[j].Value = alist[j].TrainNumber.ToString() + alist[j].StartTime.ToString() + ss[k].SeatId.ToString();;
                        }
                    }
                }
                cyx.Visible           = false;
                mc.Enabled            = false;
                qdz.Enabled           = false;
                zdz.Enabled           = false;
                txtBeginTime.ReadOnly = true;
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>$('#yc3').show();</script>", false);
            }
        }
    }
コード例 #2
0
    protected void hxxz_SelectedIndexChanged(object sender, EventArgs e)
    {
        IOpenClient           client = new DefaultOpenClient(BMEshenghuo.serverUrl, BMEshenghuo.appKey, BMEshenghuo.appSecret);
        TrainLinesListRequest req    = new TrainLinesListRequest();

        req.From = qdz.SelectedValue;
        req.To   = zdz.SelectedValue;
        //req.ItemId = mc.SelectedValue;
        req.Date = txtBeginTime.Text;
        TrainLinesListResponse response = client.Execute(req, BMEshenghuo.accessToken);

        if (!response.IsError)
        {
            List <Qianmi.Api.Domain.Elife.Trainline> alist = response.Trainlines;
            int i = 0;

            foreach (Qianmi.Api.Domain.Elife.Trainline item in alist)
            {
                List <Qianmi.Api.Domain.Elife.TrainSeat> ss = item.TrainSeats;
                if (ss != null)
                {
                    int k = 0;
                    foreach (Qianmi.Api.Domain.Elife.TrainSeat item1 in ss)
                    {
                        if (hxxz.SelectedValue == (alist[i].TrainNumber + alist[i].StartTime + alist[i].TrainSeats[k].SeatId.ToString()))
                        {
                            //seatCode.Value = item1.SeatCode;
                            //airlineCode.Value = item1.AirlineCode;
                            parPrice.Value = alist[i].TrainSeats[k].SeatPrice; //座位票面价
                            seatMsg.Value  = alist[i].TrainSeats[k].SeatName;  //座位类型名称: 二等座, 一等座, 商务座等
                            //seatStatus.Value = item1.SeatStatus;
                            flightNo.Value          = alist[i].TrainNumber;    //车次号
                            FlightCompanyName.Value = alist[i].TrainTypeName;  //车次类型
                            DepTime.Value           = alist[i].StartTime;      //发车时间
                            ArriTime.Value          = alist[i].EndTime;        //到达时间
                            lab.Text = parPrice.Value;
                            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>$('#yc3').show();</script>", false);
                            break;
                        }

                        k++;
                    }
                }
                i++;
            }
        }
    }