Beispiel #1
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);
                }
            }
        }
Beispiel #2
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("保存失败!");
                        }
                    }
                }
            }
        }