private void RefreshChart(int syear, int eyear) { IList <FORBaseColor> list = Services.BaseService.GetList <FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-" + type + "'"); IList <FORBaseColor> li = new List <FORBaseColor>(); bool bl = false; foreach (DataRow row in dataTable.Rows) { bl = false; foreach (FORBaseColor bc in list) { if (row["Title"].ToString() == bc.Title) { bl = true; FORBaseColor bc1 = new FORBaseColor(); bc1.Color1 = Color.Blue; CopyBaseColor(bc1, bc); li.Add(bc1); } } if (!bl) { FORBaseColor bc1 = new FORBaseColor(); bc1.UID = Guid.NewGuid().ToString(); bc1.Remark = this.forecastReport.ID.ToString() + "-" + type; bc1.Title = row["Title"].ToString(); bc1.Color = 16711680; bc1.Color1 = Color.Blue; Services.BaseService.Create <FORBaseColor>(bc1); li.Add(bc1); } } ArrayList hs = new ArrayList(); foreach (FORBaseColor bc2 in li) { hs.Add(bc2.Color1); } List <Ps_Forecast_Math> listValues = new List <Ps_Forecast_Math>(); for (int i = 0; i < this.treeList1.Nodes.Count; i++) { TreeListNode row = treeList1.Nodes[i]; foreach (TreeListColumn col in treeList1.Columns) { if (col.FieldName.IndexOf("y") > -1) { int yyear = int.Parse(col.FieldName.Replace("y", "")); if (yyear >= syear && yyear <= eyear) { object obj = row[col.FieldName]; if (obj != DBNull.Value) { Ps_Forecast_Math v = new Ps_Forecast_Math(); v.ForecastID = forecastReport.ID; v.ID = (string)row["ID"]; v.Title = row["Title"].ToString(); v.Sort = Convert.ToInt32(col.FieldName.Replace("y", "")); v.y1990 = (double)row[col.FieldName]; listValues.Add(v); } } } } } this.chart_user1.RefreshChart(listValues, "Title", "Sort", "y1990", hs); }
private void RefreshChart() { ArrayList ht = new ArrayList(); ht.Add(Color.Red); ht.Add(Color.Blue); ht.Add(Color.Green); ht.Add(Color.Yellow); ht.Add(Color.HotPink); ht.Add(Color.LawnGreen); ht.Add(Color.Khaki); ht.Add(Color.LightSlateGray); ht.Add(Color.LightSeaGreen); ht.Add(Color.Lime); ht.Add(Color.Black); ht.Add(Color.Brown); ht.Add(Color.Crimson); int m = 0; IList <FORBaseColor> list = Services.BaseService.GetList <FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + MIS.ProgUID + "-" + type + "'"); IList <FORBaseColor> li = new List <FORBaseColor>(); bool bl = false; ArrayList aldatablr = new ArrayList(); foreach (DataRow row in dataTable.Rows) { aldatablr.Add(row["ID"].ToString()); } foreach (DataRow row in dataTable.Rows) { if (aldatablr.Contains(row["ParentID"].ToString())) { continue; } bl = false; foreach (FORBaseColor bc in list) { if (row["Col3"].ToString() + "-" + row["Title"].ToString() == bc.Title) { bl = true; FORBaseColor bc1 = new FORBaseColor(); bc1.Color1 = Color.Blue; CopyBaseColor(bc1, bc); li.Add(bc1); } } if (!bl) { FORBaseColor bc1 = new FORBaseColor(); bc1.UID = Guid.NewGuid().ToString(); bc1.Remark = MIS.ProgUID + "-" + type; bc1.Title = row["Col3"].ToString() + "-" + row["Title"].ToString(); bc1.Color = 16711680; if (m == 0) { Random rd = new Random(); m = rd.Next(100); } Color cl = (Color)ht[m % 13]; bc1.Color = ColorTranslator.ToOle(cl); bc1.Color1 = cl; //bc1.Color1 = Color.Blue; Services.BaseService.Create <FORBaseColor>(bc1); li.Add(bc1); } m++; } ArrayList hs = new ArrayList(); foreach (FORBaseColor bc2 in li) { hs.Add(bc2.Color1); } List <Ps_Forecast_Math> listValues = new List <Ps_Forecast_Math>(); for (int i = 0; i < treeList1.Nodes.Count; i++) { TreeListNode row = treeList1.Nodes[i]; if (row.ParentNode == null) { foreach (TreeListColumn col in treeList1.Columns) { if (col.FieldName.IndexOf("y") > -1 && col.FieldName != "y1990") { object obj = row[col.FieldName]; if (obj != DBNull.Value) { Ps_Forecast_Math v = new Ps_Forecast_Math(); v.ForecastID = MIS.ProgUID; v.ID = (string)row["ID"]; v.Title = row["Col3"].ToString() + "-" + row["Title"].ToString(); v.Sort = Convert.ToInt32(col.FieldName.Replace("y", "")); v.y1991 = (double)row[col.FieldName]; listValues.Add(v); } } } } } this.chart_user1.RefreshChart(listValues, "Title", "Sort", "y1991", hs); }
/// <summary> /// 写入数据 /// </summary> /// <param name="obj"></param> /// <param name="IntRow"></param> private void WriteData(Itop.Client.Base.FormBase FB, FarPoint.Win.Spread.SheetView obj, int IntRow) { Ps_Forecast_Math pfm1 = null; //高 Ps_Forecast_Math pfm2 = null; //中 Ps_Forecast_Math pfm3 = null; //低 Ps_Forecast_Math value = null; list_QSHKJ = SelectDQData(FB, programID, "全社会口径 "); list_WGKJ = SelectDQData(FB, programID, "网供口径"); list_East = SelectDQData(FB, programID, "东部地区"); list_Midst = SelectDQData(FB, programID, "中部地区"); list_Southern = SelectDQData(FB, programID, "南部地区"); #region 全社会口径:电量 try { for (int i = IntRow; i < list_QSHKJ.Count + IntRow; ++i) { pfm1 = (Ps_Forecast_Math)list_QSHKJ[i - IntRow + 1]; if (pfm1 != null) { value = ReturnValue("电量 ", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //全社会口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion int Temp = (list_QSHKJ.Count + IntRow); #region 全社会口径:负荷 try { for (int i = Temp; i < list_QSHKJ.Count + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_QSHKJ[i - Temp + 1]; if (pfm1 != null) { value = ReturnValue("负荷 ", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //全社会口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion Temp += (list_QSHKJ.Count + 1); #region 东部地区:全社会用电量 try { for (int i = Temp; i <= 1 + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_East[1]; if (pfm1 != null) { value = ReturnValue("全社会用电量", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //全社会口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion Temp += 1; #region 东部地区:全社会最大负荷 try { for (int i = Temp; i <= 1 + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_East[1]; if (pfm1 != null) { value = ReturnValue("全社会最大负荷", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //全社会口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion Temp += 2; #region 南部地区:全社会用电量 try { for (int i = Temp; i <= 1 + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_Southern[1]; if (pfm1 != null) { value = ReturnValue("全社会用电量", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //全社会口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion Temp += 1; #region 南部地区:全社会最大负荷 try { for (int i = Temp; i <= 1 + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_Southern[1]; if (pfm1 != null) { value = ReturnValue("全社会最大负荷", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //全社会口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion Temp += 2; #region 网供口径:电量 try { for (int i = Temp; i < list_WGKJ.Count + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_WGKJ[i - Temp + 1]; if (pfm1 != null) { value = ReturnValue("电量 ", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //网供口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion Temp = (list_WGKJ.Count + Temp); #region 网供口径:负荷 try { for (int i = Temp; i < list_WGKJ.Count + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_WGKJ[i - Temp + 1]; if (pfm1 != null) { value = ReturnValue("负荷 ", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //网供口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion Temp += (list_WGKJ.Count + 1); #region 中部地区:全社会用电量 try { for (int i = Temp; i <= 1 + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_Midst[1]; if (pfm1 != null) { value = ReturnValue("全社会用电量", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { //全社会口径的数据 //电量,高中低预测 switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion Temp += 1; #region 中部地区:全社会最大负荷 try { for (int i = Temp; i <= 1 + Temp; ++i) { pfm1 = (Ps_Forecast_Math)list_Midst[1]; if (pfm1 != null) { value = ReturnValue("全社会最大负荷", pfm1.ID, pfm1.Forecast); if (value != null) { for (int j = 2; j < obj.ColumnCount; ++j) { switch (j) { case 2: obj.SetValue(i, j, value.y2010); break; case 3: obj.SetValue(i, j, value.y2011); break; case 4: obj.SetValue(i, j, value.y2012); break; case 5: obj.SetValue(i, j, value.y2013); break; case 6: obj.SetValue(i, j, value.y2014); break; case 7: obj.SetValue(i, j, value.y2015); break; case 8: obj.Cells[i, j].Formula = "POWER(" + PF.GetColumnTitle(j - 1) + (i + 1) + "/" + PF.GetColumnTitle(j - 6) + (i + 1) + ",1/5)-1"; obj.Cells[i, j].CellType = PC; break; case 9: obj.SetValue(i, j, value.y2020); break; default: break; } } } else { for (int j = 2; j < obj.ColumnCount; ++j) { obj.SetValue(i, j, null); } } } } } catch (System.Exception e) { } #endregion }
/// <summary> /// 读取原始数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FormForecastLoadData ffs = new FormForecastLoadData(); ffs.PID = MIS.ProgUID; ffs.StartYear = forecastReport.StartYear; ffs.EndYear = forecastReport.EndYear; if (ffs.ShowDialog() != DialogResult.OK) { return; } Hashtable hs = ffs.HS; if (hs.Count == 0) { return; } string id = Guid.NewGuid().ToString(); if (ffs.Selectid != "4") { foreach (Ps_History de3 in hs.Values) { Ps_Forecast_Math py = new Ps_Forecast_Math(); py.Col1 = de3.ID; py.Forecast = type; py.ForecastID = forecastReport.ID; py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByCol1", py); if (py == null) { Ps_Forecast_Math ForecastMath = new Ps_Forecast_Math(); ForecastMath.Title = de3.Title; for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { ForecastMath.GetType().GetProperty("y" + i).SetValue(ForecastMath, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null); } id = id.Substring(0, 8); ForecastMath.Col1 = de3.ID; ForecastMath.ID = id + "|" + de3.ID; ForecastMath.ParentID = id + "|" + de3.ParentID; ForecastMath.Forecast = type; ForecastMath.ForecastID = forecastReport.ID; ForecastMath.Sort = de3.Sort; Services.BaseService.Create("InsertPs_Forecast_MathbyPs_History", ForecastMath); } else { for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { py.GetType().GetProperty("y" + i).SetValue(py, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null); } Services.BaseService.Update <Ps_Forecast_Math>(py); } } } else if (ffs.Selectid == "4") { foreach (PSP_Types de3 in hs.Values) { Ps_Forecast_Math py = new Ps_Forecast_Math(); //py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByWhere", "Title='" + de3.Title + "'" + " and Forecast='0' and ForecastID='" + forecastReport.ID + "' and Col1='"+de3.ID+"'"); py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByWhere", " Forecast = '" + type + "' and ForecastID='" + forecastReport.ID + "' and Col1='" + de3.ID + "'"); if (py == null) { Ps_Forecast_Math ForecastMath = new Ps_Forecast_Math(); IList <PSP_Values> listValues = Common.Services.BaseService.GetList <PSP_Values>("SelectPSP_ValuesByWhere", "TypeID='" + de3.ID + "'"); foreach (PSP_Values value in listValues) { ForecastMath.GetType().GetProperty("y" + value.Year).SetValue(ForecastMath, value.Value, null); } id = id.Substring(0, 8); ForecastMath.Title = de3.Title; ForecastMath.Col1 = de3.ID.ToString(); ForecastMath.ID = id + "|" + de3.ID; ForecastMath.ParentID = id + "|" + de3.ParentID; ForecastMath.Forecast = type; ForecastMath.ForecastID = forecastReport.ID; object obj = Services.BaseService.GetObject("SelectPs_Forecast_MathMaxID", null); if (obj != null) { ForecastMath.Sort = ((int)obj) + 1; } else { ForecastMath.Sort = 1; } Services.BaseService.Create("InsertPs_Forecast_MathbyPs_History", ForecastMath); } else { IList <PSP_Values> listValues = Common.Services.BaseService.GetList <PSP_Values>("SelectPSP_ValuesByWhere", " TypeID='" + de3.ID + "'"); foreach (PSP_Values value in listValues) { py.GetType().GetProperty("y" + value.Year).SetValue(py, value.Value, null); } Services.BaseService.Update <Ps_Forecast_Math>(py); } } } LoadData(); this.chart_user1.All_Select(true); RefreshChart(); }
private void FormForecast10_Load(object sender, EventArgs e) { HideToolBarButton(); ////chart1.Series.Clear(); ////Show(); Application.DoEvents(); //this.Cursor = Cursors.WaitCursor; //gridView1.BeginUpdate(); Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ForecastID = forecastReport.ID; psp_Type.Forecast = type; Common.Services.BaseService.Update("DeletePs_Forecast_MathForecastIDAndForecast", psp_Type); psp_Type.Forecast = 0; IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type); foreach (Ps_Forecast_Math psp_Typetemp in listTypes) { psp_Type = new Ps_Forecast_Math(); psp_Type = psp_Typetemp; psp_Type.ID = psp_Type.ID + "|10"; psp_Type.Forecast = type; psp_Type.ParentID = psp_Type.ParentID + "|10"; Common.Services.BaseService.Create <Ps_Forecast_Math>(psp_Type); } LoadData(); //gridView1.EndUpdate(); RefreshChart(); this.Cursor = Cursors.Default; Ps_Forecast_Setup pfs = new Ps_Forecast_Setup(); pfs.Forecast = type; pfs.ForecastID = forecastReport.ID; pfs.StartYear = int.Parse(firstyear.Replace("y", "")); pfs.EndYear = int.Parse(endyear.Replace("y", "")); IList <Ps_Forecast_Setup> li = Services.BaseService.GetList <Ps_Forecast_Setup>("SelectPs_Forecast_SetupByForecast", pfs); if (li.Count != 0) { firstyear = li[0].StartYear.ToString(); endyear = li[0].EndYear.ToString(); } ha.Clear(); Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; IList <Ps_Calc> list1 = Services.BaseService.GetList <Ps_Calc>("SelectPs_CalcByForecast", pcs); foreach (Ps_Calc pcs2 in list1) { if ("年增长率法" == pcs2.CalcID) { if (pcs2.Value1 > 0) { if (!ha.ContainsKey("年增长率法")) { ha.Add("年增长率法", pcs2.Value2); } } } else if ("弹性系数法" == pcs2.CalcID) { if (pcs2.Value1 > 0) { if (!ha.ContainsKey("弹性系数法")) { ha.Add("弹性系数法", pcs2.Value2); } } } else if ("指数平滑法" == pcs2.CalcID) { if (pcs2.Value1 > 0) { if (!ha.ContainsKey("指数平滑法")) { ha.Add("指数平滑法", pcs2.Value2); } } } else if ("灰色模型法" == pcs2.CalcID) { if (pcs2.Value1 > 0) { if (!ha.ContainsKey("灰色模型法")) { ha.Add("灰色模型法", pcs2.Value2); } } } else if ("专家指定法" == pcs2.CalcID) { if (pcs2.Value1 > 0) { if (!ha.ContainsKey("专家指定法")) { ha.Add("专家指定法", pcs2.Value2); } } } else if ("外推法" == pcs2.CalcID) { if (pcs2.Value1 > 0) { if (!ha.ContainsKey("外推法")) { ha.Add("外推法", pcs2.Value2); } } } else if ("相关法" == pcs2.CalcID) { if (pcs2.Value1 > 0) { if (!ha.ContainsKey("相关法")) { ha.Add("相关法", pcs2.Value2); } } } else if ("人工神经网络法" == pcs2.CalcID) { if (pcs2.Value1 > 0) { if (!ha.ContainsKey("人工神经网络法")) { ha.Add("人工神经网络法", pcs2.Value2); } } } } if (ha.Count < 1) { simpleButton2.Enabled = false; } else { JS(); } }
private void LoadData() { Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ForecastID = forecastReport.ID; psp_Type.Forecast = type; IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type); DataTable dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math)); DataRow[] rows1 = dataTable.Select("Title like '全地区GDP%'"); if (rows1.Length == 0) { MessageBox.Show("缺少‘全地区GDP’数据!"); this.Close(); return; } Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; list1 = Services.BaseService.GetList <Ps_Calc>("SelectPs_CalcByForecast", pcs); dt.Columns.Add("ID"); dt.Columns.Add("Name"); newrow1 = dt.NewRow(); newrow1["ID"] = "ID"; newrow1["Name"] = "GDP增长率(%)"; for (int i = forecastReport.YcStartYear; i <= forecastReport.YcEndYear; i++) { dt.Columns.Add(i.ToString(), typeof(double)); DevExpress.XtraVerticalGrid.Rows.EditorRow editorRow = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); editorRow.Properties.FieldName = i.ToString().Trim(); editorRow.Properties.Caption = i.ToString().Trim(); editorRow.Height = 20; editorRow.Properties.RowEdit = this.repositoryItemCalcEdit1; this.vGridControl1.Rows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { editorRow }); double s1 = 0; double s2 = 0; double s5 = 0; try { s1 = Convert.ToDouble(rows1[0]["y" + i]); } catch { } try { s2 = Convert.ToDouble(rows1[0]["y" + (i - 1)]); } catch { } if (s2 != 0) { s5 = (s1 - s2) / s2; } newrow1[i.ToString()] = Math.Round(s5 * 100, 3); foreach (Ps_Calc pcs2 in list1) { if (i == pcs2.Year) { newrow1[i.ToString()] = Math.Round(pcs2.Value2 * 100, 3); } } } dt.Rows.Add(newrow1); vGridControl1.DataSource = dt; }
private void LoadData() { treeList1.DataSource = null; bLoadingData = true; if (dataTable2 != null) { dataTable1.Columns.Clear(); dataTable2.Columns.Clear(); treeList2.Columns.Clear(); treeList1.Columns.Clear(); } if (dataTable2 != null) { treeList3.Columns.Clear(); } if (dataTable1 != null) { dataTable1.Columns.Clear(); } AddFixColumn(); AddFixColumn2(); AddFixColumn3(); for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { AddColumn(i); } for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { AddColumn2(i); } for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { AddColumn3(i); } Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ForecastID = forecastReport.ID; psp_Type.Forecast = 0; IList <Ps_Forecast_Math> listTypes = Common.Services.BaseService.GetList <Ps_Forecast_Math>("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type); dataTable2 = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_Forecast_Math)); treeList2.DataSource = dataTable2; Hashtable ht = new Hashtable(); IList <Ps_BadData> list = new List <Ps_BadData>(); foreach (Ps_Forecast_Math pfm in listTypes) { Ps_BadData pb1 = new Ps_BadData(); pb1.ForecastID = pfm.ForecastID; pb1.Forecast = type; pb1.Col1 = pfm.ID; Ps_BadData pb = new Ps_BadData(); IList <Ps_BadData> li = Common.Services.BaseService.GetList <Ps_BadData>("SelectPs_BadDataByCol1", pb1); if (li.Count == 0) { pb = new Ps_BadData(); pb.ID = pfm.ID + "|m|" + type; pb.Title = pfm.Title; pb.ForecastID = pfm.ForecastID; pb.Forecast = type; pb.Col1 = pfm.ID; pb.ParentID = pfm.ParentID + "|m|" + type; Services.BaseService.Create <Ps_BadData>(pb); } else { pb = li[0]; } list.Add(pb); } dataTable1 = Itop.Common.DataConverter.ToDataTable((IList)list, typeof(Ps_BadData)); treeList2.Columns["Title"].OptionsColumn.AllowEdit = false; treeList1.DataSource = dataTable1; Application.DoEvents(); bLoadingData = false; }
private void FormForecastCalc4_Load(object sender, EventArgs e) { #region 电力发展实绩 Ps_YearRange py = new Ps_YearRange(); py.Col4 = "电力发展实绩经济"; py.Col5 = Itop.Client.MIS.ProgUID; IList <Ps_YearRange> li2 = Services.BaseService.GetList <Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py); if (li2.Count > 0) { firstyear1 = li2[0].StartYear; endyear1 = li2[0].FinishYear; } //新经济数据 //Ps_History psp_Type = new Ps_History(); //psp_Type.Forecast = 5; //psp_Type.Col4 = Itop.Client.MIS.ProgUID; //IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); //DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); //DataRow[] rows1 = dataTable.Select("Title like '全地区GDP%'"); Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ForecastID = forecastReport.ID; psp_Type.Forecast = type; IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type); dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math)); DataRow[] rows1 = dataTable.Select("Title like '全地区GDP%'"); DataRow[] rows4 = dataTable.Select("Title like '全社会用电量%'"); //新电量数据 //Ps_History psp_Type2 = new Ps_History(); //psp_Type2.Forecast = 6; //psp_Type2.Col4 = Itop.Client.MIS.ProgUID; //IList<Ps_History> listTypes2 = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type2); //DataTable dataTable2 = Itop.Common.DataConverter.ToDataTable((IList)listTypes2, typeof(Ps_History)); //DataRow[] rows4 = dataTable2.Select("Title like '全社会用电量%'"); if (rows1.Length == 0) { MessageBox.Show("缺少‘全地区GDP’数据!"); this.Close(); return; } if (rows4.Length == 0) { MessageBox.Show("电量数据中缺少‘全社会用电量’数据!"); this.Close(); return; } #endregion Ps_Forecast_Setup pfs = new Ps_Forecast_Setup(); pfs.Forecast = type; pfs.ForecastID = forecastReport.ID; IList <Ps_Forecast_Setup> li = Services.BaseService.GetList <Ps_Forecast_Setup>("SelectPs_Forecast_SetupByForecast", pfs); if (li.Count != 0) { firstyear = li[0].StartYear; endyear = li[0].EndYear; } Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; list1 = Services.BaseService.GetList <Ps_Calc>("SelectPs_CalcByForecast", pcs); HideToolBarButton(); dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Name"); newrow1 = dt.NewRow(); newrow1["ID"] = "ID"; newrow1["Name"] = "弹性系数"; //newrow2 = dt.NewRow(); //newrow2["Name"] = "GDP增长率"; for (int i = firstyear; i <= forecastReport.YcEndYear; i++) { dt.Columns.Add(i.ToString(), typeof(double)); DevExpress.XtraVerticalGrid.Rows.EditorRow editorRow = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); editorRow.Properties.FieldName = i.ToString().Trim(); editorRow.Properties.Caption = i.ToString().Trim(); editorRow.Height = 20; editorRow.Properties.RowEdit = this.repositoryItemCalcEdit4; this.vGridControl2.Rows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { editorRow }); double s1 = 0; double s2 = 0; double s3 = 0; double s4 = 0; double s5 = 0; double s6 = 0; double s7 = 0; try { s1 = Convert.ToDouble(rows1[0]["y" + i]); } catch { } try { s2 = Convert.ToDouble(rows1[0]["y" + (i - 1)]); } catch { } try { s3 = Convert.ToDouble(rows4[0]["y" + i]); } catch { } try { s4 = Convert.ToDouble(rows4[0]["y" + (i - 1)]); } catch { } if (s2 != 0) { s5 = (s1 - s2) / s2; } if (s4 != 0) { s6 = (s3 - s4) / s4; } if (s5 != 0) { s7 = s6 / s5; } newrow1[i.ToString()] = Math.Round(s7, 3); //newrow2[i.ToString()] =Math.Round( s5,3); if (i >= forecastReport.YcStartYear) { foreach (Ps_Calc pcs2 in list1) { if (i == pcs2.Year) { newrow1[i.ToString()] = Math.Round(pcs2.Value1, 3); } } } } dt.Rows.Add(newrow1); //dt.Rows.Add(newrow2); // gridControl1.DataSource = dt; vGridControl2.DataSource = dt; }
private void Form8XuanZhe_Load(object sender, EventArgs e) { dt1.Columns.Add("A", typeof(string)); dt1.Columns.Add("B", typeof(bool)); dt1.Columns.Add("C", typeof(string)); Ps_Forecast_Math psp_Typen = new Ps_Forecast_Math(); psp_Typen.ForecastID = ForecastID; psp_Typen.Forecast = 1; IList listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); DataRow row = dt1.NewRow(); row["A"] = "年增长率法"; row["B"] = true; if (listTypesn.Count > 0) { row["C"] = "有"; } else { row["C"] = "无"; } dt1.Rows.Add(row); row = dt1.NewRow(); row["A"] = "常规增长率-大用户预测法"; row["B"] = false; //psp_Typen.Forecast = 2; //listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); if (SelectDaYongHu(1)) { row["C"] = "有"; } else { row["C"] = "无"; } if (SelectDaYongHu(0)) { dt1.Rows.Add(row); } row = dt1.NewRow(); row["A"] = "外推法"; row["B"] = false; psp_Typen.Forecast = 2; listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); if (listTypesn.Count > 0) { row["C"] = "有"; } else { row["C"] = "无"; } dt1.Rows.Add(row); //row = dt1.NewRow(); //row["A"] = "相关法"; //row["B"] = false; //psp_Typen.Forecast = 3; //listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); //if (listTypesn.Count > 0) //{ // row["C"] = "有"; //} //else //{ // row["C"] = "无"; //} //dt1.Rows.Add(row); row = dt1.NewRow(); row["A"] = "弹性系数法"; row["B"] = false; psp_Typen.Forecast = 4; listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); if (listTypesn.Count > 0) { row["C"] = "有"; } else { row["C"] = "无"; } dt1.Rows.Add(row); row = dt1.NewRow(); row["A"] = "指数平滑法"; row["B"] = false; psp_Typen.Forecast = 5; listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); if (listTypesn.Count > 0) { row["C"] = "有"; } else { row["C"] = "无"; } dt1.Rows.Add(row); row = dt1.NewRow(); row["A"] = "灰色模型法"; row["B"] = false; psp_Typen.Forecast = 6; listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); if (listTypesn.Count > 0) { row["C"] = "有"; } else { row["C"] = "无"; } dt1.Rows.Add(row); row = dt1.NewRow(); row["A"] = "专家决策法"; row["B"] = false; psp_Typen.Forecast = 7; listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); if (listTypesn.Count > 0) { row["C"] = "有"; } else { row["C"] = "无"; } dt1.Rows.Add(row); row = dt1.NewRow(); row["A"] = "复合算法"; row["B"] = false; // psp_Typen.Forecast =9; psp_Typen.Forecast = 20; listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); if (listTypesn.Count > 0) { row["C"] = "有"; } else { row["C"] = "无"; } dt1.Rows.Add(row); //row = dt1.NewRow(); //row["A"] = "定权组合系数法"; //row["B"] = false; //psp_Typen.Forecast = 10; //listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen); //if (listTypesn.Count > 0) //{ // row["C"] = "有"; //} //else //{ // row["C"] = "无"; //} //dt1.Rows.Add(row); gridControl1.DataSource = dt1; foreach (DataColumn dc in dt4.Columns) { dt2.Columns.Add(dc.ColumnName, dc.DataType); } if (!dt2.Columns.Contains("B")) { dt2.Columns.Add("B", typeof(bool)); } if (!dt2.Columns.Contains("A")) { dt2.Columns.Add("A"); } if (!dt4.Columns.Contains("B")) { dt4.Columns.Add("B", typeof(bool)); } if (!dt4.Columns.Contains("A")) { dt4.Columns.Add("A"); } //foreach (DataRow dr2 in dt2.Rows) //{ // DataRow dr = dttemp.NewRow(); // foreach (DataColumn dc in dt2.Columns) // dr[dc.ColumnName] = dr2[dc.ColumnName]; // dttemp.Rows.Add(dr); //} ArrayList alist = new ArrayList(); //foreach (DataRow dr in dt4.Rows) //{ // DataRow defind = dt2.NewRow(); // if (dr["Title"].ToString().Contains("-")) // { // string[] str = dr["Title"].ToString().Split('-'); // if (str[0].Contains("电量")) // str[1] = str[1] + "电量"; // else if (str[0].Contains("负荷")) // str[1] = str[1] + "负荷"; // if (alist.Contains(str[1])) // { // continue; // } // foreach (DataColumn dc in dt2.Columns) // defind[dc.ColumnName] = dr[dc.ColumnName]; // defind["Title"] = str[1]; // defind["A"] = str[1]; // alist.Add(str[1]); // dt2.Rows.Add(defind); // } // else // { // if (alist.Contains(dr["Title"])) // { // continue; // } // foreach (DataColumn dc in dt2.Columns) // defind[dc.ColumnName] = dr[dc.ColumnName]; // alist.Add(dr["Title"]); // dt2.Rows.Add(defind); // } //} foreach (DataRow dr in dt2.Rows) { dr["A"] = dr["Title"].ToString(); dr["B"] = false; } // gridControl2.DataSource = dt2; gridControl2.DataSource = dt2; foreach (DataRow dr in dt3.Rows) { dr["B"] = true; dr["C"] = false; } gridControl3.DataSource = dt3; }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedItem == null) { return; } if (comboBox1.SelectedItem.ToString() == "外推法") { if (!comboBox6.Items.Contains("外推法(年增长率法)")) { comboBox6.Items.Clear(); comboBox6.Items.Add("外推法(年增长率法)"); comboBox6.Items.Add("外推法(直线)"); comboBox6.Items.Add("外推法(抛物线)"); comboBox6.Items.Add("外推法(三阶)"); comboBox6.Items.Add("外推法(指数)"); comboBox6.Items.Add("外推法(几何曲线)"); } comboBox6.Visible = true; comboBox6.Enabled = true; label6.Visible = true; label6.Enabled = true; } else if (comboBox1.SelectedItem.ToString() == "相关法") { if (!comboBox6.Items.Contains("相关法(直线)")) { comboBox6.Items.Clear(); comboBox6.Items.Add("相关法(直线)"); comboBox6.Items.Add("相关法(抛物线)"); comboBox6.Items.Add("相关法(三阶)"); comboBox6.Items.Add("相关法(指数)"); comboBox6.Items.Add("相关法(几何曲线)"); } comboBox6.Visible = true; comboBox6.Enabled = true; label6.Visible = true; label6.Enabled = true; } else if (comboBox1.SelectedItem.ToString() == "指数平滑法") { Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = 5; pcs.ForecastID = forecastReport.ID; IList <Ps_Calc> list1 = Services.BaseService.GetList <Ps_Calc>("SelectPs_CalcByForecast", pcs); if (list1.Count < 1) { MessageBox.Show("平滑参数未设置,将按默认值0.1计算"); } comboBox6.Visible = false; comboBox6.Enabled = false; label6.Visible = false; label6.Enabled = false; } else if (comboBox1.SelectedItem.ToString() == "专家决策法") { Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ForecastID = forecastReport.ID; psp_Type.Forecast = 7; IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type); if (listTypes.Count < 1) { MessageBox.Show("专家决策法没有数据,选择失败"); comboBox1.SelectedIndex = -1; } } else { comboBox6.Visible = false; comboBox6.Enabled = false; label6.Visible = false; label6.Enabled = false; } }
private void RefreshChart() { //ArrayList ht = new ArrayList(); //ht.Add(Color.Red); //ht.Add(Color.Blue); //ht.Add(Color.Green); //ht.Add(Color.Yellow); //ht.Add(Color.HotPink); //ht.Add(Color.LawnGreen); //ht.Add(Color.Khaki); //ht.Add(Color.LightSlateGray); //ht.Add(Color.LightSeaGreen); //ht.Add(Color.Lime); IList <FORBaseColor> list = Services.BaseService.GetList <FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-" + typeFlag + "'"); IList <FORBaseColor> li = new List <FORBaseColor>(); bool bl = false; foreach (DataRow row in dataTable.Rows) { bl = false; foreach (FORBaseColor bc in list) { if (row["Title"].ToString() == bc.Title) { bl = true; FORBaseColor bc1 = new FORBaseColor(); bc1.Color1 = Color.Blue; CopyBaseColor(bc1, bc); li.Add(bc1); } } if (!bl) { FORBaseColor bc1 = new FORBaseColor(); bc1.UID = Guid.NewGuid().ToString(); bc1.Remark = this.forecastReport.ID.ToString() + "-" + typeFlag; bc1.Title = row["Title"].ToString(); bc1.Color = 16711680; bc1.Color1 = Color.Blue; Services.BaseService.Create <FORBaseColor>(bc1); li.Add(bc1); } } ArrayList ht = new ArrayList(); foreach (FORBaseColor bc2 in li) { ht.Add(bc2.Color1); } List <Ps_Forecast_Math> listValues = new List <Ps_Forecast_Math>(); for (int i = 0; i < this.dataTable.Rows.Count; i++) { DataRow row = this.dataTable.Rows[i]; foreach (TreeListColumn col in treeList1.Columns) { if (col.FieldName.IndexOf("y") > -1) { object obj = row[col.FieldName]; if (obj != DBNull.Value) { Ps_Forecast_Math v = new Ps_Forecast_Math(); v.ForecastID = forecastReport.ID; v.ID = (string)row["ID"]; v.Title = row["Title"].ToString(); v.Sort = Convert.ToInt32(col.FieldName.Replace("y", "")); v.y1990 = (double)row[col.FieldName]; listValues.Add(v); } } } } chart1.Series.Clear(); ArrayList al = new ArrayList(); al.Add(Application.StartupPath + "/img/1.ico"); al.Add(Application.StartupPath + "/img/2.ico"); al.Add(Application.StartupPath + "/img/3.ico"); al.Add(Application.StartupPath + "/img/4.ico"); al.Add(Application.StartupPath + "/img/5.ico"); al.Add(Application.StartupPath + "/img/6.ico"); al.Add(Application.StartupPath + "/img/7.ico"); chart1.DataBindCrossTab(listValues, "Title", "Sort", "y1990", ""); LegendItem legendItem; LegendCell legendCell1; LegendCell legendCell2; LegendCell legendCell3; Legend legend = new Legend(); legend.AutoFitText = false; //legend.BackColor = System.Drawing.Color.Transparent; //legend.BorderColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); for (int i = 0; i < chart1.Series.Count; i++) { int j = i % 10; legendItem = new Dundas.Charting.WinControl.LegendItem(); legendCell1 = new Dundas.Charting.WinControl.LegendCell(); legendCell2 = new Dundas.Charting.WinControl.LegendCell(); legendCell3 = new Dundas.Charting.WinControl.LegendCell(); legendCell1.CellType = Dundas.Charting.WinControl.LegendCellType.Image; legendCell2.CellType = Dundas.Charting.WinControl.LegendCellType.Image; legendCell1.Name = "Cell1"; legendCell2.Name = "Cell2"; legendCell3.Alignment = System.Drawing.ContentAlignment.MiddleLeft; legendCell3.Name = "Cell3"; legendCell3.Text = chart1.Series[i].Name; legendCell3.TextColor = (Color)ht[i]; chart1.Series[i].Color = (Color)ht[i]; chart1.Series[i].Name = (i + 1).ToString() + "." + chart1.Series[i].Name; chart1.Series[i].Type = Dundas.Charting.WinControl.SeriesChartType.Line; chart1.Series[i].MarkerImage = al[i % 7].ToString(); chart1.Series[i].MarkerSize = 7; chart1.Series[i].MarkerStyle = (Dundas.Charting.WinControl.MarkerStyle)(2); chart1.Series[i].ShowInLegend = false; chart1.Series[i].Enabled = true; chart1.Series[i].XValueIndexed = true; legendItem.Cells.Add(legendCell1); legendItem.Cells.Add(legendCell2); legendItem.Cells.Add(legendCell3); legendItem.Tag = chart1.Series[i]; legendItem.Cells[1].Image = al[i % 7].ToString(); if (checkBox1.Checked) { legendItem.Cells[0].Image = string.Format(Application.StartupPath + @"/img/chk_checked.png"); } else { legendItem.Cells[0].Image = string.Format(Application.StartupPath + @"/img/chk_unchecked.png"); } legend.CustomItems.Add(legendItem); chart1.Series[i].Enabled = checkBox1.Checked; } chart1.ChartAreas["Default"].AxisY.MinorGrid.Enabled = true; chart1.ChartAreas["Default"].AxisY.MinorGrid.LineStyle = ChartDashStyle.Dash; chart1.ChartAreas["Default"].AxisY.MinorGrid.LineColor = Color.Gray; legend.Name = "Default"; this.chart1.Legends.Add(legend); }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListNode row = this.treeList1.FocusedNode; if (row == null) { return; } string parentid = row["ParentID"].ToString(); // FormTypeTitle frm = new FormTypeTitle(); string TypeTitle = row["Title"].ToString(); frmMain_Spatial fmain = new frmMain_Spatial(); frmMain_Spatial.MapType = "接线图"; frmMain_Spatial.progtype = "城市规划层"; string pid = ""; fmain.Show(); string progtype = "城市规划层"; //if (progtype == "地理信息层") { // fmain.ViewMenu(); //} if (pid == "") { fmain.Open("c5ec3bc7-9706-4cbd-9b8b-632d3606f933", ""); } else { fmain.Open("c5ec3bc7-9706-4cbd-9b8b-632d3606f933", pid); } // LoadImage = true; fmain.InitShape(); fmain.Init(progtype); fmain.InitScaleRatio(); fmain.LayerManagerShow(); fmain.OpenGHQYpropetty(TypeTitle); if (fmain.DialogResult == DialogResult.OK) { glebeProperty gp = new glebeProperty(); gp.ParentEleID = "0"; gp.SvgUID = "c5ec3bc7-9706-4cbd-9b8b-632d3606f933"; gp.ObligateField16 = TypeTitle; IList <glebeProperty> svglist = Services.BaseService.GetList <glebeProperty>("SelectglebePropertyByObligateField16", gp); //重新对选中的数据进行更新 Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); ForecastClass1.TreeNodeToDataObject <Ps_Forecast_Math>(psp_Type, row); IList <glebeYearValue> yearlist = Services.BaseService.GetList <glebeYearValue>("SelectglebeYearValueBywhere", "ParentID='" + svglist[0].UID + "'"); for (int i = 0; i < yearlist.Count; i++) { string y = "y" + yearlist[i].Year.ToString(); psp_Type.GetType().GetProperty(y).SetValue(psp_Type, yearlist[i].Burthen, null); } try { Common.Services.BaseService.Update <Ps_Forecast_Math>(psp_Type); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPSP_P_Types", psp_Type); //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); LoadData(); //treeList1.EndUpdate(); RefreshChart(); } catch (Exception ex) { } } else { //MsgBox.Show("在规划地块中,没有圈选此区域,请在规划地块模块中圈选此地块再点击编辑!"); fmain.Owner = this; } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FrmAddspatialarea FA = new FrmAddspatialarea(); FA.init(); if (FA.ShowDialog() == DialogResult.OK) { foreach (DataRow dr in dataTable.Rows) { if (dr["Title"] == FA.Areatitle) { MessageBox.Show("已经存在此地区!请重新选。"); return; } } glebeProperty gp = new glebeProperty(); gp.ParentEleID = "0"; gp.SvgUID = "c5ec3bc7-9706-4cbd-9b8b-632d3606f933"; gp.ObligateField16 = FA.Areatitle; IList <glebeProperty> svglist = Services.BaseService.GetList <glebeProperty>("SelectglebePropertyByObligateField16", gp); if (svglist.Count > 0) { frmMainProperty f = new frmMainProperty(); f.IsReadonly = true; f.InitData(svglist[0], "", "", ""); if (f.ShowDialog() == DialogResult.OK) { Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ID = Guid.NewGuid().ToString(); psp_Type.Forecast = type; psp_Type.ForecastID = forecastReport.ID; psp_Type.Title = FA.Areatitle; glebeYearValue gy = new glebeYearValue(); IList <glebeYearValue> yearlist = Services.BaseService.GetList <glebeYearValue>("SelectglebeYearValueBywhere", "ParentID='" + svglist[0].UID + "'"); for (int i = 0; i < yearlist.Count; i++) { string y = "y" + yearlist[i].Year.ToString(); psp_Type.GetType().GetProperty(y).SetValue(psp_Type, yearlist[i].Burthen, null); } object obj = Services.BaseService.GetObject("SelectPs_Forecast_MathMaxID", null); if (obj != null) { psp_Type.Sort = ((int)obj) + 1; } else { psp_Type.Sort = 1; } try { Common.Services.BaseService.Create <Ps_Forecast_Math>(psp_Type); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPSP_P_Types", psp_Type); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); } catch (Exception ex) { MsgBox.Show("增加区域出错:" + ex.Message); } RefreshChart(); } } else { Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ID = Guid.NewGuid().ToString(); psp_Type.Forecast = type; psp_Type.ForecastID = forecastReport.ID; psp_Type.Title = FA.Areatitle; //glebeYearValue gy = new glebeYearValue(); //IList<glebeYearValue> yearlist = Services.BaseService.GetList<glebeYearValue>("SelectglebeYearValueBywhere", "ParentID='" + svglist[0].UID + "'"); //for (int i = 0; i < yearlist.Count; i++) { // string y = "y" + yearlist[i].Year.ToString(); // psp_Type.GetType().GetProperty(y).SetValue(psp_Type, y, null); //} object obj = Services.BaseService.GetObject("SelectPs_Forecast_MathMaxID", null); if (obj != null) { psp_Type.Sort = ((int)obj) + 1; } else { psp_Type.Sort = 1; } try { Common.Services.BaseService.Create <Ps_Forecast_Math>(psp_Type); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPSP_P_Types", psp_Type); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); } catch (Exception ex) { MsgBox.Show("增加区域出错:" + ex.Message); } RefreshChart(); } } }
private void SelectData() { object row = this.gridView1.GetRow(this.gridView1.FocusedRowHandle); if (row == null) { return; } Ps_forecast_list pf = row as Ps_forecast_list; string id = pf.ID; int m = 1; switch (barEditItem1.EditValue.ToString()) { case "年增长率法": m = 1; break; case "外推法": m = 2; break; case "指数平滑法": //m = 3; m = 5; break; case "弹性系数法": m = 4; break; case "灰色理论法": m = 6; break; case "复合算法": m = 9; break; case "推荐值": m = 30; break; case "专家决策法": m = 7; break; } DataTable dataTable = new DataTable(); bool bLoadingData = true; if (dataTable != null) { dataTable.Columns.Clear(); this.gridView2.Columns.Clear(); } AddFixColumn(); for (int i = pf.StartYear; i <= pf.YcEndYear; i++) { AddColumn(i); } if (m == 30) { string sql2 = " Col4='yes' and Forecast=" + m + " and ParentID='' and ForecastID='" + id + "'"; IList list = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByWhere", sql2); dataTable = Itop.Common.DataConverter.ToDataTable(list, typeof(Ps_Forecast_Math)); } else { Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ForecastID = id; psp_Type.Forecast = m; IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type); dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math)); } this.gridControl2.DataSource = dataTable; Application.DoEvents(); bLoadingData = false; }
/// <summary> /// 读取原始数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FormForecastLoadData2 ffs = new FormForecastLoadData2(); ffs.PID = MIS.ProgUID; ffs.StartYear = forecastReport.StartYear; ffs.EndYear = forecastReport.EndYear; if (ffs.ShowDialog() != DialogResult.OK) { return; } Hashtable hs = ffs.HS; if (hs.Count == 0) { return; } string id = Guid.NewGuid().ToString(); foreach (Ps_History de3 in hs.Values) { if (OldHt.ContainsKey(de3.Title)) { Ps_Forecast_Math py = Common.Services.BaseService.GetOneByKey <Ps_Forecast_Math>(OldHt[de3.Title]); for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { commonhelp.ResetValue(py.ID, "y" + i); py.GetType().GetProperty("y" + i).SetValue(py, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null); } Services.BaseService.Update <Ps_Forecast_Math>(py); } else { Ps_Forecast_Math ForecastMath = new Ps_Forecast_Math(); ForecastMath.Title = de3.Title; for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { ForecastMath.GetType().GetProperty("y" + i).SetValue(ForecastMath, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null); } id = id.Substring(0, 8); ForecastMath.Col1 = de3.ID; ForecastMath.ID = id + "|" + de3.ID; if (de3.ParentID == "") { ForecastMath.ParentID = ""; } else { ForecastMath.ParentID = id + "|" + de3.ParentID; } ForecastMath.Forecast = type; ForecastMath.ForecastID = forecastReport.ID; ForecastMath.Sort = de3.Sort; Services.BaseService.Create("InsertPs_Forecast_MathbyPs_History", ForecastMath); } } LoadData(); this.chart_user1.All_Select(true); RefreshChart(); }
private void RefreshChart(int syear, int eyear) { IList <FORBaseColor> list = Services.BaseService.GetList <FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-" + type + "'"); IList <FORBaseColor> li = new List <FORBaseColor>(); bool bl = false; foreach (DataRow row in dataTable.Rows) { bl = false; foreach (FORBaseColor bc in list) { if (row["Title"].ToString() == bc.Title) { bl = true; FORBaseColor bc1 = new FORBaseColor(); bc1.Color1 = Color.Blue; CopyBaseColor(bc1, bc); li.Add(bc1); } } if (!bl) { FORBaseColor bc1 = new FORBaseColor(); bc1.UID = Guid.NewGuid().ToString(); bc1.Remark = this.forecastReport.ID.ToString() + "-" + type; bc1.Title = row["Title"].ToString(); bc1.Color = 16711680; bc1.Color1 = Color.Blue; Services.BaseService.Create <FORBaseColor>(bc1); li.Add(bc1); } } ArrayList hs = new ArrayList(); foreach (FORBaseColor bc2 in li) { hs.Add(bc2.Color1); } List <Ps_Forecast_Math> listValues = new List <Ps_Forecast_Math>(); for (int i = 0; i < this.treeList1.Nodes.Count; i++) { TreeListNode row = treeList1.Nodes[i]; foreach (TreeListColumn col in treeList1.Columns) { if (col.FieldName.IndexOf("y") > -1) { int yyear = int.Parse(col.FieldName.Replace("y", "")); if (yyear >= syear && yyear <= eyear) { object obj = row[col.FieldName]; if (obj != DBNull.Value) { Ps_Forecast_Math v = new Ps_Forecast_Math(); v.ForecastID = forecastReport.ID; v.ID = (string)row["ID"]; v.Title = row["Title"].ToString(); v.Sort = Convert.ToInt32(col.FieldName.Replace("y", "")); v.y1990 = (double)row[col.FieldName]; listValues.Add(v); } } } } } chart1.Series.Clear(); chart1.DataBindCrossTab(listValues, "Title", "Sort", "y1990", ""); //for (int i = 0; i < chart1.Series.Count; i++) //{ // chart1.Series[i].Color = (Color)hs[i]; // chart1.Series[i].Name = (i + 1).ToString() + "." + chart1.Series[i].Name; // chart1.Series[i].Type = Dundas.Charting.WinControl.SeriesChartType.Line; // chart1.Series[i].MarkerSize = 7; // chart1.Series[i].MarkerStyle = (Dundas.Charting.WinControl.MarkerStyle)(2); //} m_pf.SetChart(chart1, checkBox1, hs, null); }
private void barButtonItem10_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListNode tln = treeList1.FocusedNode; if (tln == null) { return; } if (tln.ParentNode != null) { return; } FormForecastLoadData ffs = new FormForecastLoadData(); ffs.PID = Itop.Client.MIS.ProgUID; ffs.StartYear = forecastReport.StartYear; ffs.EndYear = forecastReport.EndYear; if (ffs.ShowDialog() != DialogResult.OK) { return; } Hashtable hs = ffs.HS; if (hs.Count == 0) { return; } string id = Guid.NewGuid().ToString(); if (ffs.Selectid != "4") { foreach (Ps_History de3 in hs.Values) { Ps_Forecast_Math py = new Ps_Forecast_Math(); py.Col1 = de3.ID; py.Forecast = 3; py.ForecastID = forecastReport.ID; py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByCol1", py); if (py == null) { Ps_Forecast_Math ForecastMath = new Ps_Forecast_Math(); ForecastMath.Title = de3.Title; for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { ForecastMath.GetType().GetProperty("y" + i).SetValue(ForecastMath, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null); } id = id.Substring(0, 8); ForecastMath.Col1 = de3.ID; ForecastMath.ID = id + "|" + de3.ID; ForecastMath.ParentID = tln["ID"].ToString(); ForecastMath.Forecast = 3; ForecastMath.ForecastID = forecastReport.ID; ForecastMath.Sort = de3.Sort; Services.BaseService.Create("InsertPs_Forecast_MathbyPs_History", ForecastMath); } else { for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { py.GetType().GetProperty("y" + i).SetValue(py, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null); } Services.BaseService.Update <Ps_Forecast_Math>(py); } LoadData(); } } }
private void RefreshChart() { IList <FORBaseColor> list = Services.BaseService.GetList <FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-" + type + "'"); IList <FORBaseColor> li = new List <FORBaseColor>(); bool bl = false; foreach (DataRow row in dataTable.Rows) { bl = false; foreach (FORBaseColor bc in list) { if (row["Title"].ToString() == bc.Title) { bl = true; FORBaseColor bc1 = new FORBaseColor(); bc1.Color1 = Color.Blue; CopyBaseColor(bc1, bc); li.Add(bc1); } } if (!bl) { FORBaseColor bc1 = new FORBaseColor(); bc1.UID = Guid.NewGuid().ToString(); bc1.Remark = this.forecastReport.ID.ToString() + "-" + type; bc1.Title = row["Title"].ToString(); bc1.Color = 16711680; bc1.Color1 = Color.Blue; Services.BaseService.Create <FORBaseColor>(bc1); li.Add(bc1); } } ArrayList hs = new ArrayList(); foreach (FORBaseColor bc2 in li) { hs.Add(bc2.Color1); } List <Ps_Forecast_Math> listValues = new List <Ps_Forecast_Math>(); for (int i = 0; i < treeList1.Nodes.Count; i++) { TreeListNode row = treeList1.Nodes[i]; foreach (TreeListColumn col in treeList1.Columns) { if (col.FieldName.IndexOf("y") > -1) { object obj = row[col.FieldName]; if (obj != DBNull.Value) { Ps_Forecast_Math v = new Ps_Forecast_Math(); v.ForecastID = forecastReport.ID; v.ID = (string)row["ID"]; v.Title = (i + 1).ToString() + "." + row["Title"].ToString(); v.Sort = Convert.ToInt32(col.FieldName.Replace("y", "")); v.y1990 = (double)row[col.FieldName]; listValues.Add(v); } } } } chart1.Series.Clear(); ArrayList al = new ArrayList(); al.Add(Application.StartupPath + "/img/1.ico"); al.Add(Application.StartupPath + "/img/2.ico"); al.Add(Application.StartupPath + "/img/3.ico"); al.Add(Application.StartupPath + "/img/4.ico"); al.Add(Application.StartupPath + "/img/5.ico"); al.Add(Application.StartupPath + "/img/6.ico"); al.Add(Application.StartupPath + "/img/7.ico"); chart1.DataBindCrossTab(listValues, "Title", "Sort", "y1990", ""); for (int i = 0; i < chart1.Series.Count; i++) { chart1.Series[i].Color = (Color)hs[i]; chart1.Series[i].Name = chart1.Series[i].Name; chart1.Series[i].Type = Dundas.Charting.WinControl.SeriesChartType.Line; chart1.Series[i].MarkerImage = al[i % 7].ToString(); chart1.Series[i].MarkerSize = 7; chart1.Series[i].MarkerStyle = (Dundas.Charting.WinControl.MarkerStyle)(2); chart1.Series[i].XValueIndexed = false; } chart1.ChartAreas["Default"].AxisX.MinorGrid.Enabled = false; chart1.ChartAreas["Default"].AxisY.MinorGrid.Enabled = true; chart1.ChartAreas["Default"].AxisY.MinorGrid.LineStyle = ChartDashStyle.Dash; chart1.ChartAreas["Default"].AxisY.MinorGrid.LineColor = Color.Gray; }
/// <summary> /// 方案下拉框选择 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox2.SelectedItem == null) { return; } if (comboBox2.SelectedItem.ToString() == "外推法") { if (!comboBox6.Items.Contains("外推法(年增长率法)")) { comboBox6.Items.Clear(); m_pf.InitCommboBox(comboBox6, null, 1); } SetSubalgorithm(true); } else if (comboBox2.SelectedItem.ToString() == "相关法") { if (!comboBox6.Items.Contains("相关法(直线)")) { comboBox6.Items.Clear(); m_pf.InitCommboBox(comboBox6, null, 2); } SetSubalgorithm(true); } else if (comboBox2.SelectedItem.ToString() == "弹性系数法") { simpleButton7.Visible = true; SetSubalgorithm(false); } else if (comboBox2.SelectedItem.ToString() == "指数平滑法") { textEdit9.Visible = true; spinEdit4.Visible = true; SetSubalgorithm(false); Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = 25; pcs.ForecastID = forecastReport.ID; IList <Ps_Calc> list1 = m_pf.SelectedForecastList(25, forecastReport); // IList<Ps_Calc> list1 = Common.Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs); if (list1.Count > 0) { spinEdit4.Value = Convert.ToDecimal(list1[0].Value1); } else { spinEdit4.Value = Convert.ToDecimal(0.2); } } else if (comboBox2.SelectedItem.ToString() == "专家决策法") { Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ForecastID = forecastReport.ID; psp_Type.Forecast = 7; IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type); if (listTypes.Count < 1) { MessageBox.Show("专家决策法没有数据,选择失败"); comboBox2.SelectedIndex = -1; } SetSubalgorithm(false); } else { SetSubalgorithm(false); } if (comboBox2.SelectedItem.ToString() != "弹性系数法") { simpleButton7.Visible = false; } if (comboBox2.SelectedItem.ToString() != "指数平滑法") { textEdit9.Visible = false; spinEdit4.Visible = false; } }
private void JS() { //计算预测值 Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; IList <Ps_Calc> list1 = Services.BaseService.GetList <Ps_Calc>("SelectPs_CalcByForecast", pcs); int fyear = int.Parse(firstyear.Replace("y", "")); int syear = int.Parse(endyear.Replace("y", "")); int eyear = forecastReport.EndYear; if (ha == null) { return; } if (ha.Count < 1) { return; } IList <Ps_Forecast_Math> list = new List <Ps_Forecast_Math>(); Ps_Forecast_Math psmtemp = new Ps_Forecast_Math(); foreach (DataRow dataRow in dataTable.Rows) { //if (fyear != 0 && syear != 0) //{ // double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear); // double[] yn = new double[eyear - syear]; double[] yn = new double[forecastReport.EndYear - forecastReport.StartYear + 1]; foreach (string index in ha.Keys) { switch (index) { case "年增长率法": list.Clear(); psmtemp = new Ps_Forecast_Math(); psmtemp.ForecastID = forecastReport.ID; psmtemp.Forecast = 1; break; case "弹性系数法": list.Clear(); psmtemp = new Ps_Forecast_Math(); psmtemp.ForecastID = forecastReport.ID; psmtemp.Forecast = 4; break; case "指数平滑法": list.Clear(); psmtemp = new Ps_Forecast_Math(); psmtemp.ForecastID = forecastReport.ID; psmtemp.Forecast = 5; break; case "灰色模型法": list.Clear(); psmtemp = new Ps_Forecast_Math(); psmtemp.ForecastID = forecastReport.ID; psmtemp.Forecast = 6; break; case "专家指定法": list.Clear(); psmtemp = new Ps_Forecast_Math(); psmtemp.ForecastID = forecastReport.ID; psmtemp.Forecast = 7; break; case "外推法": list.Clear(); psmtemp = new Ps_Forecast_Math(); psmtemp.ForecastID = forecastReport.ID; psmtemp.Forecast = 2; break; case "相关法": list.Clear(); psmtemp = new Ps_Forecast_Math(); psmtemp.ForecastID = forecastReport.ID; psmtemp.Forecast = 3; break; case "人工神经网络法": list.Clear(); psmtemp = new Ps_Forecast_Math(); psmtemp.ForecastID = forecastReport.ID; psmtemp.Forecast = 8; break; } psmtemp.Title = dataRow["Title"].ToString(); list = Common.Services.BaseService.GetList <Ps_Forecast_Math>("SelectPs_Forecast_MathByForecastIDAndForecastTitle", psmtemp); if (list != null && list.Count > 0) { for (int i = 0; i <= forecastReport.EndYear - forecastReport.StartYear; i++) { yn[i] += Convert.ToDouble(ha[index]) * Convert.ToDouble(list[0].GetType().GetProperty("y" + (forecastReport.StartYear + i)).GetValue(list[0], null)); } } } for (int i = 0; i <= forecastReport.EndYear - forecastReport.StartYear; i++) { dataRow["y" + (forecastReport.StartYear + i)] = yn[i]; } // } } RefreshChart(); }
//设置GDP值 private void simpleButton7_Click(object sender, EventArgs e) { FormSetGDP frm = new FormSetGDP(); frm.forecastReport = forecastReport; frm.Text = "设置GDP值"; frm.type = type; DataRow[] rowsoldGDP = dataTable.Select("Title like '全地区GDP%'"); if (frm.ShowDialog() == DialogResult.OK) { if (frm.GetGDP) { //读取GDP历史值 if (rowsoldGDP.Length > 0) { DataRow oldrow = rowsoldGDP[0]; //新经济数据 Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = 5; psp_Type.Col4 = Itop.Client.MIS.ProgUID; IList <Ps_History> listTypes = Common.Services.BaseService.GetList <Ps_History>("SelectPs_HistoryByForecast", psp_Type); DataTable dataTable2 = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); DataRow[] rows1 = dataTable2.Select("Title like '全地区GDP%'"); for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { double s1 = 0; try { s1 = Convert.ToDouble(rows1[0]["y" + i]); } catch { } oldrow["y" + i] = s1; commonhelp.ResetValue(oldrow["ID"].ToString(), "y" + i); } Ps_Forecast_Math pfm = DataConverter.RowToObject <Ps_Forecast_Math>(oldrow); Services.BaseService.Update <Ps_Forecast_Math>(pfm); } } DataRow[] rowsgdp = dataTable.Select("Title like '全地区GDP%'"); if (rowsgdp.Length > 0) { DataRow oldrow = rowsgdp[0]; Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; IList <Ps_Calc> list1 = Services.BaseService.GetList <Ps_Calc>("SelectPs_CalcByForecast", pcs); Hashtable hs = new Hashtable(); foreach (Ps_Calc pcl1 in list1) { if (!hs.ContainsKey(pcl1.Year)) { hs.Add(pcl1.Year, pcl1.Value2); } } for (int j = forecastReport.YcStartYear; j <= forecastReport.YcEndYear; j++) { double increasenum = double.Parse(hs[j].ToString()); double basenum = double.Parse(oldrow["y" + (j - 1)].ToString()); oldrow["y" + j] = basenum * (1 + increasenum); } Ps_Forecast_Math pfm = DataConverter.RowToObject <Ps_Forecast_Math>(oldrow); Services.BaseService.Update <Ps_Forecast_Math>(pfm); } JS(); } }