qq_35202555 2016-06-19 13:35 采纳率: 66.7%
浏览 1090
已结题

新人求教,下面代码各什么意思

private void timeQuery(int id)
{
string scn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据表.mdb";
OleDbConnection mycn = new OleDbConnection(scn);

        mycn.Open();
        OleDbCommand mycmd = new OleDbCommand();
        mycmd.Connection = mycn;
        mycmd.CommandType = CommandType.Text;
        string t1 = this.dateTimePicker1.Value.ToString();
        string t = this.dateTimePicker2.Value.ToString();
        string c = "select * from point1 where id='" + id + "' and  time between # " + t1 + "# and # " + t + "# ";

        mycmd.CommandText = c;
        OleDbDataAdapter add = new OleDbDataAdapter(mycmd);
        DataSet ds = new DataSet();
        add.Fill(ds, "a");
        DataTable dt = new DataTable();
        dt = ds.Tables["a"];
        string name;
        IPointCollection ppc = new PolylineClass();
        for (int i = 0; i < dt.Rows.Count; i++)
        {

            name = dt.Rows[i]["id"].ToString();
            name = name.Trim();
            double x = Convert.ToDouble(dt.Rows[i]["x"]);
            double y = Convert.ToDouble(dt.Rows[i]["y"]);
            ITextElement pte = new TextElementClass();
            ISimpleTextSymbol psts = new TextSymbolClass();

            IFont mf = new StdFontClass();
            mf.Name = "宋体";//Courier New
            IFontDisp mt = mf as IFontDisp;
            psts.Font = mt;
            psts.Size = 18;

            pte.Symbol = psts;
            pte.Text = name;
            IElement pelt = pte as IElement;

            IElementProperties pelet = pelt as IElementProperties;
            pelet.Name = name;
            IElement pel = new MarkerElementClass();
            IPoint pp = new PointClass();

            pp.PutCoords(x, y);
            ppc.AddPoints(1, ref pp);
            pel.Geometry = pp;
            pelt.Geometry = pp;
            IElementProperties pele = pel as IElementProperties;
            pele.Name = name;

            ISimpleMarkerSymbol psm = new SimpleMarkerSymbolClass();
            IRgbColor prg = new RgbColorClass();
            IMarkerElement pme = pel as IMarkerElement;
            //psm.Style = esriSimpleMarkerStyle.esriSMSDiamond;
           IRgbColor prgb = new RgbColorClass();



            pgc.AddElement(pel, 0);

            pgc.AddElement(pelt, 0);

            this.axMapControl1.ActiveView.Refresh();

        }

        IPolyline ppl = ppc as IPolyline;
        IElement pele1 = new LineElementClass();
        pele1.Geometry = ppl;

        ILineElement ple = pele1 as ILineElement;
        ISimpleLineSymbol psl = new SimpleLineSymbolClass();
        //psl.Style = esriSimpleLineStyle.esriSLSSolid;   // ctrl + J
        IRgbColor prg1 = new RgbColorClass();


        pgc.AddElement(pele1, 0);
        this.axMapControl1.ActiveView.Refresh();

    }
  • 写回答

1条回答 默认 最新

  • threenewbee 2016-06-19 13:38
    关注

    string c = "select * from point1 where id='" + id + "' and time between # " + t1 + "# and # " + t + "# ";
    查询id和你输入id相符,并且日期在你两个选择控件日期之间的point

    for (int i = 0; i < dt.Rows.Count; i++)
    循环遍历查询出来的点,根据id,x y坐标添加到你的地图上。

    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题