426

(2 replies, posted in Script)

Hello Dmitry and all MVD users,


I have a simple (well I think) question about how to "kill" the application created with MVD on exit.


At the moment, here's what I have :

A login form shows at startup and asks for credentials.

After checking the validity of the credentials, the first form hiddes itself and the second form opens with this code :


if (FormLogin = DBLogin) and (FormPassword = DBPassword) and (DBActive = 1) then
    begin
         Form1.Hide;
         Form2.Show;
    end;

Problem is that, after 3 successfull launches and closing  of the application for testing, here is what I have in my list of processes :


http://i.imgur.com/zwIK81G.png


My application is still running.


Now, I'm pretty sure that this is due to the "Form1.Hide" I use, but I don't know what to use instead. I've tried "Form1.Close" but it opens the second Form and then kills the app smile

Any idea for me, or maybe a post related to this same subject you could point me to ?


Thanks in advance and I wish you all a good day.


Mathias

427

(6 replies, posted in Talks about all)

Hello all,

Here are 3 FREE tools I use very often when working with MVD.

1- SQLite Studio for viewing structure and data of tables (and modification / copy / backup if needed)


http://i.imgur.com/GThsaYW.png


2- XMLViewer for detailling (and modif or backup) on forms.xml
The structure of the xml file is filtered when you select an element

http://i.imgur.com/PUvOn2c.png

3- Snippet manager
This helps me keep tracks of the code (script) I write in MVD, or of those I find on the forum for later use.
This software is not limited to DELPHI and can be used to keep track on SQL request, PHP and much much more

http://i.imgur.com/8eaGzZY.png

Hope this will be usefull.

Wish you all a good day

Mathias

428

(14 replies, posted in General)

Just to make sure : your application saves data to 2 different DATABASES, not to 2 TABLES in the same DATABASE, right ?

If that is so, I'm very much curious to know how you set up the system in the first place, because I tried and failed :
- 2 different sqlite.db files
- 2 differents tables.ini files
- 2 different servers declared in the settings.ini file


In sql you can use the ATTACH command to link 2 different databases together, but I don't know how with MVD.

Mathias

429

(14 replies, posted in General)

I'm not sure I fully understand what you want to achieve.


Are you saying that you need to query a table from a reference on another table ?


If that is so, you need to use an INNER JOIN .. ON.. statment in your SQL query.
Here is a good example : INNER JOIN




It's a bit tricky you are right but fun ! If the example does not help you, give more details and I'll try to help you

Have a good day

Mathias

430

(4 replies, posted in Script)

Yes, you are right, it's the same code smile


But I made a little modification to it this morning :


1- Checkbox Visible is disabled by default, so that on opening of Form1 it is not shown.


2 - Then, when you type text in the Edit1, the checkbox appears and is checked by default


3 - If you erase the text in Edit1, the checkbox disappears again


4- and so on when you write or erase text in the Edit1



Wasn't it what you initially wanted ?

procedure Form1_Edit1_OnChange (Sender: string);

begin
    if Form1.Edit1.Text<>'' then
    begin
        Form1.CheckBox1.Visible:=True;
        Form1.Checkbox1.Checked:=True;
    end;
    if Form1.Edit1.Text='' then
    begin
        Form1.CheckBox1.Visible:=False;
    end;
end;
begin
end.

Have a good day

Mathias

431

(4 replies, posted in Script)

I created a blank projet with just Form1, Edit1 and a Checkbox1

When I enter some text in the Edit1, the checkbox is automaticaly checked, and when I empty the Edit1, the checkbox unchecks. It works for me with this code :

procedure Form1_Edit1_OnChange (Sender: string);
begin
    if Form1.Edit1.Text<>'' then
    Form1.CheckBox1.Checked:=True
    else
    Form1.CheckBox1.Checked:=False;
end;

Project is attached


Have a good day


Mathias


PS : Version si 1.49

432

(9 replies, posted in General)

Sorry to re-up that post, but I think radio-buttons make sens.


The main point is that there is only one choice possible with radio-buttons (exemple smoker / non-smoker), when with check boxes, you could have both checked which is not possible : you can not be a smoker AND a non-smoker smile

Mathias

433

(187 replies, posted in General)

Hello Dmitry,

I'd love to see the TWebBrowser Class implemented in an upcoming version, that would be great !

Nice tool :-)

Mathias

434

(7 replies, posted in Script)

Bonjour Jean,


Je me suis un peu creusé la tête sur ton problème : actualiser l'image en fonction de la ligne sélectionnée dans la grille, en tenant compte des deux cases à cocher. Je suis comme toi, j'aime les défis, et en phase de découverte d'un langage, c'est encore plus amusant.


J'ai trouvé une solution à ton problème que je te soumets en pièce jointe. J'ai rajouté une image supplémentaire et une zone image, mais rien n'empêche de conserver celle que tu avais définie. Bien entendu, ce n'est que mon approche, je suis sur que tu peux optimiser (CASE ... OF ?).


Tu verras, j'ai commenté le code à mort, ça devrait être facile à suivre.


Bonne journée


Amicalement


Mathias

435

(7 replies, posted in Script)

jean.brezhonek wrote:

Je l'ai même réduit en utilisant la conditon CASE ... OF

Là tu aiguises ma curiosité, mais tu as du oublier le petit détail suivant :

procedure Form1_Connaissance_Language (Sender: string);
var code: string;
    begin
        code := Form1.ComboBox1.Text;
        if (code) := 'PHP' then
        begin
        Form1.Edit1.Text:= 'Se débrouille pas mal';
        end;
        if (code) := 'Delphi' then
        begin
        Form1.Edit1.Text:= 'Grand débutant';
        end;
    end;

