private void skinButton1_Click(object sender, EventArgs e) { String name = skinTextBox2.Text; if (null == name || name.Length == 0) { MessageBox.Show("请输入机场名称!"); return; } if (null == skinTextBox3.Text || skinTextBox3.Text.Length == 0) { MessageBox.Show("请输入经纬度!"); return; } if (null == skinTextBox4.Text || skinTextBox4.Text.Length == 0) { MessageBox.Show("请输入经纬度!"); return; } Way_Point way_Point = new Way_Point(name, Convert.ToDouble(skinTextBox3.Text), Convert.ToDouble(skinTextBox4.Text)); // 插入数据库 ProfileHelper.Instance.Update("INSERT INTO WayPoint (Name, Lat, Lng) VALUES ('" + way_Point.Name + "', " + way_Point.Lat + ", " + way_Point.Lng + ")"); showAllWayPoint(); wayPoint_event(true, 2); }
/** * 从数据库里面查出所有的数据,展示。 * */ private void showAllWayPoint() { List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM WayPoint"); wayPointList.Clear(); foreach (Dictionary <string, object> dictionary in result) { String name = Convert.ToString(dictionary["Name"]); double lat = Convert.ToDouble(dictionary["Lat"]); double lang = Convert.ToDouble(dictionary["Lng"]); Way_Point way_Point = new Way_Point(name, lat, lang); wayPointList.Add(way_Point); } this.dataGridView1.DataSource = null; if (null != wayPointList && wayPointList.Count() > 0) { this.dataGridView1.DataSource = this.wayPointList; } }