Advertisement
Matixs

Untitled

May 31st, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.19 KB | None | 0 0
  1. unit CountyNumberAdd;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  7.   Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
  8.   Vcl.ComCtrls, Vcl.NumberBox;
  9.  
  10. type
  11.   TCountyNumberAddFrame = class(TFrame)
  12.     GroupBox: TGroupBox;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Label3: TLabel;
  16.     EditName: TEdit;
  17.     EditTownRegion: TEdit;
  18.     NumberCountyNumber: TNumberBox;
  19.     UpDown: TUpDown;
  20.     BtnSave: TButton;
  21.     procedure FrameEnter(Sender: TObject);
  22.     procedure BtnSaveClick(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.     Constructor Create(aOwner : TComponent); override;
  28.   end;
  29.  
  30. implementation
  31.  
  32. {$R *.dfm}
  33.  
  34. uses CountyNumber, BidirectionalCountyNumber, Main;
  35.  
  36.  
  37. procedure TCountyNumberAddFrame.BtnSaveClick(Sender: TObject);
  38. var
  39.     NewCountyNumber : TCountyNumber;
  40.     Key : Integer;
  41. begin
  42.     if (EditName.Text <> '') AND (EditTownRegion.Text <> '') then
  43.     begin
  44.         try
  45.             Key := TCountyNumberList.GetLastPrimaryKey(Main.CountyNumberList) + 1;
  46.             NewCountyNumber := TCountyNumber.Create(Key, StrToInt(NumberCountyNumber.Text), EditName.Text, EditTownRegion.Text);
  47.             Main.CountyNumberList.AddNewCountyNumber(NewCountyNumber);
  48.             Application.MessageBox('Округ успешно добавлен!','Добавление округа',MB_OK + MB_ICONINFORMATION);
  49.         except
  50.             On E : Exception do
  51.                 Application.MessageBox(PChar(E.Message),'Ошибка добавления округа', MB_OK + MB_ICONWARNING);
  52.         end;
  53.     end
  54.     else
  55.         Application.MessageBox('Заполните все поля!','Добавление округа',MB_OK+MB_ICONWARNING);
  56. end;
  57.  
  58. Constructor TCountyNumberAddFrame.Create(aOwner: TComponent);
  59. begin
  60.     inherited Create(aOwner);
  61.     UpDown.Associate := NumberCountyNumber;
  62. end;
  63.  
  64.  
  65. procedure TCountyNumberAddFrame.FrameEnter(Sender: TObject);
  66. begin
  67.     // TODO: передать данные из основого фрейма.
  68.  
  69.     //CountyNumberList := Main.CountyNumberList;
  70.     //PartyList := Main.PartyList;
  71.  
  72. end;
  73.  
  74. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement