C# 後臺獲取前臺交互判斷
阿新 • • 發佈:2018-11-23
前臺 ati ole main bool read for div ||
前臺傳來明細 ,判斷是否修改,在把前臺 的數據組成新的類保存
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 classt 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 }
C# 後臺獲取前臺交互判斷