Advertisement
gguuppyy

фф

May 8th, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. '''Procedure SortByCategoryAndName(Var Menu: PtMenu);
  2. Var
  3. I, J: PtMenu;
  4. Temp: TMenu;
  5. Begin
  6. I := Menu;
  7. While I <> Nil Do
  8. Begin
  9. J := I^.Next;
  10. While J <> Nil Do
  11. Begin
  12. If (I^.Data.Category > J^.Data.Category) Or ((I^.Data.Category = J^.Data.Category) And (I^.Data.Name > J^.Data.Name)) Then
  13. Begin
  14. Temp := I^.Data;
  15. I^.Data := J^.Data;
  16. J^.Data := Temp;
  17. End;
  18. J := J^.Next;
  19. End;
  20. I := I^.Next;
  21. End;
  22. End;
  23.  
  24. Function CalculateTableRevenue(TableNumber: Integer; OrderList: PtOrdList; Menu: PtMenu): Integer;
  25. Var
  26. I: PtOrdList;
  27. TotalRevenue: Integer;
  28. J: PtMenu;
  29. Begin
  30. TotalRevenue := 0;
  31. I := OrderList;
  32. While I <> Nil Do
  33. Begin
  34. If I^.Data.NumberTable = TableNumber Then
  35. Begin
  36. J := Menu;
  37. While J <> Nil Do
  38. Begin
  39. If J^.Data.CodeDish = I^.Data.CodeDish Then
  40. Begin
  41. TotalRevenue := TotalRevenue + I^.Data.Quantity * (J^.Data.Cost.Ruble * 100 + J^.Data.Cost.Penny);
  42. Break;
  43. End;
  44. J := J^.Next;
  45. End;
  46. End;
  47. I := I^.Next;
  48. End;
  49. CalculateTableRevenue := TotalRevenue;
  50. End;
  51.  
  52. Procedure TReportPractilaForm.GiveReportPractika(Sender: TObject);
  53. Var
  54. I: PtMenu;
  55. J: PtOrdList;
  56. Row, Sum: Integer;
  57. LastCategory, LastDish: String;
  58. Begin
  59. Row := 0;
  60. LastCategory := '';
  61. LastDish := '';
  62. SortByCategoryAndName(RestoranMenu);
  63. I := RestoranMenu;
  64. While I <> Nil Do
  65. Begin
  66. Sum := 0;
  67. J := OrderList;
  68. While J <> Nil Do
  69. Begin
  70. If (I^.Data.CodeDish = J^.Data.CodeDish) Then
  71. Begin
  72. Sum := Sum + J^.Data.Quantity;
  73. End;
  74. J := J^.Next;
  75. End;
  76.  
  77. If Sum > 0 Then
  78. Begin
  79. If LastCategory <> I^.Data.Category Then
  80. Begin
  81. ReportStringGrid.RowCount := ReportStringGrid.RowCount + 1;
  82. ReportStringGrid.Cells[0, Row + 1] := I^.Data.Category;
  83. LastCategory := I^.Data.Category;
  84. Inc(Row);
  85. End;
  86.  
  87. If LastDish <> I^.Data.Name Then
  88. Begin
  89. ReportStringGrid.RowCount := ReportStringGrid.RowCount + 1;
  90. ReportStringGrid.Cells[1, Row + 1] := I^.Data.Name;
  91. ReportStringGrid.Cells[2, Row + 1] := IntToStr(Sum);
  92. LastDish := I^.Data.Name;
  93. Inc(Row);
  94. End;
  95. End;
  96. I := I^.Next;
  97. End;
  98. End;
  99.  
  100. Function FindMostProfitableTable: Integer;
  101. Var
  102. I: PtMenu;
  103. MaxRevenue: Integer;
  104. MostProfitableTable: Integer;
  105. Begin
  106. MaxRevenue := 0;
  107. MostProfitableTable := -1;
  108. I := RestoranMenu;
  109. While I <> Nil Do
  110. Begin
  111. If CalculateTableRevenue(I^.Data.CodeDish, OrderList, RestoranMenu) > MaxRevenue Then
  112. Begin
  113. MaxRevenue := CalculateTableRevenue(I^.Data.CodeDish, OrderList, RestoranMenu);
  114. MostProfitableTable := I^.Data.CodeDish;
  115. End;
  116. I := I^.Next;
  117. End;
  118. FindMostProfitableTable := MostProfitableTable;
  119. End;'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement