예제 #1
0
 private void tsmiDelete_Click(object sender, EventArgs e)
 {
     if (SelectedFeature == null)
     {
         MessageBox.Show("请选择点进行删除!");
     }
     else
     {
         try
         {
             Int32 iNDH = -1;
             try
             {
                 iNDH = Convert.ToInt32(SelectedFeature["NDH"]);
             }
             catch
             { }
             Table tEditTable = (mapControl1.Map.Layers["JKINFO"] as FeatureLayer).Table;
             tEditTable.DeleteFeature(SelectedFeature);
             SelectedFeature = null;
             JKINFOBLL bllJKINFO   = new JKINFOBLL();
             String    MDBFileName = (SysInfo.HTDBInfo[cbMaps.Text] as DBInfo).MDBPath;
             bllJKINFO.DeleteJKINFO(iNDH, MDBFileName);
             MessageBox.Show("删除成功!");
         }
         catch
         {
             MessageBox.Show("数据异常!");
         }
     }
 }
예제 #2
0
        private void JKINFOList_Load(object sender, EventArgs e)
        {
            JKINFOBLL bllJKINFO = new JKINFOBLL();

            try
            {
                dataGridView1.DataSource = bllJKINFO.GetList(_MDBFileName, "").Tables[0].Copy();
            }
            catch
            {
                MessageBox.Show("¼ÓÔØÊý¾Ý³ö´í£¡");
            }
        }
예제 #3
0
        private void tsmiAdd_Click(object sender, EventArgs e)
        {
            AddJKINFO frmAddJKINFO = new AddJKINFO();

            if (frmAddJKINFO.ShowDialog() == DialogResult.OK)
            {
                Table   tEditTable = (mapControl1.Map.Layers["JKINFO"] as FeatureLayer).Table;
                Feature f          = new Feature(tEditTable.TableInfo.Columns);
                DPoint  dp         = ConvertTOJWDu(pNodePoint);
                f.Geometry = new MapInfo.Geometry.Point(mapControl1.Map.GetDisplayCoordSys(), dp);
                //f.GeometryIndex = 4;
                f.Style = sDefault;
                foreach (DataRow dr in SysInfo.TypeDataTable.Rows)
                {
                    int iType = Convert.ToInt32(dr["JKType"]);
                    if (frmAddJKINFO.OBJJKINFO.SBLX == iType)
                    {
                        f.Style = new MapInfo.Styles.CompositeStyle(new MapInfo.Styles.BitmapPointStyle(dr["BMPFileName"].ToString(), BitmapStyles.None, Color.Blue, 10));
                    }
                }
                f["NDH"] = frmAddJKINFO.OBJJKINFO.NDH;
                f["SJ"]  = frmAddJKINFO.OBJJKINFO.SJ;
                f["DW"]  = frmAddJKINFO.OBJJKINFO.DW;
                MapInfo.Data.Key ftrkey = tEditTable.InsertFeature(f);
                //MessageBox.Show(f.Key.Value.ToString());

                ///查询方法
                //SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("mi_key='8'");
                //IResultSetFeatureCollection ifs = MapInfo.Engine.Session.Current.Catalog.Search(tEditTable, si); //JKINFO

                //frmAddJKINFO.OBJJKINFO.MAPINFO_ID = Convert.ToInt32(ftrkey.Value);

                JKINFOBLL bllJKINFO = new JKINFOBLL();

                String MDBFileName = (SysInfo.HTDBInfo[cbMaps.Text] as DBInfo).MDBPath;
                if (bllJKINFO.AddJKINFO(frmAddJKINFO.OBJJKINFO, MDBFileName))
                {
                    MessageBox.Show("保存成功!");
                }
                else
                {
                    MessageBox.Show("保存失败!");
                    tEditTable.DeleteFeature(ftrkey);
                }
            }
        }
