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);
            }
        }
        private void LoadData()
        {
            treeList1.DataSource = null;
            bLoadingData = true;
            if (dataTable2 != null)
            {
                dataTable1.Columns.Clear();
                dataTable2.Columns.Clear();
                treeList2.Columns.Clear();
                treeList1.Columns.Clear();

            }
            if (dataTable2 != null)
            {
                treeList3.Columns.Clear();
            }
            if (dataTable1 != null)
            {
                dataTable1.Columns.Clear();
            }
            AddFixColumn();
            AddFixColumn2();
            AddFixColumn3();
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn(i);
            }
            for (int i = forecastReport.StartYear; i <=forecastReport.EndYear; i++)
            {
                AddColumn2(i);
            }
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn3(i);
            }

            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            IList<Ps_Forecast_Math> listTypes = Common.Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable2 = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_Forecast_Math));
            treeList2.DataSource = dataTable2;

            Hashtable ht = new Hashtable();
            IList<Ps_BadData> list = new List<Ps_BadData>();
            foreach (Ps_Forecast_Math pfm in listTypes)
            {
                Ps_BadData pb1 = new Ps_BadData();
                pb1.ForecastID = pfm.ForecastID;
                pb1.Forecast = type;
                pb1.Col1 = pfm.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 = new Ps_BadData();
                    pb.ID = pfm.ID+"|m|"+type;
                    pb.Title = pfm.Title;
                    pb.ForecastID = pfm.ForecastID;
                    pb.Forecast = type;
                    pb.Col1 = pfm.ID;
                    pb.ParentID = pfm.ParentID + "|m|" + type;
                    Services.BaseService.Create<Ps_BadData>(pb);
                }
                else
                    pb = li[0];
                list.Add(pb);
            }
            dataTable1 = Itop.Common.DataConverter.ToDataTable((IList)list, typeof(Ps_BadData));

            treeList2.Columns["Title"].OptionsColumn.AllowEdit = false;
            treeList1.DataSource = dataTable1;
            Application.DoEvents();
            bLoadingData = false;
        }
Beispiel #6
0
        private void LoadData()
        {
            treeList1.DataSource = null;
            bLoadingData         = true;
            if (dataTable2 != null)
            {
                dataTable1.Columns.Clear();
                dataTable2.Columns.Clear();
                treeList2.Columns.Clear();
                treeList1.Columns.Clear();
            }
            if (dataTable2 != null)
            {
                treeList3.Columns.Clear();
            }
            if (dataTable1 != null)
            {
                dataTable1.Columns.Clear();
            }
            AddFixColumn();
            AddFixColumn2();
            AddFixColumn3();
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn(i);
            }
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn2(i);
            }
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn3(i);
            }

            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();

            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast   = 0;
            IList <Ps_Forecast_Math> listTypes = Common.Services.BaseService.GetList <Ps_Forecast_Math>("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable2           = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_Forecast_Math));
            treeList2.DataSource = dataTable2;

            Hashtable          ht   = new Hashtable();
            IList <Ps_BadData> list = new List <Ps_BadData>();

            foreach (Ps_Forecast_Math pfm in listTypes)
            {
                Ps_BadData pb1 = new Ps_BadData();
                pb1.ForecastID = pfm.ForecastID;
                pb1.Forecast   = type;
                pb1.Col1       = pfm.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            = new Ps_BadData();
                    pb.ID         = pfm.ID + "|m|" + type;
                    pb.Title      = pfm.Title;
                    pb.ForecastID = pfm.ForecastID;
                    pb.Forecast   = type;
                    pb.Col1       = pfm.ID;
                    pb.ParentID   = pfm.ParentID + "|m|" + type;
                    Services.BaseService.Create <Ps_BadData>(pb);
                }
                else
                {
                    pb = li[0];
                }
                list.Add(pb);
            }
            dataTable1 = Itop.Common.DataConverter.ToDataTable((IList)list, typeof(Ps_BadData));

            treeList2.Columns["Title"].OptionsColumn.AllowEdit = false;
            treeList1.DataSource = dataTable1;
            Application.DoEvents();
            bLoadingData = false;
        }
Beispiel #7
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 #8
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);
            }
        }