About database development

xiaoxiao2021-03-06  18

Develop database applications, Delphi is well deserved! I am just love her.

I have seen a stuff in Delphi, I have seen a stuff, and I haven't worried, and I will change it, I am very practical.

In the application I have developed now, no one doesn't have to, it is convenient ...

effect:

Encoding -> Name Interpretation (Conversion is not restricted by field length), there are many ways, such as: using lookupfield or directly with sql or with canvas, but I use Tfields's OnGetText method, huh ... Maybe there is whom to use After you have mentioned, you will have a little impression.

Is such that:

Suppose I have a primary table (Employee: Employee Table) and a coded table (BMZW: duties)

EMPLOYEE:

XM ----- employee name

ZW ----- Director

........................

BMZW:

BM ----- Job Coding

MC ----- Director Chinese character

Now we have to do the case of all employees (EMPLOYEE), the job code (ZW) user must not read, so how to display the ZW field in the EMPLOYEE to the MC field content corresponding to the BM field in BMZW?

My solution is like this:

// ------ query1: Query Master Table Query2: Query Code Table

// ------ Button1: query

// Query the coding table

Procedure TFORM1.FormCreate (Sender: TOBJECT);

Begin

Query1.fieldByname ('ZW'). OnGettext: = query1zwwterText; // ********* //

Query2.close;

Query2.sql.text: = 'SELECT * from BMZW';

Queyr2.open;

END;

//***freed

Procedure TFORM1.FORMDESTROY (Sender: TOBJECT);

Begin

Query1.fieldbyName ('ZW'). OnGetText: = NIL;

END;

// Query the main table

Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);

Begin

Query1.close;

Query1.sql.text: = 'SELECT * FROM EMPLOYEE';

Query1.open;

END;

// ONGETEXT process (Employee.zw-> bmzw.mc)

Procedure TFORM1.QUERY1ZWGETTEXT (Sender: Tfield; var text: string;

Displaytext: boolean;

Begin

/ / Here is the key

IF query2.locate ('bm', sender.Asstring, []) THEN

Text: = query2.fieldbyname ('mc'). Asstring

Else

Text: = sender.Asstring;

END;

Temporarily, try it, try it ... it may be unclear, and you can write all the methods and write all the methods.

转载请注明原文地址:https://www.9cbs.com/read-41030.html

New Post(0)