/// <summary> /// 保存处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOk_Click(object sender, EventArgs e) { if (_Object.Text != textBox1.Text.Trim() || _Object.Message != txtMessage.Text.Trim()) { _Object.Text = textBox1.Text.Trim(); _Object.Message = txtMessage.Text.Trim(); if (AfterSave != null) { AfterSave(_Object); } } if (comboBox1.Text == "") { MessageBox.Show("请设置日期。"); comboBox1.Focus(); return; } //保存属性列表 List <PropertyData> properties = new List <PropertyData>(); DataGridView view = dataGridView1; bool change = false; if (_datatable.Rows.Count > 0) { for (int i = 0; i < dataGridView1.RowCount; i++) { string colname = dataGridView1.Rows[i].Cells[0].Value.ToString(); if (_datatable.Rows[0][colname].ToString() != GetValue(view, i, 1)) { change = true; break; } } } else { change = true; } if (!change) { return; } if (change) { string type = "0"; //如果是保存交易信息 //循环设置保存属性列表 for (int i = 0; i < view.Rows.Count; i++) { if (view.Rows[i].Cells[0].Value != null) { PropertyData data = new PropertyData(); if (view.Rows[i].Cells[1].Value != null) { data.Data = view.Rows[i].Cells[1].Value.ToString(); } data.PropertyName = view.Rows[i].Cells[0].Value.ToString(); properties.Add(data); } } //保存属性 MapDBClass.SaveProperty(_MapId, _LayerId, _Object.ID, comboBox1.Text.Trim(), properties, _UpdateDate); } bool find = false; for (int i = 0; i < comboBox1.Items.Count; i++) { if (comboBox1.Items[i].ToString() == comboBox1.Text.Trim()) { find = true; break; } } if (!find) { comboBox1.Items.Add(comboBox1.Text.Trim()); } comboBox1_SelectedIndexChanged(null, null); }