Example #1
0
        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();
        }
Example #2
0
        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.YcEndYear;

            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);
                        commonhelp.ResetValue(dataRow["ID"].ToString(), "y" + (syear + i));
                    }
                }

            }
            ForecastClass fc = new ForecastClass();
            fc.MaxForecast(forecastReport, dataTable);
            RefreshChart();
        }
        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 JS(int index)
        {
            //计算预测值

            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 { }



                if (fyear != 0 && syear != 0)
                {
                    double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear);
                    double[] yn            = new double[eyear - syear];
                    int      M             = syear - fyear;
                    double[] yn1           = new double[M];

                    double M1 = 0;
                    double M2 = 0;
                    double M3 = 0;
                    double M4 = 0;

                    switch (index)
                    {
                    case 1:
                        yn  = Calculator.One(historyValues, eyear - syear, ref M1, ref M2);
                        yn1 = Calculator.One1(M, M1, M2);
                        break;

                    case 2:
                        yn = Calculator.Second(historyValues, eyear - syear, ref M1, ref M2, ref M3);

                        yn1 = Calculator.Second1(M, M1, M2, M3);

                        break;

                    case 3:
                        yn  = Calculator.Three(historyValues, eyear - syear, ref M1, ref M2, ref M3, ref M4);
                        yn1 = Calculator.Three1(M, M1, M2, M3, M4);
                        break;

                    case 4:
                        yn  = Calculator.Index(historyValues, eyear - syear, ref M1, ref M2);
                        yn1 = Calculator.Index1(M, M1, M2);
                        break;

                    case 5:
                        yn  = Calculator.LOG(historyValues, eyear - syear, ref M1, ref M2);
                        yn1 = Calculator.LOG1(M, M1, M2);
                        break;
                    }
                    if (M1 == -999999 && M2 == -999999)
                    {
                        MsgBox.Show("此算法模拟失败,方程无解");
                        break;
                    }

                    for (int i = 1; i <= eyear - syear; i++)
                    {
                        dataRow["y" + (syear + i)] = yn[i - 1];
                    }
                    double n  = 0;
                    double n1 = 0;
                    double n2 = 0;
                    for (int j = 0; j < yn1.Length; j++)
                    {
                        try { n1 = yn1[j]; }
                        catch { }
                        try { n2 = (double)dataRow["y" + (fyear + j)]; }
                        catch { }

                        n += (n2 - n1) * (n2 - n1);
                    }
                    dataRow["N2"] = n;
                }
            }


            ForecastClass fc = new ForecastClass();

            fc.MaxForecast(forecastReport, dataTable);
            RefreshChart();
        }
        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;
                bool bl = false;
                double value1 = 0;
                try { value1 = (double)dataRow["y" + syear]; }
                catch { }

                if (fyear != 0 && syear != 0)
                {
                    double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear);
                    double[] yn = new double[eyear - syear];
                    int M=syear - fyear;
                    double[] yn1 = new double[M];

                    double M1 = 0;
                    double M2 = 0;
                    double M3 = 0;
                    double M4 = 0;

                    switch (index)
                    {
                        case 1:
                            yn = Calculator.One(historyValues, eyear - syear,ref M1,ref M2);
                            yn1 = Calculator.One1(M, M1, M2);
                            break;
                        case 2:
                            yn = Calculator.Second(historyValues, eyear - syear, ref M1, ref M2, ref M3);

                            yn1 = Calculator.Second1(M, M1, M2,M3);

                            break;
                        case 3:
                            yn = Calculator.Three(historyValues, eyear - syear, ref M1, ref M2, ref M3, ref M4);
                            yn1 = Calculator.Three1(M, M1, M2, M3,M4);
                            break;
                        case 4:
                            yn = Calculator.Index(historyValues, eyear - syear, ref M1, ref M2);
                            yn1 = Calculator.Index1(M, M1, M2);
                            break;
                        case 5:
                            yn = Calculator.LOG(historyValues, eyear - syear, ref M1, ref M2);
                            yn1 = Calculator.LOG1(M, M1, M2);
                            break;

                    }
                    if (M1 == -999999 && M2 == -999999 )
                    {
                        MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                        break;
                    }

                    for (int i = 1; i <= eyear - syear; i++)
                    {
                        dataRow["y" + (syear + i)] = yn[i - 1];

                        commonhelp.ResetValue(dataRow["ID"].ToString(), "y" + (syear + i));
                    }
                    double n = 0;
                    double n1 =0;
                    double n2=0;
                    for (int j = 0; j < yn1.Length; j++)
                    {
                        try { n1 = yn1[j]; }
                        catch { }
                        try { n2 = (double)dataRow["y" + (fyear + j)]; }
                        catch { }

                        n += (n2 - n1) * (n2 - n1);
                    }
                    dataRow["N2"] = n;
                }
            }

            ForecastClass fc = new ForecastClass();
            fc.MaxForecast(forecastReport, dataTable);
            RefreshChart();
        }
