unit Unit20;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DBGridEh, Vcl.DBCtrls, Vcl.StdCtrls,
  Vcl.Mask, DBCtrlsEh, DBLookupEh, Vcl.Buttons, Vcl.ExtCtrls, Data.DB;

type
  TfValueEdit = class(TForm)
    Label4: TLabel;
    Panel1: TPanel;
    bbOk: TBitBtn;
    bbCancel: TBitBtn;
    DBLookupComboboxEh1: TDBLookupComboboxEh;
    dsDevType: TDataSource;
    Label2: TLabel;
    DBEdit2: TDBEdit;
    DBEditEh1: TDBEditEh;
    procedure DBEditEh1EditButtons0Click(Sender: TObject; var Handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fValueEdit: TfValueEdit;

implementation

{$R *.dfm}

uses Unit2, Unit19;

procedure TfValueEdit.DBEditEh1EditButtons0Click(Sender: TObject; var Handled: Boolean);
  var
    str : string;
    i : integer;
begin
  str := 'V000000000';
  if fValue.qValueid.AsInteger > 0 then begin
     i := Length(fValue.qValueid.AsString);
     Delete(str, (10-i), i);
     if ( str + fValue.qValueid.AsString <> fValue.qValuevendor.AsString ) then begin
        fValue.qValue.Edit;
        fValue.qValuevendor.AsString := str+fValue.qValueid.AsString;
     end;
  end
  else begin
     if Application.MessageBox('Для продолжения необходимо сохранить текущую запись. Сохранить?', 'Подтверждение', MB_ICONQUESTION+MB_YESNO) = idYes then begin
        if fValue.qValue.Modified then
           fValue.qValue.Post;
        i := Length(fValue.qValueid.AsString);
        Delete(str, (10-i), i);
        fValue.qValue.Edit;
        fValue.qValuevendor.AsString := str + fValue.qValueid.AsString;
     end;
  end;
end;

end.
