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; } }
/// <summary> /// 添加数据到datatable中 /// </summary> private bool AddDataToDatatable(Ps_Calc pcs) { DataRow dr; Ps_Calc _CalcTemp = new Ps_Calc(); //刷新数据 m_CalcList.Clear(); m_CalcList = m_pf.SelectedForecastList(type, forecastReport); if(m_CalcList != null && m_CalcList.Count != 0) { _CalcTemp = m_CalcList[0];//保证各个算法的时间一致 } bool _IsTrue = false; dr = dt.NewRow(); if (comboBox6.Visible) { dr["A"] = comboBox6.SelectedItem; if (bCompare(dr["A"])) { MessageBox.Show("不能用同一种算法!!!"); _IsTrue = true; } } else { dr["A"] = comboBox2.SelectedItem; if (bCompare(dr["A"])) { MessageBox.Show("不能用同一种算法!!!"); _IsTrue = true; } } pcs.ID = Guid.NewGuid().ToString(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; //算法名 pcs.CalcID = dr["A"].ToString(); pcs.Col4 = spinEdit1.Value.ToString() + "%";//权重值存放到表col4字段 //================================================================ AddYears(pcs, dr, _CalcTemp); //====================================================================================== //id dr["ID"] = pcs.ID; //权重值,把这个数据存放在数据库表中的Col4字段中 dr["D"] = pcs.Col4 ; if (!_IsTrue) { dt.Rows.Add(dr); } return _IsTrue; }
/// <summary> /// 修改历史年份和预测年份 /// </summary> /// <param name="pcs"></param> /// <param name="dr"></param> /// <param name="_CalcTemp"></param> private void AddYears_Update(Ps_Calc pcs, DataRow dr) { if (m_CalcList == null || m_CalcList.Count == 0) { pcs.Value2 = Convert.ToDouble(comboBox3.SelectedItem.ToString().Replace("年", "")); pcs.Value3 = Convert.ToDouble(comboBox5.SelectedItem.ToString().Replace("年", "")); pcs.Value4 = Convert.ToDouble(comboBox1.SelectedItem.ToString().Replace("年", "")); pcs.Value5 = Convert.ToDouble(comboBox4.SelectedItem.ToString().Replace("年", "")); //选择历史年份 dr["B"] = comboBox1.SelectedItem + "-" + comboBox4.SelectedItem; //选择预测年份 dr["C"] = comboBox3.SelectedItem + "-" + comboBox5.SelectedItem; SaveValue(pcs, false); } else { foreach (Ps_Calc m_Calc in m_CalcList) { if(dr["ID"].ToString() == m_Calc.ID) { m_Calc.Col4 = spinEdit1.Value.ToString() + "%"; } m_Calc.Value2 = Convert.ToDouble(comboBox3.SelectedItem.ToString().Replace("年", "")); m_Calc.Value3 = Convert.ToDouble(comboBox5.SelectedItem.ToString().Replace("年", "")); m_Calc.Value4 = Convert.ToDouble(comboBox1.SelectedItem.ToString().Replace("年", "")); m_Calc.Value5 = Convert.ToDouble(comboBox4.SelectedItem.ToString().Replace("年", "")); SaveValue(m_Calc, false); } } }
private void JS(int index) { //����Ԥ��ֵ int fyear = int.Parse(firstyear.Replace("y", "")); int syear = int.Parse(endyear.Replace("y", "")); int eyear = forecastReport.YcEndYear; foreach (DataRow dataRow in dataTable.Rows) { double zzl = 0; double value1 = 0; try { value1 = (double)dataRow["y" + syear]; } catch { } if (fyear != 0 && syear != 0) { if (fyear != 0 && syear != 0) { if (syear - fyear < 2) { MessageBox.Show("��ʷ��ݱ���������꣡"); return; } } double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear); Ps_Calc pcs = new Ps_Calc(); switch (index) { case 1: double[,] u = Calculator.GrayMethodAU(historyValues, eyear - syear); u[0, 0]=Math.Round(u[0,0],2); u[1, 0] = Math.Round(u[1, 0], 2); bool bl = false; foreach (Ps_Calc pc11 in list1) { if (pc11.CalcID == dataRow["ID"].ToString()) { bl = true; pc11.Value1 = u[0,0]; pc11.Value2 = u[1, 0]; Services.BaseService.Update<Ps_Calc>(pc11); } } if (!bl) { pcs.ID = Guid.NewGuid().ToString(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; pcs.CalcID = dataRow["ID"].ToString(); pcs.Value1 = u[0, 0]; pcs.Value2 = u[1, 0]; Services.BaseService.Create<Ps_Calc>(pcs); } break; case 2: double[] yn = new double[eyear - syear]; if (this.treeList1.FocusedNode !=null) { if (this.treeList1.FocusedNode["ID"].ToString() == dataRow["ID"].ToString()) { double[,] au = Calculator.GrayMethodAU(historyValues, eyear - syear); au[0, 0] = Math.Round(au[0, 0], 2); au[1, 0] = Math.Round(au[1, 0], 2); spinEdit1.Value = (decimal)au[0, 0]; spinEdit2.Value = (decimal)au[1, 0]; } } simpleButton2.Enabled = true; yn = Calculator.GrayMethod(historyValues, eyear - syear); for (int i = 1; i <= eyear - syear; i++) { dataRow["y" + (syear + i)] = yn[i - 1]; commonhelp.ResetValue(dataRow["ID"].ToString(), "y" + (syear + i)); } ForecastClass fc = new ForecastClass(); fc.MaxForecast(forecastReport, dataTable); RefreshChart(); break; } } } }
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; foreach (DataRow dataRow in dataTable.Rows) { double zzl = 0; bool bl = false; double value1 = 0; try { value1 = (double)dataRow["y" + syear]; } catch { } foreach (Ps_Calc pc11 in list1) { if (pc11.CalcID == dataRow["ID"].ToString().Trim()) { bl = true; zzl = pc11.Value1; } } if (!bl) { if (fyear != 0 && syear != 0) { double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear); zzl = 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(); pcs1.Value1 = zzl; Services.BaseService.Create<Ps_Calc>(pcs1); } } if (fyear != 0 && syear != 0) { for (int i = 1; i <= eyear - syear; i++) { dataRow["y" + (syear + i)] = value1 * Math.Pow(1 + zzl, i); } } } ForecastClass fc = new ForecastClass(); fc.MaxForecast(forecastReport, dataTable); RefreshChart(); }
private void LoadData() { checkfixedvalue(); treeList1.DataSource = null; bLoadingData = true; if (dataTable != null) { dataTable.Columns.Clear(); treeList1.Columns.Clear(); } AddFixColumn(); for (int i = forecastReport.StartYear; i <= forecastReport.YcEndYear; i++) { AddColumn(i); } 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)); OldHt.Clear(); foreach (DataRow row in dataTable.Rows) { if (!OldHt.ContainsKey(row["Title"].ToString())) { OldHt.Add(row["Title"].ToString(), row["ID"].ToString()); } } treeList1.DataSource = dataTable; treeList1.Columns["Title"].OptionsColumn.AllowEdit = false; 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 > 0) { spinEdit1.Value = (decimal)list1[0].Value1; } Application.DoEvents(); bLoadingData = false; }
private void simpleButton3_Click(object sender, EventArgs e) { if (gridView1.FocusedRowHandle < 0) { return; } if (comboBox1.SelectedItem == null || comboBox2.SelectedItem == null || comboBox3.SelectedItem == null || comboBox4.SelectedItem == null || comboBox5.SelectedItem == null || (comboBox6.SelectedItem == null && comboBox6.Visible)) { MessageBox.Show("�������ò���ȷ��"); return; } int yearselect1 = Convert.ToInt32(comboBox4.SelectedItem.ToString().Replace("��", "")); int yearselect2 = Convert.ToInt32(comboBox5.SelectedItem.ToString().Replace("��", "")); DataRowView drv = gridView1.GetRow(gridView1.FocusedRowHandle) as DataRowView; DataRow dr = drv.Row; int intex = dt.Rows.IndexOf(dr); int i = 0; foreach (DataRow ndr in dt.Rows) { int year1 = Convert.ToInt32(ndr["C"].ToString().Split('-')[0].Replace("��", "")); int year2 = Convert.ToInt32(ndr["C"].ToString().Split('-')[1].Replace("��", "")); if ((!(yearselect1 > year2 || year1 > yearselect2)) && i != intex) { MessageBox.Show("��ѡ��ݰ�����" + ndr["C"]); return; } i++; } if (comboBox6.Visible) dt.Rows[intex]["A"] = comboBox6.SelectedItem; else dt.Rows[intex]["A"] = comboBox1.SelectedItem; dt.Rows[intex]["B"] = comboBox2.SelectedItem + "-" + comboBox3.SelectedItem; dt.Rows[intex]["C"] = comboBox4.SelectedItem + "-" + comboBox5.SelectedItem; Ps_Calc pcs = new Ps_Calc(); pcs.ID = dt.Rows[intex]["ID"].ToString(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; pcs.CalcID = dr["A"].ToString(); pcs.Value2 = Convert.ToDouble(comboBox4.SelectedItem.ToString().Replace("��", "")); pcs.Value3 = Convert.ToDouble(comboBox5.SelectedItem.ToString().Replace("��", "")); pcs.Value4 = Convert.ToDouble(comboBox2.SelectedItem.ToString().Replace("��", "")); pcs.Value5 = Convert.ToDouble(comboBox3.SelectedItem.ToString().Replace("��", "")); savevalue(pcs, false); gridView1.RefreshData(); }
private void savevalue(Ps_Calc pc11,bool iscreat) { if(!iscreat) { Services.BaseService.Update<Ps_Calc>(pc11); } else { //Ps_Calc pcs = new Ps_Calc(); //pcs.ID = Guid.NewGuid().ToString(); //pcs.Forecast = type; //pcs.ForecastID = forecastReport.ID; //pcs.CalcID = title; Services.BaseService.Create<Ps_Calc>(pc11); } }
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 JS2() { if (firstyear == "0" || endyear == "0") { MsgBox.Show("��������ʷ������ʼ���������ٵ��������"); return; } //����Ԥ��ֵ Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; IList<Ps_Calc> list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecastCalcID", pcs); int fyear = 0; int syear = 0; int eyear = 0; foreach (DataRow dataRow in dataTable.Rows) { syear = 0; eyear = 0; double zzl = 0; bool bl = false; double value1 = 0; //try { value1 = (double)dataRow["y" + syear]; } //catch { } pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; pcs.CalcID = dataRow["ID"].ToString().Trim(); list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByWhere", "Forecast = '" + type + "' and ForecastID ='"+ forecastReport.ID+"' and CalcID = '"+ dataRow["ID"].ToString().Trim()+"' order by Value2"); foreach (Ps_Calc pc11 in list1) { //if (pc11.CalcID == dataRow["ID"].ToString().Trim()) //{ bl = true; zzl = pc11.Value4; syear = Convert.ToInt32(pc11.Value2); eyear = Convert.ToInt32(pc11.Value3); //} //else // continue; //if (!bl) //{ // if (fyear != 0 && syear != 0) // { // double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear); // zzl = 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(); // pcs1.Value1 = zzl; // pcs.Value2 = Convert.ToDouble(comboBox4.SelectedItem.ToString().Replace("��", "")); // pcs.Value3 = Convert.ToDouble(comboBox5.SelectedItem.ToString().Replace("��", "")); // pcs.Value4 = Convert.ToDouble(dr["B"].ToString().Replace("%", "")); // pcs.Col1 = comboBox1.SelectedItem.ToString(); // Services.BaseService.Create<Ps_Calc>(pcs1); // } //} if (syear != 0 && eyear != 0) { for (int i = syear; i <= eyear; i++) { try { value1 = (double)dataRow["y" + (i-1 )]; } catch { } dataRow["y" + i] = value1 *(1 +zzl*0.01); } } } if (!bl) { if (firstyear != "0" && endyear != "0") { double value2 = 0; syear = Convert.ToInt32(endyear.Replace("y", "")); eyear = Convert.ToInt32(forecastReport.EndYear) - 1; double[] historyValues = GenerateHistoryValue(dataRow, Convert.ToInt32(firstyear.Replace("y", "")), syear); zzl = Math.Round(Calculator.AverageIncreasing(historyValues) * 100, 2); Ps_Calc pcs1 = new Ps_Calc(); pcs1.ID = Guid.NewGuid().ToString(); pcs1.Forecast = type; pcs1.ForecastID = forecastReport.ID; pcs1.CalcID = dataRow["ID"].ToString(); pcs1.Col1 = dataRow["Title"].ToString(); pcs1.Value2 = Convert.ToInt32(endyear.Replace("y", ""))+1; pcs1.Value3 = Convert.ToInt32(forecastReport.EndYear); pcs1.Value4 = zzl; Services.BaseService.Create<Ps_Calc>(pcs1); for (int i = syear; i <= eyear; i++) { try { value1 = (double)dataRow["y" + (i-1)]; } catch { } dataRow["y" + i ] = value1 * (1 + zzl * 0.01); } } } ForecastClass fc = new ForecastClass(); fc.MaxForecast(forecastReport, dataTable); RefreshChart(); treeList1.Refresh(); } }
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; }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleButton2_Click(object sender, EventArgs e) { if (gridView1.FocusedRowHandle < 0) { return; } Ps_Calc pcs = new Ps_Calc(); //if (m_pf.DecideDataAddin_comboBox(comboBox2)) //{ // return; //} //if (m_pf.DecideDataAddin_comboBox(comboBox6)) //{ // return; //} if (m_pf.DecideDataAddin_comboBox(comboBox1)) { return; } if (m_pf.DecideDataAddin_comboBox(comboBox4)) { return; } if (m_pf.DecideDataAddin_comboBox(comboBox3)) { return; } if (m_pf.DecideDataAddin_comboBox(comboBox5)) { return; } if (m_pf.DecideDataAddin_SpinEdit(spinEdit1)) { return; } //刷新数据 m_CalcList.Clear(); m_CalcList = m_pf.SelectedForecastList(type, forecastReport); AddToDataRow_Update(pcs); ////重新刷新grid InitGridControl(); }
/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleButton1_Click(object sender, EventArgs e) { Ps_Calc pcs = new Ps_Calc(); if(m_pf.DecideDataAddin_comboBox(comboBox2)) { return; } if(m_pf.DecideDataAddin_comboBox(comboBox6)) { return; } if(m_pf.DecideDataAddin_comboBox(comboBox1)) { return; } if(m_pf.DecideDataAddin_comboBox(comboBox4)) { return; } if(m_pf.DecideDataAddin_comboBox(comboBox3)) { return; } if(m_pf.DecideDataAddin_comboBox(comboBox5)) { return; } if(m_pf.DecideDataAddin_SpinEdit(spinEdit1)) { return; } AddToDataRow(); if(AddDataToDatatable(pcs)) { return; } SaveValue(pcs, true); //清空spinEdit spinEdit1.Value = 0; spinEdit3.Value = 1; }
/// <summary> /// 保存数据 /// </summary> /// <param name="_Calc"></param> /// <param name="_bCreate">true is create ,false is update</param> private void SaveValue(Ps_Calc _Calc, bool _bCreate) { if(!_bCreate) { //Common.Services.BaseService.GetObject("UpdatePs_CalcWhereID", _Calc); Common.Services.BaseService.Update("UpdatePs_CalcWhereID", _Calc); } else { Common.Services.BaseService.Create<Ps_Calc>(_Calc); } }
/// <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() == "指数平滑法") { SetSubalgorithm(false); Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = 5; pcs.ForecastID = forecastReport.ID; //IList<Ps_Calc> list1 = m_pf.SelectedForecastList(5, forecastReport); IList<Ps_Calc> list1 = Common.Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs); if (list1.Count < 1) { MessageBox.Show("平滑参数未设置,将按默认值0.1计算"); } } 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); } }
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 FormForecastCalc9Third_Load(object sender, EventArgs e) { dt.Columns.Clear(); comboBox1.Items.Add("�������ʷ�"); comboBox1.Items.Add("����ϵ����"); comboBox1.Items.Add("��ط�"); comboBox1.Items.Add("��ɫģ�ͷ�"); comboBox1.Items.Add("���Ʒ�"); comboBox1.Items.Add("ָ��ƽ����"); comboBox1.Items.Add("ר�Ҿ��߷�"); comboBox6.Items.Add("���Ʒ�(�������ʷ�)"); comboBox6.Items.Add("���Ʒ�(ֱ��)"); comboBox6.Items.Add("���Ʒ�(������)"); comboBox6.Items.Add("���Ʒ�(����)"); comboBox6.Items.Add("���Ʒ�(ָ��)"); comboBox6.Items.Add("���Ʒ�(��������)"); dt.Columns.Add("A", typeof(string)); dt.Columns.Add("B", typeof(string)); dt.Columns.Add("C", typeof(string)); dt.Columns.Add("ID", typeof(string)); Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs); DataRow dr; for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { comboBox2.Items.Add(i + "��"); comboBox3.Items.Add(i + "��"); comboBox4.Items.Add(i + "��"); comboBox5.Items.Add(i + "��"); } foreach (Ps_Calc pcs2 in list1) { dr = dt.NewRow(); dr["id"] = pcs2.ID; dr["A"] = pcs2.CalcID; if (pcs2.Value5 != 0 && pcs2.Value4!=0) { dr["B"] = pcs2.Value4 + "��-" + pcs2.Value5 + "��"; } else { continue; } if (pcs2.Value2 != 0 && pcs2.Value3 != 0) { dr["C"] = pcs2.Value2 + "��-" + pcs2.Value3 + "��"; } else { continue; } dt.Rows.Add(dr); } //dt= // GetSortTable(ref dt, "C", true); gridControl1.DataSource = dt; }
private void FormForecastCalc1Third_Load(object sender, EventArgs e) { dt.Columns.Clear(); dt.Columns.Add("A", typeof(string)); dt.Columns.Add("B", typeof(string)); dt.Columns.Add("CalcID", typeof(string)); dt.Columns.Add("C", typeof(string)); dt.Columns.Add("ID", typeof(string)); Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs); for (int i =endyear+1; i <= forecastReport.EndYear; i++) { comboBox4.Items.Add(i + "年"); comboBox5.Items.Add(i + "年"); } foreach (DataRow dr2 in dataTable.Rows) { comboBox1.Items.Add(dr2["Title"]); comboBox2.Items.Add(dr2["ID"]); } DataRow dr; foreach (Ps_Calc pcs2 in list1) { dr = dt.NewRow(); dr["ID"] = pcs2.ID; dr["A"] = pcs2.Col1; dr["B"] = pcs2.Value4+"%"; dr["CalcID"] = pcs2.CalcID; if (pcs2.Value2 != 0 && pcs2.Value3 != 0 && (!(pcs2.Value2 < endyear || pcs2.Value3 > forecastReport.EndYear)) && comboBox1.Items.IndexOf(pcs2.Col1) > -1 && (comboBox1.Items.IndexOf(pcs2.Col1) == comboBox2.Items.IndexOf(pcs2.CalcID))) { dr["C"] = pcs2.Value2 + "年-" + pcs2.Value3 + "年"; } else { continue; } dt.Rows.Add(dr); } dt=GetSortTable( dt, "A,C", true); gridControl1.DataSource = dt; }
private void simpleButton2_Click_1(object sender, EventArgs e) { if (gridView1.FocusedRowHandle < 0) { return; } int i = gridView1.FocusedRowHandle; //gridView1.FocusedRowHandle = -1; DataRowView drv = gridView1.GetRow(i) as DataRowView; if (drv == null) { MessageBox.Show("ɾ��ʧ�ܣ�"); gridView1.RefreshData(); return; } Ps_Calc pcs = new Ps_Calc(); pcs.ID = drv.Row["ID"].ToString(); pcs = Services.BaseService.GetOneByKey<Ps_Calc>(pcs); if (pcs != null) Services.BaseService.Delete<Ps_Calc>(pcs); else { MessageBox.Show("ɾ��ʧ��!"); gridView1.RefreshData(); return; } dt.Rows.Remove(drv.Row); gridView1.RefreshData(); }
private void simpleButton1_Click(object sender, EventArgs e) { if (gridView1.FocusedRowHandle < 0) { return; } if (comboBox4.SelectedItem == null || comboBox5.SelectedItem == null) { MessageBox.Show("参数设置不正确!"); return; } int yearselect1 = Convert.ToInt32(comboBox4.SelectedItem.ToString().Replace("年", "")); int yearselect2 = Convert.ToInt32(comboBox5.SelectedItem.ToString().Replace("年", "")); string strname = comboBox1.SelectedItem.ToString(); DataRowView drv = gridView1.GetRow(gridView1.FocusedRowHandle) as DataRowView; DataRow dr = drv.Row; int intex = dt.Rows.IndexOf(dr); int i = 0; foreach (DataRow ndr in dt.Rows) { if (strname != ndr["A"].ToString()) { i++; continue; } int year1 = Convert.ToInt32(ndr["C"].ToString().Split('-')[0].Replace("年", "")); int year2 = Convert.ToInt32(ndr["C"].ToString().Split('-')[1].Replace("年", "")); if ((!(yearselect1 > year2 || year1 > yearselect2)) && i != intex) { MessageBox.Show(ndr["A"] + "的" + "所选年份包含在" + ndr["C"]); return; } i++; } dt.Rows[intex]["B"] = spinEdit2.Value + "%"; dt.Rows[intex]["C"] = comboBox4.SelectedItem + "-" + comboBox5.SelectedItem; Ps_Calc pcs = new Ps_Calc(); pcs.ID = dt.Rows[intex]["ID"].ToString(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; pcs.CalcID = comboBox2.SelectedItem.ToString(); pcs.Value2 = Convert.ToDouble(comboBox4.SelectedItem.ToString().Replace("年", "")); pcs.Value3 = Convert.ToDouble(comboBox5.SelectedItem.ToString().Replace("年", "")); pcs.Value4 = Convert.ToDouble(dr["B"].ToString().Replace("%", "")); pcs.Col1 = comboBox1.SelectedItem.ToString(); dt.Rows[intex]["ID"] = pcs.ID; dt.Rows[intex]["CalcID"] = pcs.CalcID; dt.Rows[intex]["A"] = pcs.Col1; savevalue(pcs, false); gridView1.RefreshData(); }
private void simpleButton4_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem == null || comboBox2.SelectedItem == null || comboBox3.SelectedItem == null || comboBox4.SelectedItem == null || comboBox5.SelectedItem == null || (comboBox6.SelectedItem == null && comboBox6.Visible)) { MessageBox.Show("�������ò���ȷ��"); return; } int yearselect1 = Convert.ToInt32(comboBox4.SelectedItem.ToString().Replace("��", "")); int yearselect2 = Convert.ToInt32(comboBox5.SelectedItem.ToString().Replace("��", "")); foreach (DataRow ndr in dt.Rows) { int year1 = Convert.ToInt32(ndr["C"].ToString().Split('-')[0].Replace("��", "")); int year2 = Convert.ToInt32(ndr["C"].ToString().Split('-')[1].Replace("��", "")); if (!(yearselect1 > year2 || year1 > yearselect2)) { MessageBox.Show("��ѡ��ݰ�����" + ndr["C"]); return; } } DataRow dr; dr = dt.NewRow(); if (comboBox6.Visible) dr["A"] = comboBox6.SelectedItem; else dr["A"] = comboBox1.SelectedItem; Ps_Calc pcs = new Ps_Calc(); pcs.ID = Guid.NewGuid().ToString(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; pcs.CalcID = dr["A"].ToString(); pcs.Value2 = Convert.ToDouble(comboBox4.SelectedItem.ToString().Replace("��", "")); pcs.Value3 = Convert.ToDouble(comboBox5.SelectedItem.ToString().Replace("��", "")); pcs.Value4 = Convert.ToDouble(comboBox2.SelectedItem.ToString().Replace("��", "")); pcs.Value5 = Convert.ToDouble(comboBox3.SelectedItem.ToString().Replace("��", "")); dr["B"] = comboBox2.SelectedItem + "-" + comboBox3.SelectedItem; dr["C"] = comboBox4.SelectedItem + "-" + comboBox5.SelectedItem; dr["ID"] = pcs.ID; dt.Rows.Add(dr); savevalue(pcs, true); comboBox2.SelectedIndex = -1; comboBox3.SelectedIndex = -1; comboBox4.SelectedIndex = -1; comboBox5.SelectedIndex = -1; }
private void simpleButton2_Click_1(object sender, EventArgs e) { if (comboBox1.SelectedItem == null || comboBox4.SelectedItem == null || comboBox5.SelectedItem == null) { MessageBox.Show("参数设置不正确!"); return; } int yearselect1 = Convert.ToInt32(comboBox4.SelectedItem.ToString().Replace("年", "")); int yearselect2 = Convert.ToInt32(comboBox5.SelectedItem.ToString().Replace("年", "")); string strname = comboBox1.SelectedItem.ToString(); foreach (DataRow ndr in dt.Rows) { if (strname != ndr["A"].ToString()) continue; int year1 = Convert.ToInt32(ndr["C"].ToString().Split('-')[0].Replace("年", "")); int year2 = Convert.ToInt32(ndr["C"].ToString().Split('-')[1].Replace("年", "")); if (!(yearselect1 > year2 || year1 > yearselect2)) { MessageBox.Show(ndr["A"] + "的" + "所选年份包含在" + ndr["C"]); return; } } DataRow dr; dr = dt.NewRow(); dr["B"] = spinEdit2.Value + "%"; ; Ps_Calc pcs = new Ps_Calc(); pcs.ID = Guid.NewGuid().ToString(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; pcs.CalcID = comboBox2.SelectedItem.ToString(); pcs.Value2 = Convert.ToDouble(comboBox4.SelectedItem.ToString().Replace("年", "")); pcs.Value3 = Convert.ToDouble(comboBox5.SelectedItem.ToString().Replace("年", "")); pcs.Value4 = Convert.ToDouble(dr["B"].ToString().Replace("%", "")); pcs.Col1 = comboBox1.SelectedItem.ToString(); dr["C"] = comboBox4.SelectedItem + "-" + comboBox5.SelectedItem; dr["ID"] = pcs.ID; dr["CalcID"] = pcs.CalcID; dr["A"] = pcs.Col1; dt.Rows.Add(dr); savevalue(pcs, true); comboBox4.SelectedIndex = -1; comboBox5.SelectedIndex = -1; }
private void CS() { 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 > 0) { list1[0].Value1 =Convert.ToDouble(spinEdit1.Value); Services.BaseService.Update<Ps_Calc>(list1[0]); } else { Ps_Calc pc = new Ps_Calc(); pc.ID = Guid.NewGuid().ToString(); pc.Forecast = 5; pc.ForecastID = forecastReport.ID; pc.Value1 = Convert.ToDouble(spinEdit1.Value); Services.BaseService.Create<Ps_Calc>(pc); } }
//����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(); } }
private void LoadData() { this.splitContainerControl1.SplitterPosition = (2 * this.splitterControl1.Width) / 3; this.splitContainerControl2.SplitterPosition = splitContainerControl2.Height / 2; treeList1.DataSource = null; bLoadingData = true; if (dataTable != null) { dataTable.Columns.Clear(); treeList1.Columns.Clear(); } AddFixColumn(); for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { AddColumn(i); } 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)); treeList1.DataSource = dataTable; treeList1.Columns["Title"].OptionsColumn.AllowEdit = false; 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 > 0) { spinEdit1.Value = (decimal)list1[0].Value1; } Application.DoEvents(); bLoadingData = 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.YcEndYear; foreach (DataRow dataRow in dataTable.Rows) { if (dataRow["Title"].ToString().Contains("ȫ����GDP")) { continue; } double[] yn = new double[eyear - syear]; if (fyear != 0 && syear != 0) { // Calculator.StartYear = fyear; Calculator.StartYear = syear; Calculator.Type = type.ToString(); double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear); yn = Calculator.SpringCoefficientMethod((double)dataRow["y" + (syear)], eyear - syear, forecastReport.ID); for (int i = 1; i <= eyear - syear; i++) { dataRow["y" + (syear + i)] = yn[i - 1]; commonhelp.ResetValue(dataRow["ID"].ToString(), "y" + (syear + i)); } } } ForecastClass fc = new ForecastClass(); fc.MaxForecast(forecastReport, dataTable); RefreshChart(); }
private void simpleButton1_Click(object sender, EventArgs e) { Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; pcs =(Ps_Calc) Services.BaseService.GetObject("SelectPs_CalcByForecast", pcs); if (pcs!=null) { pcs.Value1 = Convert.ToDouble(spinEdit1.Value); Services.BaseService.Update<Ps_Calc>(pcs); } else { pcs = new Ps_Calc(); pcs.ID = System.Guid.NewGuid().ToString(); pcs.Forecast=type; pcs.ForecastID = forecastReport.ID; pcs.Value1 =Convert.ToDouble(spinEdit1.Value) ; Services.BaseService.Create<Ps_Calc>(pcs); } }
private void simpleButton1_Click(object sender, EventArgs e) { int i = 1; foreach (DataColumn dc in dt.Columns) { if (dc.ColumnName == "Name" || dc.ColumnName == "ID" || Convert.ToInt32(dc.ColumnName)<=endyear) continue; double value1 = 0; //double value2 = 0; try { value1 = (double)newrow1[dc.ColumnName]; //value2 = (double)newrow2[dc.ColumnName]; } catch { } bool bl = false; foreach (Ps_Calc pc11 in list1) { if (pc11.Year == Convert.ToInt32( dc.ColumnName)) { bl = true; pc11.Value1 = value1; //pc11.Value2 = value2; Services.BaseService.Update<Ps_Calc>(pc11); } } if (!bl) { Ps_Calc pcs = new Ps_Calc(); pcs.ID = Guid.NewGuid().ToString(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; pcs.Year = Convert.ToInt32(dc.ColumnName); pcs.Value1 = value1; //pcs.Value2 = value2; Services.BaseService.Create<Ps_Calc>(pcs); } } this.DialogResult = DialogResult.OK; }
/// <summary> /// 查找算法模型 /// </summary> /// <param name="forecastReport">Ps_forecast_list对象</param> /// <param name="type">类型</param> /// <returns></returns> public IList<Ps_Calc> SelectedForecastList(int type, Ps_forecast_list forecastReport) { IList<Ps_Calc> _CalcList = new List<Ps_Calc>(); //string sql = " Forecast = '" +forecastReport.ID+"' and Forecast = '"+ type + // "' and Col4 != ''"; if(type != null && forecastReport != null) { Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; _CalcList = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcOfCol4", pcs); return _CalcList; } else { return _CalcList; } }
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; }