private void Save()
        {
            //保存

            foreach (DataRow dataRow in dataTable1.Rows)
            {
                TreeListNode row = treeList1.FindNodeByKeyID(dataRow["ID"]);
                Ps_BadData   v   = Services.BaseService.GetOneByKey <Ps_BadData>(row["ID"].ToString());
                foreach (TreeListColumn col in this.treeList1.Columns)
                {
                    if (col.FieldName.IndexOf("y") > -1)
                    {
                        object obj = row[col.FieldName];
                        if (obj != DBNull.Value)
                        {
                            v.GetType().GetProperty(col.FieldName).SetValue(v, obj, null);
                        }
                    }
                }

                try
                {
                    Services.BaseService.Update <Ps_BadData>(v);
                }
                catch { }
            }
            //MsgBox.Show("保存成功!");
        }
Beispiel #2
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (MessageBox.Show("保存后修改数据将替换原始数据?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                //清楚坏数据点的修正值

                foreach (DataRow dataRow in dataTable1.Rows)
                {
                    TreeListNode row = treeList1.FindNodeByKeyID(dataRow["ID"]);
                    Ps_BadData   v   = Services.BaseService.GetOneByKey <Ps_BadData>(row["ID"].ToString());
                    foreach (TreeListColumn col in this.treeList1.Columns)
                    {
                        if (col.FieldName.IndexOf("y") > -1)
                        {
                            object obj = row[col.FieldName];
                            if (obj != DBNull.Value)
                            {
                                v.GetType().GetProperty(col.FieldName).SetValue(v, 0, null);
                            }
                        }
                    }

                    try
                    {
                        Services.BaseService.Update <Ps_BadData>(v);
                    }
                    catch { }
                }
                //保存修改后的数据
                foreach (DataRow dataRow in dataTable3.Rows)
                {
                    TreeListNode     row = treeList3.FindNodeByKeyID(dataRow["ID"]);
                    Ps_Forecast_Math v   = Services.BaseService.GetOneByKey <Ps_Forecast_Math>(row["ID"].ToString());
                    foreach (TreeListColumn col in this.treeList3.Columns)
                    {
                        if (col.FieldName.IndexOf("y") > -1)
                        {
                            object obj = row[col.FieldName];
                            if (obj != DBNull.Value)
                            {
                                v.GetType().GetProperty(col.FieldName).SetValue(v, obj, null);
                            }
                        }
                    }

                    try
                    {
                        Services.BaseService.Update <Ps_Forecast_Math>(v);
                    }
                    catch { }
                }
                this.Close();
                MessageBox.Show("更新完成!");
            }
        }
Beispiel #3
0
        public void MaxForecast(Ps_forecast_list forecastReport, DataTable dataTable)
        {
            foreach (DataRow dataRow in dataTable.Rows)
            {
                string id = dataRow["Col1"].ToString();

                Ps_BadData pb1 = new Ps_BadData();
                pb1.ForecastID = forecastReport.ID;
                pb1.Forecast   = 2;
                pb1.Col1       = id;
                Ps_BadData         pb = new Ps_BadData();
                IList <Ps_BadData> li = Common.Services.BaseService.GetList <Ps_BadData>("SelectPs_BadDataByCol1", pb1);
                if (li.Count > 0)
                {
                    pb = li[0];
                    for (int i = forecastReport.StartYear; i < forecastReport.EndYear; i++)
                    {
                        PropertyInfo pi1 = pb.GetType().GetProperty("y" + i);
                        double       dl  = 0;
                        double       dl1 = 0;
                        try
                        {
                            dl = Convert.ToDouble(dataRow["y" + i].ToString());
                        }
                        catch { }

                        try
                        {
                            dl1 = Convert.ToDouble(pi1.GetValue(pb, null));
                        }
                        catch { }

                        dataRow["y" + i] = dl + dl1;
                    }
                }
            }
        }
