private void button10_Click(object sender, EventArgs e) { //删除映射 if (comboBox1.SelectedIndex > -1) { if (MessageBox.Show("确定要删除该映射么?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { FieldMap <string, string> m = comboBox1.SelectedItem as FieldMap <string, string>; if (FieldMapLogic <string, string> .GetInstance().DeleteFieldMap(m)) { MessageBox.Show("删除映射成功!"); LoadAllMaps(); } else { MessageBox.Show("删除映射失败!"); } } } else { MessageBox.Show("请先选择要删除的映射!"); comboBox1.Focus(); } }
private void button9_Click(object sender, EventArgs e) { //添加映射 map = new FieldMap <string, string>(); map.Name = textBox2.Text.Trim(); FieldMapLogic <string, string> fml = FieldMapLogic <string, string> .GetInstance(); if (fml.ExistsName(map.Name)) { if (MessageBox.Show("系统中已经存在该映射,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { int i = fml.AddFieldMap(map); if (i > 0) { LoadAllMaps(); MessageBox.Show("添加成功!"); } } else { textBox2.Focus(); textBox2.SelectAll(); } } else { int i = fml.AddFieldMap(map); if (i > 0) { LoadAllMaps(); MessageBox.Show("添加成功!"); } } }
private void button8_Click(object sender, EventArgs e) { //修改映射 map.Name = textBox2.Text.Trim(); FieldMapLogic <string, string> fml = FieldMapLogic <string, string> .GetInstance(); if (fml.ExistsNameOther(map.Name, map.ID)) { if (MessageBox.Show("系统中已经存在该提醒,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { bool f = fml.UpdateFieldMap(map); if (f) { LoadAllMaps(); MessageBox.Show("修改成功!"); } } else { textBox2.Focus(); textBox2.SelectAll(); } } else { bool f = fml.UpdateFieldMap(map); if (f) { LoadAllMaps(); MessageBox.Show("修改成功!"); } } }
public static FieldMapLogic <T, K> GetInstance() { if (instance == null) { instance = new FieldMapLogic <T, K>(); } return(instance); }
private void LoadAllMaps() { List <FieldMap <string, string> > maps = FieldMapLogic <string, string> .GetInstance().GetAllFieldMaps(); comboBox1.Items.Clear(); foreach (FieldMap <string, string> map in maps) { comboBox1.Items.Add(map); } }