private void FormDyhptl_Load(object sender, EventArgs e) { int firstyear = 0; int endyear = 0; 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); if (list1.Count > 0) { spinEdit1.Value = (decimal)list1[0].Value1; } }
//设置历史年份 private void SetHistoryYear() { Ps_Forecast_Setup pfs = new Ps_Forecast_Setup(); pfs.ID = Guid.NewGuid().ToString(); pfs.Forecast = type; pfs.ForecastID = forecastReport.ID; pfs.StartYear = forecastReport.StartYear; pfs.EndYear = forecastReport.EndYear; IList <Ps_Forecast_Setup> li = Services.BaseService.GetList <Ps_Forecast_Setup>("SelectPs_Forecast_SetupByForecast", pfs); if (li.Count == 0) { Services.BaseService.Create <Ps_Forecast_Setup>(pfs); } else { Services.BaseService.Update("UpdatePs_Forecast_SetupByForecast", pfs); } IList <Ps_Forecast_Setup> li2 = Services.BaseService.GetList <Ps_Forecast_Setup>("SelectPs_Forecast_SetupByForecast", pfs); if (li2.Count != 0) { firstyear = li2[0].StartYear.ToString(); endyear = li2[0].EndYear.ToString(); } }
private void Form8Forecast_Load(object sender, EventArgs e) { HideToolBarButton(); //chart1.Series.Clear(); //Show(); Application.DoEvents(); //this.Cursor = Cursors.WaitCursor; //treeList1.BeginUpdate(); LoadData(); //treeList1.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(); } }
private void barButtonItem26_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.Nodes.Count == 0) { MessageBox.Show("无数据,不能操作!"); return; } if (barButtonItem26.Caption == "开始截取历史数据") { barButtonItem26.Caption = "结束截取历史数据"; firstyear = "0"; endyear = "0"; selectdral = false; this.simpleButton2.Enabled = false; this.barButtonItem17.Enabled = false; this.simpleButton4.Enabled = false; treeList1.OptionsSelection.MultiSelect = true; treeList1.OptionsBehavior.Editable = false; treeList1.Refresh(); } else if (barButtonItem26.Caption == "结束截取历史数据") { barButtonItem26.Caption = "开始截取历史数据"; selectdral = true; this.simpleButton2.Enabled = true; this.barButtonItem17.Enabled = true; this.simpleButton4.Enabled = true; if (firstyear != "Title") { Ps_Forecast_Setup pfs = new Ps_Forecast_Setup(); pfs.ID = Guid.NewGuid().ToString(); 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) { Services.BaseService.Create <Ps_Forecast_Setup>(pfs); } else { Services.BaseService.Update("UpdatePs_Forecast_SetupByForecast", pfs); } } treeList1.OptionsSelection.MultiSelect = false; treeList1.OptionsBehavior.Editable = true; } }
private void FormForecastCalcTX_Load(object sender, EventArgs e) { #region 电力发展实绩 ArrayList al = new ArrayList(); IList <Base_Data> li1 = Common.Services.BaseService.GetStrongList <Base_Data>(); foreach (Base_Data bd in li1) { al.Add(bd.Title); } Ps_History psp_Type1 = new Ps_History(); psp_Type1.Forecast = 1; psp_Type1.Col4 = Itop.Client.MIS.ProgUID; IList <Ps_History> listTypes1 = Common.Services.BaseService.GetList <Ps_History>("SelectPs_HistoryByForecast", psp_Type1); for (int c = 0; c < al.Count; c++) { bool bl = true; foreach (Ps_History ph in listTypes1) { if (al[c].ToString() == ph.Title) { bl = false; } } if (bl) { Ps_History pf = new Ps_History(); pf.ID = Guid.NewGuid().ToString() + "|" + Itop.Client.MIS.ProgUID; pf.Forecast = 1; pf.ForecastID = "1"; pf.Title = al[c].ToString(); pf.Col4 = Itop.Client.MIS.ProgUID; Services.BaseService.Create <Ps_History>(pf); listTypes1.Add(pf); } } 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 = 1; 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='全地区GDP(亿元)'"); DataRow[] rows4 = dataTable.Select("Title='全社会用电量(亿kWh)'"); #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.EndYear; 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); foreach (Ps_Calc pcs2 in list1) { if (i == pcs2.Year) { newrow1[i.ToString()] = Math.Round(pcs2.Value1, 3); newrow2[i.ToString()] = Math.Round(pcs2.Value2, 3); } } } dt.Rows.Add(newrow1); dt.Rows.Add(newrow2); vGridControl2.DataSource = dt; }
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 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 FormCalculator_Load(object sender, EventArgs e) { int firstyear = 0; int endyear = 0; 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(); #region 年平均s dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Name"); DataRow newrow1 = dt.NewRow(); newrow1["ID"] = "ID"; newrow1["Name"] = "历史增长率"; newrow2 = dt.NewRow(); newrow2["Name"] = "当前增长率"; foreach (DataRow dataRow in dataTable.Rows) { dt.Columns.Add(dataRow["ID"].ToString().Trim(), typeof(double)); DevExpress.XtraVerticalGrid.Rows.EditorRow editorRow = new DevExpress.XtraVerticalGrid.Rows.EditorRow(); editorRow.Properties.FieldName = dataRow["ID"].ToString().Trim(); editorRow.Properties.Caption = dataRow["Title"].ToString().Trim(); editorRow.Height = 20; editorRow.Properties.RowEdit = this.repositoryItemCalcEdit4; this.vGridControl2.Rows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { editorRow }); int forecastYears = forecastReport.EndYear - forecastReport.StartYear; double[] historyValues = GenerateHistoryValue(dataRow, firstyear, endyear); newrow1[dataRow["ID"].ToString().Trim()] = Calculator.AverageIncreasing(historyValues); bool bl = false; foreach (Ps_Calc pc11 in list1) { if (pc11.CalcID == editorRow.Properties.FieldName) { bl = true; newrow2[dataRow["ID"].ToString().Trim()] = pc11.Value1; } } if (!bl) { newrow2[dataRow["ID"].ToString().Trim()] = Calculator.AverageIncreasing(historyValues); Ps_Calc pcs1 = new Ps_Calc(); pcs1.ID = Guid.NewGuid().ToString(); pcs1.Forecast = type; pcs1.ForecastID = forecastReport.ID; pcs1.CalcID = dataRow["ID"].ToString().Trim(); pcs1.Value1 = Calculator.AverageIncreasing(historyValues); Services.BaseService.Create <Ps_Calc>(pcs1); } } dt.Rows.Add(newrow1); dt.Rows.Add(newrow2); vGridControl2.DataSource = dt; #endregion }