Jump to content

Serge_G

Members
  • Content Count

    310
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Serge_G


  1. Hi,

     

    2 solutions.

    First one is to use a TListView and Dynamic appearance, like this (listview "livebinded" to fdmemtable)

    image.thumb.png.647fca0b60a6f3cb7fcc13aae0475e4e.png

    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

    • Like 1

  2. Hi,

    22 hours ago, XylemFlow said:

    Could I create a class deriving from TSpinBox and then override some of the functionality perhaps? 

    No, this new TSpinBox should use the same style.

    22 hours ago, XylemFlow said:

    The other annoying thing with styles is that I have to create the style for each platform, including each Windows version.

    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.

    22 hours ago, XylemFlow said:

    I think that the reason the exception didn't happen in Windows XP compatibility mode is because there was no style for it. 

    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 :classic_blush: 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 😉


  3. On 10/19/2022 at 10:50 AM, tobenschain said:

    BudSys_DB.RecNo := recnum;

    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

    • Like 1

  4. 35 minutes ago, Pat Foley said:

    Serge_G listbox coding is very nice example.  Serge's "Introduction to FireMonkey XE4 Styles" is good start about differences between FMX and VCL and in text!  His A.F.R.O may help you with the disappearing.  

    Thanks, but this AFRO thing is now obsolete because IDE force it when you close designer (ouf)


  5. 16 hours ago, Kurt G said:

    But the compiler give error: Undeclared identifier: TListviewItem in the line:   Lvi : TListViewItem;

    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

    image.thumb.png.0b21752a820b9aaa732b23f20e4acbd7.png


    A list box (simple one without style) should be filled with Listbox1.Items.Add('Hello')
    image.thumb.png.af4d5ce47078989151d43062a5ee8ed4.png

     

    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)
     

     

     


  6. 19 hours ago, lt.col.blair said:

    The forms have that stylebook assigned in their StyleBook property.

    Set UseStyleManager to true of StyleBook to avoid this. Note : Only one TStyleBook can be set.

    19 hours ago, lt.col.blair said:

    I don't understand the difference between "StyleLookup" and "StyleName". 

    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 :classic_smile:image.png.cb34e3de112528a984742664e4a6ae16.png

     

    19 hours ago, lt.col.blair said:

    But when I double click the StyleBook, that is placed on the DataSet to edit its styles, it is completely empty!

    Ok, but did you pay attention to platform ? Have a look at platform 'default' and others if any in stylebook.styles collection
    image.thumb.png.fdc3fe77ada09ee12e3cdbf5f3283461.png

     

    20 hours ago, lt.col.blair said:

    I could not find any Style settings in the .fmx

    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

     


  7. 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;

     

    • Like 2

  8. 16 hours ago, Henry Olive said:

    ACCAccount table is like below

    ACCCODE,  DEBIT,  CREDIT

    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


  9. 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 !

    • Thanks 1

  10. 6 hours ago, Henry Olive said:

    I asked this question a couple of months ago here Mr.Serge

    replied me (Thank you again) and said it is normal.

    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 ")"

    :classic_blush: sorry for mistyping, when I quoted the second part about size, something happened and I was thinking No it's abnormal  


  11. @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;

     

    • Thanks 1

  12. 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;

     


  13. 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

    • Thanks 1

  14. 37 minutes ago, Stano said:

    I checked the translation where "and I don't create an runtime TFDQuery"

    not my mother tongue too

     

    37 minutes ago, Stano said:

    a communication error somewhere

    Yes, here I miss some words I think

     

    I am not a fan of the WITH but, sometimes using it by lazyness 


  15. 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; 

     


  16. 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 :classic_smile: and I don't create an runtime TFDQuery .... :classic_biggrin:) but queries with parameters is, I think is a very usefull technique (I use for years)   

     
     


  17. 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]);

     

     

     

×