关于Delphi里DBGrid组件内,如何产生一组随机时间的问题? 急急急,在线等!!!
按下打印按钮,想在交易日期那一列上按序随机产生20个2013-1-1到2013-12-31的随机日期,本人刚学delphi,请多多谅解,能中文注释下关键地方,下面有图有代...
按下打印按钮,想在交易日期那一列上按序随机产生20个2013-1-1到2013-12-31的随机日期,本人刚学delphi,请多多谅解,能中文注释下关键地方,下面有图有代码,谢谢!
procedure TForm1.dyClick(Sender: TObject);
begin
ClientDataSet1.FieldDefs.Clear;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'rq';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'sj';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'je';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'ye';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'hh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'cdh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'rzh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'qd';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'jym';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'zy';
Size := 10;
DataType := ftString;
end;
//动态创建数据集
ClientDataSet1.CreateDataSet;
//激活和打开该数据集
ClientDataSet1.Open;
ClientDataSet1.Append;
ClientDataSet1.FieldByName('rq').AsString:='20130904';
ClientDataSet1.FieldByName('sj').AsString:='094147';
ClientDataSet1.FieldByName('je').AsString:='-40000.00';
ClientDataSet1.FieldByName('ye').AsString:='114.30';
ClientDataSet1.FieldByName('hh').AsString:='19-2551';
ClientDataSet1.FieldByName('cdh').AsString:='2tu50012';
ClientDataSet1.FieldByName('rzh').AsString:='33765062';
ClientDataSet1.FieldByName('qd').AsString:='TERM';
ClientDataSet1.FieldByName('jym').AsString:='4213';
ClientDataSet1.FieldByName('zy').AsString:='现支';
ClientDataSet1.Post;
end; 展开
procedure TForm1.dyClick(Sender: TObject);
begin
ClientDataSet1.FieldDefs.Clear;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'rq';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'sj';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'je';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'ye';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'hh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'cdh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'rzh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'qd';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'jym';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'zy';
Size := 10;
DataType := ftString;
end;
//动态创建数据集
ClientDataSet1.CreateDataSet;
//激活和打开该数据集
ClientDataSet1.Open;
ClientDataSet1.Append;
ClientDataSet1.FieldByName('rq').AsString:='20130904';
ClientDataSet1.FieldByName('sj').AsString:='094147';
ClientDataSet1.FieldByName('je').AsString:='-40000.00';
ClientDataSet1.FieldByName('ye').AsString:='114.30';
ClientDataSet1.FieldByName('hh').AsString:='19-2551';
ClientDataSet1.FieldByName('cdh').AsString:='2tu50012';
ClientDataSet1.FieldByName('rzh').AsString:='33765062';
ClientDataSet1.FieldByName('qd').AsString:='TERM';
ClientDataSet1.FieldByName('jym').AsString:='4213';
ClientDataSet1.FieldByName('zy').AsString:='现支';
ClientDataSet1.Post;
end; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询