private void 添加负荷ToolStripMenuItem_Click(object sender, EventArgs e) { TreeListNode tln = treeList2.FocusedNode; if (tln == null) { return; } TreeListColumn tnc = treeList2.FocusedColumn; if (tnc.Caption.IndexOf("年") < 0) { return; } FormNewZengZhangLv fnf = new FormNewZengZhangLv(); if (fnf.ShowDialog() != DialogResult.OK) { return; } double fuhe = fnf.Fuhe; int a = 0; try { a = int.Parse(tnc.Caption.Replace("年", "")); } catch { } int b = forecastReport.EndYear; double fh = 0; for (int i = a; i <= b; i++) { fh = 0; try { fh = (double)tln[i + "年"]; } catch { } tln.SetValue(i + "年", fh + fuhe); } treeList1.BeginUpdate(); LoadData(); treeList1.EndUpdate(); RefreshChart(); }
private void 指定增长率ToolStripMenuItem_Click(object sender, EventArgs e) { TreeListNode tln = treeList1.FocusedNode; if (tln == null) return; TreeListColumn tnc = treeList1.FocusedColumn; if (tnc.Caption.IndexOf("年") < 0) return; FormNewZengZhangLv fnf = new FormNewZengZhangLv(); if (fnf.ShowDialog() != DialogResult.OK) return; double fuhe = fnf.Fuhe; int a = 0; try { a = int.Parse(tnc.Caption.Replace("年", "")); } catch { } int b = forecastReport.EndYear; double fh = 0; for (int i = a; i <= b; i++) { fh = 0; //try { fh = (double)tln[i + "年"]; } //catch { } tln.SetValue(i + "年", fh + fuhe); } treeList2.BeginUpdate(); try { for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow dr = dataTable2.Rows[i]; TreeListNode node = treeList2.FindNodeByKeyID(dr["ID"]); if (!node.HasChildren) { foreach (DataColumn col in dataTable.Columns) { if (col.ColumnName.IndexOf("年") > 0) { int nPreYear = Convert.ToInt32(col.ColumnName.Replace("年", "")) - 1; dr[col.ColumnName] = Math.Round((double)dr[nPreYear + "年"] * (1 + (double)dataTable.Rows[i][col]), 2); } } //父节点的最后一个子节点,调用计算公式 if (node.NextNode == null) { CalculateSum(node); } } } //RefreshChart(); } catch { //chart1.Series.Clear(); MsgBox.Show("计算出错:出现异常数据,请查检历史数据和增长率!"); } finally { treeList2.EndUpdate(); } }
private void 添加负荷ToolStripMenuItem_Click(object sender, EventArgs e) { TreeListNode tln = treeList2.FocusedNode; if (tln == null) return; TreeListColumn tnc = treeList2.FocusedColumn; if (tnc.Caption.IndexOf("年") < 0) return; FormNewZengZhangLv fnf = new FormNewZengZhangLv(); if (fnf.ShowDialog() != DialogResult.OK) return; double fuhe = fnf.Fuhe; int a = 0; try { a = int.Parse(tnc.Caption.Replace("年", "")); } catch { } int b = forecastReport.EndYear; double fh = 0; for (int i = a; i <= b; i++) { fh = 0; try { fh = (double)tln[i + "年"]; } catch { } tln.SetValue(i + "年", fh + fuhe); } treeList1.BeginUpdate(); LoadData(); treeList1.EndUpdate(); RefreshChart1(); }
private void 指定增长率ToolStripMenuItem_Click(object sender, EventArgs e) { TreeListNode tln = treeList1.FocusedNode; if (tln == null) { return; } TreeListColumn tnc = treeList1.FocusedColumn; if (tnc.Caption.IndexOf("年") < 0) { return; } FormNewZengZhangLv fnf = new FormNewZengZhangLv(); if (fnf.ShowDialog() != DialogResult.OK) { return; } double fuhe = fnf.Fuhe; int a = 0; try { a = int.Parse(tnc.Caption.Replace("年", "")); } catch { } int b = forecastReport.EndYear; double fh = 0; for (int i = a; i <= b; i++) { fh = 0; //try { fh = (double)tln[i + "年"]; } //catch { } tln.SetValue(i + "年", fh + fuhe); } treeList2.BeginUpdate(); try { for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow dr = dataTable2.Rows[i]; TreeListNode node = treeList2.FindNodeByKeyID(dr["ID"]); if (!node.HasChildren) { foreach (DataColumn col in dataTable.Columns) { if (col.ColumnName.IndexOf("年") > 0) { int nPreYear = Convert.ToInt32(col.ColumnName.Replace("年", "")) - 1; dr[col.ColumnName] = Math.Round((double)dr[nPreYear + "年"] * (1 + (double)dataTable.Rows[i][col]), 2); } } //父节点的最后一个子节点,调用计算公式 if (node.NextNode == null) { CalculateSum(node); } } } //RefreshChart(); } catch { //chart1.Series.Clear(); MsgBox.Show("计算出错:出现异常数据,请查检历史数据和增长率!"); } finally { treeList2.EndUpdate(); } }