Advertisement
MaksNew

Untitled

Jan 31st, 2021
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 23.60 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls,
  8.   Vcl.Samples.Spin, Vcl.Grids, Vcl.ExtDlgs, Vcl.WinXCtrls;
  9.  
  10. Type
  11.     InputType = (FromConsole, FromFile);
  12.     Worker = Record
  13.         Name: String[15];
  14.         DetailsOnMonday: Integer;
  15.         DetailsOnTuesday: Integer;
  16.         DetailsOnWednesday: Integer;
  17.         DetailsOnThursday: Integer;
  18.         DetailsOnFriday: Integer;
  19.         DetailsOnSaturday: Integer;
  20.     End;
  21.     AoW = Array of Worker;
  22.  
  23. type
  24.   TMainForm = class(TForm)
  25.     MainMenu1: TMainMenu;
  26.     N1: TMenuItem;
  27.     LabelOfWorkers: TLabel;
  28.     SpinEditOfWorkers: TSpinEdit;
  29.     N2: TMenuItem;
  30.     N3: TMenuItem;
  31.     N4: TMenuItem;
  32.     N5: TMenuItem;
  33.     N6: TMenuItem;
  34.     N7: TMenuItem;
  35.     FindDialog1: TFindDialog;
  36.     MainStringGrid: TStringGrid;
  37.     PopupMenu1: TPopupMenu;
  38.     N8: TMenuItem;
  39.     OpenDialog1: TOpenDialog;
  40.     N9: TMenuItem;
  41.     N10: TMenuItem;
  42.     N11: TMenuItem;
  43.     N12: TMenuItem;
  44.     OpenDialog2: TOpenDialog;
  45.     SaveDialog1: TSaveDialog;
  46.     N13: TMenuItem;
  47.     procedure N1Click(Sender: TObject);
  48.     procedure FormActivate(Sender: TObject);
  49.     procedure SpinEditOfWorkersChange(Sender: TObject);
  50.     procedure FindDialog1Find(Sender: TObject);
  51.     procedure N6Click(Sender: TObject);
  52.     procedure N7Click(Sender: TObject);
  53.     procedure MainStringGridMouseDown(Sender: TObject; Button: TMouseButton;
  54.       Shift: TShiftState; X, Y: Integer);
  55.     procedure N8Click(Sender: TObject);
  56.     procedure N3Click(Sender: TObject);
  57.     procedure N10Click(Sender: TObject);
  58.     procedure N11Click(Sender: TObject);
  59.     procedure N12Click(Sender: TObject);
  60.     procedure N4Click(Sender: TObject);
  61.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  62.     procedure SpinEditOfWorkersClick(Sender: TObject);
  63.   private
  64.     { Private declarations }
  65.   public
  66.     { Public declarations }
  67.   end;
  68.  
  69. var
  70.   MainForm: TMainForm;
  71.   ACol, ARow: Integer;
  72.   //GlobalBuf: Integer;
  73.   GlobalCorrect: Boolean;
  74.  
  75. implementation
  76.  
  77. {$R *.dfm}
  78. uses
  79.     Unit2;
  80.  
  81. function IsMainStringGridCorrect(StringGrid: TStringGrid; SpinEdit: TSpinEdit):boolean;
  82. var
  83.     I, J: Integer;                                             //Проверка таблицы на корректность данных
  84.     IsCorrect: Boolean;
  85. begin
  86.     IsCorrect := True;
  87.     I := 1;
  88.     while ((I <= SpinEdit.Value) and (IsCorrect)) do
  89.     begin
  90.         J := 2;
  91.         while ((J < 8) and (IsCorrect)) do
  92.         Begin
  93.             Try
  94.                 StrToInt(StringGrid.Cells[J, I])
  95.             Except
  96.                 IsCorrect := False;
  97.             End;
  98.             Inc(J);
  99.         End;
  100.         Inc(I);
  101.     end;
  102.     IsMainStringGridCorrect := IsCorrect;
  103. end;
  104.  
  105. procedure TMainForm.FindDialog1Find(Sender: TObject);
  106. var
  107.     I, J, Sum: Integer;
  108.     IsFound: Boolean;
  109. begin
  110.     Sum := 0;
  111.     IsFound := False;
  112.     for I := 1 to SpinEditOfWorkers.Value do
  113.     if MainStringGrid.Cells[1, i] = FindDialog1.FindText then
  114.         begin
  115.             for J := 2 to 7 do
  116.                 Sum := Sum + StrToInt(MainStringGrid.Cells[J, I]);
  117.             IsFound := True;
  118.             ShowMessage(FindDialog1.FindText + ' за шестидневную неделю в сумме сделал ' + IntToStr(Sum) + ' деталей');
  119.         end;
  120.     if not(IsFound) then
  121.         ShowMessage(FindDialog1.FindText + ' не найден в списке!');
  122. end;
  123.  
  124. procedure TMainForm.FormActivate(Sender: TObject);
  125. begin
  126.     //MainStringGrid.Options := MainStringGrid.Options + [goRowSelect];
  127.     MainStringGrid.Cells[0,1]:= '1';
  128.     MainStringGrid.Cells[0,2]:= '2';
  129.     MainStringGrid.Cells[0,0]:= '№ записи';
  130.     MainStringGrid.Cells[1,0]:= 'Фамилия сборщика';
  131.     MainStringGrid.Cells[2,0]:= 'Понедельник';
  132.     MainStringGrid.Cells[3,0]:= 'Вторник';
  133.     MainStringGrid.Cells[4,0]:= 'Среда';
  134.     MainStringGrid.Cells[5,0]:= 'Четверг';
  135.     MainStringGrid.Cells[6,0]:= 'Пятница';
  136.     MainStringGrid.Cells[7,0]:= 'Суббота';
  137.     SpinEditOfWorkers.Value := 1;
  138.     //GlobalBuf := SpinEditOfWorkers.Value;
  139.     N8.Enabled := False;
  140.  
  141. end;
  142.  
  143. procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  144. var
  145.     Choise: Integer;
  146. begin
  147.     Choise := Messagedlg('Вы уверены, что хотите выйти?', mtinformation, [mbYes, mbNo], 0);
  148.     case Choise of
  149.         mrYes: CanClose:= True;
  150.         mrNo: CanClose:= False;
  151.     end;
  152. end;
  153.  
  154. function VerifyFileCorOfChanging(var FileCor: TextFile): boolean;
  155. var
  156.     I, CorIndex, Details: Integer;
  157.     Name: AnsiString;
  158.     IsCorrect: Boolean;
  159.     RussianChars: set of ansichar;       //ПРОВЕРКА НА ИЗМЕНИТЬ
  160. begin
  161.     IsCorrect := True;
  162.     Details := 0;
  163.     Reset(FileCor);
  164.     RussianChars := ['A'..'Я', 'a'..'я'];
  165.     while not(EoF(FileCor)) do
  166.     begin
  167.         Try
  168.             Readln(FileCor, CorIndex);
  169.         Except
  170.             IsCorrect := False;
  171.         End;
  172.         Readln(FileCor, Name);
  173.         I := 1;
  174.         while ((I <= Length(Name)) and (IsCorrect)) do
  175.         begin
  176.             if not(Name[I] in RussianChars) then
  177.                 IsCorrect := False;
  178.             Inc(I)
  179.         end;
  180.         I := 1;
  181.         while not(eoln(FileCor)) and IsCorrect do
  182.         begin
  183.             Try
  184.                 Read(FileCor, Details);
  185.             Except
  186.                 IsCorrect := False;
  187.             End;
  188.             Inc(I)
  189.         end;
  190.         Readln(FileCor);
  191.     end;
  192.     CloseFile(FileCor);
  193.     VerifyFileCorOfChanging := IsCorrect;
  194. end;
  195.  
  196. procedure TMainForm.MainStringGridMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  197. begin
  198.   MainStringGrid.MouseToCell(X, Y, ACol, ARow); //Получаем индексы ячейки ACol и ARow
  199. end;
  200.  
  201. procedure TMainForm.N10Click(Sender: TObject);
  202. var
  203.     FileCor:TextFile;
  204.     I, J, CorIndex: Integer;
  205.     Name: AnsiString;
  206.     ArofScore: array[1..6] of integer;
  207. begin
  208. //изменить через файл корректур
  209.     if IsMainStringGridCorrect(MainStringGrid, SpinEditOfWorkers) then
  210.     begin
  211.         if OpenDialog2.Execute then
  212.         begin
  213.             AssignFile(FileCor, OpenDialog2.FileName);
  214.             if VerifyFileCorOfChanging(FileCor) then
  215.             begin
  216.                 Reset(FileCor);
  217.                 while not(EoF(FileCor)) do
  218.                 begin
  219.                     Readln(FileCor, CorIndex);
  220.                     Readln(FileCor, Name);
  221.                     I := 1;
  222.                     while not(eoln(FileCor)) do
  223.                     begin
  224.                         Read(FileCor, ArOfScore[I]);
  225.                         Inc(I)
  226.                     end;
  227.                     for I := 1 to SpinEditOfWorkers.Value do
  228.                         if I = CorIndex then
  229.                         begin
  230.                             MainStringGrid.Cells[1, I] := Name;
  231.                             for J := 2 to 7 do
  232.                                 MainStringGrid.Cells[J, I] := IntToStr(ArOfScore[J-1]);
  233.                         end;
  234.                     Readln(FileCor);
  235.                 end;
  236.                 CloseFile(FileCor)
  237.             end
  238.             else
  239.                 ShowMessage('Проверьте содержимое файла!');
  240.         end
  241.     end
  242.     else
  243.         ShowMessage('Проверьте таблицу!');
  244. end;
  245.  
  246. function VerifyFileCorOfAdding(var FileCor: TextFile): boolean;
  247. var
  248.     I, Details: Integer;
  249.     Name: AnsiString;
  250.     IsCorrect: Boolean;
  251.     RussianChars: set of ansichar;       //ПРОВЕРКА НА ДОБАВИТЬ
  252. begin
  253.     IsCorrect := True;
  254.     Details := 0;
  255.     Reset(FileCor);
  256.     RussianChars := ['A'..'Я', 'a'..'я'];
  257.     while not(EoF(FileCor)) do
  258.     begin
  259.         Readln(FileCor, Name);
  260.         I := 1;
  261.         while ((I <= Length(Name)) and (IsCorrect)) do
  262.         begin
  263.             if not(Name[I] in RussianChars) then
  264.                 IsCorrect := False;
  265.             Inc(I)
  266.         end;
  267.         I := 1;
  268.         while not(eoln(FileCor)) and IsCorrect do
  269.         begin
  270.             Try
  271.                 Read(FileCor, Details);
  272.             Except
  273.                 IsCorrect := False;
  274.             End;
  275.             Inc(I)
  276.         end;
  277.         Readln(FileCor);
  278.     end;
  279.     CloseFile(FileCor);
  280.     VerifyFileCorOfAdding := IsCorrect;
  281. end;
  282.  
  283. procedure TMainForm.N11Click(Sender: TObject); //Добавление ячеек таблицы при помощи файла корректур
  284. var
  285.     FileCor:TextFile;
  286.     I, J: Integer;
  287.     Name: AnsiString;
  288.     ArofScore: array[1..6] of integer;
  289. begin
  290.     if IsMainStringGridCorrect(MainStringGrid, SpinEditOfWorkers) then
  291.     begin
  292.         if OpenDialog2.Execute then
  293.         begin
  294.             AssignFile(FileCor, OpenDialog2.FileName);
  295.             if VerifyFileCorOfAdding(FileCor) then
  296.             begin
  297.                 Reset(FileCor);
  298.                 while not(EoF(FileCor)) do
  299.                 begin
  300.                     Readln(FileCor, Name);
  301.                     I := 1;
  302.                     while not(EoLn(FileCor)) do
  303.                     begin
  304.                         Read(FileCor, ArOfScore[I]);
  305.                         Inc(I)
  306.                     end;
  307.                     SpinEditOfWorkers.Value := SpinEditOfWorkers.Value + 1;
  308.                     MainStringGrid.Cells[1, SpinEditOfWorkers.Value] := Name;
  309.                     for J := 2 to 7 do
  310.                         MainStringGrid.Cells[J, SpinEditOfWorkers.Value] := IntToStr(ArOfScore[J-1]);
  311.                     Readln(FileCor);
  312.                 end;
  313.                 CloseFile(FileCor);
  314.             end
  315.             else
  316.                 ShowMessage('Проверьте содержимое файла!');
  317.         end;
  318.     end
  319.     else
  320.         ShowMessage('Проверьте таблицу');
  321. end;
  322.  
  323. function VerifyFileCorOfDelete(var FileCor: TextFile; MaxValue: Integer): boolean;
  324. var
  325.     I, DeleteIndex: Integer;
  326.     Name: AnsiString;
  327.     IsCorrect: Boolean;      //Проверка файла корректур с данными для удаления ячеек
  328. begin
  329.     IsCorrect := True;
  330.     DeleteIndex := 0;
  331.     I := 1;
  332.     Reset(FileCor);
  333.     while not(EoF(FileCor)) do
  334.     begin
  335.         Try
  336.             Readln(FileCor, DeleteIndex);
  337.         Except
  338.             IsCorrect := False;
  339.         End;
  340.         if IsCorrect then
  341.             if DeleteIndex > MaxValue then
  342.                 IsCorrect := False;
  343.         Inc(I);
  344.     end;
  345.     CloseFile(FileCor);
  346.     if I > MaxValue then
  347.         IsCorrect := False;    
  348.     VerifyFileCorOfDelete := IsCorrect;
  349. end;
  350.  
  351. procedure TMainForm.N12Click(Sender: TObject); //Удаление ячеек таблицы при помощи файла корректур
  352. var
  353.     FileCor:TextFile;
  354.     ARowF, I, Buf: Integer;
  355.     IsCorrect: boolean;
  356.     Records: AoW;
  357. begin
  358.     if IsMainStringGridCorrect(MainStringGrid, SpinEditOfWorkers) then
  359.     begin
  360.         if OpenDialog2.Execute then
  361.         begin
  362.             AssignFile(FileCor, OpenDialog2.FileName);
  363.             if VerifyFileCorOfDelete(FileCor, SpinEditOfWorkers.Value) then
  364.             begin
  365.                 Reset(FileCor);
  366.                 SetLength(Records, SpinEditOfWorkers.Value-1);
  367.                 I := 1;
  368.                 Buf := 0;
  369.                 ARowF := 0;
  370.                 While not(EoF(FileCor)) do
  371.                 begin
  372.                     Readln(FileCor, ARowF);
  373.                     if Buf > 0 then
  374.                         Dec(ARowF);
  375.                     while (I < ARowF) do
  376.                     begin
  377.                         Records[I-1].Name := MainStringGrid.Cells[1, I];
  378.                         Records[I-1].DetailsOnMonday := StrToInt(MainStringGrid.Cells[2, I]);
  379.                         Records[I-1].DetailsOnTuesday := StrToInt(MainStringGrid.Cells[3, I]);
  380.                         Records[I-1].DetailsOnWednesday := StrToInt(MainStringGrid.Cells[4, I]);
  381.                         Records[I-1].DetailsOnThursday := StrToInt(MainStringGrid.Cells[5, I]);
  382.                         Records[I-1].DetailsOnFriday := StrToInt(MainStringGrid.Cells[6, I]);
  383.                         Records[I-1].DetailsOnSaturday := StrToInt(MainStringGrid.Cells[7, I]);
  384.                         Inc(I);
  385.                     end;
  386.  
  387.                     I := ARowF + 1;
  388.  
  389.                     while (I <= SpinEditOfWorkers.Value) do
  390.                     begin
  391.                         Records[I-2].Name := MainStringGrid.Cells[1, I];
  392.                         Records[I-2].DetailsOnMonday := StrToInt(MainStringGrid.Cells[2, I]);
  393.                         Records[I-2].DetailsOnTuesday := StrToInt(MainStringGrid.Cells[3, I]);
  394.                         Records[I-2].DetailsOnWednesday := StrToInt(MainStringGrid.Cells[4, I]);
  395.                         Records[I-2].DetailsOnThursday := StrToInt(MainStringGrid.Cells[5, I]);
  396.                         Records[I-2].DetailsOnFriday := StrToInt(MainStringGrid.Cells[6, I]);
  397.                         Records[I-2].DetailsOnSaturday := StrToInt(MainStringGrid.Cells[7, I]);
  398.                         Inc(I);
  399.                     end;
  400.  
  401.                     for I := 1 to 7 do
  402.                         MainStringGrid.Cells[I, SpinEditOfWorkers.Value] := ' ';
  403.  
  404.                     SpinEditOfWorkers.Value := SpinEditOfWorkers.Value - 1;
  405.                     for I := 1 to SpinEditOfWorkers.Value do
  406.                     begin
  407.                         MainStringGrid.Cells[1, I] := Records[I-1].Name;
  408.                         MainStringGrid.Cells[2, I] := IntToStr(Records[I-1].DetailsOnMonday);
  409.                         MainStringGrid.Cells[3, I] := IntToStr(Records[I-1].DetailsOnTuesday);
  410.                         MainStringGrid.Cells[4, I] := IntToStr(Records[I-1].DetailsOnWednesday);
  411.                         MainStringGrid.Cells[5, I] := IntToStr(Records[I-1].DetailsOnThursday);
  412.                         MainStringGrid.Cells[6, I] := IntToStr(Records[I-1].DetailsOnFriday);
  413.                         MainStringGrid.Cells[7, I] := IntToStr(Records[I-1].DetailsOnSaturday);
  414.                     end;
  415.                     Inc(Buf);
  416.                 end;
  417.                 CloseFile(FileCor);
  418.             end
  419.             else
  420.                 ShowMessage('Проверьте содержимое файла!');
  421.         end;
  422.     end
  423.     else
  424.         ShowMessage('Проверьте таблицу!');
  425. end;
  426.  
  427.  
  428.  
  429. procedure TMainForm.N1Click(Sender: TObject);
  430. begin
  431.    Form2.Show;
  432. end;
  433.  
  434. procedure TMainForm.N3Click(Sender: TObject);
  435. var
  436.     TypeFile: File of Worker;
  437.     I, J: Integer;
  438.     IsCorrect: boolean;
  439.     Records: AoW;
  440. begin
  441.     if OpenDialog1.Execute then
  442.     begin
  443.         for I := 1 to SpinEditOfWorkers.Value do
  444.             for J := 1 to 7 do
  445.                 MainStringGrid.Cells[J, I] := '';
  446.         AssignFile(TypeFile, OpenDialog1.FileName);
  447.         Reset(TypeFile);
  448.         SpinEditOfWorkers.Value := FileSize(TypeFile);
  449.         for I := 1 to SpinEditOfWorkers.Value do
  450.             MainStringGrid.Cells[0, I] := IntToStr(I);
  451.         SetLength(Records, SpinEditOfWorkers.Value);
  452.         I := 0;
  453.         While not(EoF(TypeFile)) do
  454.         Begin
  455.             Read(TypeFile, Records[I]);
  456.             Inc(I);
  457.         End;
  458.  
  459.         for I := 1 to SpinEditOfWorkers.Value do
  460.         begin
  461.             MainStringGrid.Cells[1, I] := Records[I-1].Name;
  462.             MainStringGrid.Cells[2, I] := IntToStr(Records[I-1].DetailsOnMonday);
  463.             MainStringGrid.Cells[3, I] := IntToStr(Records[I-1].DetailsOnTuesday);
  464.             MainStringGrid.Cells[4, I] := IntToStr(Records[I-1].DetailsOnWednesday);
  465.             MainStringGrid.Cells[5, I] := IntToStr(Records[I-1].DetailsOnThursday);
  466.             MainStringGrid.Cells[6, I] := IntToStr(Records[I-1].DetailsOnFriday);
  467.             MainStringGrid.Cells[7, I] := IntToStr(Records[I-1].DetailsOnSaturday);
  468.         end;
  469.         CloseFile(typefile);
  470.     end;
  471. end;
  472.  
  473. procedure TMainForm.N4Click(Sender: TObject);   //СОХРАНИТЬ
  474. var
  475.     I: Integer;
  476.     SaveTypeFile: File of Worker;
  477.     SaveRecord: AoW;
  478. begin
  479.     if IsMainStringGridCorrect(MainStringGrid, SpinEditOfWorkers) then
  480.     begin
  481.         if SaveDialog1.Execute then
  482.         begin
  483.             AssignFile(SaveTypeFile, SaveDialog1.FileName);
  484.             Rewrite(SaveTypeFile);
  485.             SetLength(SaveRecord, SpinEditOfWorkers.Value);
  486.             for I := 1 to SpinEditOfWorkers.Value do
  487.             begin
  488.                 SaveRecord[I-1].Name := MainStringGrid.Cells[1, I];
  489.                 SaveRecord[I-1].DetailsOnMonday := StrToInt(MainStringGrid.Cells[2, I]);
  490.                 SaveRecord[I-1].DetailsOnTuesday := StrToInt(MainStringGrid.Cells[3, I]);
  491.                 SaveRecord[I-1].DetailsOnWednesday := StrToInt(MainStringGrid.Cells[4, I]);
  492.                 SaveRecord[I-1].DetailsOnThursday := StrToInt(MainStringGrid.Cells[5, I]);
  493.                 SaveRecord[I-1].DetailsOnFriday := StrToInt(MainStringGrid.Cells[6, I]);
  494.                 SaveRecord[I-1].DetailsOnSaturday := StrToInt(MainStringGrid.Cells[7, I]);
  495.             end;
  496.  
  497.             for I := 0 to SpinEditOfWorkers.Value-1 do
  498.                 Write(SaveTypeFile, SaveRecord[I]);
  499.             CloseFile(SaveTypeFile);
  500.         end;
  501.     end
  502.     else
  503.         ShowMessage('Проверьте таблицу!');
  504. end;
  505.  
  506. procedure TMainForm.N6Click(Sender: TObject);
  507. begin
  508.     if IsMainStringGridCorrect(MainStringGrid, SpinEditOfWorkers) then
  509.         FindDialog1.Execute()
  510.     else
  511.         ShowMessage('Проверьте таблицу!');
  512. end;
  513.  
  514. procedure TMainForm.N7Click(Sender: TObject);
  515. var
  516.     ArrayOfSumOfProducts: array of integer;
  517.     BestWorkman, BestDay: AnsiString;
  518.     I, J, Sum, MaxPerf, BestBuf: Integer;
  519. begin
  520.     if IsMainStringGridCorrect(MainStringGrid, SpinEditOfWorkers) then
  521.     begin
  522.         SetLength(ArrayOfSumOfProducts, SpinEditOfWorkers.Value);
  523.         MaxPerf := 0;
  524.         BestBuf := 0;
  525.         for I := 0 to SpinEditOfWorkers.Value-1 do //находит сумму всех деталей каждого рабочего
  526.         begin
  527.             Sum := 0;
  528.             for J := 2 to 7 do
  529.             begin
  530.                 Sum := Sum + StrToInt(MainStringGrid.Cells[J,I+1]);
  531.             end;
  532.             ArrayOfSumOfProducts[I] := Sum;
  533.         end;
  534.  
  535.         for I := 0 to SpinEditOfWorkers.Value-1 do   // ищет максимум деталей среди рабочих и день высшей производительности
  536.         begin
  537.             if ((ArrayOfSumOfProducts[I] > ArrayOfSumOfProducts[I-1]) and (ArrayOfSumOfProducts[I] > MaxPerf)) then
  538.             begin
  539.                 MaxPerf := ArrayOfSumOfProducts[I];
  540.                 BestWorkman := MainStringGrid.Cells[1, I+1];
  541.                 for J := 2 to 6 do
  542.                     if ((StrToInt(MainStringGrid.Cells[J, I+1]) > StrToInt(MainStringGrid.Cells[J+1,I+1])) and (StrToInt(MainStringGrid.Cells[J, I+1]) > BestBuf)) then
  543.                     begin
  544.                         BestDay := MainStringGrid.Cells[J,0];
  545.                         BestBuf := StrToInt(MainStringGrid.Cells[J, I+1])
  546.                     end;
  547.             end;
  548.         end;
  549.  
  550.         if MaxPerf > 0 then
  551.             ShowMessage(BestWorkman + ' собрал ' + IntToStr(MaxPerf) + ' деталей, что является лучшим показателем! День высшей производительности: ' + BestDay)
  552.         else
  553.             ShowMessage('Таких нет!');
  554.     end
  555.     else
  556.         ShowMessage('Проверьте таблицу!');
  557. end;
  558.  
  559. procedure TMainForm.N8Click(Sender: TObject);
  560. var
  561.     Records: AoW;
  562.     I: Integer;
  563. begin
  564.     GlobalCorrect := False;
  565.     if SpinEditOfWorkers.Value > 0 then
  566.     begin
  567.         if IsMainStringGridCorrect(MainStringGrid, SpinEditOfWorkers) then
  568.         begin
  569.             Setlength(Records, SpinEditOfWorkers.Value-1);
  570.             I := 1;
  571.             while (I < ARow) do
  572.             begin
  573.                 Records[I-1].Name := MainStringGrid.Cells[1, I];
  574.                 Records[I-1].DetailsOnMonday := StrToInt(MainStringGrid.Cells[2, I]);
  575.                 Records[I-1].DetailsOnTuesday := StrToInt(MainStringGrid.Cells[3, I]);
  576.                 Records[I-1].DetailsOnWednesday := StrToInt(MainStringGrid.Cells[4, I]);
  577.                 Records[I-1].DetailsOnThursday := StrToInt(MainStringGrid.Cells[5, I]);
  578.                 Records[I-1].DetailsOnFriday := StrToInt(MainStringGrid.Cells[6, I]);
  579.                 Records[I-1].DetailsOnSaturday := StrToInt(MainStringGrid.Cells[7, I]);
  580.                 Inc(I);
  581.             end;
  582.  
  583.             I := ARow + 1;
  584.  
  585.             while (I <= SpinEditOfWorkers.Value) do
  586.             begin
  587.                 Records[I-2].Name := MainStringGrid.Cells[1, I];
  588.                 Records[I-2].DetailsOnMonday := StrToInt(MainStringGrid.Cells[2, I]);
  589.                 Records[I-2].DetailsOnTuesday := StrToInt(MainStringGrid.Cells[3, I]);
  590.                 Records[I-2].DetailsOnWednesday := StrToInt(MainStringGrid.Cells[4, I]);
  591.                 Records[I-2].DetailsOnThursday := StrToInt(MainStringGrid.Cells[5, I]);
  592.                 Records[I-2].DetailsOnFriday := StrToInt(MainStringGrid.Cells[6, I]);
  593.                 Records[I-2].DetailsOnSaturday := StrToInt(MainStringGrid.Cells[7, I]);
  594.                 Inc(I);
  595.             end;
  596.  
  597.             for I := 1 to 7 do
  598.                 MainStringGrid.Cells[I, SpinEditOfWorkers.Value] := ' ';
  599.  
  600.             SpinEditOfWorkers.Value := SpinEditOfWorkers.Value - 1;
  601.             for I := 1 to SpinEditOfWorkers.Value do
  602.             begin
  603.                 MainStringGrid.Cells[1, I] := Records[I-1].Name;
  604.                 MainStringGrid.Cells[2, I] := IntToStr(Records[I-1].DetailsOnMonday);
  605.                 MainStringGrid.Cells[3, I] := IntToStr(Records[I-1].DetailsOnTuesday);
  606.                 MainStringGrid.Cells[4, I] := IntToStr(Records[I-1].DetailsOnWednesday);
  607.                 MainStringGrid.Cells[5, I] := IntToStr(Records[I-1].DetailsOnThursday);
  608.                 MainStringGrid.Cells[6, I] := IntToStr(Records[I-1].DetailsOnFriday);
  609.                 MainStringGrid.Cells[7, I] := IntToStr(Records[I-1].DetailsOnSaturday);
  610.             end;
  611.         end
  612.         else
  613.             ShowMessage('Проверьте таблицу!');
  614.     end
  615. end;
  616.  
  617. procedure TMainForm.SpinEditOfWorkersChange(Sender: TObject);
  618. var
  619.     UserHigh, I, Buf: Integer;
  620. begin
  621.   {  if ((GlobalCorrect) and (SpinEditOfWorkers.Value < GlobalBuf)) then
  622.         SpinEditOfWorkers.Value := GlobalBuf
  623.     else
  624.         GlobalBuf := SpinEditOfWorkers.Value;  }
  625.     UserHigh := 200;
  626.     if ((SpinEditOfWorkers.Value > 0) and (SpinEditOfWorkers.Value < 23)) then
  627.     begin
  628.         MainStringGrid.Cells[0,SpinEditOfWorkers.Value]:= IntToStr(SpinEditOfWorkers.Value);
  629.         MainStringGrid.Options := MainStringGrid.Options+[goEditing];
  630.         MainStringGrid.RowCount := SpinEditOfWorkers.Value+1;
  631.         MainStringGrid.Height := 36 * MainStringGrid.RowCount;
  632.         if (MainStringGrid.Height + MainStringGrid.Top < UserHigh) then
  633.             ClientHeight := UserHigh
  634.         else
  635.             ClientHeight := MainStringGrid.Height + MainStringGrid.Top + 10;
  636.     end
  637.     else
  638.         MainStringGrid.Options := MainStringGrid.Options-[goEditing];
  639.     if (SpinEditOfWorkers.Value > 1) then
  640.     begin
  641.         N6.Enabled := True;
  642.         N7.Enabled := True;
  643.         N8.Enabled := True;
  644.         N12.Enabled := True
  645.     end
  646.     else
  647.     begin
  648.         N6.Enabled := False;
  649.         N7.Enabled := False;
  650.         N8.Enabled := False;
  651.         N12.Enabled := False;
  652.     end;
  653. end;
  654.  
  655. procedure TMainForm.SpinEditOfWorkersClick(Sender: TObject);
  656. begin
  657.     GlobalCorrect := True;
  658. end;
  659.  
  660. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement