Exemplo n.º 1
0
        /// <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.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 (New_Flag)
            {
                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 (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);
            //}

            this.chart_user1.All_Select(true);
            RefreshChart();
        }
Exemplo n.º 2
0
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //ForecastClass fc = new ForecastClass();
            //fc.BadForecast(type, forecastReport);

            //LoadData();

            //RefreshChart();

            FormForecastLoadData2 ffs = new FormForecastLoadData2();
            ffs.PID = MIS.ProgUID;
            ffs.StartYear = forecastReport.StartYear;
            ffs.EndYear = forecastReport.YcEndYear;
            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();
        }