201

(4 replies, posted in General)

Also is there an example with the following?

SET SESSION wait_timeout = 999999;

Tnx

202

(4 replies, posted in General)

Hello Dmitry and MVD Lovers,

https://s6.postimg.cc/d0ct0824h/EXCEPTION.png

I'm using the following function provided by Dmitry to control error message on MySQL Connection and Queries.
It works fine but at the second attempt it starts again with the system error messages.
Any Help?

function OnSQLException(Sender: TObject; Msg: string; SQL: string): boolean;
begin

    // how to catch lost connection for MySQL
    if Pos('Lost connection to MySQL server during query', Msg)=1 then
    //if Pos('Lost connection to MySQL server during query', Msg)=1 then
    begin
        result := True; // to prevent system message
        // Own message
        MessageBox('Lost connection. Please try again.', 'Error', MB_OK+MB_ICONWARNING);
    end;

end;

Thanks

I want to multi select rows in tableGrid so that when I click on report button it generates report for the selected rows but I don't want to use shift to do the selection

Please is there a better way to achieve the effect below?
Multi select tableGrid for reporting
https://s6.postimg.cc/qy3pe1b01/multi_Select_Print.png

procedure Form1_OnShow (Sender: string; Action: string);
begin
    Form1.TableGrid1.Columns.InsertcheckboxColumn(0);
    Form1.TableGrid1.Columns[0].Header.Caption  := 'checkbox' ;
    Form1.TableGrid1.Options := Form1.TableGrid1.Options + goMultiSelect ;
    Form1.TableGrid1.OnChange := @Grid1_onChange_onClick;
    Form1.TableGrid1.OnCellClick := @Grid1_onChange_onClick;
end;

procedure Grid1_onChange_onClick(Sender: TObject; ACol, ARow: Integer);
var
    i : integer ;
begin
    for i := 0 to   Form1.TableGrid1.RowCount - 1 do
        if Form1.TableGrid1.Cell[0,i].AsBoolean then
            Form1.TableGrid1.Selected[i]:=True
        else
            Form1.TableGrid1.Selected[i]:=False;
end;

begin

end.

Wow so fast
Tnx Dmitry

Hello,
Please how do I select multiple rows with script in the tableGrid on a button click.
Example
When I click on button1 row 1, 2 and 5 should be selected in the tableGrid.
Meaning that when I want to print, the selected rows ate the once to print.
Tnx

Thank you Dmitry.
You have made my day.
This is really useful.

Hi guy, please is it possible to use {$I filename} or {$INCLUDE filename} or Units in MVD. I want to write seperate scripts and link them in the main script file.
If YES, how can it be done.
Thank you.

Hello MVD lovers,
I have updated the function for the money. It now includes Decimals and Currency
https://s6.postimg.cc/3yj286qvl/to_Wards2.jpg

Let me know if interested so I can send to you.
Tnx

For more explanation follow link below
https://www.fast-report.com/documentati … groups.htm

I have been able to figure it out. Thank you guys.

What I did was to place the SQL below in the report button.
Then I used the group header in the FastReport to generate the result I needed.

SELECT register.id,
       score.examsScore,
       score.classScore,
       register.fname,
       register.lname,
       register.oname,
       course.courseName
  FROM score
       LEFT OUTER JOIN register
                    ON register.id = score.id_register
       LEFT OUTER JOIN course
                    ON course.id = score.id_course
 WHERE score.id_register = register.id
 ORDER BY id_register;

Thanks

I'm using a beta version
Tnx all the same

Hello Dmitry and MVD Friends,

The studentReport system records exams and class scores for each student
TABLE
1. register: student details
2. score : students scores
3. course: the subjects students are taking

PROBLEMS
I want to make a report in fastReport which will output each student and the (courses with scores[exams,class])