Beispiel #4
0
        public void BadForecast(int type, Ps_forecast_list forecastReport)
        {
            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)
            {
                string id = psp_Typetemp.ID;
                psp_Type          = new Ps_Forecast_Math();
                psp_Type          = psp_Typetemp;
                psp_Type.ID       = type + "|" + id;// Guid.NewGuid().ToString();
                psp_Type.Forecast = type;
                psp_Type.Col1     = id;
                psp_Type.ParentID = type + "|" + psp_Typetemp.ParentID;

                Ps_BadData pb1 = new Ps_BadData();
                pb1.ForecastID = psp_Typetemp.ForecastID;
                pb1.Forecast   = 1;
                pb1.Col1       = id;
                Ps_BadData         pb = new Ps_BadData();
                IList <Ps_BadData> li = Common.Services.BaseService.GetList <Ps_BadData>("SelectPs_BadDataByCol1", pb1);
                if (li.Count > 0)
                {
                    pb = li[0];
                    for (int i = forecastReport.StartYear; i < forecastReport.EndYear; i++)
                    {
                        double       dl  = 0;
                        double       dl1 = 0;
                        PropertyInfo pi  = psp_Type.GetType().GetProperty("y" + i);
                        PropertyInfo pi1 = pb.GetType().GetProperty("y" + i);
                        try
                        {
                            dl = Convert.ToDouble(pi.GetValue(psp_Type, null));
                        }
                        catch (Exception ex)
                        {
                            int b = 1;
                            b++;
                        }
                        try
                        {
                            dl1 = Convert.ToDouble(pi1.GetValue(pb, null));
                        }
                        catch (Exception ex)
                        {
                            int b = 1;
                            b++;
                        }

                        if (dl1 != 0)
                        {
                            pi.SetValue(psp_Type, dl + dl1, null);
                        }
                    }
                }

                Common.Services.BaseService.Create <Ps_Forecast_Math>(psp_Type);
            }
        }
Beispiel #5
0
        public void MaxForecast(Ps_forecast_list forecastReport,DataTable dataTable)
        {
            foreach (DataRow dataRow in dataTable.Rows)
            {
                string id = dataRow["Col1"].ToString();

                Ps_BadData pb1 = new Ps_BadData();
                pb1.ForecastID = forecastReport.ID;
                pb1.Forecast = 2;
                pb1.Col1 = id;
                Ps_BadData pb = new Ps_BadData();
                IList<Ps_BadData> li = Common.Services.BaseService.GetList<Ps_BadData>("SelectPs_BadDataByCol1", pb1);
                if (li.Count > 0)
                {
                    pb = li[0];
                    for (int i = forecastReport.StartYear; i < forecastReport.EndYear; i++)
                    {
                        PropertyInfo pi1 = pb.GetType().GetProperty("y" + i);
                        double dl = 0;
                        double dl1 = 0;
                        try
                        {
                            dl = Convert.ToDouble(dataRow["y" + i].ToString());
                        }
                        catch { }

                        try
                        {
                            dl1 = Convert.ToDouble(pi1.GetValue(pb, null));
                        }
                        catch { }

                        dataRow["y" + i] = dl + dl1;
                    }
                }
            }
        }
Beispiel #6
0
        public void BadForecast(int type, Ps_forecast_list forecastReport)
        {
            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)
            {
                string id = psp_Typetemp.ID;
                psp_Type = new Ps_Forecast_Math();
                psp_Type = psp_Typetemp;
                psp_Type.ID = type + "|" + id;// Guid.NewGuid().ToString();
                psp_Type.Forecast = type;
                psp_Type.Col1 = id;
                psp_Type.ParentID = type + "|" + psp_Typetemp.ParentID;

                Ps_BadData pb1 = new Ps_BadData();
                pb1.ForecastID = psp_Typetemp.ForecastID;
                pb1.Forecast = 1;
                pb1.Col1 = id;
                Ps_BadData pb = new Ps_BadData();
                IList<Ps_BadData> li = Common.Services.BaseService.GetList<Ps_BadData>("SelectPs_BadDataByCol1", pb1);
                if (li.Count > 0)
                {
                    pb = li[0];
                    for(int i=forecastReport.StartYear;i<forecastReport.EndYear;i++)
                    {
                        double dl = 0;
                        double dl1 = 0;
                        PropertyInfo pi = psp_Type.GetType().GetProperty("y" + i);
                        PropertyInfo pi1 = pb.GetType().GetProperty("y" + i);
                            try
                            {

                                dl = Convert.ToDouble(pi.GetValue(psp_Type, null));
                            }
                        catch(Exception ex)
                            {
                                int b = 1;
                                b++;
                        }
                        try
                        {

                            dl1 = Convert.ToDouble(pi1.GetValue(pb, null));

                        }
                        catch (Exception ex)
                        {
                            int b = 1;
                            b++;
                        }

                        if(dl1!=0)
                            pi.SetValue(psp_Type, dl + dl1, null);

                    }
                }

                Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type);
            }
        }