Advertisement
gguuppyy

PartyUnit

May 4th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. Unit PartyUnit;
  2.  
  3. Interface
  4.  
  5. Uses
  6. Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  7. System.Classes, Vcl.Graphics,
  8. Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls,
  9. CandidateListUnit, PartyListUnit, Vcl.Menus, Vcl.ExtDlgs;
  10.  
  11. Type
  12. TPartyForm = Class(TForm)
  13. MainMenu: TMainMenu;
  14. FileMenuItem: TMenuItem;
  15. SaveMenuItem: TMenuItem;
  16. SaveTextFileDialog: TSaveTextFileDialog;
  17.  
  18. ContentEdit: TEdit;
  19. PartyStringGrid: TStringGrid;
  20.  
  21. Procedure CreateParams(Var Params: TCreateParams); Override;
  22. Function FormHelp(Command: Word; Data: NativeInt; Var CallHelp: Boolean): Boolean;
  23. Procedure FormKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
  24.  
  25. Procedure CreateBulletinForm();
  26. Procedure CreatePartyForm();
  27. Procedure FormShow(Sender: TObject);
  28.  
  29. Procedure SaveMenuItemClick(Sender: TObject);
  30.  
  31. Procedure PartyStringGridSelectCell(Sender: TObject; ACol, ARow: Integer; Var CanSelect: Boolean);
  32.  
  33. Private
  34. { Private declarations }
  35. Public
  36. { Public declarations }
  37. End;
  38.  
  39. Var
  40. PartyForm: TPartyForm;
  41.  
  42. Implementation
  43.  
  44. {$R *.dfm}
  45.  
  46. Uses
  47. MenuUnit, SearchUnit;
  48.  
  49. Procedure TPartyForm.CreateParams(Var Params: TCreateParams);
  50. Begin
  51. Inherited;
  52. Params.ExStyle := Params.ExStyle Or WS_EX_APPWINDOW;
  53. End;
  54.  
  55. Function TPartyForm.FormHelp(Command: Word; Data: NativeInt; Var CallHelp: Boolean): Boolean;
  56. Begin
  57. CallHelp := False;
  58. FormHelp := False;
  59. End;
  60.  
  61. Procedure TPartyForm.FormKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
  62. Begin
  63. If Key = VK_ESCAPE Then
  64. Close;
  65. End;
  66.  
  67.  
  68. Procedure TPartyForm.CreateBulletinForm();
  69. Begin
  70. PartyForm.Caption := 'Бюллетень';
  71. With PartyStringGrid Do
  72. Begin
  73. ColCount := 4;
  74. DefaultColWidth := 211;
  75. Cells[0, 0] := 'Партия';
  76. Cells[1, 0] := 'Заявления';
  77. Cells[2, 0] := 'Возраст';
  78. Cells[3, 0] := 'Профессия';
  79. FillBulletinStringGrid(CandidateList, PartyStringGrid);
  80. End;
  81. End;
  82.  
  83. Procedure TPartyForm.CreatePartyForm();
  84. Begin
  85. PartyForm.Caption := 'Партия ' + String(PartyName);
  86. With PartyStringGrid Do
  87. Begin
  88. ColCount := 6;
  89. DefaultColWidth := 140;
  90. Cells[0, 0] := '№ округа';
  91. Cells[1, 0] := 'Фамилия';
  92. Cells[2, 0] := 'Имя';
  93. Cells[3, 0] := 'Отчество';
  94. Cells[4, 0] := 'Возраст';
  95. Cells[5, 0] := 'Профессия';
  96. FillPartyStringGrid(CandidateList, PartyStringGrid, PartyName);
  97. End;
  98. End;
  99.  
  100. Procedure TPartyForm.FormShow(Sender: TObject);
  101. Begin
  102. If StateForm = Bulletin Then
  103. CreateBulletinForm()
  104. Else
  105. CreatePartyForm();
  106. End;
  107.  
  108.  
  109. procedure TPartyForm.SaveMenuItemClick(Sender: TObject);
  110. Var
  111. OutputFile: TextFile;
  112. Row: Integer;
  113. Begin
  114. If SaveTextFileDialog.Execute Then
  115. Begin
  116. AssignFile(OutputFile, SaveTextFileDialog.FileName);
  117. Rewrite(OutputFile);
  118. If PartyStringGrid.ColCount = 4 Then
  119. For Row := 0 To PartyStringGrid.RowCount - 1 Do
  120. WriteLn(OutputFile, Format('%-40s %-9s %-7s %-30s', [PartyStringGrid.Cells[0, Row], PartyStringGrid.Cells[1, Row], PartyStringGrid.Cells[2, Row], PartyStringGrid.Cells[3, Row]]))
  121. Else
  122. For Row := 0 To PartyStringGrid.RowCount - 1 Do
  123. WriteLn(OutputFile, Format('%-8s %-30s %-30s %-30s %-7s %-30s', [PartyStringGrid.Cells[0, Row], PartyStringGrid.Cells[1, Row], PartyStringGrid.Cells[2, Row], PartyStringGrid.Cells[3, Row], PartyStringGrid.Cells[4, Row], PartyStringGrid.Cells[5, Row]]));
  124. CloseFile(OutputFile);
  125. End;
  126. end;
  127.  
  128.  
  129. Procedure TPartyForm.PartyStringGridSelectCell(Sender: TObject; ACol, ARow: Integer; Var CanSelect: Boolean);
  130. Begin
  131. If ARow > 0 Then
  132. ContentEdit.Text := PartyStringGrid.Cells[ACol, ARow]
  133. Else
  134. ContentEdit.Text := '';
  135. End;
  136.  
  137. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement