private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FormForecastLoadData ffs = new FormForecastLoadData(); // ffs.Type = type; ffs.PID = pid; 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 = 0; 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 = 0; 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='0' 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 = 0; 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(); //ArrayList al = M1(); //for (int i = 0; i < al.Count; i++) //{ // TreeListNode tlnn = (TreeListNode)al[i]; // aaa(tlnn); //} RefreshChart(); }
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(); } } }