예제 #4
0
        private void tsmiView_Click(object sender, EventArgs e)
        {
            if (SelectedFeature == null)
            {
                MessageBox.Show("请选择点进行查看!");
            }
            else
            {
                try
                {
                    Int32     iNDH                 = Convert.ToInt32(SelectedFeature["NDH"]);
                    JKINFOBLL bllJKINFO            = new JKINFOBLL();
                    String    MDBFileName          = (SysInfo.HTDBInfo[cbMaps.Text] as DBInfo).MDBPath;
                    MapApp.Entities.JKINFO oJKINFO = bllJKINFO.GetJKINFO(iNDH, MDBFileName);

                    ViewJKINFO frmViewJKINFO = new ViewJKINFO(oJKINFO);
                    frmViewJKINFO.ShowDialog();
                }
                catch
                {
                    MessageBox.Show("数据异常!");
                }
            }
        }
예제 #5
0
        private static void RewNew()
        {
            while (true)
            {
                JKINFOBLL bllJKINFO   = new JKINFOBLL();
                String    MDBFileName = (SysInfo.HTDBInfo[sMapName] as DBInfo).MDBPath;
                DataTable dtAllRow    = bllJKINFO.GetList(MDBFileName, "").Tables[0].Copy();

                if (dtAllRow.Rows.Count <= 0)
                {
                    return;
                }


                if (ifs.Count <= 0)
                {
                    return;
                }
                else
                {
                    //FeatureLayer lyrTemp = (FeatureLayer)mapControl1.Map.Layers["JKINFO"];
                    //if (lyrTemp != null)
                    //{
                    //    IFeatureEnumerator fen = (lyrTemp.Table as IFeatureCollection).GetFeatureEnumerator();
                    //    while (fen.MoveNext())
                    //    {
                    //        Feature ftemp = fen.Current;
                    //        try
                    //        {
                    //            Int32 iNDH = -1;
                    //            if (ftemp["NDH"] == null)
                    //                continue;
                    //            try
                    //            {
                    //                iNDH = Convert.ToInt32(ftemp["NDH"]);
                    //                foreach (DataRow dr in dtAllRow.Rows)
                    //                {
                    //                    try
                    //                    {
                    //                        if (iNDH == Convert.ToInt32(dr["NDH"]))
                    //                        {
                    //                            ftemp["SJ"] = dr["SJ"];
                    //                            ftemp["DW"] = dr["DW"];
                    //                            ftemp.Table.UpdateFeature(ftemp);
                    //                            break;
                    //                        }
                    //                    }
                    //                    catch
                    //                    { }
                    //                }
                    //            }
                    //            catch
                    //            {
                    //            }
                    //        }
                    //        catch (Exception ex)
                    //        {
                    //            MessageBox.Show("更新中发生错误:" + ex.Message);
                    //        }
                    //    }
                    //}



                    for (int i = 0; i < ifs.Count; i++)
                    {
                        Feature ftemp = ifs[i];
                        try
                        {
                            Int32 iNDH = -1;
                            if (ftemp["NDH"] == null)
                            {
                                continue;
                            }
                            try
                            {
                                iNDH = Convert.ToInt32(ftemp["NDH"]);
                                foreach (DataRow dr in dtAllRow.Rows)
                                {
                                    try
                                    {
                                        if (iNDH == Convert.ToInt32(dr["NDH"]))
                                        {
                                            ftemp["SJ"] = dr["SJ"];
                                            ftemp["DW"] = dr["DW"];
                                            ftemp.Table.UpdateFeature(ftemp);
                                            break;
                                        }
                                    }
                                    catch
                                    { }
                                }
                            }
                            catch
                            {
                            }
                        }
                        catch //(Exception ex)
                        {
                            //MessageBox.Show("更新中发生错误:" + ex.Message);
                        }
                    }
                }
                Thread.Sleep(3000);
            }
        }
