private void NewReport() { TreeNode Node = treeView1.SelectedNode; Selection Selection = Node.Tag as Selection; Boolean IsReport = Convert.ToBoolean(Selection.Value); if (!IsReport) { string Code = DepositoryReportCatlog.GetNextCode(Node.Name); string ReportName = DepositoryReportCatlog.GetReportName(Node.Name, "新建表单"); ReportConfiguration Report = new ReportConfiguration(); Report.Code = Code; Report.Description = ReportName; Boolean Result = DepositoryReportConfiguration.New(Report); if (Result) { TreeNode SubNode = new TreeNode(); SubNode.Name = Code; Selection = new Selection(); Selection.ID = Report.Index; Selection.Value = "true"; SubNode.Tag = Selection; SubNode.Text = ReportName; SubNode.SelectedImageIndex = 2; SubNode.ImageIndex = 2; Node.Nodes.Add(SubNode); Node.Expand(); Node.TreeView.SelectedNode = SubNode; } } }
private void BindTree() { treeView1.Nodes.Clear(); TreeNode top = new TreeNode("报表配置"); treeView1.Nodes.Add(top); DataTable dt = DepositoryReportConfiguration.GetReportConfigData(); DataTable dtModule = DepositoryReportConfiguration.GetReportConfigList(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode configNode = new TreeNode(dt.Rows[i]["TestName"].ToString()); configNode.Name = dt.Rows[i]["ID"].ToString(); top.Nodes.Add(configNode); DataRow[] dtCM = dtModule.Select("ID=" + configNode.Name); if (dtCM != null && dtCM.Length > 0) { for (int j = 0; j < dtCM.Length; j++) { TreeNode subNode = new TreeNode(dtCM[j]["ModuleName"].ToString()); subNode.Name = dtCM[j]["ModuleID"].ToString(); configNode.Nodes.Add(subNode); } } } treeView1.ExpandAll(); } }
private void CustomDataTableDialog_Load(object sender, EventArgs e) { DataTable dt = DepositoryReportConfiguration.GetReportConfig(); if (dt != null) { FpSpread_Panel.Columns.Count = 4; FpSpread_Panel.ColumnHeader.Cells[0, 0].Text = "ID"; FpSpread_Panel.ColumnHeader.Cells[0, 1].Text = "项目"; FpSpread_Panel.ColumnHeader.Cells[0, 2].Text = "单位"; FpSpread_Panel.ColumnHeader.Cells[0, 3].Text = "频率"; FpSpread_Panel.Columns[0].Width = 80; FpSpread_Panel.Columns[1].Width = 200; FpSpread_Panel.Columns[2].Width = 100; FpSpread_Panel.Columns[3].Width = 100; FpSpread_Panel.Rows.Count = dt.Rows.Count; for (int i = 0; i < dt.Rows.Count; i++) { FpSpread_Panel.Cells[i, 0].Value = dt.Rows[i]["ID"].ToString(); FpSpread_Panel.Cells[i, 1].Value = dt.Rows[i]["TestName"].ToString(); FpSpread_Panel.Cells[i, 2].Value = dt.Rows[i]["UnitName"].ToString(); FpSpread_Panel.Cells[i, 3].Value = dt.Rows[i]["Frequency"].ToString(); FpSpread_Panel.Rows[i].Tag = dt.Rows[i]["ModuleID"].ToString(); CellNote.SetNoteInformation(FpSpread_Panel.Cells[i, 0], dt.Rows[i]["ModuleName"].ToString()); } } }
private void btn_remove_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null) { if (treeView1.SelectedNode.Name.Length > 10) { DepositoryReportConfiguration.RemoveReportConfigModule(treeView1.SelectedNode.Name, treeView1.SelectedNode.Parent.Name); BindModuleData(); BindTree(); } } }
private void DeleteReport() { TreeNode Node = treeView1.SelectedNode; Selection Selection = Node.Tag as Selection; Boolean IsReport = Convert.ToBoolean(Selection.Value); string Msg = "你确定要删除报表 ‘" + Node.Text + "’ 吗?"; if (IsReport && DialogResult.Yes == MessageBox.Show(Msg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk)) { DepositoryReportConfiguration.Delete(Selection.ID); ReportWindow.RemoveReport(); Node.Remove(); } }
private void btn_add_Click(object sender, EventArgs e) { int selected; List <TreeNode> nodes = GetSelectedModules(); if (nodes.Count > 0 && treeView1.SelectedNode != null) { if (int.TryParse(treeView1.SelectedNode.Name, out selected)) { foreach (TreeNode item in nodes) { DepositoryReportConfiguration.AddReportConfigModule(item.Name, treeView1.SelectedNode.Name); } BindModuleData(); BindTree(); } } }
private void BindModuleData() { DataTable dt = DepositoryReportConfiguration.GetUnBindModules(); treeView2.Nodes.Clear(); TreeNode top = new TreeNode("模板列表"); treeView2.Nodes.Add(top); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode n = new TreeNode(dt.Rows[i]["Name"].ToString()); n.Name = dt.Rows[i]["ID"].ToString(); top.Nodes.Add(n); } } }
private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (e.Label != null) { if (e.Label.Length > 0) { if (e.Label.IndexOfAny(new char[] { '@', '.', ',', '!' }) == -1) { e.Node.EndEdit(false); Selection Selection = (e.Node.Tag as Selection); Boolean IsReport = Convert.ToBoolean(Selection.Value); if (!IsReport) { DepositoryReportCatlog.Update(e.Node.Name, e.Label); } else { Boolean result = DepositoryReportConfiguration.UpdateReportName(Selection.ID, e.Label); } } else { e.CancelEdit = true; MessageBox.Show("无效的树节点文本.\n" + "无效的字符是: '@','.', ',', '!'", "编辑节点"); e.Node.BeginEdit(); } } else { e.CancelEdit = true; MessageBox.Show("无效的树节点文本.\n文本不能为空", "编辑节点"); e.Node.BeginEdit(); } e.Node.TreeView.LabelEdit = false; } }