private void skinButton1_Click(object sender, EventArgs e) { String name = skinTextBox3.Text; if (string.IsNullOrEmpty(name)) { MessageBox.Show("请选择航线!"); return; } if (string.IsNullOrEmpty(comboBox2.Text)) { MessageBox.Show("请选择航站点!"); return; } int num = Convert.ToInt32(skinTextBox1.Text); String wayPoint = comboBox2.Text; Route_WayPoint routeWayPoint = new Route_WayPoint(0, name, comboBox2.Text, num); if (skinLabel11.Text.Equals("ID")) { ProfileHelper.Instance.Update("INSERT INTO RouteWayPoint (Id, PortId, WayPoint, Num) VALUES ( NULL, '" + routeWayPoint.PortId + "', '" + routeWayPoint.WayPoint + "', " + routeWayPoint.Num + ")"); skinTextBox1.Text = (num + 1).ToString(); } else { List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM RouteWayPoint WHERE ID = " + skinLabel11.Text); if (result.Count > 0) { // 更改其他列的信息 ProfileHelper.Instance.Update( "UPDATE RouteWayPoint set " + " WayPoint = '" + routeWayPoint.WayPoint + "'" + " where ID = '" + skinLabel11.Text + "'"); skinButton1.Text = "新增"; comboBox2.SelectedValue = ""; skinButton3.Visible = false; } } showAllRouteWaypoint(name); }
private void showAllRouteWaypoint(String name) { skinLabel11.Text = "ID"; List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM RouteWayPoint WHERE PortId = '" + name + "'"); routeWayPointList.Clear(); foreach (Dictionary <string, object> dictionary in result) { int id = Convert.ToInt16(dictionary["ID"]); String portId = Convert.ToString(dictionary["PortId"]); String wayPoint = Convert.ToString(dictionary["WayPoint"]); int num = Convert.ToInt32(dictionary["Num"]); Route_WayPoint routeWayPoint = new Route_WayPoint(id, portId, wayPoint, num); routeWayPointList.Add(routeWayPoint); } this.dataGridView2.DataSource = null; if (null != routeWayPointList && routeWayPointList.Count() > 0) { this.dataGridView2.DataSource = this.routeWayPointList; } }