LogicModel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Media;
  8. namespace Prakticheskaya5_Venediktov
  9. {
  10. public partial class Users
  11. {
  12. public string gender;
  13. public string Genders
  14. {
  15. get { return gender; }
  16. set { gender = value; }
  17. }
  18. public string role;
  19. public string Roles
  20. {
  21. get { return role; }
  22. set { role = value; }
  23. }
  24. }
  25. public class User
  26. {
  27. public List<Users> usr;
  28. public User()
  29. {
  30. usr = newuser();
  31. }
  32. public List<Users> newuser()
  33. {
  34. List<Users> users = new List<Users>();
  35. Users buff;
  36. List<Users> bdusers = Base.database.Users.ToList();
  37. foreach (Users user in bdusers)
  38. {
  39. buff = new Users();
  40. buff.ID_User = user.ID_User;
  41. buff.Name = user.Name;
  42. buff.Surname = user.Surname;
  43. buff.Login = user.Login;
  44. buff.Password = user.Password;
  45. buff.ID_Gender = user.ID_Gender;
  46. buff.Birthday = user.Birthday;
  47. buff.ID_Role = user.ID_Role;
  48. buff.ID_Gender = user.ID_Gender;
  49. Pol gender = Base.database.Pol.FirstOrDefault(x => x.ID_Gender == buff.ID_Gender);
  50. buff.gender = gender.Gender;
  51. Role role = Base.database.Role.FirstOrDefault(x => x.ID_Role == buff.ID_Role);
  52. buff.role = role.Role1;
  53. users.Add(buff);
  54. }
  55. return users;
  56. }
  57. }
  58. public partial class Medicine
  59. {
  60. public string usedmedicined;
  61. public string Usedmedicined
  62. {
  63. get { return usedmedicined; }
  64. set { usedmedicined = value; }
  65. }
  66. public bool Color { get => Vid == "Сироп"; }
  67. public SolidColorBrush BGColor
  68. {
  69. get
  70. {
  71. if (Color)
  72. {
  73. return Brushes.Azure;
  74. }
  75. else
  76. {
  77. return Brushes.White;
  78. }
  79. }
  80. }
  81. public class Preparats
  82. {
  83. public List<Medicine> medicine;
  84. public Preparats()
  85. {
  86. medicine = newmedicine();
  87. }
  88. public List<Medicine> newmedicine()
  89. {
  90. List<Medicine> medicines = new List<Medicine>();
  91. Medicine buff;
  92. List<Medicine> bdmedicine = Base.database.Medicine.ToList();
  93. List<Used_medicined> bdusedmedicine = Base.database.Used_medicined.ToList();
  94. List<Users> bdusers = Base.database.Users.ToList();
  95. foreach (Medicine medicine in bdmedicine)
  96. {
  97. buff = new Medicine();
  98. buff.ID_Medicine = medicine.ID_Medicine;
  99. buff.Name_Medicine = medicine.Name_Medicine;
  100. buff.Vid = medicine.Vid;
  101. buff.Price = medicine.Price;
  102. string allmedicaments = "";
  103. foreach (Used_medicined used_Medicined in bdusedmedicine)
  104. {
  105. if (medicine.ID_Medicine == used_Medicined.ID_Medicine)
  106. {
  107. foreach (Users users in bdusers)
  108. {
  109. if (users.ID_User == used_Medicined.ID_User)
  110. {
  111. allmedicaments += used_Medicined.Users + ", ";
  112. medicine.usedmedicined = allmedicaments;
  113. break;
  114. }
  115. }
  116. }
  117. }
  118. buff.usedmedicined = medicine.usedmedicined;
  119. medicines.Add(buff);
  120. }
  121. return medicines;
  122. }
  123. }
  124. }
  125. }