Jump to content

Serge_G

Members
  • Content Count

    310
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Serge_G

  1. Serge_G

    Listview Programming

    Hi, 2 solutions. First one is to use a TListView and Dynamic appearance, like this (listview "livebinded" to fdmemtable) In this case, it could be easy to manage groups. pro : if data is in a Table, it's easy to fill with livebindings and easy to manage groups con : if you want different size (possible) you have to code Second one is to use a TScollbox and a TFrame (same design as Item). pro : It's easy to resize a TFrame. In this case, Headergroup should certainly be another frame. con : All is to code Depending of solution you choose, I will explain more if needed
  2. I don't think soundex to be a good algorithm, I certainly look for phonetic
  3. Hi, No, this new TSpinBox should use the same style. Except if you put this style in the default collection. As I remember when style is to be applied, "delphi" look for platform style and then default style if stylelookup is not found. Ah, this should be a possibility Another solution is to change the style of the component during runtime (I found this trick some month ago, but I don't remember where I save this one) [EDIT] Finally, found. If you read French it's in my blog I explain 2 methods, I think second one "modify the style directly" could apply. If you can screenshot what you expect I will take this like a challenge 😉
  4. Serge_G

    delete record

    Really ! I don't think this use of recnum is serious. Why don't you use something like if FDConnection.ExecSQL('DELETE FROM mytable where Key=:K',[sysp^.key ])>0 then showmessage('record(s) deleted'); Even if I am not sure of this sysp^.key have the good value 😲 expect yes, but this should be tested by debug
  5. Serge_G

    NetHTTPRequest PUT and api

    Perhaps some tips here Developer Skill Print
  6. Serge_G

    How can i display skew t and hodograph plots

    You can use Python4Delphi
  7. Thanks, but this AFRO thing is now obsolete because IDE force it when you close designer (ouf)
  8. You declare a TListbox not a TListView so it's normal, units for Tlistview ( FMX.TlistView,FMX.TlistView.xxxx) are not declared works with a TlistView A list box (simple one without style) should be filled with Listbox1.Items.Add('Hello') other way is to declare a TListboxItem var aItem : TlistboxItem; begin aItem:=TlistboxItem.Create(Self); aItem.Parent:=ListBox1; aItem.Text:='Hello'; end; P.S. If you want to involve style, here is a tutorial I wrote (long time ago, XE4, when TListview does not exists) Intro to styles Firemonkey XE4 (sorry in French)
  9. Serge_G

    FMX and Excel application

    Or you can use Firedac CDATA Excel
  10. Serge_G

    Missing CommandText property

    Hi, Generally, I use this syntax tbAddUser.Insert; tbAddUser.FieldByName('JM_User').asString := userstring; tbAddUser.FieldByName('OldValue').asString := DBEdit23.Text; tbAddUser.Post;
  11. Serge_G

    FB-3 Create a New Table

    There are no Firebird command for this. But you are in a Delphi forum, so my response should be :"Use FDBatchmove "
  12. Serge_G

    Where are my styles?

    Set UseStyleManager to true of StyleBook to avoid this. Note : Only one TStyleBook can be set. for exemple : put a Tpath and a panel on a form, fill the tpath with some data and set stylename to i.e. 'mytpath' now set panel.stylelookup to 'mytpath' and you will have your response Ok, but did you pay attention to platform ? Have a look at platform 'default' and others if any in stylebook.styles collection Ho ! You surely miss it because it's in "binary format" object StyleBook1: TStyleBook Styles = < item ResourcesBin = { 464D585F5354594C4520322E350106125370656564427574746F6E315374796C 653103EA13005450463007544C61796F757400095374796C654E616D65061253... } end item Platform = 'Windows 10 Desktop' ResourcesBin = { 464D585F5354594C4520322E3501060D427574746F6E315374796C6531039B0F 005450463007544C61796F757400095374796C654E616D65060D427574746F6E
  13. Serge_G

    FB-3 Delete

    Agree with @Stano. Read the manuals https://firebirdsql.org/file/documentation/html/en/refdocs/fblangref30/firebird-30-language-reference.html#fblangref30-dml-delete Have a look at global syntax of Delete it does not support jointures (noted as [<joins>] in a SELECT clause). You have to use a subquery DELETE FROM ORDETAIL OD WHERE OD.REMAINQTY = 0 AND Not Exists (SELECT 1 FOM ORDERS WHERE ID = OD.ID and INVDOCNO IS NOT NULL )
  14. Serge_G

    Function with 2 return values ?

    Hi, only a single result but you can change to function GetBomCosts(const ItemCode : String; var value1, value2 : Double) : boolean begin with TFDQuery.Create do begin Value1:=0; value2:=0; Connection:= FDConnection1; SQL.Text:='SELECT itemcode,value1,value2 from table where code='+quotedstr(itemcode); active:=true; if fieldbyname('Itemcode').isNull then result:=false else begin value1:=FieldByName('value1').asFloat; value2:=FieldByName('value2').asFloat; result:=true; end; active:=false; end; end;
  15. Serge_G

    FB3 Update

    Why do I ask for table description because I was thinking about a ACCOUNT,YEAR key or worst Why did you use 2 "embedded" SELECT when only one is needed ? So I suggest you to write and test this for first one ALTER PROCEDURE UPDATEACC_SINGLE ( ACCCODE VARCHAR(20), ACTIVEYEAR VARCHAR(4) ) AS DECLARE VARIABLE ACCREDIT NUMERIC(15,2); DECLARE VARIABLE ACDEBIT NUMERIC(15,2); BEGIN IF (ACCCODE IS NULL) THEN EXIT; SELECT SUM(AD.DEBIT),SUM(AD.CREDIT) FROM ACCRECDETAIL AD JOIN ACCRECEIPT AR ON AD.RNO=AR.RNO WHERE AD.ACCCODE=:ACCCODE and EXTRACT(YEAR FROM AR.TDATE)=:ACTIVEYEAR) INTO :ACDEBIT,:ACCREDIT; UPDATE ACCACCOUNT SET DEBIT=:ACDEBIT,CREDIT=:ACCREDIT WHERE ACCCODE=:ACCCODE END And second one /* For all records update s.proc */ ALTER PROCEDURE UPDATEACC_ALL ( ACTIVEYEAR VARCHAR(4) ) AS DECLARE VARIABLE ACCOUNT VARCHAR(20); DECLARE VARIABLE ACCREDIT NUMERIC (15,2); DECLARE VARIABLE ACDEBIT NUMERIC (15,2); begin FOR SELECT ACCCODE, SUM(AD.DEBIT),SUM(AD.CREDIT) FROM ACCRECDETAIL AD JOIN ACCRECEIPT AR ON AR.RNO=AD.RNO WHERE EXTRACT(YEAR FROM AR.TDATE)=:ACTIVEYEAR GROUP BY ACCCODE INTO :ACCOUNT,:ACDEBIT,:ACCREDIT DO UPDATE ACCACCOUNT SET DEBIT=:DEBIT, CREDIT=:AMOUNT WHERE ACCCODE=:ACCOUNT; end Note : you have to adjust VARIABLE declaration to your need of course
  16. Serge_G

    FB3 Update

    Hi, for me the 2 updates lack of a WHERE clause, but it depend on ACCACCOUNT table description
  17. Serge_G

    Fastreport

    I should say it's a problem of dataset(s). For me, your fastreport design is not good. In my mind you have to rework your datasets but this mean you have to give us more information than 2 screenshots ie. involved tables structure By the way : 1 - you have a french forum for this https://www.developpez.net/forums/f1771/logiciels/solutions-d-entreprise/business-intelligence/autres-outils-decisionnels/fastreport/ 2- your question need a cystalball !
  18. Serge_G

    Delphi10.3 - FB3 - Firedac BackUp

    Are you sure I wrote "normal" ? Oh! I see my "yes" was not for size (abnormal for me ) but for the "if there are users connected ("warmbackup ")" sorry for mistyping, when I quoted the second part about size, something happened and I was thinking No it's abnormal
  19. Serge_G

    Split String

    @Fr0sT.Brutal, code was edited during your post. Just a thing, this MyCode = 600.005.0010 then requested result = 600.005.0011 should not work you have to manage a way to have the good formatstring something like procedure TForm23.Button1Click(Sender: TObject); var S : TArray<String>; fmt : string; begin S:=Edit3.Text.Split(['.']); fmt:='%.'+Length(S[Length(S)-1]).tostring+'d'; S[length(S)-1]:=Format(fmt,[(StrToInt(S[Length(S)-1])+1)]); Edit3.Text:=String.Join('.',S); end;
  20. Serge_G

    Split String

    Hi, yes you can Split procedure TForm23.Button1Click(Sender: TObject); var S : TArray<String>; begin S:=Edit3.Text.Split(['.']); S[length(S)-1]:=Format('%.3d',[(StrToInt(S[Length(S)-1])+1)]); Edit3.Text:=String.Join('.',S); end;
  21. Serge_G

    Fd

    This is an error I had sometimes when using an FDQuery on a Form and the related FDConnection in a DataModule. I do not hide from you that this has the gift of annoying me, especially when I use the visual designer of LiveBindings and my DataModule is in the list of uses
  22. Serge_G

    FB-3 SELECT WHERE

    not my mother tongue too Yes, here I miss some words I think I am not a fan of the WITH but, sometimes using it by lazyness
  23. Serge_G

    FB-3 SELECT WHERE

    Something like : const SQL = // asSQltext with TFDQuery.Create(self) do begin connection:=fdconnection; SQL.Text:=SQL; //parambyName //macrobyname Open; // processing Close; end; or const SQL = 'your sql'; var Q : TFDQuery; Q:=TFDQuery.Create(self); try Q.Connection:=FDConnection; Q.SQL.Text:=SQL; //Q.ParamByName //Q.macrobyName Q.Open; // processing Q.Close; finally Q.Free; end;
  24. Serge_G

    FB-3 SELECT WHERE

    Stano Ok, my response is in three parts. 1- The first is only a Firebird compliant SQL on how to use DATEADD function, and for the question asked, just sufficient. 2- Why I am not fan of the subquery ? Because it is evaluated at each row of MYTABLE . Perhaps a CTE should be better, but with the so poor data sample I am lazy to test over WITH X AS (SELECT MAX(DATEADD(-10 DAYS FROM TDATE)) MD FROM MYTABLE) SELECT M.ID,M.TNAME,M.TDATE,M.INVNO FROM MYTABLE M JOIN X ON 1=1 WHERE M.TNAME='AA' AND (TDATE>=X.MD OR M.INVNO IS NULL) Note that I prefer the list of each column to an * 3- Delphi side, yes there is code (much more lines and I don't create an runtime TFDQuery .... ) but queries with parameters is, I think is a very usefull technique (I use for years)
  25. Serge_G

    FB-3 SELECT WHERE

    Hi, - what is this X.INVRNO ? Your test table only contains INVNO column ! - use DateAdd Firebird function to compute your old date parameter DATEADD(-10 DAYS FROM SELECT MAX(TDATE) FROM MYTABLE )) or SELECT MAX(DATEADD(-10 DAYS FROM TDATE)) FROM MYTABLE I am not fan of sub-querys I should certainly prefer a Delphi Code based (we are in a Delphi forum 😉) and a Firedac query with parameters and macro (for the in clause) var d : variant; begin YourFDquery.Close; d:=FDConnection.ExecSQLScalar('SELECT MAX(DATEADD(:g DAYS FROM TDATE)) FROM MYTABLE',[-10]) // in this way you can change day number if not VarisEmpty(d) then begin YourFDQuery.SQl.text('SELECT * FROM MYTABLE WHERE (TDATE >= :d or INVNO IS NULL) &inmacro'); YourFDQuery.ParamByName('d').asDateTime:=d; yourFDquery.MacroByName('inmacro').asRaw:='AND TNAME IN (''AA'')'; // so you can easily change, i.e *using format or clear clause yourFDQuery.Open; end; Ok, I change position of the IN clause to easily clear the clause but, you can modify SQL text to YourFDQuery.SQl.text('SELECT * FROM MYTABLE WHERE &inmacro (TDATE>=:D OR INVNO IS NULL)'); YourFDQuery.ParamByName('d').asDateTime:=d; yourFDquery.MacroByName('inmacro').asRaw:='TNAME IN (''AA'') AND'; * "inmacro" can be computed by a format, var mymacro : String; begin mymacro:=Format('TNAME IN (%s) AND',[list_of_quoted_tname]);
×