Example #7
0
        private void JS(int index)
        {
            //计算预测值

            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;

                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];
                        //double[] au = new double[2];
                        // pcs = new Ps_Calc();
                        //pcs.Forecast = type;
                        //pcs.ForecastID = forecastReport.ID;
                        //pcs.CalcID=dataRow["ID"].ToString();

                        //pcs = (Ps_Calc)Services.BaseService.GetObject("SelectPs_CalcByForecastCalcID", pcs);
                        //au[0] = pcs.Value1;
                        //au[1] = pcs.Value2;
                        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];
                        }
                        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 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 (TreeListNode tln in treeList1.Nodes)
            {
                int nodecount=tln.Nodes.Count;
                if (nodecount == 0)
                    continue;

                int x1= syear - fyear + 1;
                int x2 = eyear - syear;
                int y1=nodecount + 1;

                double[,] B = new double[x1, y1];
                double[,] Y = new double[x1, 1];
                double[,] BT = new double[y1, x1];
                double[,] BTBTBT = new double[y1, 1];

                double[,] X = new double[x2, y1];
                //double[,] Y1 = new double[x2, 1];

                for (int i = 0; i <= eyear - fyear; i++)
                {

                    int k = 1;
                    if (i <= syear - fyear)
                    Y[i, 0] = (double)tln["y" + (fyear + i)];
                    foreach (TreeListNode tln1 in tln.Nodes)
                    {
                        if (i <= syear - fyear)
                        {
                            B[i, 0] = 1;
                            B[i, k] = (double)tln1["y" + (fyear + i)];
                            k++;
                        }
                        else
                        {
                            int m = i -1- (syear - fyear);
                            X[m, 0] = 1;
                            X[m, k] = (double)tln1["y" + (fyear + i)];
                            k++;

                        }

                    }

                }

                //�������B��Ϊ����Y��ת�Ⱦ���BT��ֵ
                for (int i = 0; i < x1; i++)
                {
                    for (int j = 0; j < y1; j++)
                    BT[j, i] = B[i, j] ;
                }
                //BT*B�Ľ��
                double[,] BTB = Calculator.MultiplyMatrix(BT, B);
                //BTB�������
                try
                {
                    double[,] BTBInverse = Calculator.InverseMatrix(BTB);

                    //BTB�������*BT
                    double[,] BTBT = Calculator.MultiplyMatrix(BTBInverse, BT);

                    //BTB�������*BT
                    BTBTBT = Calculator.MultiplyMatrix(BTBT, Y);

                    double[,] Y1 = Calculator.MultiplyMatrix(X, BTBTBT);

                    if (fyear != 0 && syear != 0)
                    {
                        for (int i = 1; i <= eyear - syear; i++)
                        {
                            tln["y" + (syear + i)] = Y1[i - 1, 0];
                        }
                    }
                   // MessageBox.Show("��������ɣ��鿴������ѡ��������㷨");
                }
                catch(System.Exception error)
                {
                    return;
                }
            }

            //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();
        }
        /// <summary>
        /// 计算2
        /// </summary>
        private void Calc2()
        {
            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)
                {

                    bl = true;

                    zzl = pc11.Value4;
                    syear = Convert.ToInt32(pc11.Value2);
                    eyear = Convert.ToInt32(pc11.Value3);

                    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);

                            commonhelp.ResetValue(dataRow["ID"].ToString(), "y" + i);
                        }

                    }

                }
                if (!bl)
                {
                    try
                    {
                        if (firstyear != "0" && endyear != "0")
                        {
                            double value2 = 0;
                            syear = Convert.ToInt32(endyear.Replace("y", ""));
                            eyear = Convert.ToInt32(forecastReport.YcEndYear);
                            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.YcEndYear);
                            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);

                                commonhelp.ResetValue(dataRow["ID"].ToString(), "y" + i);
                            }
                        }
                    }
                    catch (System.Exception e)
                    {
                        MessageBox.Show(e.Source + e.Message);
                    }

                }
                ForecastClass fc = new ForecastClass();
                fc.MaxForecast(forecastReport, dataTable);
                RefreshChart();
                treeList1.Refresh();
            }
        }