##########################################################################################
#    EXAMPLE
##########################################################################################
#    NAME Eric Obeng
#
#    SUBJECT        |    EXAMS SCORE    |    CLASS SCORE
#    ..........................................................................
#    ENGLISH        |    80                        |    80
#    MATHS                    |    80                        |    92
#    SCIENCE        |    80                        |    82
#
#
#
#    NAME Linda Obeng
#
#    SUBJECT        |    EXAMS SCORE    |    CLASS SCORE
#    ..........................................................................
#    ENGLISH        |    84                        |    91
#    MATHS                    |    73                        |    87
#    SCIENCE        |    78                        |    85
#      ICT                       |    70                        |    84
#
#########################################################################################
Attached is the project

214

(13 replies, posted in General)

Ohk
Then I'm redownloading it.
Thank you.

It's working after doing the download.
Thank you so much

215

(13 replies, posted in General)

Hello jean.brezhonek,
Thank you for you response.
I did all what you have specified above but the error message I get is

Undeclared identifier:'GetCursorPos', (meaning GetCursorPos procedure does not exist).

Thank you.

216

(13 replies, posted in General)

Hi Dmitry,
Please the GetCursorPos is still not working.
I have downloaded the version 4.6 beta but it still did not work.
Any help?
Thank you.

217

(5 replies, posted in Script)

Hi ehwagner,
Please check the attached fixed of your project.
I think you were calling the onChange Event at a time the Form2 hadn't initialized.
Let me know if it works for you.

procedure Form2_OnShow (Sender: string; Action: string);
begin
     //Form2.Edit1.SetFocus;//it will still work without the setfocus
     Form2_Edit1_OnChange
end;

procedure Form2_Edit1_OnChange;
begin
    If Form2.Edit1.GetTextLen = 4 then Form2.SetFocusNextControl;
end;

begin

end.

218

(2 replies, posted in General)

Thank you.
Appreciated

There was a little bug, so I have updated the example file

I have created a function to address that for my use.
I think this may be useful to others so find the example project below

http://thezimguy.vacau.com/MVD/toWords.jpg

function NumberToWords(Number: real): string;
var
    Billion: real;
    Million: real;
    Thousand: real;
    Hundred: real;
    Tens : Array[2..9] of string = ['','','Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety'];
    Units: array[1..9] of string = ['','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'];
    Teens: array[10..19] of string = ['Ten','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'];
begin                 
    Billion := 1000000000;
    Million := 1000000;
    Thousand := 1000;
    Hundred := 100;
    if (Number < 0) then Result := 'minus ' else Result := '';
    Number := Abs(Number);
    if (Number >= Billion) then
    begin
        Result := Result + NumberToWords(Number div Billion) + ' billion, ';
        Number := Number mod Billion;
    end;
    if (Number >= Million) then
    begin
        Result:= Result + NumberToWords(Number div Million) + ' million, ';
        Number:= Number mod Million;
    end;
    if (Number >= Thousand) then
    begin
        Result:= Result + NumberToWords(Number div Thousand) + ' thousand, ';
        Number:= Number mod Thousand;
    end;
    if (Number >= Hundred) then
    begin
        Result:= Result + NumberToWords(Number div Hundred) + ' hundred, ';
        Number:= Number mod Hundred;
    end;
    if (Number > 0) and (Result <> '') then
    begin
        Result := Trim(Result);
        if(Result[Length(Result)] = ',') then Delete(Result, Length(Result), 1);
        Result := Result + ' and ';
    end;
    if (Number >= 20) then
    begin
        Result := Result + Tens[StrToInt(FloatToStr(Number)) div 10] + ' ';
        Number := Number mod 10;
    end;
    if(Number >= 10) then
    begin
        Result :=Result + Teens[StrToInt(FloatToStr(Number mod 10))];
        Number := 0;
    end;
    if (Number >= 1) then Result := Result + Units[StrToInt(FloatToStr(Number))];
    Result := Trim(Result);
    if (Result = '') then Result := 'zero'
    else
    if (Result[Length(Result)] = ',') then Delete(Result, Length(Result), 1);
end;

procedure btnMoneyToWord(Sender: string; var Cancel: boolean);
var
    s: string;
    begin
        s:=NumberToWords(Form1.edAmount.Value);
        ShowMessage(s);
    end;

begin
end.

MVD, THE BEST

DriveSoft wrote:

