private void button1_Click(object sender, EventArgs e) { bl.SetValue( textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text ); if (bl.BlNo == "" || bl.Start == "" || bl.End == "" || bl.Distance == "") { MessageBox.Show("请填写空余项"); return; } if (Intent.State == "ADD" || bl.BlNo != Intent.OLD_ID) { sql = @"" + " SELECT * FROM [Buslines]" + " WHERE [BlNo]='" + bl.BlNo + "'"; table = db.GetBySQL(sql); if (table.Rows.Count > 0) { MessageBox.Show("路线编号重复,请重新填写"); return; } } this.DialogResult = DialogResult.OK; this.Close(); }
private void ChangeBtn3_Click(object sender, EventArgs e) { if (listView3.SelectedItems.Count == 0) { MessageBox.Show("请选择一行"); return; } Intent.State = "CHANGE"; BuslineEdit ble = new BuslineEdit(); Busline bl = new Busline(); bl.SetValue( listView3.SelectedItems[0].SubItems[0].Text, listView3.SelectedItems[0].SubItems[1].Text, listView3.SelectedItems[0].SubItems[2].Text, listView3.SelectedItems[0].SubItems[3].Text ); ble.bl = bl; Intent.OLD_ID = bl.BlNo; if (ble.ShowDialog() == DialogResult.OK) { sql = @"" + " UPDATE [Buslines]" + " SET" + " [BlNo]=" + ble.bl.BlNo + "," + " [Start]='" + ble.bl.Start + "'," + " [End]='" + ble.bl.End + "'," + " [Distance]=" + ble.bl.Distance + "" + " WHERE [BlNo]=" + Intent.OLD_ID + ""; db.SetBySQL(sql); UpdateListView(); } }