AgentGetData.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Media;
  7. namespace WhiteList
  8. {
  9. public partial class Agent
  10. {
  11. public string GetIcon
  12. {
  13. get => Logo == null ? "Images/picture.png" : Logo;
  14. }
  15. public string GetTypeAndTitle
  16. {
  17. get => AgentType.Title + " | " + Title;
  18. }
  19. public int GetCountSale
  20. {
  21. get
  22. {
  23. int count = 0;
  24. foreach(ProductSale ps in DB.dbCon.ProductSale.Where(x=>x.AgentID == ID).ToList())
  25. {
  26. if(ps.SaleDate>=DateTime.Now.AddDays(-365))
  27. {
  28. count += ps.ProductCount;
  29. }
  30. }
  31. return count;
  32. }
  33. }
  34. public int GetPercent
  35. {
  36. get
  37. {
  38. int sale = 0;
  39. int count = GetCountSale;
  40. if (count >= 10000)
  41. {
  42. sale = 5;
  43. }
  44. if(count>=50000)
  45. {
  46. sale = 10;
  47. }
  48. if(count>=150000)
  49. {
  50. sale = 20;
  51. }
  52. if (count >= 500000)
  53. {
  54. sale = 25;
  55. }
  56. return sale;
  57. }
  58. }
  59. public SolidColorBrush GetBackground
  60. {
  61. get => GetPercent >= 25 ? new SolidColorBrush(Color.FromRgb(120, 170, 150)) : new SolidColorBrush(Color.FromRgb(170, 200, 255));
  62. }
  63. }
  64. }