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

2021-06-29 19:05

阅读:636

标签:获取   int   new   rgs   tor   code   var   lse   ati   

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

 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 dd { get; set; }
15     }
16     class Program
17     {
18 
19         static void Main(string[] args)
20         {
21             var q = new List { 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 { 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     }

 

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

标签:获取   int   new   rgs   tor   code   var   lse   ati   

原文地址:https://www.cnblogs.com/LiuFengH/p/10005862.html


评论


亲,登录后才可以留言!