Exemplo n.º 1
0
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // 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 = Guid.NewGuid().ToString();
            //    psp_Type.Forecast = type;
            //    Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type);
            //}

            ForecastClass fc = new ForecastClass();

            fc.BadForecast(type, forecastReport);

            LoadData();

            RefreshChart();
        }
Exemplo n.º 2
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.EndYear;

            foreach (DataRow dataRow in dataTable.Rows)
            {
                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];
                    }
                }
            }


            ForecastClass fc = new ForecastClass();

            fc.MaxForecast(forecastReport, dataTable);
            RefreshChart();
        }
Exemplo n.º 3
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.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();
        }
Exemplo n.º 4
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;
                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();
        }
Exemplo n.º 5
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.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();
        }
Exemplo n.º 6
0
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // 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 = Guid.NewGuid().ToString();
            //    psp_Type.Forecast = type;
            //    Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type);
            //}

            ForecastClass fc = new ForecastClass();
            fc.BadForecast(type, forecastReport);

            LoadData();

            RefreshChart();
        }
Exemplo n.º 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;
                    }
                }
            }
        }
Exemplo n.º 8
0
        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();
            }
        }
Exemplo n.º 9
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.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的逆矩阵
                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];
                    }
                }
            }


            //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();
        }
Exemplo n.º 10
0
        /// <summary>
        /// ���µ�Ԥ��ֵ������������Ԥ�⡱�еġ��������á�����
        /// </summary>
        private void CalcPredictedValue()
        {
            Ps_Calc pcs = new Ps_Calc();

            IList<Ps_Calc> list1;

            //Ȩ��ֵ
            string m_StrWeightedValue = "";
            double m_nWeightedValue = 0.0;

            //��ʱ��ż���õ�ÿ��Ԥ������,����TempData[1,0],һά��������Щ�㷨����ά��ÿ���㷨����Щ�������
            //
            double[,] TempData = null;
            ////��ʷ���
            //string strHYears = ha[0].ToString().Split('@')[1];
            ////��ʷ��ݵ���ʼ��
            //int nHYears = Convert.ToInt32(strHYears.Split('-')[0].ToString());

            //Ԥ�����
            string strFYears = ha[0].ToString().Split('@')[2];
            //Ԥ����ݵĽ�����
            int nFYears = Convert.ToInt32(strFYears.Split('-')[1].ToString());

            int syear = Convert.ToInt32(strFYears.Split('-')[0].ToString()); ;
            int eyear = forecastReport.EndYear;
            TempData = new double[(ha.Count), (eyear - syear + 1)];
            //��ʷ��ݵ���ʼ��
            int histsyear = 0;
            //��ʷ��ݵĽ�����
            int histeyear = 0;
            if (ha == null)
                return;
            if (ha.Count < 1)
                return;
            bool isfalse = false;
            IList<Ps_Forecast_Math> list = new List<Ps_Forecast_Math>();
            Ps_Forecast_Math psmtemp = new Ps_Forecast_Math();
            foreach (DataRow dataRow in dataTable.Rows)
            {
                //if (fyear != 0 && syear != 0)
                //{
                //   double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear);
                //     double[] yn = new double[eyear - syear];

                int m_Index = 0;//TempData��һά�±�
                for (int intextemp = 0; intextemp < ha.Count; intextemp++)
                {
                    string index = ha[intextemp].ToString();
                    string name = index.Split('@')[0];
                    string strhistyear = index.Split('@')[1];
                    string strforecastyear = index.Split('@')[2];
                    //Ȩ��ֵ
                    m_StrWeightedValue = index.Split('@')[3];
                    m_nWeightedValue = Convert.ToDouble(m_StrWeightedValue.Split('%')[0].ToString());
                    //��ʷ��ݵ���ʼ��
                    histsyear = Convert.ToInt32(strhistyear.Split('-')[0].ToString());
                    //��ʷ��ݵĽ�����
                    histeyear = Convert.ToInt32(strhistyear.Split('-')[1].ToString());
                    //Ԥ����ݵĽ�����
                    syear = Convert.ToInt32(strforecastyear.Split('-')[0].ToString());

                    //eyear = Convert.ToInt32(strforecastyear.Split('-')[1].ToString());

                    double[] yn = new double[eyear - syear + 1];
                    double zzl = 0;
                    bool bl = false;
                    double value1 = 0;
                    try { value1 = (double)dataRow["y" + histeyear]; }
                    catch { }
                    int M = histeyear - histsyear;
                    double[] yn1 = new double[M];

                    double M1 = 0;
                    double M2 = 0;
                    double M3 = 0;
                    double M4 = 0;
                    double[] historyValues = GenerateHistoryValue(dataRow, histsyear, histeyear);

                    switch (name)
                    {
                        case "���Ʒ�(�������ʷ�)":
                        case "�������ʷ�":
                            //�������������
                            //zzl = Calculator.AverageIncreasing(historyValues);
                            try
                            {
                                zzl = Math.Round(Calculator.AverageIncreasing(historyValues) * 100, 2);
                            }
                            catch (System.Exception e)
                            {

                            }
                            if (syear != 0 && eyear != 0)
                            {
                                for (int i = 1; i <= eyear - syear + 1; i++)
                                {
                                    //pcs = new Ps_Calc();
                                    //pcs.Forecast = 1;
                                    //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 (syear + i - 1 >= pc11.Value2 && syear + i - 1 <= pc11.Value3)
                                    //    {
                                    //        zzl = pc11.Value4;
                                    //    }

                                    //}
                                    try {
                                            if(i==1)
                                            {
                                                value1 = (double)dataRow["y" + (i + syear - 2)];
                                                TempData[m_Index, (i - 1)] = 0;
                                                TempData[m_Index, (i - 1)] = value1 * (1 + zzl * 0.01) * (m_nWeightedValue / 100);
                                            }
                                            else
                                            {
                                                value1 = TempData[m_Index, (i - 2)];
                                                TempData[m_Index, (i - 1)] = 0;
                                                TempData[m_Index, (i - 1)] = value1 * (1 + zzl * 0.01) ;
                                            }
                                        }
                                    catch { }
                                        //dataRow["y" + (syear + i - 1)] = value1 * Math.Pow(1 + zzl, i);

                                }
                            }

                            break;

                        case "���Ʒ�(ֱ��)":
                        case "��ط�(ֱ��)":
                            try
                            {
                                yn = Calculator.One(historyValues, eyear - syear + 1, ref M1, ref M2);
                                yn1 = Calculator.One1(M, M1, M2);
                            }
                            catch (System.Exception e)
                            {

                            }
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                //dataRow["y" + (syear + i - 1)] = yn[i - 1];
                                TempData[m_Index, (i - 1)] = 0;
                                TempData[m_Index, (i - 1)] = yn[i - 1] * (m_nWeightedValue / 100);
                            }
                            break;
                        case "���Ʒ�(������)":
                        case "��ط�(������)":
                            try
                            {
                                yn = Calculator.Second(historyValues, eyear - syear + 1, ref M1, ref M2, ref M3);
                                yn1 = Calculator.Second1(M, M1, M2, M3);
                            }
                            catch (System.Exception e)
                            {

                            }
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                //dataRow["y" + (syear + i - 1)] = yn[i - 1];
                                TempData[m_Index, (i - 1)] = 0;
                                TempData[m_Index, (i - 1)] = yn[i - 1] * (m_nWeightedValue / 100);
                            }

                            break;
                        case "���Ʒ�(����)":
                        case "��ط�(����)":
                            try
                            {
                                yn = Calculator.Three(historyValues, eyear - syear + 1, ref M1, ref M2, ref M3, ref M4);
                                yn1 = Calculator.Three1(M, M1, M2, M3, M4);
                            }
                            catch (System.Exception e)
                            {

                            }
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                //dataRow["y" + (syear + i - 1)] = yn[i - 1];
                                TempData[m_Index, (i - 1)] = 0;
                                TempData[m_Index, (i - 1)] = yn[i - 1] * (m_nWeightedValue / 100);
                            }

                            break;
                        case "���Ʒ�(ָ��)":
                        case "��ط�(ָ��)":
                            try
                            {
                                yn = Calculator.Index(historyValues, eyear - syear + 1, ref M1, ref M2);
                                yn1 = Calculator.Index1(M, M1, M2);
                            }
                            catch (System.Exception e)
                            {

                            }
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                //dataRow["y" + (syear + i - 1)] = yn[i - 1];
                                TempData[m_Index, (i - 1)] = 0;
                                TempData[m_Index, (i - 1)] = yn[i - 1] * (m_nWeightedValue / 100);
                            }

                            break;
                        case "���Ʒ�(��������)":
                        case "��ط�(��������)":
                            try
                            {
                                yn = Calculator.LOG(historyValues, eyear - syear + 1, ref M1, ref M2);
                                yn1 = Calculator.LOG1(M, M1, M2);
                            }
                            catch (System.Exception e)
                            {

                            }
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                //dataRow["y" + (syear + i - 1)] = yn[i - 1];
                                TempData[m_Index, (i - 1)] = 0;
                                TempData[m_Index, (i - 1)] = yn[i - 1] * (m_nWeightedValue / 100);
                            }

                            break;
                        case "����ϵ����":
                            Calculator.StartYear = syear;
                            //Calculator.Type = type.ToString();
                            Calculator.Type = "24";//�ڸ����㷨�ĵ���ϵ�����в������õ�������24
                            historyValues = GenerateHistoryValue(dataRow, histsyear, syear);
                            try
                            {
                                yn = Calculator.SpringCoefficientMethod((double)dataRow["y" + (syear-1)], eyear - syear+1, forecastReport.ID);
                            }
                            catch (System.Exception e)
                            {

                            }

                            for (int i = 1; i <= eyear - syear+1; i++)
                            {
                                //dataRow["y" + (syear + i - 1)] = yn[i - 1];
                                TempData[m_Index, (i - 1)] = 0;
                                TempData[m_Index, (i - 1)] = yn[i - 1] * (m_nWeightedValue / 100);
                            }
                            break;

                        case "ָ��ƽ����":
                            pcs = new Ps_Calc();
                            //pcs.Forecast = 5;
                            pcs.Forecast = 25;
                            pcs.ForecastID = forecastReport.ID;
                            list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs);
                            if (list1.Count > 0)
                            {

                                yn = Calculator.IndexSmoothMethod(historyValues, eyear - syear + 1, list1[0].Value1);
                            }
                            else
                            {
                                yn = Calculator.IndexSmoothMethod(historyValues, eyear - syear + 1, 0.2);
                            }

                            ////������ֵ
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                //dataRow["y" + (syear + i - 1)] = yn[i - 1];
                                TempData[m_Index, (i - 1)] = 0;
                                TempData[m_Index, (i - 1)] = yn[i - 1] * Convert.ToDouble(m_nWeightedValue / 100.00);
                            }

                            break;
                        case "��ɫģ�ͷ�":
                            try
                            {
                                yn = Calculator.GrayMethod(historyValues, eyear - syear + 1);
                            }
                            catch (System.Exception e)
                            {

                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                //dataRow["y" + (syear + i - 1)] = yn[i - 1];
                                TempData[m_Index, (i - 1)] = 0;
                                TempData[m_Index, (i - 1)] = yn[i - 1] * (m_nWeightedValue / 100);
                            }
                            break;
                        case "ר�Ҿ��߷�":
                            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);
                            foreach (Ps_Forecast_Math psp_Typetemp in listTypes)
                            {
                                if (psp_Typetemp.Title == dataRow["Title"].ToString())
                                {
                                    double firstvalue = 0;
                                    double secvalue = 0;
                                    for (int i = syear; i <= eyear ; i++)
                                    {
                                        firstvalue = (double)psp_Typetemp.GetType().GetProperty("y" + i).GetValue(psp_Typetemp, null);
                                        secvalue = (double)psp_Typetemp.GetType().GetProperty("y" + (i + 1)).GetValue(psp_Typetemp, null);
                                        double dbtemp = 0;
                                        if (dataRow["y" + i] != DBNull.Value && dataRow["y" + i] != null && dataRow["y" + i].ToString() != "")
                                            dbtemp = Convert.ToDouble(dataRow["y" + i]);
                                        else
                                            dbtemp = 0;
                                        if (firstvalue != 0)
                                        {
                                            //dataRow["y" + (i + 1)] = dbtemp * (1 + Math.Round((secvalue - firstvalue) / firstvalue, 2));
                                            TempData[m_Index, (i - syear)] = 0;
                                            TempData[m_Index, (i - syear)] = (dbtemp * (1 + Math.Round((secvalue - firstvalue) / firstvalue, 2))) * (m_nWeightedValue / 100);
                                        }
                                        else
                                        {
                                            //dataRow["y" + (i + 1)] = 0;
                                            TempData[m_Index, (i - syear)] = 0;
                                        }
                                    }
                                }
                            }
                            break;

                        //case "��ط�":
                        //    list.Clear();
                        //    psmtemp = new Ps_Forecast_Math();
                        //    psmtemp.ForecastID = forecastReport.ID;
                        //    psmtemp.Forecast = 3;
                        //    break;

                        //case "�˹������編":
                        //    list.Clear();
                        //    psmtemp = new Ps_Forecast_Math();
                        //    psmtemp.ForecastID = forecastReport.ID;
                        //    psmtemp.Forecast = 8;
                        //    break;

                    }
                    ++m_Index;
                }

                double m_CalcWeight = 0.0;
                for (int i = 1; i <= eyear - syear + 1; ++i)
                {
                    m_CalcWeight = 0.0;
                    for (int j = 0; j < ha.Count; ++j)
                    {
                        if(TempData != null)
                        {
                            m_CalcWeight += TempData[j, (i - 1)];
                        }
                    }
                    dataRow["y" + (syear + i-1)] = m_CalcWeight;
                }
                //   }
                if (isfalse)
                {
                    break;
                }

            }

            ForecastClass fc = new ForecastClass();
            fc.MaxForecast(forecastReport, dataTable);

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

            LoadData();

            RefreshChart();
        }
