比如:现在单据号为:2867数据提交后为:0002867,我用的是.db桌面数据库,单据号码为“I”型字段。
2、我用DBGRID作为数据录入时,每行数据输入时利用字典方式从基础数据库中将已有的物资信息添加的多个列中,如何实现?
如果分数不够可以加分的。。
11 个解决方案
#1
1、单据号码要为“s”型字段,要不然,数据库会自动把前面的0删掉的!
至于加0好做了!
var x:string;
i:integer;
for i:=1 to 7-length(x) then
temp:=temp+'0';
next
y:=temp+x
没有测试过,你自己试吧!
2、dbgrid好像有x、y的吧,你查帮助吧,我记不清了!
至于加0好做了!
var x:string;
i:integer;
for i:=1 to 7-length(x) then
temp:=temp+'0';
next
y:=temp+x
没有测试过,你自己试吧!
2、dbgrid好像有x、y的吧,你查帮助吧,我记不清了!
#2
1:
function strnum(x:integer):string;
var s:string;
begin
s:=str(x);
return:=copy('000000000000000',1,7-length(s))+s
end;
2:不大明白,写个通用子程序
readrecord(fieldnames:array of string):array of variant
大概for i:=0 to length(fieldnames)-1
tablex.fieldbyname(fieldnames[i])加入
fillrecord(values:array of variant;fieldnames:array of string)
with correnttable as table
fieldbyname(fieldnames[i]).value:=values;
好好写,非常有用
function strnum(x:integer):string;
var s:string;
begin
s:=str(x);
return:=copy('000000000000000',1,7-length(s))+s
end;
2:不大明白,写个通用子程序
readrecord(fieldnames:array of string):array of variant
大概for i:=0 to length(fieldnames)-1
tablex.fieldbyname(fieldnames[i])加入
fillrecord(values:array of variant;fieldnames:array of string)
with correnttable as table
fieldbyname(fieldnames[i]).value:=values;
好好写,非常有用
#3
用strcopy好象可以达到字符转换的效果
#4
//No.1
function IntStrLen(mInt: Integer; mLen: Integer): string;
begin
Str(mInt:mLen, Result);
Result := StringReplace(Result, #32, '0', [rfReplaceAll]);
end;
//No.2
DBGrid1.Columns[0].ButtonStyle = cbsEllipsis;
//EditButtonClick事件
procedure TForm1.DBGrid1EditButtonClick(Sender: TObject);
begin
if TDBGrid(Sender).SelectedField.FieldName = 'KeyFiled' then begin
with TQuery.Create(Self) do try
DatabaseName := '';
SQL.Text := Format('SELECT * FROM TableDoc WHERE KeyFiled=%s',
[QuotedStr(TDBGrid(Sender).SelectedField.AsString)]);
Open;
if RecordCount <> 0 then begin
TDBGrid(Sender).DataSource.DataSet.Edit;
TDBGrid(Sender).DataSource.DataSet['Field1'] := FieldValues['Field1'];
TDBGrid(Sender).DataSource.DataSet['Field2'] := FieldValues['Field2'];
TDBGrid(Sender).DataSource.DataSet['Field3'] := FieldValues['Field3'];
end;
finally
Free;
end;
end;
end;
function IntStrLen(mInt: Integer; mLen: Integer): string;
begin
Str(mInt:mLen, Result);
Result := StringReplace(Result, #32, '0', [rfReplaceAll]);
end;
//No.2
DBGrid1.Columns[0].ButtonStyle = cbsEllipsis;
//EditButtonClick事件
procedure TForm1.DBGrid1EditButtonClick(Sender: TObject);
begin
if TDBGrid(Sender).SelectedField.FieldName = 'KeyFiled' then begin
with TQuery.Create(Self) do try
DatabaseName := '';
SQL.Text := Format('SELECT * FROM TableDoc WHERE KeyFiled=%s',
[QuotedStr(TDBGrid(Sender).SelectedField.AsString)]);
Open;
if RecordCount <> 0 then begin
TDBGrid(Sender).DataSource.DataSet.Edit;
TDBGrid(Sender).DataSource.DataSet['Field1'] := FieldValues['Field1'];
TDBGrid(Sender).DataSource.DataSet['Field2'] := FieldValues['Field2'];
TDBGrid(Sender).DataSource.DataSet['Field3'] := FieldValues['Field3'];
end;
finally
Free;
end;
end;
end;
#5
functin bl(const s:string):string;
begin
Result := format('%7.7d',[s]);
end
begin
Result := format('%7.7d',[s]);
end
#6
Format('%0.7d', [Value]);
#7
上面的敲错了,应该是这样:
functin bl(const s:string):string;
begin
Result := format('%7.7d',[StrToInt(s)]);
end
functin bl(const s:string):string;
begin
Result := format('%7.7d',[StrToInt(s)]);
end
#8
方法多多 ,
自己参照吧。
自己参照吧。
#9
第一个问题已经解决,谢谢各位,等我再加分后请再回答第二个问题。
#10
分数已经由20分加到了40分,请大家继续讨论第二个问题。
#11
最简单办法:
1.formatfloat('0000000',2867)//=0002867
2.dbgrid1.Fields[0].DisplayLabel//标题信息
1.formatfloat('0000000',2867)//=0002867
2.dbgrid1.Fields[0].DisplayLabel//标题信息
#1
1、单据号码要为“s”型字段,要不然,数据库会自动把前面的0删掉的!
至于加0好做了!
var x:string;
i:integer;
for i:=1 to 7-length(x) then
temp:=temp+'0';
next
y:=temp+x
没有测试过,你自己试吧!
2、dbgrid好像有x、y的吧,你查帮助吧,我记不清了!
至于加0好做了!
var x:string;
i:integer;
for i:=1 to 7-length(x) then
temp:=temp+'0';
next
y:=temp+x
没有测试过,你自己试吧!
2、dbgrid好像有x、y的吧,你查帮助吧,我记不清了!
#2
1:
function strnum(x:integer):string;
var s:string;
begin
s:=str(x);
return:=copy('000000000000000',1,7-length(s))+s
end;
2:不大明白,写个通用子程序
readrecord(fieldnames:array of string):array of variant
大概for i:=0 to length(fieldnames)-1
tablex.fieldbyname(fieldnames[i])加入
fillrecord(values:array of variant;fieldnames:array of string)
with correnttable as table
fieldbyname(fieldnames[i]).value:=values;
好好写,非常有用
function strnum(x:integer):string;
var s:string;
begin
s:=str(x);
return:=copy('000000000000000',1,7-length(s))+s
end;
2:不大明白,写个通用子程序
readrecord(fieldnames:array of string):array of variant
大概for i:=0 to length(fieldnames)-1
tablex.fieldbyname(fieldnames[i])加入
fillrecord(values:array of variant;fieldnames:array of string)
with correnttable as table
fieldbyname(fieldnames[i]).value:=values;
好好写,非常有用
#3
用strcopy好象可以达到字符转换的效果
#4
//No.1
function IntStrLen(mInt: Integer; mLen: Integer): string;
begin
Str(mInt:mLen, Result);
Result := StringReplace(Result, #32, '0', [rfReplaceAll]);
end;
//No.2
DBGrid1.Columns[0].ButtonStyle = cbsEllipsis;
//EditButtonClick事件
procedure TForm1.DBGrid1EditButtonClick(Sender: TObject);
begin
if TDBGrid(Sender).SelectedField.FieldName = 'KeyFiled' then begin
with TQuery.Create(Self) do try
DatabaseName := '';
SQL.Text := Format('SELECT * FROM TableDoc WHERE KeyFiled=%s',
[QuotedStr(TDBGrid(Sender).SelectedField.AsString)]);
Open;
if RecordCount <> 0 then begin
TDBGrid(Sender).DataSource.DataSet.Edit;
TDBGrid(Sender).DataSource.DataSet['Field1'] := FieldValues['Field1'];
TDBGrid(Sender).DataSource.DataSet['Field2'] := FieldValues['Field2'];
TDBGrid(Sender).DataSource.DataSet['Field3'] := FieldValues['Field3'];
end;
finally
Free;
end;
end;
end;
function IntStrLen(mInt: Integer; mLen: Integer): string;
begin
Str(mInt:mLen, Result);
Result := StringReplace(Result, #32, '0', [rfReplaceAll]);
end;
//No.2
DBGrid1.Columns[0].ButtonStyle = cbsEllipsis;
//EditButtonClick事件
procedure TForm1.DBGrid1EditButtonClick(Sender: TObject);
begin
if TDBGrid(Sender).SelectedField.FieldName = 'KeyFiled' then begin
with TQuery.Create(Self) do try
DatabaseName := '';
SQL.Text := Format('SELECT * FROM TableDoc WHERE KeyFiled=%s',
[QuotedStr(TDBGrid(Sender).SelectedField.AsString)]);
Open;
if RecordCount <> 0 then begin
TDBGrid(Sender).DataSource.DataSet.Edit;
TDBGrid(Sender).DataSource.DataSet['Field1'] := FieldValues['Field1'];
TDBGrid(Sender).DataSource.DataSet['Field2'] := FieldValues['Field2'];
TDBGrid(Sender).DataSource.DataSet['Field3'] := FieldValues['Field3'];
end;
finally
Free;
end;
end;
end;
#5
functin bl(const s:string):string;
begin
Result := format('%7.7d',[s]);
end
begin
Result := format('%7.7d',[s]);
end
#6
Format('%0.7d', [Value]);
#7
上面的敲错了,应该是这样:
functin bl(const s:string):string;
begin
Result := format('%7.7d',[StrToInt(s)]);
end
functin bl(const s:string):string;
begin
Result := format('%7.7d',[StrToInt(s)]);
end
#8
方法多多 ,
自己参照吧。
自己参照吧。
#9
第一个问题已经解决,谢谢各位,等我再加分后请再回答第二个问题。
#10
分数已经由20分加到了40分,请大家继续讨论第二个问题。
#11
最简单办法:
1.formatfloat('0000000',2867)//=0002867
2.dbgrid1.Fields[0].DisplayLabel//标题信息
1.formatfloat('0000000',2867)//=0002867
2.dbgrid1.Fields[0].DisplayLabel//标题信息