Home > Back-end >  Delphi7 how to add the serial number in the table
Delphi7 how to add the serial number in the table

Time:09-19

Using sql2000 query dbgrid
I have a sales table, table orderly number (dj_sn) fields, while sales of make out an invoice number automatically increase and deposited in the database, now can increase, but if delete a line, the serial number is wrong, (if: I have 10 rows of data, I delete the first line, the line at the back of the serial number will be minus one in order to) will be the new serial number assigned to the dj_sn this column, now is too slow, still have what way?

CodePudding user response:

My experience, the original is not I on the table there is a number or serial number of the field, use the DBGrid, you are not the same problems, through practice:
1, cancel the number or sequence number field in the table,
2, use DBGridEh shows that as long as the property of ancient dghShowRecNo is True, can be the first column shows the number of rows in the table automatically,
3, print form, use RecNo serial number, can, very convenient,

CodePudding user response:

The key is I want to put the serial number to a database table, DBGridEh line?

CodePudding user response:

What are you doing to save it? Useful

CodePudding user response:

Useful, of course, a table, there are a lot of list, each list to difference with ticket number, serial number, are there in each of the documents so that the serial number in the table is a field, so DBGrid just show

CodePudding user response:

If there is a serial number "" in each of the documents, it should not be" I have 10 rows of data, I delete the first line, the line at the back of the serial number will, in turn, minus one "
If you the serial number is to discharge in order according to the record, it's no use,

CodePudding user response:

Don't need a table number, because each list, can have its own serial number,
Using RecNo print form, serial number, can, very convenient,

CodePudding user response:

Logic design problems

CodePudding user response:

Procedure Tfrm_zj. DBGridPane3Main1DBTableView1RowNoGetDisplayText (
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
Var AText: String);
The begin
Inherited;
AText:=IntToStr (ARecord. Index + 1);
end;

CodePudding user response:

Upstairs is a way, there is a way, if use SQL2000 is determined, you can use the trigger, in the case of delete events, to perform the update SQL, such as serial number record number,

CodePudding user response:

Generally are discontinuous number allows documents, if it is one of the documents detailed need continuous, but in the audit process, recalculate the serial number

CodePudding user response:

refer to 7th floor liups response:
there is something wrong with the logic design

Using a temporary table or memory table to temporary store sales data, when the save sales orders, just written to the sales table, to write an article with a serial number

CodePudding user response:

11 references yellowlongriver response:
Quote: refer to 7th floor liups response:

Logic design problems

Use temporary table or memory tables to temporary store sales data, when the save sales orders, just written to the sales table, to write an article with a serial number


When multiple users how to do? This line of thinking wrong!

Such as: Banks + ticket number boc constitute the number!

CodePudding user response:

refer to 12 floor liups reply:
Quote: reference 11 floor yellowlongriver response:

Quote: refer to 7th floor liups response:

Logic design problems

Use temporary table or memory tables to temporary store sales data, when the save sales orders, just written to the sales table, to write an article with a serial number


When multiple users how to do? This line of thinking wrong!

Such as: Banks + ticket number boc constitute the number!

Multi-user: no problem, each user to create a temporary table for the user, the table name is the same, but the SQL server management is the only table name, a temporary table is finished using the disappeared, run by the SQL server

CodePudding user response:

Procedure Tfrm_zj. DBGridPane3Main1DBTableView1RowNoGetDisplayText (
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
Var AText: String);
The begin
Inherited;
AText:=IntToStr (ARecord. Index + 1);
end;

CodePudding user response:

Order number field in the table, when the sales order, the serial number will be updated when the real to the table, so that after the accident (power failure or broken network) can come to order, so can't use a temporary solution

CodePudding user response:

Don't put the serial number in the table, put a status field is ok, if you put a serial number, serial number on the state of temporary changes can add,

CodePudding user response:

If need to UPDATE the database code can UPDATE TableName Set No=No - 1 where No> DelNo

CodePudding user response:

refer to 6th floor lyhoo163 response:
do not need to use a table number, because each list can have its own serial number,
Using RecNo print form, serial number, can, very convenient,

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Here is RecNo adoquery properties, is very convenient.

CodePudding user response:

In the data table is set to Auto number serial number will be automatic sorting

CodePudding user response:

Add code in dj_dn field OnGetText events:
Text: Sender.=DataSource. The DataSet. RecNo
  • Related