/** * 从数据库里面查出所有的数据,展示。 * */ private void showAllAirSpace() { List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM AirSpace"); airSpaceList.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"]); int type = Convert.ToInt16(dictionary["Type"]); int id = Convert.ToInt16(dictionary["Id"]); double radius = Convert.ToDouble(dictionary["Radius"]); Air_Space air_Space; if (0 == type) { // 多边形 air_Space = new Air_Space(name, lat, lang, "多边形", id, 0); } else { // 圆形 air_Space = new Air_Space(name, lat, lang, "圆形", 0, radius); } airSpaceList.Add(air_Space); } this.dataGridView1.DataSource = null; if (null != airSpaceList && airSpaceList.Count() > 0) { this.dataGridView1.DataSource = this.airSpaceList; } }
private void doCircular() { 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; } if (null == skinTextBox1.Text || skinTextBox1.Text.Length == 0) { MessageBox.Show("请输入半径!"); return; } Air_Space air_Spacet = new Air_Space( name, Convert.ToDouble(skinTextBox3.Text), Convert.ToDouble(skinTextBox4.Text), "圆形", 0, Convert.ToDouble(skinTextBox1.Text)); // 插入数据库 ProfileHelper.Instance.Update("INSERT INTO AirSpace (Name, Lat, Lng, Type, Id, Radius) " + "VALUES ('" + air_Spacet.Name + "', " + air_Spacet.Lat + ", " + air_Spacet.Lng + ", 1, " + air_Spacet.Id + ", " + air_Spacet.Radius + ")"); showAllAirSpace(); airSpace_event(true, 2); }