Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Lab_4_1_Form;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus;
- type
- TFormMenu = class(TForm)
- ButtonCreateNewRecord: TButton;
- ButtonChangeRecord: TButton;
- ButtonDeleteRecord: TButton;
- ButtonSeeRecord: TButton;
- LabelWelcome: TLabel;
- LabelProgramFunction: TLabel;
- LabelChooseFunction: TLabel;
- ButtonFindSpecialPrinters: TButton;
- LabelTask: TLabel;
- LabelAbout: TLabel;
- ButtonAbout: TButton;
- ButtonHelp: TButton;
- LabelHelp: TLabel;
- procedure ButtonAboutClick(Sender: TObject);
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure ButtonCreateNewRecordClick(Sender: TObject);
- procedure ButtonChangeRecordClick(Sender: TObject);
- procedure ButtonDeleteRecordClick(Sender: TObject);
- procedure ButtonSeeRecordClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure ButtonHelpClick(Sender: TObject);
- procedure ButtonFindSpecialPrintersClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormMenu: TFormMenu;
- implementation
- {$R *.dfm}
- uses UnitAbout, UnitError, UnitExit, UnitCreateNewRecord, UnitChangeRecord,
- UnitDeleteRecord, UnitSeeRecord, UnitInstructionMenu, UnitTaskSearch;
- {Type
- TPrinter = record
- Brand: String[15];
- Kind: Char;
- Format: Integer;
- Cost: Integer;
- end;
- var
- F: File of TPrinter;
- Printer: TPrinter; }
- procedure TFormMenu.ButtonAboutClick(Sender: TObject);
- begin
- UnitAbout.FormAbout.ShowModal();
- end;
- procedure TFormMenu.ButtonChangeRecordClick(Sender: TObject);
- begin
- FormMenu.Visible := false;
- UnitChangeRecord.FormChangeRecord.ShowModal();
- FormMenu.Visible := true;
- end;
- procedure TFormMenu.ButtonCreateNewRecordClick(Sender: TObject);
- begin
- FormMenu.Visible := false;
- UnitCreateNewRecord.FormCreateNewRecord.ShowModal();
- FormMenu.Visible := true;
- end;
- procedure TFormMenu.ButtonDeleteRecordClick(Sender: TObject);
- begin
- FormMenu.Visible := false;
- UnitDeleteRecord.FormDeleteRecord.ShowModal();
- FormMenu.Visible := true;
- end;
- procedure TFormMenu.ButtonFindSpecialPrintersClick(Sender: TObject);
- begin
- UnitTaskSearch.FormTaskSearch.ShowModal();
- end;
- procedure TFormMenu.ButtonHelpClick(Sender: TObject);
- begin
- UnitInstructionMenu.FormInstructionMenu.ShowModal();
- end;
- procedure TFormMenu.ButtonSeeRecordClick(Sender: TObject);
- begin
- FormMenu.Visible := false;
- UnitSeeRecord.FormSeeRecord.ShowModal();
- FormMenu.Visible := true;
- end;
- procedure TFormMenu.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- var
- Res: Integer;
- begin
- Res := UnitExit.FormExit.ShowModal();
- If Res = mrOk Then
- CanClose := True
- Else
- CanClose := False;
- end;
- procedure TFormMenu.FormCreate(Sender: TObject);
- begin
- {Reset(F); }
- end;
- end.
- unit UnitTaskSearch;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Menus;
- type
- TFormTaskSearch = class(TForm)
- RadioGroupChooseFormat: TRadioGroup;
- ButtonChoosePrinters: TButton;
- EditPrinterCount: TEdit;
- LabelPrinterCount: TLabel;
- LabelAveragePrice: TLabel;
- EditAveragePrice: TEdit;
- ButtonExit: TButton;
- MainMenuTask: TMainMenu;
- ButtonSaveToFile: TMenuItem;
- SaveDialogTask: TSaveDialog;
- procedure RadioGroupChooseFormatClick(Sender: TObject);
- procedure ButtonChoosePrintersClick(Sender: TObject);
- procedure ButtonExitClick(Sender: TObject);
- procedure ButtonSaveToFileClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormTaskSearch: TFormTaskSearch;
- implementation
- {$R *.dfm}
- uses UnitError;
- const
- PATH = 'Records.rcd';
- Type
- TPrinter = record
- Brand: String[15];
- Kind: Char;
- Format: Integer;
- CostRub, CostCop: Integer;
- end;
- var
- F: File of TPrinter;
- Printer: TPrinter;
- ChosenFormat: Integer;
- function GetAveragePrice(Rub, Cop, Count: Integer): Double;
- var
- AllRub: Integer;
- AllPrice: Double;
- begin
- AllRub := Rub + (Cop div 100);
- AllPrice := AllRub + ((Cop mod 100) / 100);
- GetAveragePrice := AllPrice / Count;
- end;
- procedure TFormTaskSearch.ButtonChoosePrintersClick(Sender: TObject);
- var
- IsCorrect: Boolean;
- Size, I, Count, CostRub, CostCop: Integer;
- AveragePrice: Double;
- begin
- Count := 0;
- CostRub := 0;
- CostCop := 0;
- IsCorrect := true;
- try
- AssignFile(F, PATH);
- Reset(F);
- Seek(F, 0);
- Size := FileSize(F);
- for I := 0 to (Size - 1) do
- begin
- Read(F, Printer);
- if (Printer.Kind = 'M') and (Printer.Format = ChosenFormat) then
- begin
- Inc(Count);
- CostRub := CostRub + Printer.CostRub;
- CostCop := CostCop + Printer.CostCop;
- end;
- end;
- if Count <> 0 then
- begin
- AveragePrice := GetAveragePrice(CostRub, CostCop, Count);
- try
- EditAveragePrice.Text := FloatToStr(AveragePrice);
- EditPrinterCount.Text := IntToStr(Count);
- finally
- CloseFile(F);
- end;
- ButtonSaveToFile.Enabled := true;
- end
- else
- begin
- UnitError.FormError.LabelError.Caption := 'Не найдено записей, ' +
- 'подходящих условию отборки. ';
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- except
- IsCorrect := false;
- UnitError.FormError.LabelError.Caption := 'Ошибка. Нет доступа к фай' +
- 'лу. Проверьте наличие файла Records.rdc в папке с приложением, а также' +
- ' доступ к нему. ';
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- end;
- procedure TFormTaskSearch.ButtonExitClick(Sender: TObject);
- begin
- EditAveragePrice.Text := '';
- EditPrinterCount.Text := '';
- RadioGroupChooseFormat.ItemIndex := -1;
- ModalResult := mrOk;
- end;
- procedure TFormTaskSearch.ButtonSaveToFileClick(Sender: TObject);
- var
- SaveFile: TextFile;
- SavePath, Error: String;
- IsCorrect: Boolean;
- begin
- IsCorrect := True;;
- Error := '';
- if SaveDialogTask.Execute() then
- begin
- SavePath := SaveDialogTask.FileName;
- AssignFile(SaveFile, SavePath);
- Try
- Rewrite(SaveFile);
- Try
- Writeln(SaveFile, 'Количество матричных принтеров с заданным' +
- ' форматом: ', EditPrinterCount.Text);
- Writeln(SaveFile, 'Их средняя цена: ', EditAveragePrice.Text)
- Finally
- CloseFile(SaveFile);
- End;
- Except
- IsCorrect := False;
- Error := 'Нет доступа к файлу';
- End;
- if not(IsCorrect) then
- begin
- UnitError.FormError.LabelError.Caption := 'Ошибка считывания с файла. ' + Error;
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end
- else
- ButtonSaveToFile.Enabled := false;
- end;
- end;
- procedure TFormTaskSearch.RadioGroupChooseFormatClick(Sender: TObject);
- begin
- EditAveragePrice.Text := '';
- EditPrinterCount.Text := '';
- ButtonSaveToFile.Enabled := false;
- case RadioGroupChooseFormat.ItemIndex of
- 0: ChosenFormat := 1;
- 1: ChosenFormat := 2;
- 2: ChosenFormat := 3;
- 3: ChosenFormat := 4;
- 4: ChosenFormat := 5;
- 5: ChosenFormat := 6;
- end;
- end;
- end.
- unit UnitTaskSearch;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Menus;
- type
- TFormTaskSearch = class(TForm)
- RadioGroupChooseFormat: TRadioGroup;
- ButtonChoosePrinters: TButton;
- EditPrinterCount: TEdit;
- LabelPrinterCount: TLabel;
- LabelAveragePrice: TLabel;
- EditAveragePrice: TEdit;
- ButtonExit: TButton;
- MainMenuTask: TMainMenu;
- ButtonSaveToFile: TMenuItem;
- SaveDialogTask: TSaveDialog;
- procedure RadioGroupChooseFormatClick(Sender: TObject);
- procedure ButtonChoosePrintersClick(Sender: TObject);
- procedure ButtonExitClick(Sender: TObject);
- procedure ButtonSaveToFileClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormTaskSearch: TFormTaskSearch;
- implementation
- {$R *.dfm}
- uses UnitError;
- const
- PATH = 'Records.rcd';
- Type
- TPrinter = record
- Brand: String[15];
- Kind: Char;
- Format: Integer;
- CostRub, CostCop: Integer;
- end;
- var
- F: File of TPrinter;
- Printer: TPrinter;
- ChosenFormat: Integer;
- function GetAveragePrice(Rub, Cop, Count: Integer): Double;
- var
- AllRub: Integer;
- AllPrice: Double;
- begin
- AllRub := Rub + (Cop div 100);
- AllPrice := AllRub + ((Cop mod 100) / 100);
- GetAveragePrice := AllPrice / Count;
- end;
- procedure TFormTaskSearch.ButtonChoosePrintersClick(Sender: TObject);
- var
- IsCorrect: Boolean;
- Size, I, Count, CostRub, CostCop: Integer;
- AveragePrice: Double;
- begin
- Count := 0;
- CostRub := 0;
- CostCop := 0;
- IsCorrect := true;
- try
- AssignFile(F, PATH);
- Reset(F);
- Seek(F, 0);
- Size := FileSize(F);
- for I := 0 to (Size - 1) do
- begin
- Read(F, Printer);
- if (Printer.Kind = 'M') and (Printer.Format = ChosenFormat) then
- begin
- Inc(Count);
- CostRub := CostRub + Printer.CostRub;
- CostCop := CostCop + Printer.CostCop;
- end;
- end;
- if Count <> 0 then
- begin
- AveragePrice := GetAveragePrice(CostRub, CostCop, Count);
- try
- EditAveragePrice.Text := FloatToStr(AveragePrice);
- EditPrinterCount.Text := IntToStr(Count);
- finally
- CloseFile(F);
- end;
- ButtonSaveToFile.Enabled := true;
- end
- else
- begin
- UnitError.FormError.LabelError.Caption := 'Не найдено записей, ' +
- 'подходящих условию отборки. ';
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- except
- IsCorrect := false;
- UnitError.FormError.LabelError.Caption := 'Ошибка. Нет доступа к фай' +
- 'лу. Проверьте наличие файла Records.rdc в папке с приложением, а также' +
- ' доступ к нему. ';
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- end;
- procedure TFormTaskSearch.ButtonExitClick(Sender: TObject);
- begin
- EditAveragePrice.Text := '';
- EditPrinterCount.Text := '';
- RadioGroupChooseFormat.ItemIndex := -1;
- ModalResult := mrOk;
- end;
- procedure TFormTaskSearch.ButtonSaveToFileClick(Sender: TObject);
- var
- SaveFile: TextFile;
- SavePath, Error: String;
- IsCorrect: Boolean;
- begin
- IsCorrect := True;;
- Error := '';
- if SaveDialogTask.Execute() then
- begin
- SavePath := SaveDialogTask.FileName;
- AssignFile(SaveFile, SavePath);
- Try
- Rewrite(SaveFile);
- Try
- Writeln(SaveFile, 'Количество матричных принтеров с заданным' +
- ' форматом: ', EditPrinterCount.Text);
- Writeln(SaveFile, 'Их средняя цена: ', EditAveragePrice.Text)
- Finally
- CloseFile(SaveFile);
- End;
- Except
- IsCorrect := False;
- Error := 'Нет доступа к файлу';
- End;
- if not(IsCorrect) then
- begin
- UnitError.FormError.LabelError.Caption := 'Ошибка считывания с файла. ' + Error;
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end
- else
- ButtonSaveToFile.Enabled := false;
- end;
- end;
- procedure TFormTaskSearch.RadioGroupChooseFormatClick(Sender: TObject);
- begin
- EditAveragePrice.Text := '';
- EditPrinterCount.Text := '';
- ButtonSaveToFile.Enabled := false;
- case RadioGroupChooseFormat.ItemIndex of
- 0: ChosenFormat := 1;
- 1: ChosenFormat := 2;
- 2: ChosenFormat := 3;
- 3: ChosenFormat := 4;
- 4: ChosenFormat := 5;
- 5: ChosenFormat := 6;
- end;
- end;
- end.
- unit UnitDeleteRecord;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Grids, Vcl.Menus;
- type
- TFormDeleteRecord = class(TForm)
- LabelCondition: TLabel;
- ButtonDeleteRecord: TButton;
- Records: TStringGrid;
- LabelDeleteRecord: TLabel;
- EditDeleteRecord: TEdit;
- MainMenuDeleteRecord: TMainMenu;
- OpenDialogDeleteRecord: TOpenDialog;
- ButtonDeleteRecordFromFile: TMenuItem;
- ButtonInstruction: TMenuItem;
- procedure FormShow(Sender: TObject);
- procedure ButtonExitClick(Sender: TObject);
- procedure ComboBoxDeleteRecordKeyPress(Sender: TObject; var Key: Char);
- procedure EditDeleteRecordKeyPress(Sender: TObject; var Key: Char);
- procedure ButtonDeleteRecordClick(Sender: TObject);
- procedure ButtonDeleteRecordFromFileClick(Sender: TObject);
- procedure ButtonInstructionClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormDeleteRecord: TFormDeleteRecord;
- implementation
- {$R *.dfm}
- uses UnitError, UnitInstructionDeleteRecord;
- const
- PATH = 'Records.rcd';
- PATH_DELETE = 'NewRecords.rcd';
- MAX_RUB = 9999;
- MIN_RUB = 1;
- MAX_COP = 99;
- MIN_COP = 0;
- MAX_LENGTH = 15;
- MIN_LENGTH = 1;
- MAX_FORMAT = 6;
- MIN_FORMAT = 1;
- MIN_RECORDS_SIZE = 1;
- type
- TPrinter = record
- Brand: String[15];
- Kind: Char;
- Format: Integer;
- CostRub: Integer;
- CostCop: Integer;
- end;
- var
- F: File of TPrinter;
- Printer: TPrinter;
- SizeOfFile: Integer;
- procedure TFormDeleteRecord.ButtonDeleteRecordClick(Sender: TObject);
- var
- TempF: File of TPrinter;
- Number, I: Integer;
- Error: String;
- IsCorrect: Boolean;
- begin
- Error := 'Ошибка доступа к файлу' +
- '. Проверьте, находится ли файл Records.rcd в папке с приложением' +
- ', а также доступ к нему. ';
- IsCorrect := true;
- AssignFile(F, PATH);
- AssignFile(TempF, PATH_DELETE);
- try
- Reset(F);
- try
- Number := StrToInt(EditDeleteRecord.Text);
- if not(Number in [1..FileSize(F)]) then
- begin
- IsCorrect := false;
- Error := 'Нет записи с таким номером. ';
- end;
- except
- IsCorrect := false;
- Error := 'Некорректно введён номер записи. ';
- end;
- if (IsCorrect) then
- begin
- Rewrite(TempF);
- I := 1;
- while I <= FileSize(F) do
- begin
- Read(F, Printer);
- if not(I = Number) then
- Write(TempF, Printer);
- Inc(I);
- end;
- CloseFile(TempF);
- end;
- CloseFile(F);
- except
- IsCorrect := False;
- Error := 'Ошибка доступа к файлу' +
- '. Проверьте, находится ли файл Records.rcd в папке с приложением' +
- ', а также доступ к нему. ';
- end;
- if (IsCorrect) then
- begin
- DeleteFile(PATH);
- RenameFile(PATH_DELETE, PATH);
- EditDeleteRecord.Text := '';
- ModalResult := mrOk;
- end
- else
- begin
- UnitError.FormError.LabelError.Caption := Error;
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- end;
- procedure CheckCost(Str: String; var Err: String; var IsCorrect: Boolean; var Rub: Integer; var Cop: Integer);
- var
- I: Integer;
- IsFirst: Boolean;
- begin
- if (Str = '') then
- begin
- Err := 'В файле не найдено элементов. ';
- IsCorrect := False;
- end
- else
- try
- IsFirst := true;
- I := 1;
- while (I <= Length(Str)) do
- begin
- if (Str[I] = ' ') then
- begin
- if I = 1 then
- begin
- Delete(Str, 1, 1);
- if (IsFirst) then
- Dec(I)
- else
- Inc(I);
- end;
- if (I > 1) and (IsFirst) then
- begin
- Rub := StrToInt(Copy(Str, 1, (I - 1)));
- IsFirst := false;
- Delete(Str, 1, (I - 1));
- I := 0;
- end;
- if (I > 1) and not(isFirst) then
- begin
- Cop := StrToInt(Copy(Str, 1, Length(Str)));
- I := Length(Str);
- end;
- end;
- Inc(I);
- end;
- if (Rub > MAX_RUB) or (Rub < MIN_RUB) or
- (Cop > MAX_COP) or (Cop < MIN_COP) then
- begin
- Err := 'Значение цены не входит в допустимый диапазон. ';
- IsCorrect := false;
- end;
- except
- IsCorrect := False;
- Err := 'Обнаружена некорректно записанная цена. ';
- end;
- end;
- procedure TFormDeleteRecord.ButtonDeleteRecordFromFileClick(Sender: TObject);
- var
- FileForDelete: TextFile;
- DeletePath, Error, Brand, Cost: String;
- Format, CostRub, CostCop, Number: Integer;
- Kind: Char;
- IsCorrect: Boolean;
- begin
- IsCorrect := True;
- If OpenDialogDeleteRecord.Execute() Then
- Begin
- DeletePath := OpenDialogDeleteRecord.FileName;
- AssignFile(FileForDelete, DeletePath);
- Try
- Error := 'Нет доступа к файлу. ';
- Reset(FileForDelete);
- Try
- Readln(FileForDelete, Number);
- if (Number < MIN_RECORDS_SIZE) or (Number > SizeOfFile) then
- begin
- IsCorrect := false;
- Error := 'Неверный номер записи. ';
- end;
- Finally
- CloseFile(FileForDelete);
- End;
- Except
- IsCorrect := False;
- Error := 'Ошибка считывания с файла. ' + Error;
- End;
- if (IsCorrect) then
- begin
- EditDeleteRecord.Text := IntToStr(Number);
- ButtonDeleteRecordClick(Sender);
- end
- else
- begin
- UnitError.FormError.LabelError.Caption := 'Ошибка. ' + Error;
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- End;
- end;
- procedure TFormDeleteRecord.ButtonExitClick(Sender: TObject);
- begin
- ModalResult := mrOk;
- end;
- procedure TFormDeleteRecord.ButtonInstructionClick(Sender: TObject);
- begin
- UnitInstructionDeleteRecord.FormInstructionDeleteRecord.ShowModal();
- end;
- procedure TFormDeleteRecord.ComboBoxDeleteRecordKeyPress(Sender: TObject;
- var Key: Char);
- begin
- Key := #0;
- end;
- procedure TFormDeleteRecord.EditDeleteRecordKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if not(Key in ['0'..'9', #8, #13]) then
- Key := #0;
- if (length(EditDeleteRecord.Text) = 0) and (Key = '0') then
- Key := #0;
- if (Length(EditDeleteRecord.Text) > 0) and (Key = #13) then
- ButtonDeleteRecordClick(Sender);
- end;
- procedure TFormDeleteRecord.FormShow(Sender: TObject);
- var
- I: Integer;
- begin
- AssignFile(F, PATH);
- try
- Reset(F);
- Seek(F, 0);
- SizeOfFile := FileSize(F);
- Records.RowCount := SizeOfFile + 1;
- I := 1;
- while I <= SizeOfFile do
- begin
- Read(F, Printer);
- Records.Cells[0, I] := IntToStr(I);
- with Printer do
- begin
- Records.Cells[1, I] := Brand;
- case Kind of
- 'M': Records.Cells[2, I] := 'Матричный';
- 'J': Records.Cells[2, I] := 'Струйный';
- 'L': Records.Cells[2, I] := 'Лазерный';
- end;
- Records.Cells[3, I] := IntToStr(CostRub);
- Records.Cells[4, I] := IntToStr(CostCop);
- Records.Cells[5, I] := 'A' + IntToStr(Format);
- end;
- Inc(I);
- end;
- CloseFile(F);
- except
- UnitError.FormError.LabelError.Caption := 'Ошибка доступа к файлу' +
- '. Проверьте, находится ли файл Records.rcd в папке с приложением' +
- ', а также доступ к нему. ';
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- //layot table
- Records.Cells[0, 0] := '№';
- Records.ColWidths[0] := 35;
- Records.Cells[1, 0] := 'Марка';
- Records.ColWidths[1] := 120;
- Records.Cells[2, 0] := 'Тип';
- Records.ColWidths[2] := 120;
- Records.Cells[3, 0] := 'Цена(руб)';
- Records.Cells[4, 0] := 'Цена(коп)';
- Records.Cells[5, 0] := 'Формат печати';
- Records.ColWidths[5] := 135;
- end;
- end.
- unit UnitCreateNewRecord;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus, Vcl.ExtCtrls;
- type
- TFormCreateNewRecord = class(TForm)
- LabelAddRecord: TLabel;
- MainMenuCreateNewRecord: TMainMenu;
- LabelBrand: TLabel;
- EditPrinterBrand: TEdit;
- EditCostRub: TEdit;
- LabelPrintFormat: TLabel;
- LabelCost: TLabel;
- ButtonAddRecordFromFile: TMenuItem;
- ButtonAdd: TButton;
- ButtonExit: TButton;
- EditCostCop: TEdit;
- RadioButtonA1: TRadioButton;
- RadioButtonA2: TRadioButton;
- RadioButtonA3: TRadioButton;
- RadioButtonA6: TRadioButton;
- RadioButtonA5: TRadioButton;
- RadioButtonA4: TRadioButton;
- RadioGroupType: TRadioGroup;
- ButtonInstructionForCreate: TMenuItem;
- OpenDialogForCreateRecord: TOpenDialog;
- procedure ButtonExitClick(Sender: TObject);
- procedure EditCostRubKeyPress(Sender: TObject; var Key: Char);
- procedure EditCostCopKeyPress(Sender: TObject; var Key: Char);
- procedure ButtonAddClick(Sender: TObject);
- procedure RadioButtonA1Click(Sender: TObject);
- procedure RadioButtonA2Click(Sender: TObject);
- procedure RadioButtonA3Click(Sender: TObject);
- procedure RadioButtonA4Click(Sender: TObject);
- procedure RadioButtonA5Click(Sender: TObject);
- procedure RadioButtonA6Click(Sender: TObject);
- procedure RadioGroupTypeClick(Sender: TObject);
- procedure ButtonAddRecordFromFileClick(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure ButtonInstructionForCreateClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormCreateNewRecord: TFormCreateNewRecord;
- implementation
- {$R *.dfm}
- uses Lab_4_1_Form, UnitError, UnitInstructionCreateRecord;
- const
- MAX_RUB = 9999;
- MIN_RUB = 1;
- MAX_COP = 99;
- MIN_COP = 0;
- PATH = 'Records.rcd';
- MAX_LENGTH = 15;
- MIN_LENGTH = 1;
- MAX_FORMAT = 6;
- MIN_FORMAT = 1;
- type
- TPrinter = record
- Brand: String[15];
- Kind: Char;
- Format: Integer;
- CostRub: Integer;
- CostCop: Integer;
- end;
- var
- F: file of TPrinter;
- Printer: TPrinter;
- Size: Integer;
- procedure TFormCreateNewRecord.ButtonAddClick(Sender: TObject);
- var
- IsCorrect: Boolean;
- Error: String;
- begin
- IsCorrect := true;
- Error := '';
- try
- if (Length(EditPrinterBrand.Text) = 0) then
- begin
- Error := Error + 'Не введено название марки. ';
- IsCorrect := false;
- end;
- if (RadioGroupType.ItemIndex = -1) then
- begin
- Error := Error + 'Не выбран тип принтера. ';
- IsCorrect := false;
- end;
- Printer.CostRub := StrToInt(EditCostRub.Text);
- if (Printer.CostRub < MIN_RUB) or (Printer.CostRub > MAX_RUB) then
- begin
- Error := Error + 'Значение стоимости(рубли) неверного диаипазона. ';
- IsCorrect := false;
- end;
- if not(Length(EditCostCop.Text) = 0) then
- begin
- Printer.CostCop := StrToInt(EditCostCop.Text);
- if ((Printer.CostCop < MIN_COP) or (Printer.CostCop > MAX_COP)) then
- begin
- Error := Error + 'Значение стоимости(копейки) неверного диаипазона. ';
- IsCorrect := false;
- end;
- end
- else
- Printer.CostCop := 0;
- if not(RadioButtonA1.Checked) and not(RadioButtonA2.Checked) and
- not(RadioButtonA3.Checked) and not(RadioButtonA4.Checked) and
- not(RadioButtonA5.Checked) and not(RadioButtonA6.Checked) then
- begin
- Error := Error + 'Не выбран формат(ы) печати принтера. ';
- IsCorrect := false;
- end;
- except
- IsCorrect := false;
- Error := Error + 'Некорректно введено значение цены';
- end;
- if (IsCorrect) then
- begin
- Printer.Brand := EditPrinterBrand.Text;
- try
- AssignFile(F, PATH);
- Reset(F);
- Seek(F, FileSize(F));
- try
- Write(F, Printer);
- finally
- CloseFile(F);
- end;
- except
- UnitError.FormError.LabelError.Caption := 'Ошибка доступа к файлу' +
- '. Проверьте, находится ли файл Records.rcd в папке с приложением' +
- ', а также доступ к нему. ';
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- end
- else
- begin
- UnitError.FormError.LabelError.Caption := 'Ошибка. ' + Error;
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- //clear record
- EditPrinterBrand.Text := '';
- RadioGroupType.ItemIndex := -1;
- EditCostRub.Text := '';
- EditCostCop.Text := '';
- RadioButtonA1.Checked := False;
- RadioButtonA2.Checked := False;
- RadioButtonA3.Checked := False;
- RadioButtonA4.Checked := False;
- RadioButtonA5.Checked := False;
- RadioButtonA6.Checked := False;
- end;
- procedure CheckCost(Str: String; var Err: String; var IsCorrect: Boolean; var Rub: Integer; var Cop: Integer);
- var
- I: Integer;
- IsFirst: Boolean;
- begin
- if (Str = '') then
- begin
- Err := 'В файле не найдено элементов. ';
- IsCorrect := False;
- end
- else
- try
- IsFirst := true;
- I := 1;
- while (I <= Length(Str)) do
- begin
- if (Str[I] = ' ') then
- begin
- if I = 1 then
- begin
- Delete(Str, 1, 1);
- if (IsFirst) then
- Dec(I)
- else
- Inc(I);
- end;
- if (I > 1) and (IsFirst) then
- begin
- Rub := StrToInt(Copy(Str, 1, (I - 1)));
- IsFirst := false;
- Delete(Str, 1, (I - 1));
- I := 0;
- end;
- if (I > 1) and not(isFirst) then
- begin
- Cop := StrToInt(Copy(Str, 1, Length(Str)));
- I := Length(Str);
- end;
- end;
- Inc(I);
- end;
- if (Rub > MAX_RUB) or (Rub < MIN_RUB) or
- (Cop > MAX_COP) or (Cop < MIN_COP) then
- begin
- Err := 'Значение цены не входит в допустимый диапазон. ';
- IsCorrect := false;
- end;
- except
- IsCorrect := False;
- Err := 'Обнаружена некорректно записанная цена. ';
- end;
- end;
- procedure TFormCreateNewRecord.ButtonAddRecordFromFileClick(Sender: TObject);
- var
- F: TextFile;
- Path, Error, Brand, Cost: String;
- Format, CostRub, CostCop: Integer;
- Kind: Char;
- IsCorrect: Boolean;
- begin
- IsCorrect := True;
- If OpenDialogForCreateRecord.Execute() Then
- Begin
- Path := OpenDialogForCreateRecord.FileName;
- AssignFile(F, Path);
- Try
- Error := 'Нет доступа к файлу. ';
- Reset(F);
- Try
- Error := '';
- Readln(F, Brand);
- if (Length(Brand) < MIN_LENGTH) or (Length(Brand) > MAX_LENGTH) then
- begin
- IsCorrect := false;
- Error := Error + 'Неправильная длина названия марки принтера. ';
- end;
- Readln(F, Kind);
- if not(Kind in ['M', 'L', 'J', 'm', 'l', 'j']) then
- begin
- IsCorrect := false;
- Error := Error + 'Неизвестный тип принтера. ';
- end;
- Readln(F, Cost);
- CheckCost(Cost, Error, IsCorrect, CostRub, CostCop);
- try
- Readln(F, Format);
- if (Format < MIN_FORMAT) or (Format > MAX_FORMAT) then
- begin
- IsCorrect := false;
- Error := Error + 'Недопустимый формат принтера. ';
- end;
- except
- IsCorrect := false;
- Error := Error + 'Некорректное значение формата принтера. ';
- end;
- Finally
- CloseFile(F);
- End;
- Except
- IsCorrect := False;
- Error := 'Ошибка считывания с файла. ' + Error;
- End;
- if (IsCorrect) then
- begin
- EditPrinterBrand.Text := UTF8ToAnsi(Brand);
- if (Kind in ['M', 'm']) then
- begin
- RadioGroupType.ItemIndex := 0;
- Printer.Kind := 'M';
- end;
- if (Kind in ['J', 'j']) then
- begin
- RadioGroupType.ItemIndex := 1;
- Printer.Kind := 'J';
- end;
- if (Kind in ['L', 'l']) then
- begin
- RadioGroupType.ItemIndex := 2;
- Printer.Kind := 'L';
- end;
- EditCostRub.Text := IntToStr(CostRub);
- EditCostCop.Text := IntToStr(CostCop);
- case Format of
- 1:
- begin
- RadioButtonA1.Checked := true;
- Printer.Format := 1;
- end;
- 2:
- begin
- RadioButtonA2.Checked := true;
- Printer.Format := 2;
- end;
- 3:
- begin
- RadioButtonA3.Checked := true;
- Printer.Format := 3;
- end;
- 4:
- begin
- RadioButtonA4.Checked := true;
- Printer.Format := 4;
- end;
- 5:
- begin
- RadioButtonA5.Checked := true;
- Printer.Format := 5;
- end;
- 6:
- begin
- RadioButtonA6.Checked := true;
- Printer.Format := 6;
- end;
- end;
- end
- else
- begin
- UnitError.FormError.LabelError.Caption := 'Ошибка. ' + Error;
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- End;
- end;
- procedure TFormCreateNewRecord.ButtonExitClick(Sender: TObject);
- begin
- EditPrinterBrand.Text := '';
- RadioGroupType.ItemIndex := -1;
- EditCostRub.Text := '';
- EditCostCop.Text := '';
- RadioButtonA1.Checked := False;
- RadioButtonA2.Checked := False;
- RadioButtonA3.Checked := False;
- RadioButtonA4.Checked := False;
- RadioButtonA5.Checked := False;
- RadioButtonA6.Checked := False;
- ModalResult := mrOk;
- end;
- procedure TFormCreateNewRecord.ButtonInstructionForCreateClick(Sender: TObject);
- begin
- UnitInstructionCreateRecord.FormInstructionCreateRecord.ShowModal();
- end;
- procedure TFormCreateNewRecord.EditCostCopKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if not (Key in ['0'..'9', #8]) then
- Key := #0;
- if (Length(EditCostCop.Text) = 1) and (EditCostCop.Text[1] = '0') and not(Length(EditCostCop.SelText) > 0) and not(Key = #8) then
- Key := #0;
- end;
- procedure TFormCreateNewRecord.EditCostRubKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if not (Key in ['0'..'9', #8]) then
- Key := #0;
- if (Length(EditCostRub.Text) = 0) and (Key = '0') then
- Key := #0;
- if (Length(EditCostRub.SelText) > 0) and (Key = '0') then
- Key := #0;
- end;
- procedure TFormCreateNewRecord.FormClose(Sender: TObject;
- var Action: TCloseAction);
- begin
- EditPrinterBrand.Text := '';
- RadioGroupType.ItemIndex := -1;
- EditCostRub.Text := '';
- EditCostCop.Text := '';
- RadioButtonA1.Checked := False;
- RadioButtonA2.Checked := False;
- RadioButtonA3.Checked := False;
- RadioButtonA4.Checked := False;
- RadioButtonA5.Checked := False;
- RadioButtonA6.Checked := False;
- end;
- procedure TFormCreateNewRecord.RadioButtonA1Click(Sender: TObject);
- begin
- Printer.Format := 1;
- end;
- procedure TFormCreateNewRecord.RadioButtonA2Click(Sender: TObject);
- begin
- Printer.Format := 2;
- end;
- procedure TFormCreateNewRecord.RadioButtonA3Click(Sender: TObject);
- begin
- Printer.Format := 3;
- end;
- procedure TFormCreateNewRecord.RadioButtonA4Click(Sender: TObject);
- begin
- Printer.Format := 4;
- end;
- procedure TFormCreateNewRecord.RadioButtonA5Click(Sender: TObject);
- begin
- Printer.Format := 5;
- end;
- procedure TFormCreateNewRecord.RadioButtonA6Click(Sender: TObject);
- begin
- Printer.Format := 6;
- end;
- procedure TFormCreateNewRecord.RadioGroupTypeClick(Sender: TObject);
- begin
- if (RadioGroupType.ItemIndex = 0) then
- Printer.Kind := 'M';
- if (RadioGroupType.ItemIndex = 1) then
- Printer.Kind := 'J';
- if (RadioGroupType.ItemIndex = 2) then
- Printer.Kind := 'L';
- end;
- end.
- unit UnitChangeRecord;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Grids, Vcl.Menus;
- type
- TFormChangeRecord = class(TForm)
- Records: TStringGrid;
- ButtonSaveAndExit: TButton;
- MainMenuChangeRecord: TMainMenu;
- OpenDialogChangeRecord: TOpenDialog;
- ButtonUseProofFile: TMenuItem;
- ButtonInstruction: TMenuItem;
- procedure FormShow(Sender: TObject);
- procedure RecordsSelectCell(Sender: TObject; ACol, ARow: Integer;
- var CanSelect: Boolean);
- procedure RecordsGetEditMask(Sender: TObject; ACol, ARow: Integer;
- var Value: string);
- procedure ButtonSaveAndExitClick(Sender: TObject);
- procedure ButtonUseProofFileClick(Sender: TObject);
- procedure ButtonInstructionClick(Sender: TObject);
- procedure RecordsKeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormChangeRecord: TFormChangeRecord;
- implementation
- {$R *.dfm}
- uses UnitError, UnitInstructionChangeRecord;
- const
- PATH = 'Records.rcd';
- PATH_REWRITE = 'NewRecords.rcd';
- MAX_RUB = 9999;
- MIN_RUB = 1;
- MAX_COP = 99;
- MIN_COP = 0;
- MAX_LENGTH = 15;
- MIN_LENGTH = 1;
- MAX_FORMAT = 6;
- MIN_FORMAT = 1;
- MIN_RECORDS_SIZE = 1;
- type
- TPrinter = record
- Brand: String[15];
- Kind: Char;
- Format: Integer;
- CostRub: Integer;
- CostCop: Integer;
- end;
- var
- F: File of TPrinter;
- Printer: TPrinter;
- SizeOfFile: Integer;
- procedure TFormChangeRecord.ButtonInstructionClick(Sender: TObject);
- begin
- UnitInstructionChangeRecord.FormInstructionChangeRecord.ShowModal();
- end;
- procedure TFormChangeRecord.ButtonSaveAndExitClick(Sender: TObject);
- var
- NewFile: File of TPrinter;
- IsCorrect: Boolean;
- Error: String;
- I: Integer;
- begin
- I := 1;
- IsCorrect := true;
- while (IsCorrect) and (I <= SizeOfFile) do
- begin
- Error := '';
- try
- if (Length(Records.Cells[1, I]) < MIN_LENGTH) or
- (Length(Records.Cells[1, I]) > MAX_LENGTH) then
- begin
- Error := Error + 'Не введено название марки в записи №' +
- IntToStr(I) + '. ';
- IsCorrect := false;
- end;
- if (Length(Records.Cells[2, I]) = 0) then
- begin
- Error := Error + 'Не введен тип принтера в записи №' +
- IntToStr(I) + '. ';
- IsCorrect := false;
- end;
- if not(Records.Cells[2, I] = 'Матричный') and
- not(Records.Cells[2, I] = 'Струйный') and
- not(Records.Cells[2, I] = 'Лазерный') then
- begin
- IsCorrect := false;
- Error := Error + 'Неизвестный тип принтера. Проверьте '
- + 'правильность написания типа принтера в записи №' +
- IntToStr(I) + '. ';
- end;
- Printer.CostRub := StrToInt(Records.Cells[3, I]);
- if (Printer.CostRub < MIN_RUB) or (Printer.CostRub > MAX_RUB) then
- begin
- Error := Error + 'Значение стоимости(рубли) неверного диапаз' +
- 'она в записи №' + IntToStr(I) + '. ';
- IsCorrect := false;
- end;
- if not(Length(Records.Cells[4, I]) = 0) then
- begin
- Printer.CostCop := StrToInt(Records.Cells[4, I]);
- if ((Printer.CostCop < MIN_COP) or (Printer.CostCop > MAX_COP))
- then
- begin
- Error := Error + 'Значение стоимости(копейки) неверного ' +
- 'диапазона в записи №' + IntToStr(I) + '. ';
- IsCorrect := false;
- end;
- end
- else
- Printer.CostCop := 0;
- if (Length(Records.Cells[5, I]) = 0) or (Length(Records.Cells[5, I])
- = 1) then
- begin
- IsCorrect := false;
- Error := Error + 'Не введен формат принтера в записи №' +
- IntToStr(I) + '. ';
- end
- else
- begin
- if not(Records.Cells[5, I][1] = 'A') then
- begin
- IsCorrect := false;
- Error := Error + 'Название формата принтера должно начина' +
- 'ться с заглавной буквы А';
- end
- else
- begin
- if not(Records.Cells[5, I][2] in ['1'..'6']) then
- begin
- IsCorrect := false;
- Error := Error + 'Выбран неиспользуемый номер формата '
- + 'принтера. ';
- end
- else
- Printer.Format := StrToInt(Records.Cells[5, I][2]);
- end;
- end;
- except
- IsCorrect := false;
- Error := Error + 'Найдено некорректно введённое значение цены. ';
- end;
- if (IsCorrect) then
- begin
- Printer.Brand := Records.Cells[1, I];;
- if (Records.Cells[2, I] = 'Матричный') then
- Printer.Kind := 'M';
- if (Records.Cells[2, I] = 'Струйный') then
- Printer.Kind := 'J';
- if (Records.Cells[2, I] = 'Лазерный') then
- Printer.Kind := 'L';
- try
- AssignFile(NewFile, PATH_REWRITE);
- Reset(NewFile);
- Seek(NewFile, FileSize(NewFile));
- try
- Write(NewFile, Printer);
- finally
- CloseFile(NewFile);
- end;
- except
- UnitError.FormError.LabelError.Caption := 'Ошибка доступа к ' +
- 'файлу. Проверьте, находится ли файл NewRecords.rcd в папке с ' +
- 'приложением, а также доступ к нему. ';
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- end
- else
- begin
- UnitError.FormError.LabelError.Caption := 'Ошибка. ' + Error;
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- Inc(I);
- end;
- if (IsCorrect) then
- begin
- DeleteFile(PATH);
- RenameFile(PATH_REWRITE, PATH);
- ModalResult := mrOk;
- end;
- end;
- procedure CheckCost(Str: String; var Err: String; var IsCorrect: Boolean; var Rub: Integer; var Cop: Integer);
- var
- I: Integer;
- IsFirst: Boolean;
- begin
- if (Str = '') then
- begin
- Err := 'В файле не найдено элементов. ';
- IsCorrect := False;
- end
- else
- try
- IsFirst := true;
- I := 1;
- while (I <= Length(Str)) do
- begin
- if (Str[I] = ' ') then
- begin
- if I = 1 then
- begin
- Delete(Str, 1, 1);
- if (IsFirst) then
- Dec(I)
- else
- Inc(I);
- end;
- if (I > 1) and (IsFirst) then
- begin
- Rub := StrToInt(Copy(Str, 1, (I - 1)));
- IsFirst := false;
- Delete(Str, 1, (I - 1));
- I := 0;
- end;
- if (I > 1) and not(isFirst) then
- begin
- Cop := StrToInt(Copy(Str, 1, Length(Str)));
- I := Length(Str);
- end;
- end;
- Inc(I);
- end;
- if (Rub > MAX_RUB) or (Rub < MIN_RUB) or
- (Cop > MAX_COP) or (Cop < MIN_COP) then
- begin
- Err := 'Значение цены не входит в допустимый диапазон. ';
- IsCorrect := false;
- end;
- except
- IsCorrect := False;
- Err := 'Обнаружена некорректно записанная цена. ';
- end;
- end;
- procedure TFormChangeRecord.ButtonUseProofFileClick(Sender: TObject);
- var
- F: TextFile;
- Path, Error, Brand, Cost: String;
- Format, CostRub, CostCop, Number: Integer;
- Kind: Char;
- IsCorrect: Boolean;
- NewPrinter: TPrinter;
- begin
- IsCorrect := True;
- If OpenDialogChangeRecord.Execute() Then
- Begin
- Path := OpenDialogChangeRecord.FileName;
- AssignFile(F, Path);
- Try
- Error := 'Нет доступа к файлу. ';
- Reset(F);
- Try
- Error := '';
- Readln(F, Number);
- if (Number < MIN_RECORDS_SIZE) or (Number > SizeOfFile) then
- begin
- IsCorrect := false;
- Error := Error + 'Неверный номер записи. ';
- end;
- Readln(F, Brand);
- if (Length(Brand) < MIN_LENGTH) or (Length(Brand) > MAX_LENGTH) then
- begin
- IsCorrect := false;
- Error := Error + 'Неправильная длина названия марки принтера. ';
- end;
- Readln(F, Kind);
- if not(Kind in ['M', 'L', 'J', 'm', 'l', 'j']) then
- begin
- IsCorrect := false;
- Error := Error + 'Неизвестный тип принтера. ';
- end;
- Readln(F, Cost);
- CheckCost(Cost, Error, IsCorrect, CostRub, CostCop);
- try
- Readln(F, Format);
- if (Format < MIN_FORMAT) or (Format > MAX_FORMAT) then
- begin
- IsCorrect := false;
- Error := Error + 'Недопустимый формат принтера. ';
- end;
- except
- IsCorrect := false;
- Error := Error + 'Некорректное значение формата принтера. ';
- end;
- Finally
- CloseFile(F);
- End;
- Except
- IsCorrect := False;
- Error := 'Ошибка считывания с файла. ' + Error;
- End;
- if (IsCorrect) then
- begin
- Records.Cells[1, Number] := UTF8ToAnsi(Brand);
- if (Kind in ['M', 'm']) then
- begin
- Records.Cells[2, Number] := 'Матричный';
- end;
- if (Kind in ['J', 'j']) then
- begin
- Records.Cells[2, Number] := 'Струйный';
- end;
- if (Kind in ['L', 'l']) then
- begin
- Records.Cells[2, Number] := 'Лазерный';
- end;
- Records.Cells[3, Number] := IntToStr(CostRub);
- Records.Cells[4, Number] := IntToStr(CostCop);
- Records.Cells[5, Number] := 'A' + IntToStr(Format);
- end
- else
- begin
- UnitError.FormError.LabelError.Caption := 'Ошибка. ' + Error;
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- End;
- end;
- procedure TFormChangeRecord.FormShow(Sender: TObject);
- var
- I: Integer;
- New: File of TPrinter;
- begin
- AssignFile(F, PATH);
- AssignFile(New, PATH_REWRITE);
- try
- Rewrite(New);
- CloseFile(New);
- Reset(F);
- Seek(F, 0);
- SizeOfFile := FileSize(F);
- Records.RowCount := SizeOfFile + 1;
- I := 1;
- while I <= SizeOfFile do
- begin
- Read(F, Printer);
- Records.Cells[0, I] := IntToStr(I);
- with Printer do
- begin
- Records.Cells[1, I] := Brand;
- case Kind of
- 'M': Records.Cells[2, I] := 'Матричный';
- 'J': Records.Cells[2, I] := 'Струйный';
- 'L': Records.Cells[2, I] := 'Лазерный';
- end;
- Records.Cells[3, I] := IntToStr(CostRub);
- Records.Cells[4, I] := IntToStr(CostCop);
- Records.Cells[5, I] := 'A' + IntToStr(Format);
- end;
- Inc(I);
- end;
- CloseFile(F);
- except
- UnitError.FormError.LabelError.Caption := 'Ошибка доступа к файлу' +
- '. Проверьте, находится ли файл Records.rcd в папке с приложением' +
- ', а также доступ к нему. ';
- UnitError.FormError.ShowModal();
- UnitError.FormError.LabelError.Caption := '';
- end;
- //layot table
- Records.Cells[0, 0] := '№';
- Records.ColWidths[0] := 35;
- Records.Cells[1, 0] := 'Марка';
- Records.ColWidths[1] := 120;
- Records.Cells[2, 0] := 'Тип';
- Records.ColWidths[2] := 120;
- Records.Cells[3, 0] := 'Цена(руб)';
- Records.Cells[4, 0] := 'Цена(коп)';
- Records.Cells[5, 0] := 'Формат печати';
- Records.ColWidths[5] := 135;
- end;
- procedure TFormChangeRecord.RecordsGetEditMask(Sender: TObject; ACol,
- ARow: Integer; var Value: string);
- begin
- if (ACol = 3) and (ARow > 0) then
- Value := '0999;0; ';
- if (ACol = 4) and (ARow > 0) then
- Value := '09;1; ';
- if (ACol = 5) and (ARow > 0) then
- Value := 'L0;1; ';
- end;
- procedure TFormChangeRecord.RecordsKeyPress(Sender: TObject; var Key: Char);
- begin
- if Key = #13 then
- ButtonSaveAndExitClick(Sender);
- end;
- procedure TFormChangeRecord.RecordsSelectCell(Sender: TObject; ACol,
- ARow: Integer; var CanSelect: Boolean);
- begin
- if (ARow = 0) and (ACol = 0) then
- CanSelect := false;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement