Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''Procedure SortByCategoryAndName(Var Menu: PtMenu);
- Var
- I, J: PtMenu;
- Temp: TMenu;
- Begin
- I := Menu;
- While I <> Nil Do
- Begin
- J := I^.Next;
- While J <> Nil Do
- Begin
- If (I^.Data.Category > J^.Data.Category) Or ((I^.Data.Category = J^.Data.Category) And (I^.Data.Name > J^.Data.Name)) Then
- Begin
- Temp := I^.Data;
- I^.Data := J^.Data;
- J^.Data := Temp;
- End;
- J := J^.Next;
- End;
- I := I^.Next;
- End;
- End;
- Function CalculateTableRevenue(TableNumber: Integer; OrderList: PtOrdList; Menu: PtMenu): Integer;
- Var
- I: PtOrdList;
- TotalRevenue: Integer;
- J: PtMenu;
- Begin
- TotalRevenue := 0;
- I := OrderList;
- While I <> Nil Do
- Begin
- If I^.Data.NumberTable = TableNumber Then
- Begin
- J := Menu;
- While J <> Nil Do
- Begin
- If J^.Data.CodeDish = I^.Data.CodeDish Then
- Begin
- TotalRevenue := TotalRevenue + I^.Data.Quantity * (J^.Data.Cost.Ruble * 100 + J^.Data.Cost.Penny);
- Break;
- End;
- J := J^.Next;
- End;
- End;
- I := I^.Next;
- End;
- CalculateTableRevenue := TotalRevenue;
- End;
- Procedure TReportPractilaForm.GiveReportPractika(Sender: TObject);
- Var
- I: PtMenu;
- J: PtOrdList;
- Row, Sum: Integer;
- LastCategory, LastDish: String;
- Begin
- Row := 0;
- LastCategory := '';
- LastDish := '';
- SortByCategoryAndName(RestoranMenu);
- I := RestoranMenu;
- While I <> Nil Do
- Begin
- Sum := 0;
- J := OrderList;
- While J <> Nil Do
- Begin
- If (I^.Data.CodeDish = J^.Data.CodeDish) Then
- Begin
- Sum := Sum + J^.Data.Quantity;
- End;
- J := J^.Next;
- End;
- If Sum > 0 Then
- Begin
- If LastCategory <> I^.Data.Category Then
- Begin
- ReportStringGrid.RowCount := ReportStringGrid.RowCount + 1;
- ReportStringGrid.Cells[0, Row + 1] := I^.Data.Category;
- LastCategory := I^.Data.Category;
- Inc(Row);
- End;
- If LastDish <> I^.Data.Name Then
- Begin
- ReportStringGrid.RowCount := ReportStringGrid.RowCount + 1;
- ReportStringGrid.Cells[1, Row + 1] := I^.Data.Name;
- ReportStringGrid.Cells[2, Row + 1] := IntToStr(Sum);
- LastDish := I^.Data.Name;
- Inc(Row);
- End;
- End;
- I := I^.Next;
- End;
- End;
- Function FindMostProfitableTable: Integer;
- Var
- I: PtMenu;
- MaxRevenue: Integer;
- MostProfitableTable: Integer;
- Begin
- MaxRevenue := 0;
- MostProfitableTable := -1;
- I := RestoranMenu;
- While I <> Nil Do
- Begin
- If CalculateTableRevenue(I^.Data.CodeDish, OrderList, RestoranMenu) > MaxRevenue Then
- Begin
- MaxRevenue := CalculateTableRevenue(I^.Data.CodeDish, OrderList, RestoranMenu);
- MostProfitableTable := I^.Data.CodeDish;
- End;
- I := I^.Next;
- End;
- FindMostProfitableTable := MostProfitableTable;
- End;'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement