private void mnuAddDomain_Click(object sender, EventArgs e) { TreeNode node = trvDatabase.SelectedNode; if (node.Text == "数据字典") { IYTDomain domain = new YTDomain(); frmEditDomain frm = new frmEditDomain(); frm.SetDatabase(node.Parent.Tag as ITemplateDatabase); frm.SetDomain(domain); DialogResult result = frm.ShowDialog(); if (result == DialogResult.OK) { node.Nodes.Clear(); LoadDomains(node.Parent.Tag as ITemplateDatabase, node); } } }
private bool SaveDomain() { IYTDomain domain = new YTDomain(); domain.Name = txtName.EditValue == null ? "" : txtName.EditValue.ToString(); domain.Description = txtDescription.EditValue == null ? "" : txtDescription.EditValue.ToString(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { string code = dataGridView1.Rows[i].Cells[0].Value == null ? "" : dataGridView1.Rows[i].Cells[0].Value.ToString(); string description = dataGridView1.Rows[i].Cells[1].Value == null ? "" : dataGridView1.Rows[i].Cells[1].Value.ToString(); if (string.IsNullOrEmpty(code)) { continue; } YTDomainValue pair = new YTDomainValue() { Value = code, Description = description }; domain.ValuePairs.Add(pair); } int back = _database.GetObjectID(domain.Name, enumTemplateObjectType.Domain); if (back > 0 && back != _domain.ID) { MessageBox.Show("该数据字典已经存在,请改名后保存!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } domain.ID = _domain.ID; return(_database.SaveDomain(domain)); _domain = domain; }