Je ne te ferai pas l'affront de traduire smile

436

(7 replies, posted in Script)

Ravi de te croiser ici smile


Depuis tout à l'heure, j'ai trouvé comment rafraîchir l'affichage des informations sur un simple clic dans la grille : il faut passer par une requête SQL qui récupère l'id de l'enregistrement sur lequel on a clique, et qui remplit les champs avec les résultats de la requête.


Une fiche comme celle-ci voit les infos (à droite) rafraîchies automatiquement quand on sélectionne (simple clic) une société dans la liste


http://i.imgur.com/aZsUjHv.png


Et le script associé :


//Procédure d'affichage des données de la société sélectionnée (simple clic) dans la fenêtre de droite
procedure Form1_TableGrid1_OnClick (Sender: string);

var    sID: string;
begin

    begin
        sID := Form1.TableGrid1.sqlValue; // id de l'enregistrement à afficher
        Form1.ed_company_name.Text:= SQLExecute('SELECT company_name FROM company WHERE id='+sID); // get company_name
        Form1.ed_company_adr1.Text:= SQLExecute('SELECT company_adr1 FROM company WHERE id='+sID); // get company_adr1
        Form1.ed_company_adr2.Text:= SQLExecute('SELECT company_adr2 FROM company WHERE id='+sID); // get company_adr2
        Form1.ed_company_pobox.Text:= SQLExecute('SELECT company_pobox FROM company WHERE id='+sID); // get company_pobox
        Form1.ed_company_pc.Text:= SQLExecute('SELECT company_pc FROM company WHERE id='+sID); // get company_pc
        Form1.ed_company_town.Text:= SQLExecute('SELECT company_town FROM company WHERE id='+sID); // get company_town
        Form1.ed_company_country.Text:= SQLExecute('SELECT company_country FROM company WHERE id='+sID); // get company_country
        Form1.ed_company_phone.Text:= SQLExecute('SELECT company_phone FROM company WHERE id='+sID); // get company_phone
        Form1.ed_company_fax.Text:= SQLExecute('SELECT company_fax FROM company WHERE id='+sID); // get company_fax
        Form1.ed_company_website.Text:= SQLExecute('SELECT company_website FROM company WHERE id='+sID); // get company_website
        Form1.ed_company_type.Text:= SQLExecute('SELECT company_type.type_name FROM company_type INNER JOIN company ON company_type.id='+sID); // get company_type
        Form1.ed_company_note.Text:= SQLExecute('SELECT company_note FROM company WHERE id='+sID); // get company_note
        Form1.label_nb_contact.Caption:= SQLExecute('SELECT COUNT (*) FROM contact WHERE id_company='+sID); //get number of contact for the company

    end;
end;

437

(7 replies, posted in Script)

Hello,

With a name like yours, I bet you are french, so I'll take the chance and write in french.
If you are not, I'll translate to english smile


Tout d'abord, je ne suis qu'un amateur et aucunement membre de ce projet. Je me dérouille en PHP mais je découvre le Delphi alors...


J'ai regardé ton projet, et je pense que tu vas avoir du mal à accomplir ce que tu souhaites avec tes cases à cocher ET sans utiliser des conditions.


Ton script précise quoi faire si une case est cochée, mais pas quoi faire dans les autres cas.


Pour commencer, voici la liste des conditions à tester pour couvrir tous les cas possibles : tu as 2 cases à cocher avec 2 états possibles pour chacune, ce qui te donne un total de 4 combinaisons à tester :

  • fumer coché et non-fumer non coché

  • fumeur non coché et non-fumeur coché

  • fumeur non coché et non-fumeur non coché

  • fumeur cochéet non-fumeur coché


Pour te simplifier la vie, je mettrais des menus déroulants à la place des cases à cocher, en faisant un test sur le contenu (ComboBox.Text) plutôt que sur l'état de tes cases.


J'ai fais vite fait un petit projet pour toi mais pas le tiens (sinon ce n'est pas drôle hein ?) dans lequel on saisit des contacts en précisant leur sexe :

  • au moment de la saisie, sélectionner un genre dans le menu déroulant affiche l'image correspondante dans la fiche

  • ensuite, en double cliquant dans la grille (mode édition), les images s'adaptent au genre de la personne

  • j'ai aussi couvert le cas où le sexe n'est pas précisé, mais cela ne me fait toujours que 3 cas à tester, au lieu des 4 avec tes cases


Jette un oeil, en espérant que cela t'aide.


NOTE 1 : j'ai essayé de faire en sorte que l'image s'affiche à la simple sélection de la ligne dans la grille (simple clic au lieu de double), mais je me creuse encore la tête la dessus.


NOTE 2 : La version utilisée est la 1.49


A bientôt


Math

438

(12 replies, posted in General)

Very nice script !

Ii took the opportunity to modify it as follows :

begin
     c := Form1.GridEmployees.RowCount - 1;
     for i := 0 to c do
     begin
         s := Form1.GridEmployees.Cells[2,i];
         if ValidDate(s) then
             if (StrToDate(s) - 15) >= now then Form1.GridEmployees.Cell[2,i].Color := clGreen;
             if (StrToDate(s) - 15) < now then Form1.GridEmployees.Cell[2,i].Color := clYellow;
             if (StrToDate(s) - 7) < now then Form1.GridEmployees.Cell[2,i].Color := clRed;
     end;
end;

The result is :
- 15 or more days -> color is green
- less than 15 days ->color is yellow
- less than 7 days -> color is red

Your tool is howesome !

Thanks for teh great work.

Math