Sorry, but I can't change this function only for you )
Usually not written word 'and'

Thank you so much Dmitry.
I really appreciated the time you dedicate to us.

222

(2 replies, posted in General)

Hello Dmitry and MVD funs
Do you please have any idea on how to drag files and drop on form to load the files in a tableGrid?

https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRxrhEU6TVydN8LVHCQmMWvxwaViOMXkxShhfOliwCdMx4pjpCwKA

http://codehill.com/media/dragndrop.png
Tnx in advance.

223

(13 replies, posted in General)

DriveSoft wrote:

Hello.


Please download latest beta version
https://www.dropbox.com/s/wutj7mnux7f3a … a.zip?dl=0


I have added new procedure GetCursorPos, example for you

var
  PopupMenu: TPopupMenu; // global variable

procedure Form1_btnPopup_OnMouseUp (Sender: TObject; MouseLeft, MouseRight, MouseMiddle: boolean; Shift, Alt, Ctrl: boolean; X, Y: Integer);
var
    mX, mY: integer;
begin
    if MouseLeft then
    begin
        GetCursorPos(mX, mY);
        PopupMenu.Popup(mX, mY);
    end;

end;

procedure Form1_OnShow (Sender: string; Action: string);
var
  MyItem: TMenuItem;
begin
  PopupMenu := TPopupMenu.Create(Form1);

  MyItem := TMenuItem.Create (PopupMenu);
  MyItem.Caption := 'Add';
  MyItem.OnClick := @popupMenuOnClick;
  PopupMenu.Items.Add(MyItem);

  MyItem := TMenuItem.Create (PopupMenu);
  MyItem.Caption := 'Edit';
  MyItem.OnClick := @popupMenuOnClick;
  PopupMenu.Items.Add(MyItem);

  MyItem := TMenuItem.Create (PopupMenu);
  MyItem.Caption := 'Delete';
  MyItem.OnClick := @popupMenuOnClick;
  PopupMenu.Items.Add(MyItem);
end;

This is PERFECT. Thank you Dmitry
You are always at our aid.
MVD, the best

I created that function in php with the following code

<?php
//echo convert_number(645647);
function convert_number($number){
    if(($number<0)||($number>9999999999)){
        throw new Exception("Number is out of range");
    }
    $Mn=floor($number/1000000);/*millions(giga)*/
    $number-=$Mn*1000000;
    $Gn=floor($number/100000);/*millions(giga)*/
    $number-=$Gn*100000;
    $kn=floor($number/1000);/*Thousands(hecto)*/
    $number-=$kn*1000;
    $Hn=floor($number/100);/*hundreds(hecto)*/
    $number-=$Hn*100;
    $Dn=floor($number/10);/*Tens(deca)*/
    $n=$number%10;/*ones*/
    $res="";
    $z="";
    if($Mn){
        $res.=convert_number($Mn)." Million ";
        $z="mil";//$res.=convert_number($Gn)." Hundred and";
    }
    if($Gn && ($z=="mil")){
      $res.=convert_number($Gn)." Hundred and";
    }
    else if($Gn && ($z=="")){
      $res.=convert_number($Gn)." Hundred ";
    }
    
    if($kn){
        $res.=(empty($res)?"":" ").convert_number($kn)." Thousand ";
    }
    if($Hn){
        $res.=(empty($res)?"":" ").convert_number($Hn)." Hundred ";
    }
    $ones=array("","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen");
    $tens=array("","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety");
    
    if($Dn||$n){
        if(!empty($res)){
            $res.=" and ";
        }
        if($Dn<2){
            $res.=$ones[$Dn*10+$n];
        }else{
            $res.=$tens[$Dn];
            if($n){
                $res.="-".$ones[$n];
            }
        }
    }
if(empty($res)){
    $res="Zero";
}
return $res;
}
?>

225

(13 replies, posted in General)

jean.brezhonek wrote:

Hello thezimguy

I quoted Delphi because MVD was written in this language (Embarcadero RAD XE3).

I can solve some MVD problems by going to the Embarcadero website.

JB


Thank you so much.
I'm very much grateful for your help