• C# 后台获取前台交互判断


    前台传来明细 ,判断是否修改,在把前台 的数据组成新的类保存

     1 public class tt
     2     {
     3         public string id { get; set; }
     4         public string e_id { get; set; }
     5         public string name { get; set; }
     6         public int age { get; set; }
     7         public bool sex { get; set; }
     8 
     9     }
    10     public class t
    11     {
    12         public string id { get; set; }
    13         public string name { get; set; }
    14         public List<tt> dd { get; set; }
    15     }
    16     class Program
    17     {
    18 
    19         static void Main(string[] args)
    20         {
    21             var q = new List<tt> { new tt { id = "123",e_id="1", name = "pg", age = 12, sex = true }, new tt { id = "124",e_id="1", name = "pp", age = 13, sex = true } };  //后台数据
    22             var w = new List<tt> { new tt { name = "pg", e_id = "2", age = 12, sex = true }, new  ConsoleApplication2.tt { name = "pp", e_id = "2", age = 13, sex = true }, new tt { name = "ppd", e_id = "2", age = 11, sex = true } };  //前台数据 
    23 
    24             var e =   new t { id = "1", name = "pg", dd = q  };     //父行
    25 
    26             var ischange1 = false;
    27             var ischange2 = false;
    28             foreach (var item in w)
    29             {
    30                 item.e_id = e.id;    //父ID
    31                 tt ex = q.Where(d => d.name == item.name).FirstOrDefault();
    32                 if (ex == null)
    33                 {
    34                     ischange2 = true;
    35                 }
    36                 else
    37                 {
    38                     if (ex.age != item.age || ex.sex != item.sex)
    39                     {
    40                         ischange2 = true;
    41                     }
    42                 }
    43             }
    44  
    45              if (q.Count != w.Count)
    46             {
    47                 ischange2 = true;
    48             }
    49             if (ischange1 == true || ischange2 == true)
    50             {
    51                 if (ischange2 == true)
    52                 {
    53                     e.dd = w;
    54                 }
    55             }
    56             Console.WriteLine(ischange2);
    57 
    58             Console.ReadKey(true);
    59         }
    60 
    61     }
  • 相关阅读:
    多线程编程(8)Timer
    WPF 元素的查找
    拖放操作和文件复制小功能
    gridview 编辑,删除,更新的用法
    VS2005 制作安装程序
    C# 学习基础概念二十五问
    DBHelper
    c# 实现网页上用户自动登陆|asp.net 模拟网站登录
    C#模拟登录总结
    Python 调用.net framework写的类库的方法
  • 原文地址:https://www.cnblogs.com/LiuFengH/p/10005862.html
Copyright © 2020-2023  润新知