Exemplo n.º 12
0
        private void JS2()
        {
            //����Ԥ��ֵ
             Ps_Calc pcs = new Ps_Calc();

             IList<Ps_Calc> list1;

            int syear = forecastReport.StartYear;
            int eyear = forecastReport.EndYear;
            int histsyear = 0;
            int histeyear = 0;
            if (ha == null)
                return;
            if (ha.Count <1)
                return;
            bool isfalse = false;
            IList<Ps_Forecast_Math> list = new List<Ps_Forecast_Math>();
            Ps_Forecast_Math psmtemp=new Ps_Forecast_Math ();
            foreach (DataRow dataRow in dataTable.Rows)
            {
                //if (fyear != 0 && syear != 0)
                //{
                 //   double[] historyValues = GenerateHistoryValue(dataRow, fyear, syear);
               //     double[] yn = new double[eyear - syear];

                for (int intextemp = 0; intextemp < ha.Count; intextemp++)
                {
                    string index = ha[intextemp].ToString();
                    string name = index.Split('@')[0];
                    string strhistyear = index.Split('@')[1];
                    string strforecastyear = index.Split('@')[2];
                    histsyear = Convert.ToInt32(strhistyear.Split('-')[0].ToString());
                    histeyear = Convert.ToInt32(strhistyear.Split('-')[1].ToString());
                    syear = Convert.ToInt32(strforecastyear.Split('-')[0].ToString());
                    eyear = Convert.ToInt32(strforecastyear.Split('-')[1].ToString());

                    double[] yn = new double[eyear - syear + 1];
                    double zzl = 0;
                    bool bl = false;
                    double value1 = 0;
                    try { value1 = (double)dataRow["y" + histeyear]; }
                    catch { }
                    int M = histeyear - histsyear;
                    double[] yn1 = new double[M];

                    double M1 = 0;
                    double M2 = 0;
                    double M3 = 0;
                    double M4 = 0;
                    double[] historyValues = GenerateHistoryValue(dataRow, histsyear, histeyear);
                    switch (name)
                    {
                        case "���Ʒ�(�������ʷ�)":
                        case "�������ʷ�":
                            zzl = Calculator.AverageIncreasing(historyValues);
                            if (syear != 0 && eyear != 0)
                            {
                                for (int i = 1; i <= eyear - syear + 1; i++)
                                {
                                    pcs = new Ps_Calc();
                                    pcs.Forecast = 1;
                                    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 (syear + i - 1 >= pc11.Value2 && syear + i - 1 <= pc11.Value3)
                                        {
                                            zzl = pc11.Value4;
                                        }

                                    }
                                    dataRow["y" + (syear + i - 1)] = value1 * Math.Pow(1 + zzl, i);
                                }
                            }

                            break;

                        case "���Ʒ�(ֱ��)":
                        case "��ط�(ֱ��)":
                            yn = Calculator.One(historyValues, eyear - syear + 1, ref M1, ref M2);
                            yn1 = Calculator.One1(M, M1, M2);
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear+1; i++)
                            {
                                dataRow["y" + (syear + i-1)] = yn[i - 1];
                            }
                            break;
                        case "���Ʒ�(������)":
                        case "��ط�(������)":
                            yn = Calculator.Second(historyValues, eyear - syear + 1, ref M1, ref M2, ref M3);
                            yn1 = Calculator.Second1(M, M1, M2, M3);
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                dataRow["y" + (syear + i - 1)] = yn[i - 1];
                            }

                            break;
                        case "���Ʒ�(����)":
                        case "��ط�(����)":
                            yn = Calculator.Three(historyValues, eyear - syear + 1, ref M1, ref M2, ref M3, ref M4);
                            yn1 = Calculator.Three1(M, M1, M2, M3, M4);
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                dataRow["y" + (syear + i - 1)] = yn[i - 1];
                            }

                            break;
                        case "���Ʒ�(ָ��)":
                        case "��ط�(ָ��)":
                            yn = Calculator.Index(historyValues, eyear - syear + 1, ref M1, ref M2);
                            yn1 = Calculator.Index1(M, M1, M2);
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                dataRow["y" + (syear + i - 1)] = yn[i - 1];
                            }

                            break;
                        case "���Ʒ�(��������)":
                        case "��ط�(��������)":
                            yn = Calculator.LOG(historyValues, eyear - syear + 1, ref M1, ref M2);
                            yn1 = Calculator.LOG1(M, M1, M2);
                            if (M1 == -999999 && M2 == -999999)
                            {
                                isfalse = true;
                                MsgBox.Show("���㷨ģ��ʧ�ܣ������޽�");
                                break;
                            }
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                dataRow["y" + (syear + i - 1)] = yn[i - 1];
                            }

                            break;
                        case "����ϵ����":
                            Calculator.StartYear = syear;
                            Calculator.Type = type.ToString();
                            yn = Calculator.SpringCoefficientMethod((double)dataRow["y" + (syear-1)], eyear - syear+1, forecastReport.ID);

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

                        case "ָ��ƽ����":
                            pcs = new Ps_Calc();
                            pcs.Forecast = 5;
                            pcs.ForecastID = forecastReport.ID;
                            list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs);
                            if (list1.Count > 0)
                            {

                                yn = Calculator.IndexSmoothMethod(historyValues, eyear - syear + 1,list1[0].Value1 );
                            }
                            else
                            {
                                yn = Calculator.IndexSmoothMethod(historyValues, eyear - syear + 1, 0.1);
                            }

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

                            break;
                        case "��ɫģ�ͷ�":
                            yn = Calculator.GrayMethod(historyValues, eyear - syear + 1);
                            for (int i = 1; i <= eyear - syear + 1; i++)
                            {
                                dataRow["y" + (syear + i - 1)] = yn[i - 1];
                            }
                            break;
                        case "ר�Ҿ��߷�":
                            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);
                            foreach (Ps_Forecast_Math psp_Typetemp in listTypes)
                            {
                                if (psp_Typetemp.Title == dataRow["Title"].ToString())
                                {
                                    double firstvalue = 0;
                                    double secvalue = 0;
                                    for (int i = histsyear; i <= eyear-1; i++)
                                    {
                                        firstvalue=(double)psp_Typetemp.GetType().GetProperty("y" + i).GetValue(psp_Typetemp,null);
                                        secvalue = (double)psp_Typetemp.GetType().GetProperty("y" + (i+1)).GetValue(psp_Typetemp, null);
                                          double dbtemp=0;
                                        if(dataRow["y"+i]!=DBNull.Value&&dataRow["y"+i]!=null&&dataRow["y"+i].ToString()!="")
                                         dbtemp=Convert.ToDouble(dataRow["y"+i]);
                                        else
                                            dbtemp=0;
                                        if (firstvalue != 0)
                                             dataRow["y" + (i + 1)] = dbtemp *(1+ Math.Round((secvalue - firstvalue) / firstvalue, 2));
                                        else
                                        {
                                            dataRow["y" + (i + 1)] = 0;
                                        }
                                    }
                                }
                            }
                            break;

                        //case "��ط�":
                        //    list.Clear();
                        //    psmtemp = new Ps_Forecast_Math();
                        //    psmtemp.ForecastID = forecastReport.ID;
                        //    psmtemp.Forecast = 3;
                        //    break;

                        //case "�˹������編":
                        //    list.Clear();
                        //    psmtemp = new Ps_Forecast_Math();
                        //    psmtemp.ForecastID = forecastReport.ID;
                        //    psmtemp.Forecast = 8;
                        //    break;
                    }

                }

             //   }
                if(isfalse)
                {
                    break;
                }

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

            RefreshChart();
        }
