Exemplo n.º 1
0
        private void btnSrch_Click(object sender, EventArgs e)
        {
            if (comKd.SelectedIndex < 0)
            {
                MessageBox.Show("请选择快递公司!");
                return;
            }
            if (edtKdh.Text == "")
            {
                MessageBox.Show("请输入快递单号!");
                return;
            }
            ComboxItem item   = comKd.SelectedItem as ComboxItem;
            ApiUtils   apiGet = new ApiUtils();
            object     obj    = null;

            if (apiGet.ApiData_Get(PubApi.ApiTypeEnum.ApiExpressInfo, out obj, item.Value, edtKdh.Text))
            {
                if (obj != null)
                {
                    apiDataObject.ExpressInfoObj dataInfo = obj as apiDataObject.ExpressInfoObj;
                    if (dataInfo.status != "200")
                    {
                        MessageBox.Show("查询失败!");
                        return;
                    }
                    else
                    {
                        string sNr = string.Empty;
                        for (int i = 0; i < dataInfo.data.Count; i++)
                        {
                            sNr += dataInfo.data[i].time + "\r\n";
                            sNr += dataInfo.data[i].context + "\r\n";
                            sNr += "------------------------------------------------------------------------\r\n";
                        }
                        memoNr.Text = sNr;
                    }
                }
            }
        }