예제 #1
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            SearchListView.Visibility       = Visibility.Collapsed;
            RideChart.Visibility            = Visibility.Collapsed;
            OnedayChart.Visibility          = Visibility.Collapsed;
            BackgroundStackPanel.Visibility = Visibility.Collapsed;
            NoResultStackPanel.Visibility   = Visibility.Collapsed;
            SearchListView.Items.Clear();
            bool searchResult = DataHelper.SearchData("BikePnts", "BikeID = '" + SearchTextBox.Text + "'", "SearchTemp");

            if (searchResult == true)
            {
                Fields Flds = null;
                Field  Fld  = null;
                long   ID   = 0;
                Record Rcd  = null;

                //变量初始化
                Rcd  = new Record();
                Flds = new Fields();

                Server svr = new Server();
                //连接数据源
                svr.Connect("MapGISLocal", "", "");
                DataBase    GDB   = svr.OpenGDB("Templates");
                SFeatureCls SFCls = new SFeatureCls(GDB);
                SFCls.Open("SearchTemp", 0);
                //获取属性结构
                Flds = SFCls.Fields;
                if (Flds == null)
                {
                    SFCls.Close();
                    OnedayChart.Visibility          = Visibility.Collapsed;
                    RideChart.Visibility            = Visibility.Collapsed;
                    SearchListView.Visibility       = Visibility.Collapsed;
                    BackgroundStackPanel.Visibility = Visibility.Collapsed;
                    NoResultStackPanel.Visibility   = Visibility.Visible;
                    return;
                }
                int num = Flds.Count;

                //目的类对象的个数
                int objnum = SFCls.Count;

                //获取所有对象的ID,思想是根据对象的个数进行循环,若OID不存在,则OID自加继续循环直到循环objnum次
                int n = 0;
                ID = 1;

                string[] listItem = new string[8];
                while (n < objnum)
                {
                    //取得ID=ID.Int的简单要素的属性
                    Rcd = SFCls.GetAtt(ID);

                    //取得属性结构对象中的字段数目
                    if (Rcd != null)
                    {
                        Flds = Rcd.Fields;

                        listItem[0] = ID.ToString();

                        //获取对应属性字段的值
                        for (int i = 0; i < num; i++)
                        {
                            object val = null;
                            Fld = Flds.GetItem(i);
                            string name = Fld.FieldName;
                            val             = Rcd.get_FldVal(name);
                            listItem[i + 1] = ((val != null) ? val.ToString() : "");
                        }
                        n++;
                        SearchListView.Items.Add(new { OID = listItem[0], BikeID = listItem[3], Time = listItem[4].Substring(9), XAsis = listItem[6].Substring(0, 8), YAsis = listItem[7].Substring(0, 8) });
                    }
                    ID++;
                }
                SFCls.Close();
                SearchListView.Visibility = Visibility.Visible;
            }
            else
            {
                OnedayChart.Visibility          = Visibility.Collapsed;
                RideChart.Visibility            = Visibility.Collapsed;
                SearchListView.Visibility       = Visibility.Collapsed;
                BackgroundStackPanel.Visibility = Visibility.Collapsed;
                NoResultStackPanel.Visibility   = Visibility.Visible;
            }
        }