Guest User

Untitled

a guest
Apr 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.25 KB | None | 0 0
  1. unit Unit3;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, Grids, DBGrids, DB, ADODB, Menus, StdCtrls, ExtCtrls, Buttons, unit2,shellapi;
  8.  
  9. type
  10.   TForm3 = class(TForm)
  11.     MainMenu1: TMainMenu;
  12.     N1: TMenuItem;
  13.     N3: TMenuItem;
  14.     StringGrid1: TStringGrid;
  15.     BitBtn1: TBitBtn;
  16.     Edit2: TEdit;
  17.     Edit1: TEdit;
  18.     BitBtn2: TBitBtn;
  19.     N4: TMenuItem;
  20.     Label1: TLabel;
  21.     Label2: TLabel;
  22.     N2: TMenuItem;
  23.     BitBtn3: TBitBtn;
  24.     procedure N3Click(Sender: TObject);
  25.     procedure FormCreate(Sender: TObject);
  26.     procedure BitBtn1Click(Sender: TObject);
  27.     procedure BitBtn2Click(Sender: TObject);
  28.     procedure N4Click(Sender: TObject);
  29.     procedure BitBtn3Click(Sender: TObject);
  30.     procedure N2Click(Sender: TObject);
  31.   private
  32.     { Private declarations }
  33.   public
  34.     { Public declarations }
  35.   end;
  36.  
  37. var
  38.   Form3: TForm3;
  39.   int: integer;      // Вводим переменные
  40.   s:real;
  41.  
  42. implementation
  43.  
  44. {$R *.dfm}
  45.  
  46.  
  47. procedure TForm3.BitBtn1Click(Sender: TObject);     // Начало процедуры обработки щелчка
  48. begin
  49.  s:=0;
  50.  for int:=1 to 4 do begin
  51.  if  Stringgrid1.Cells[3,int]=edit1.text
  52.  then s:=s+strtofloat( Stringgrid1.Cells[2,int]);
  53.  end;
  54.  edit2.text:=floattostr (s);
  55.  
  56. end;
  57.  
  58.  
  59.  
  60. procedure TForm3.BitBtn2Click(Sender: TObject);  // Процедура очистки данных из полей
  61. begin
  62. edit1.clear;
  63. edit2.clear;
  64. end;
  65.  
  66. procedure TForm3.BitBtn3Click(Sender: TObject);  //Процедура вычисления среднемесячного заработка
  67. begin
  68. s:=0;
  69.  for int:=1 to 4 do begin
  70.  if  Stringgrid1.Cells[3,int]=edit1.text
  71.  then s:=s+strtofloat( Stringgrid1.Cells[2,int])/2;
  72.  end;
  73.  edit2.text:=floattostr (s);
  74. end;
  75.  
  76. procedure TForm3.FormCreate(Sender: TObject);    // Процедура при запуске программы
  77. begin
  78. StringGrid1.Cells[0,1]:='1';        // При создании формы данные автоматически вводятся в таблицу
  79. StringGrid1.Cells[0,2]:='2';
  80. StringGrid1.Cells[0,3]:='3';
  81. StringGrid1.Cells[0,4]:='4';
  82. StringGrid1.Cells[1,0]:='Фамилия';
  83. StringGrid1.Cells[2,0]:='Зарплата';
  84. StringGrid1.Cells[3,0]:='Наименование цеха' ;
  85. StringGrid1.Cells[1,1]:='Алексеев';
  86. StringGrid1.Cells[1,2]:='Борисов';
  87. StringGrid1.Cells[1,3]:='Гринчук';
  88. StringGrid1.Cells[1,4]:='Дмитриев';
  89. StringGrid1.Cells[2,1]:='8000';
  90. StringGrid1.Cells[2,2]:='12000';
  91. StringGrid1.Cells[2,3]:='7000';
  92. StringGrid1.Cells[2,4]:='14000';
  93. StringGrid1.Cells[3,1]:='Первый';
  94. StringGrid1.Cells[3,2]:='Второй';
  95. StringGrid1.Cells[3,3]:='Третий';
  96. StringGrid1.Cells[3,4]:='Первый';
  97. end;
  98.  
  99. procedure TForm3.N2Click(Sender: TObject); // Подключаем документацию в CHM формате
  100. begin
  101.  ShellExecute(Handle,
  102.   'open', PChar('Документация.chm'), nil, nil, SW_SHOWNORMAL);
  103. end;
  104.  
  105. procedure TForm3.N3Click(Sender: TObject); // Процедура выхода через меню
  106. begin
  107. close;
  108. end;
  109.  
  110.  
  111. procedure TForm3.N4Click(Sender: TObject); // Открывает информационное окно
  112. begin
  113. form2.showmodal;
  114. end;
  115.  
  116. end.
Add Comment
Please, Sign In to add comment