예제 #6
0
        private void tsmiEdit_Click(object sender, EventArgs e)
        {
            if (SelectedFeature == null)
            {
                MessageBox.Show("请选择点进行查看!");
            }
            else
            {
                JKINFOBLL bllJKINFO   = new JKINFOBLL();
                String    MDBFileName = (SysInfo.HTDBInfo[cbMaps.Text] as DBInfo).MDBPath;
                try
                {
                    Int32 iNDH = Convert.ToInt32(SelectedFeature["NDH"]);

                    MapApp.Entities.JKINFO oJKINFO = bllJKINFO.GetJKINFO(iNDH, MDBFileName);

                    EditJKINFO frmEditJKINFO = new EditJKINFO(oJKINFO);
                    if (frmEditJKINFO.ShowDialog() == DialogResult.OK)
                    {
                        if (bllJKINFO.EditJKINFO(frmEditJKINFO.OBJJKINFO, MDBFileName))
                        {
                            SelectedFeature["DW"] = frmEditJKINFO.OBJJKINFO.DW;
                            SelectedFeature["SJ"] = frmEditJKINFO.OBJJKINFO.SJ;

                            SelectedFeature.Style = sDefault;
                            foreach (DataRow dr in SysInfo.TypeDataTable.Rows)
                            {
                                int iType = Convert.ToInt32(dr["JKType"]);
                                if (frmEditJKINFO.OBJJKINFO.SBLX == iType)
                                {
                                    SelectedFeature.Style = new MapInfo.Styles.CompositeStyle(new MapInfo.Styles.BitmapPointStyle(dr["BMPFileName"].ToString(), BitmapStyles.None, Color.Blue, 10));
                                    break;
                                }
                            }

                            SelectedFeature.Table.UpdateFeature(SelectedFeature);
                            MessageBox.Show("保存成功!");
                        }
                        else
                        {
                            MessageBox.Show("保存失败!");
                        }
                    }
                }
                catch
                {
                    AddJKINFO frmAddJKINFO = new AddJKINFO();
                    if (frmAddJKINFO.ShowDialog() == DialogResult.OK)
                    {
                        Table tEditTable = (mapControl1.Map.Layers["JKINFO"] as FeatureLayer).Table;

                        SelectedFeature.Style = sDefault;
                        foreach (DataRow dr in SysInfo.TypeDataTable.Rows)
                        {
                            int iType = Convert.ToInt32(dr["JKType"]);
                            if (frmAddJKINFO.OBJJKINFO.SBLX == iType)
                            {
                                SelectedFeature.Style = new MapInfo.Styles.CompositeStyle(new MapInfo.Styles.BitmapPointStyle(dr["BMPFileName"].ToString(), BitmapStyles.None, Color.Blue, 10));
                            }
                        }
                        SelectedFeature["NDH"] = frmAddJKINFO.OBJJKINFO.NDH;
                        SelectedFeature["SJ"]  = frmAddJKINFO.OBJJKINFO.SJ;
                        SelectedFeature["DW"]  = frmAddJKINFO.OBJJKINFO.DW;
                        tEditTable.UpdateFeature(SelectedFeature);

                        if (bllJKINFO.AddJKINFO(frmAddJKINFO.OBJJKINFO, MDBFileName))
                        {
                            MessageBox.Show("保存成功!");
                        }
                        else
                        {
                            MessageBox.Show("保存失败!");
                        }
                    }
                }
            }
        }
