public MapListForm(bool opentempmap) { InitializeComponent(); DialogResult = DialogResult.Cancel; OpenTempMap = opentempmap; DataTable table; if (opentempmap) { this.Text = "选择要恢复的地图"; table = MapDBClass.GetTempMapList(); } else { table = MapDBClass.GetMapList(); } dataGridView1.DataSource = table; btnDelete.Enabled = table.Rows.Count > 0; button1.Enabled = table.Rows.Count > 0; }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Trim() == "") { MessageBox.Show("请输入地图名称。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataTable table = MapDBClass.GetMapList(); for (int i = 0; i < table.Rows.Count; i++) { if (table.Rows[i]["MapName"].ToString() == textBox1.Text.Trim()) { MessageBox.Show("地图名称重复,请重新输入。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.SelectAll(); textBox1.Focus(); return; } } MapName = textBox1.Text; MapComment = textBox2.Text; Result = DialogResult.OK; Close(); }