Exemplo n.º 13
0
        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_CalcByForecast", pcs);

            //int fyear = 0;
            //int syear = 0;
            //int eyear = 0;
            //IList<Ps_forecast_list> listReports = Common.Services.BaseService.GetList<Ps_forecast_list>("SelectPs_forecast_listByWhere", "UserID='" + Itop.Client.MIS.ProgUID + "' and Col1='2' and Title='" + forecastReport.Title + "'");
            //if (listReports.Count < 1)
            //{
            //    return;
            //}
            //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");

            //    Ps_Forecast_Math psp_TypePan = new Ps_Forecast_Math();
            //    string[] str = new string[2] { "",""};
            //    int typetemp = 0;
            //    if (dataRow["Title"].ToString().Contains("����"))
            //    {
            //        typetemp = 2;
            //        str[1] = dataRow["Title"].ToString();
            //        if (dataRow["Title"].ToString().Substring(dataRow["Title"].ToString().Length - 2, 2) == "����")
            //            str[1] = dataRow["Title"].ToString().Substring(0, dataRow["Title"].ToString().Length - 2);
            //    }
            //    else if (dataRow["Title"].ToString().Contains("����"))
            //    {
            //        typetemp = 3;

            //        str[1] = dataRow["Title"].ToString();
            //        if (dataRow["Title"].ToString().Substring(dataRow["Title"].ToString().Length - 2, 2) == "����")
            //            str[1] = dataRow["Title"].ToString().Substring(0, dataRow["Title"].ToString().Length - 2);
            //    }

            //    if (str[1].Contains("ȫ���") && !str[1].Contains("(ȫ����)"))
            //    {
            //        str[1] = str[1] + "(ȫ����)";
            //    }
            //    //psp_Type.Forecast = 2;
            //    //psp_Type.ForecastID = listReports[0].ID;
            //    //psp_Type.Title=str[1];
            //    object obj = Common.Services.BaseService.GetObject("SelectPs_Forecast_MathByWhere",
            //        "Forecast='" + typetemp + "' and ForecastID='" + listReports[0].ID + "' and Title='" + str[1] + "'");
            //    if (obj == null)
            //        continue;
            //    Ps_Forecast_Math psp_Type = obj as Ps_Forecast_Math;
            //    psp_TypePan = obj as Ps_Forecast_Math;
            //    string mathstr="";

            //    IList<Ps_Forecast_Math> list = Common.Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByWhere",
            //        "Forecast='" + typetemp + "' and ForecastID='" + listReports[0].ID + "' and ParentID='" + psp_Type.ID + "'" + " and ( Title like '����%' or Title  like '���û�%' or Title  like 'ͬʱ��%'   ) order by sort");
            //    if (list.Count == 0)
            //        continue;
            //    Ps_Forecast_Math pfscgui = new Ps_Forecast_Math();

            //    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)
            //        {
            //            double value2 = 0;
            //            double value3 = 0;
            //            foreach (Ps_Forecast_Math ms in list)
            //            {
            //                // value1 = (double)dataRow["y" + (i )];

            //                // value1 = (double)dataRow["y" + (i )];
            //                if (ms.Title.Contains("����"))
            //                {

            //                    pfscgui = ms;
            //                }
            //            }
            //            for (int i = syear; i <= eyear; i++)
            //            {
            //                try {
            //                    foreach(Ps_Forecast_Math ms in list){
            //                   // value1 = (double)dataRow["y" + (i )];

            //                            // value1 = (double)dataRow["y" + (i )];
            //                            if (ms.Title.Contains("����"))
            //                            {
            //                                value1 = Math.Round(Convert.ToDouble(ms.GetType().GetProperty("y" + (i-1)).GetValue(ms, null)), 2);
            //                                //pfscgui = ms;
            //                            }

            //                            else
            //                    if (ms.Title.Contains("���û�"))
            //                        value2 = Math.Round(Convert.ToDouble(ms.GetType().GetProperty("y" + i).GetValue(ms, null)), 2);

            //                    else
            //                        if (ms.Title.Contains("ͬʱ��"))
            //                            value3 = Math.Round(Convert.ToDouble(ms.GetType().GetProperty("y" + i).GetValue(ms, null)), 2);
            //                    }

            //                }
            //                catch { }
            //                value1 =Math.Round( value1 * (1 + zzl * 0.01),2);
            //                pfscgui.GetType().GetProperty("y" + i ).SetValue(pfscgui, value1, null);

            //                if (pfscgui.Forecast==2)
            //                dataRow["y" + i ] = value1 + value2;
            //                else
            //                if (pfscgui.Forecast == 3)
            //                    dataRow["y" + i ] = (value1 + value2)*value3;

            //            }
            //        }

            //    }
            //    if(!bl)
            //    {
            //        if (firstyear != "0" && endyear != "0")
            //        {
            //            double value2 = 0;
            //            double value3 = 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
            //                {
            //                    foreach (Ps_Forecast_Math ms in list)
            //                    {
            //                        // value1 = (double)dataRow["y" + (i )];

            //                        // value1 = (double)dataRow["y" + (i )];
            //                        if (ms.Title.Contains("����"))
            //                        {
            //                            value1 = Math.Round(Convert.ToDouble(ms.GetType().GetProperty("y" +( i-1)).GetValue(ms, null)), 2);
            //                            pfscgui = ms;
            //                        }

            //                        else
            //                            if (ms.Title.Contains("���û�"))
            //                                value2 = Math.Round(Convert.ToDouble(ms.GetType().GetProperty("y" + i ).GetValue(ms, null)), 2);

            //                            else
            //                                if (ms.Title.Contains("ͬʱ��"))
            //                                    value3 = Math.Round(Convert.ToDouble(ms.GetType().GetProperty("y" + i).GetValue(ms, null)), 2);
            //                    }

            //                }
            //                catch { }
            //                value1 = Math.Round(value1 * (1 + zzl * 0.01), 2);
            //                pfscgui.GetType().GetProperty("y" + (i )).SetValue(pfscgui, value1, null);
            //                if (pfscgui.Forecast == 2)
            //                    dataRow["y" + (i )] = value1 + value2;
            //                else
            //                    if (pfscgui.Forecast == 3)
            //                        dataRow["y" + (i)] = (value1 + value2) * value3;

            //            }

            //        }

            //    }
            //    ForecastClass fc = new ForecastClass();
            //    fc.MaxForecast(forecastReport, dataTable);
            //    RefreshChart();
            //    treeList1.Refresh();
            //}
            //��԰���
            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();
            }
        }
Exemplo n.º 14
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.EndYear;

            foreach (DataRow dataRow in dataTable.Rows)
            {

                 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];
                                    }
                    }
                }

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