예제 #7
0
        void t_Tick(object sender, EventArgs e)
        {
            JKINFOBLL bllJKINFO   = new JKINFOBLL();
            String    MDBFileName = (SysInfo.HTDBInfo[cbMaps.Text] as DBInfo).MDBPath;

            dtAllRow = bllJKINFO.GetList(MDBFileName, "").Tables[0].Copy();

            if (dtAllRow.Rows.Count <= 0)
            {
                return;
            }

            SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("1=1");

            si.QueryDefinition.Columns = new string[] { "*" };// new string[] { "NDH" }; //null
            IResultSetFeatureCollection ifs = MapInfo.Engine.Session.Current.Catalog.Search("JKINFO", si);

            foreach (MapInfo.Data.Feature f in ifs)
            {
                try
                {
                    Int32 iNDH = -1;
                    if (f["NDH"] != null)
                    {
                        try
                        {
                            iNDH = Convert.ToInt32(f["NDH"]);
                            foreach (DataRow dr in dtAllRow.Rows)
                            {
                                try
                                {
                                    if (iNDH == Convert.ToInt32(dr["NDH"]))
                                    {
                                        f["SJ"] = dr["SJ"];
                                        f["DW"] = dr["DW"];
                                        f.Table.UpdateFeature(f);
                                        break;
                                    }
                                }
                                catch
                                { }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                catch //(Exception ex)
                {
                    //MessageBox.Show("更新中发生错误:" + ex.Message);
                }
            }

            //SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("1=1");
            //si.QueryDefinition.Columns = new string[] { "*" } ;// new string[] { "NDH" }; //null
            //IResultSetFeatureCollection ifs = MapInfo.Engine.Session.Current.Catalog.Search("JKINFO", si);
            //if (ifs.Count <= 0)
            //{
            //    return;
            //}
            //else
            //{
            //    //FeatureLayer lyrTemp = (FeatureLayer)mapControl1.Map.Layers["JKINFO"];
            //    //if (lyrTemp != null)
            //    //{
            //    //    IFeatureEnumerator fen = (lyrTemp.Table as IFeatureCollection).GetFeatureEnumerator();
            //    //    while (fen.MoveNext())
            //    //    {
            //    //        Feature ftemp = fen.Current;
            //    //        try
            //    //        {
            //    //            Int32 iNDH = -1;
            //    //            if (ftemp["NDH"] == null)
            //    //                continue;
            //    //            try
            //    //            {
            //    //                iNDH = Convert.ToInt32(ftemp["NDH"]);
            //    //                foreach (DataRow dr in dtAllRow.Rows)
            //    //                {
            //    //                    try
            //    //                    {
            //    //                        if (iNDH == Convert.ToInt32(dr["NDH"]))
            //    //                        {
            //    //                            ftemp["SJ"] = dr["SJ"];
            //    //                            ftemp["DW"] = dr["DW"];
            //    //                            ftemp.Table.UpdateFeature(ftemp);
            //    //                            break;
            //    //                        }
            //    //                    }
            //    //                    catch
            //    //                    { }
            //    //                }
            //    //            }
            //    //            catch
            //    //            {
            //    //            }
            //    //        }
            //    //        catch (Exception ex)
            //    //        {
            //    //            MessageBox.Show("更新中发生错误:" + ex.Message);
            //    //        }
            //    //    }
            //    //}

            //    for (int i = 0; i < ifs.Count; i++)
            //    {
            //        try
            //        {
            //            Int32 iNDH = -1;
            //            if (ifs[i]["NDH"] != null)
            //            {
            //                try
            //                {
            //                    iNDH = Convert.ToInt32(ifs[i]["NDH"]);
            //                    foreach (DataRow dr in dtAllRow.Rows)
            //                    {
            //                        try
            //                        {
            //                            if (iNDH == Convert.ToInt32(dr["NDH"]))
            //                            {
            //                                ifs[i]["SJ"] = dr["SJ"];
            //                                ifs[i]["DW"] = dr["DW"];
            //                                ifs[i].Table.UpdateFeature(ifs[i]);
            //                                break;
            //                            }
            //                        }
            //                        catch
            //                        { }
            //                    }
            //                }
            //                catch
            //                {
            //                }
            //            }
            //        }
            //        catch //(Exception ex)
            //        {
            //            //MessageBox.Show("更新中发生错误:" + ex.Message);
            //        }

            //    }
            //}
        }