procedure TfrmJuchu.BtnInsClick(Sender: TObject);
//クライアントデータセットより最終枝番を取得し+1 function Get_Edno:integer;
begin
if cdsJuchuM.Aggregates.Items[0].Value = Null then
Result := 1
else
Result := cdsJuchuM.Aggregates.Items[0].Value + 1;
end;
begin
//登録・修正モード以外は不可
if not sbnInsert.Down and not sbnUpdate.Down then
begin
MessageDlg('登録または修正以外は実行できません',
mtError ,[mbOK],0);
Abort;
end;
//受注番号入力チェック
if EditNo.Text = '' then
begin
MessageDlg('受注番号が未入力です',
mtError ,[mbOK],0);
Abort;
end;
//【登録時】クエリー 設定
with qryJUCHUM do
begin
Active := False;
ParamByName('pSKJUNO').AsInteger := StrToInt(EditNo.Text);
end;
//明細入力画面呼び出し
frmMeisai := TfrmMeisai.Create(Self);
//登録フラグをTrue
frmMeisai.SINSFLG := True;
//明細入力画面終了後
if frmMeisai.ShowModal = mrOk then
begin
with cdsJuchuM do
begin
//受注番号
FieldByName('JUCHUNO').AsInteger := StrToInt(EditNo.Text);
//枝番
FieldByName('EDANO').AsInteger := Get_Edno;
Post;
end;
end;
frmMeisai.Release;
end;
|