private void ButtonOk_Click(object sender, EventArgs e) { TreeNode Node = DictionaryView.SelectedNode; Selection Selection = Node.Tag as Selection; if (Selection.TypeFlag != "@Dictionary") { this.DialogResult = DialogResult.None; return; } CellType.ReferenceStyle = BizCommon.ReferenceStyle.Dictionary; DictionaryReference Reference = CellType.ReferenceInfo as DictionaryReference; String Cell = Arabic_Numerals_Convert.Excel_Word_Numerals(ColumnIndex) + (RowIndex + 1).ToString(); //bool HaveItem = SheetConfiguration.DataTableSchema.HaveDataItem(Cell); //if (HaveItem) //{ // FieldDefineInfo FieldInfo = SheetConfiguration.DataTableSchema.GetDataItem(Cell); // if (FieldInfo != null) // { // Reference.TableName = FieldInfo.TableInfo.Name; // Reference.ColumnName = FieldInfo.FieldName; // } //} Reference.DictionaryIndex = Node.Name; Reference.ReferenceXml = Node.Name; this.DialogResult = DialogResult.OK; this.Close(); }
private void ReferenceForm_Load(object sender, EventArgs e) { ImageList imageList = new ImageList(); imageList.Images.Add(IcoResource.Forlder); imageList.Images.Add(IcoResource.Col); DictionaryView.ImageList = imageList; DictionaryView.Nodes.Clear(); TreeNode TopNode = new TreeNode(); TopNode.Text = "字典列表"; TopNode.SelectedImageIndex = 0; TopNode.ImageIndex = 0; TopNode.Name = ""; DictionaryView.Nodes.Add(TopNode); //加载所有字典 DataTable dt = DictionaryManager.GetAllDictionary(); if (dt != null) { foreach (DataRow row in dt.Rows) { String ID = row["ID"].ToString(); String CodeClass = row["CodeClass"].ToString(); String Description = row["DESCRIPTION"].ToString(); String Code = row["Code"].ToString(); if (row["Code"] == DBNull.Value) { TreeNode Node = new TreeNode(); Node.Name = CodeClass; Node.Text = Description; Node.SelectedImageIndex = 0; Node.ImageIndex = 0; Selection selection = new Selection(); selection.TypeFlag = "@Dictionary"; selection.ID = ID; selection.Code = null; selection.Value = Code; Node.Tag = selection; DictionaryView.TopNode.Nodes.Add(Node); } else { foreach (TreeNode ChildNode in DictionaryView.TopNode.Nodes) { if (row["CodeClass"].ToString() == ChildNode.Name) { TreeNode childNode = new TreeNode(); childNode.Name = Code; childNode.Text = Description; childNode.SelectedImageIndex = 1; childNode.ImageIndex = 1; Selection selection = new Selection(); selection.TypeFlag = "@DictionaryItem"; selection.ID = ID; selection.Code = CodeClass; selection.Value = Code; childNode.Tag = selection; ChildNode.Nodes.Add(childNode); } } } } DictionaryView.TopNode.Expand(); //显示配置的字典 DictionaryReference Reference = CellType.ReferenceInfo as DictionaryReference; if (Reference != null) { TreeNode[] Nodes = DictionaryView.Nodes.Find(Reference.DictionaryIndex, true); if (Nodes.Length > 0) { DictionaryView.SelectedNode = Nodes[0]; } } } }