• 类 映射 遍历大全


                    foreach (T_GL_AnalysisCalculation item in AnalysisCalculationList)
                    {
                        foreach (System.Reflection.PropertyInfo p in item.GetType().GetProperties())
                        {
                            var Key = p.Name;
                            var Value = p.GetValue(item, null);


                            #region 行业最优
                            if (Key == "Reporttype" && Value.ToString() == "Max")
                            {
                                foreach (System.Reflection.PropertyInfo pYear in item.GetType().GetProperties())
                                {
                                    var KeyYear = pYear.Name;
                                    var ValueYear = pYear.GetValue(item, null);
                                    if (KeyYear == "Year" && ValueYear.ToString() == "1")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueMax1 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "3")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueMax3 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "5")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueMax5 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "10")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueMax10 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                }
                            }

                            #endregion

                            #region 行业平均
                            if (Key == "Reporttype" && Value.ToString() == "Average")
                            {
                                foreach (System.Reflection.PropertyInfo pYear in item.GetType().GetProperties())
                                {
                                    var KeyYear = pYear.Name;
                                    var ValueYear = pYear.GetValue(item, null);
                                    if (KeyYear == "Year" && ValueYear.ToString() == "1")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueAverage1 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "3")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueAverage3 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "5")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueAverage5 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "10")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueAverage10 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                }
                            }


                            #endregion

                            #region 行业最差
                            if (Key == "Reporttype" && Value.ToString() == "Min")
                            {
                                foreach (System.Reflection.PropertyInfo pYear in item.GetType().GetProperties())
                                {
                                    var KeyYear = pYear.Name;
                                    var ValueYear = pYear.GetValue(item, null);
                                    if (KeyYear == "Year" && ValueYear.ToString() == "1")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueMin1 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "3")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueMin3 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "5")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueMin5 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                    if (KeyYear == "Year" && ValueYear.ToString() == "10")
                                    {
                                        foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                        {
                                            var KeyYearName = pYearValue.Name;
                                            var KeyYearValue = pYearValue.GetValue(item, null);
                                            if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                            {
                                                entiey.ValueMin10 = Convert.ToDecimal(KeyYearValue);
                                            }
                                        }
                                    }
                                }
                            }


                            #endregion

                        }
                    }


                    foreach (System.Reflection.PropertyInfo p in entiey.GetType().GetProperties())
                    {
                        var Key = p.Name;
                        var Value = p.GetValue(entiey, null);
                        if (Key.Substring(0, 1) == "Q")
                        {


                            foreach (var item in AnalysisCalculationQAllList)
                            {
                                if (item.Reporttype == quarter + Key.Substring(1, Key.Length - 1))
                                {
                                    foreach (System.Reflection.PropertyInfo I in item.GetType().GetProperties())
                                    {
                                        var itemKey = I.Name;
                                        var itemValue = I.GetValue(item, null);
                                        if (code.ToString() == itemKey.Replace("_", "."))
                                        {
                                            p.SetValue(entiey, itemValue, null);
                                        }
                                    }
                                }
                            }
                        }
                    }

  • 相关阅读:
    hdu 2896 AC自动机模版题
    快递公司送货员送到货时,打电话通知客户来取的改进
    Scala数据类型中的Symbol(符号文本)
    hdu 3065 AC自动机模版题
    Oracle DB 复制数据库
    Java打包生成exe(使用exe4j和inno setup)
    C#的Lambda表达式嵌套例子
    WPF设置控件获得焦点FocusManager
    Winform给TextBox设置默认值(获取焦点后默认值消失)
    使用signtool.exe来验证程序的数字签名是否成功(命令行)
  • 原文地址:https://www.cnblogs.com/520cc/p/4081642.html
Copyright © 2020-2023  润新知