🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.database.win32
2 messages
2 total messages Started by anithegregorian Wed, 24 Oct 2007 19:27
UdateStatus Blues (repost)
#120
Author: anithegregorian
Date: Wed, 24 Oct 2007 19:27
69 lines
3673 bytes
I apologise for this trouble of making a repost but I couldnt find a 
solution
anywhere on the net or on codegear.
Im developing a db app. I use third party database and their components as
well which are compatible with delphi datasets. When a purchase is made in
the app. records are tallyed with inventory and inventory is updated and/or
new records are inserted accordingly. I used BeforePost event to tally
inventory with purchase cause AfterPost will not give the record status
after they are posted. Before records are posted I want to check if the
record is new or modified based on that i'll update the inventory. Here's
the code:

procedure TMastData.TPDetailsBeforePost(DataSet: TDataSet);
begin
  { First prepare inventory query }
  QCSelect.SQL.Clear;
  QCSelect.SQL    := QryStore.ItemByName['InventoryByID'].Strings;
  QCSelect.ParamByName('p_itemid').AsInteger := TPDetailsf_itemid.Value;
  QCSelect.Active := True;

  { If a new record then insert it in inventory }
  if DataSet.UpdateStatus = usInserted then
  begin

  end;
  { If record modified then just update inventory }
  if DataSet.UpdateStatus = usModified then
  begin
    { Check current item with inventory item }
    if TPDetailsf_itemid.Value = QCSelect.FieldByName('f_itemid').AsInteger
then
    begin
      with QCUpdate do
      begin
        SQL.Clear;
        SQL    := QryStore.ItemByName['UpdtFrmPurchaseMast'].Strings;
        { Setup parameters }
        ParamByName('p_item').Value := TPDetailsf_item.Value;
        ParamByName('p_code').Value := TPDetailsf_code.Value;
        ParamByName('p_group').Value := TPDetailsf_group.Value;
        ParamByName('p_pdate').Value := TPMasterf_date.Value;
        ParamByName('p_size').Value := TPDetailsf_size.Value;
        ParamByName('p_unit').Value := TPDetailsf_unit.Value;
        ParamByName('p_rate').Value := TPDetailsf_rate.Value;
        ParamByName('p_qty').Value := TPDetailsf_acceptedqty.Value;
        ParamByName('p_tax').Value := TPDetailsf_tax.Value;
        ParamByName('p_amount').Value := TPDetailsf_amount.Value;
        ParamByName('p_itemid').AsInteger := TPDetailsf_itemid.Value;
        { Execute the query }
        Active := True;
        Prepare;
        ExecSQL;
        Active := False;
      end;
    end;
  end;
  if DataSet.UpdateStatus = usDeleted then
  begin

  end;
  { Close queries and move to next record }
  QCSelect.Active := False;
end;

When I check the status of record during debugging it shows usUnmodified???
I don't know how and why this is happening.
If you guys have any idea then I'd thank you in advance. One more thing that
I have not used client datasets for cached updates
in this app either.
Re: UdateStatus Blues (repost)
#121
Author: anithegregorian
Date: Sat, 27 Oct 2007 20:56
17 lines
1937 bytes
Never mind the post I have already found a solution to me own problem. The 
solution was to use a ClientDataSet and DataSetProvider components and use 
them for checking updates/deletes or inserts. Yes they are there to make 
your miserable life a little bit easier. I'd highly recommend using 
clientdatasets for all those who are into making database applications in 
Delphi. They extensively provide you with options to deal with the 
complexity of building either single-tier or multi-tier database 
applications.

If you need more information on how to use client datasets you can PM me on 
this forums or leave an offliner on me yahoo id -> anithegregorian or MSN -> 
anithegregorian or Skype -> anithegregorian. If youre lucky I can provide 
some tips to use Client datasets...

REMEMBER: God only helps those who help themselves!!!

Regards, 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads