Материал: Автоматизация контроля качества ФГУП "Научно-производственный центр автоматики и приборостроения имени Н.А. Пилюгина"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
122
{ Private declarations }
public
{ Public declarations }
end;
var
frmTypes: TfrmTypes;
implementation
uses DataBase;
{$R *.dfm}
procedure TfrmTypes.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DataInfo.qTypes.Close;
end;
procedure TfrmTypes.FormShow(Sender: TObject);
begin
if frmTypes.Tag=1 then
begin
frmTypes.Caption:='Новый тип';
DataInfo.qTypes.Close;
DataInfo.qTypes.Parameters.ParamValues['TypeId']:=0;
DataInfo.qTypes.Open;
DataInfo.qTypes.Insert;
end
else
begin
123
frmTypes.Caption:=DataInfo.qListTypes.FieldByName('TypeName').asString;
DataInfo.qTypes.Close;
DataInfo.qTypes.Parameters.ParamValues['TypeId']:=DataInfo.qListTypes.FieldByNa
me('Id').asInteger;
DataInfo.qTypes.Open;
DataInfo.qTypes.Edit;
end;
end;
procedure TfrmTypes.btnNoClick(Sender: TObject);
begin
DataInfo.qTypes.Cancel;
frmTypes.Close;
end;
procedure TfrmTypes.btnYesClick(Sender: TObject);
begin
if DataInfo.qTypes.FieldByName('TypeName').isNull then
begin
MessageDlg('Укажите название типа изделия!',mtError,[mbOk],0);
Exit
end;
DataInfo.qTypes.Post;
try
Pos:=DataInfo.qListTypes.GetBookmark;
DataInfo.qListTypes.Close;
DataInfo.qListTypes.Open;
DataInfo.qListTypes.GotoBookmark(Pos);
finally
DataInfo.qListTypes.FreeBookmark(Pos);
124
end;
frmTypes.Close;
end;
end.
unit Ware;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxLookAndFeels, cxLookAndFeelPainters, Menus,
dxSkinsCore, dxSkinsDefaultPainters, StdCtrls, cxButtons, cxControls,
cxStyles, cxEdit, cxDBLookupComboBox, cxVGrid, cxDBVGrid,
cxInplaceContainer;
type
TfrmWares = class(TForm)
btnYes: TcxButton;
btnNo: TcxButton;
vgWares: TcxDBVerticalGrid;
vgWaresCategoryId: TcxDBEditorRow;
vgWaresDateInput: TcxDBEditorRow;
vgWaresWareName: TcxDBEditorRow;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure btnNoClick(Sender: TObject);
procedure btnYesClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
125
end;
var
frmWares: TfrmWares;
implementation
uses DataBase;
{$R *.dfm}
procedure TfrmWares.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DataInfo.qListUsers.Close;
DataInfo.qListCategories.Close;
DataInfo.qWares.Close;
end;
procedure TfrmWares.FormShow(Sender: TObject);
begin
DataInfo.qListUsers.Open;
DataInfo.qListCategories.Open;
if frmWares.Tag=1 then
begin
frmWares.Caption:='Новое изделие';
DataInfo.qWares.Close;
DataInfo.qWares.Parameters.ParamValues['WareId']:=0;
DataInfo.qWares.Open;
DataInfo.qWares.Insert;
end
else
begin
126
frmWares.Caption:=DataInfo.qListWares.FieldByName('WareName').asString;
DataInfo.qWares.Close;
DataInfo.qWares.Parameters.ParamValues['WareId']:=DataInfo.qListWares.FieldByN
ame('Id').asInteger;
DataInfo.qWares.Open;
DataInfo.qWares.Edit;
end;
end;
procedure TfrmWares.btnNoClick(Sender: TObject);
begin
DataInfo.qWares.Cancel;
frmWares.Close;
end;
procedure TfrmWares.btnYesClick(Sender: TObject);
begin
if DataInfo.qWares.FieldByName('CategoryId').isNull then
begin
MessageDlg('Выберите категорию изделия!',mtError,[mbOk],0);
Exit
end;
if DataInfo.qWares.FieldByName('DateInput').isNull then
begin
MessageDlg('Укажите дату поступления!',mtError,[mbOk],0);
Exit
end;
if DataInfo.qWares.FieldByName('WareName').isNull then
begin
MessageDlg('Укажите название изделия!',mtError,[mbOk],0);
Источник: https://baza.diplomsite.ru/previewfile/1836