如题,下面的代码不能实现~!
{with DM.OraTable1 do
begin
Close;
TableName:='001';
Filter:='num='''+xnum+''' and RQ='''+StrtoDate(xrq)+'''';//这里的过滤条件设置的类型不对,num是string,rq是日期型(TDate)
Filtered:=True;
Open;
if Eof then
begin
while i<=stringgrid1.RowCount do
begin
if (Length(stringgrid1.Cells[2,i])<>0) or ((stringgrid1.Cells[1,i]='DK) and (Length(stringgrid1.Cells[2,i])=0)) then
begin
DM.OraTable1.Append;
with stringgrid1 do
begin
DM.OraTable1['num']:=xnum;
try
DM.OraTable1['rq']:=StrtoDate(xrq);
except
messagedlg('错误的日期范围', mtinformation, [mbok], 0);
tjbz:=1;
Break;
end;
try
DM.OraTable1['xjjrq']:=StrtoDate(edtXJJRQ.Text);
except
messagedlg('错误的日期范围', mtinformation, [mbok], 0);
tjbz:=1;
Break;
end;
DM.OraTable1['yyxh']:=Trim(Cells[0,i]);
if i>1 then
if (Cells[1,i-1]='FGQ) then
begin
DM.OraTable1['xxmc']:='';
Cells[1,i]:='';
end;
DM.OraTable1['xxmc']:=Trim(Cells[1,i]);
with DM.OraTable3 do
begin
Close;
TableName := 'DM_XXMC';
Filter := 'xxMC='''+Trim(Cells[1, i])+'''';
Filtered := true;
Open;
if not Eof then
DM.OraTable1['xxdm'] := FIELDBYNAME('xxdm').ASSTRING
else
DM.OraTable1['xxdm'] := ''
end;
DM.OraTable3.Close; try
cd := StrToFloat(string(Cells[2, i], 5, 2));
if (cd < 5) or (cd > 10) then
begin
if stringgrid1.Cells[1, i] = 'YG' then
messagedlg('长度范围错(1~10)!', mtinformation, [mbok], 0)
else if cd > 8888.00 then
messagedlg('长度范围错(0~8888.00)!', mtinformation,[mbok], 0);
tjbz := 1;
Break;
end
else
DM.OraTable1['xxcd']:=cd;
except
messagedlg('长度数据格式错!', mtinformation, [mbok], 0);
tjbz := 1;
Break;
end; try
if CELLS[1, I] = 'DK' then
DM.OraTable1['xxsd'] := StrtoFloat(string(Cells[4, i + 1], 7, 2)) -0.5
else
DM.OraTable1['xxsd'] := StrtoFloat(Trim(Cells[4, i]));
except
if cd <> 0 then
DM.OraTable1['xxsd'] := StrtoFloat(Trim(Cells[4, i - 1])) + cd
end; if i = 0 then
begin
if Length(Cells[0, i]) = 0 then
begin
gs1 := 0;
cd1 := cd;
qsxh := 1;
gg := Cells[3, i];
end
else
begin
gs1 := 1;
cd1 := cd;
qsxh := 1;
gg := Cells[3, i];
end;
end; DM.OraTable1['xxxh'] := Trim(Cells[3, i]); //型号
if (Cells[1, I] = 'YG') or (Cells[1, I] = 'DJ') then
begin
if i>0 then
begin
if Trim(Cells[3, i]) = gg then
begin
gs1 := gs1 + 1;
cd1 := cd1 + cd
end
else
begin
with DM.OraTable2 do
begin
Close;
TableName:='002';
Filter:='';
Filtered:=False;
Open;
end;
DM.OraTable2.Append;
DM.OraTable2['num']:=Trim(xnum);
DM.OraTable2['rq']:=StrtoDate(xrq);
DM.OraTable2['yyyggg'] := gg;
DM.OraTable2['yyygcd'] := cd1;
DM.OraTable2['yyyggs'] := gs1;
DM.OraTable2['yyqsgxh'] := qsxh;
qsxh := qsxh + gs1;
gs1 := 1;
cd1 := cd;
gg := Cells[3, i];
end;
end;
end;
end;
end;
i := i + 1;
end;
if tjbz = 0 then
begin
DM.OraTable1.Post;
DM.OraTable2.Append;
DM.OraTable2['num']:=xnum;
DM.OraTable2['rq']:=StrtoDate(xrq);
DM.OraTable2['yyyggg']:=gg;
j := i;
while (Length(stringgrid1.Cells[2, i]) <> 0) and
(StrtoFloat(stringgrid1.Cells[2, i]) > 0) do
begin
if stringgrid1.Cells[1, j] = 'YG' then
begin
cd1 := cd1 + cd;
j := j + 1;
end;
end;
DM.OraTable2['yyygcd']:=cd1;
DM.OraTable2['yyyggs']:=gs1;
DM.OraTable2['yyqsgxh']:=qsxh;
DM.OraTable2.Post;
end;
end;
end;
messagedlg('数据保存完毕.....', mtinformation, [mbok], 0);
{with DM.OraTable1 do
begin
Close;
TableName:='001';
Filter:='num='''+xnum+''' and RQ='''+StrtoDate(xrq)+'''';//这里的过滤条件设置的类型不对,num是string,rq是日期型(TDate)
Filtered:=True;
Open;
if Eof then
begin
while i<=stringgrid1.RowCount do
begin
if (Length(stringgrid1.Cells[2,i])<>0) or ((stringgrid1.Cells[1,i]='DK) and (Length(stringgrid1.Cells[2,i])=0)) then
begin
DM.OraTable1.Append;
with stringgrid1 do
begin
DM.OraTable1['num']:=xnum;
try
DM.OraTable1['rq']:=StrtoDate(xrq);
except
messagedlg('错误的日期范围', mtinformation, [mbok], 0);
tjbz:=1;
Break;
end;
try
DM.OraTable1['xjjrq']:=StrtoDate(edtXJJRQ.Text);
except
messagedlg('错误的日期范围', mtinformation, [mbok], 0);
tjbz:=1;
Break;
end;
DM.OraTable1['yyxh']:=Trim(Cells[0,i]);
if i>1 then
if (Cells[1,i-1]='FGQ) then
begin
DM.OraTable1['xxmc']:='';
Cells[1,i]:='';
end;
DM.OraTable1['xxmc']:=Trim(Cells[1,i]);
with DM.OraTable3 do
begin
Close;
TableName := 'DM_XXMC';
Filter := 'xxMC='''+Trim(Cells[1, i])+'''';
Filtered := true;
Open;
if not Eof then
DM.OraTable1['xxdm'] := FIELDBYNAME('xxdm').ASSTRING
else
DM.OraTable1['xxdm'] := ''
end;
DM.OraTable3.Close; try
cd := StrToFloat(string(Cells[2, i], 5, 2));
if (cd < 5) or (cd > 10) then
begin
if stringgrid1.Cells[1, i] = 'YG' then
messagedlg('长度范围错(1~10)!', mtinformation, [mbok], 0)
else if cd > 8888.00 then
messagedlg('长度范围错(0~8888.00)!', mtinformation,[mbok], 0);
tjbz := 1;
Break;
end
else
DM.OraTable1['xxcd']:=cd;
except
messagedlg('长度数据格式错!', mtinformation, [mbok], 0);
tjbz := 1;
Break;
end; try
if CELLS[1, I] = 'DK' then
DM.OraTable1['xxsd'] := StrtoFloat(string(Cells[4, i + 1], 7, 2)) -0.5
else
DM.OraTable1['xxsd'] := StrtoFloat(Trim(Cells[4, i]));
except
if cd <> 0 then
DM.OraTable1['xxsd'] := StrtoFloat(Trim(Cells[4, i - 1])) + cd
end; if i = 0 then
begin
if Length(Cells[0, i]) = 0 then
begin
gs1 := 0;
cd1 := cd;
qsxh := 1;
gg := Cells[3, i];
end
else
begin
gs1 := 1;
cd1 := cd;
qsxh := 1;
gg := Cells[3, i];
end;
end; DM.OraTable1['xxxh'] := Trim(Cells[3, i]); //型号
if (Cells[1, I] = 'YG') or (Cells[1, I] = 'DJ') then
begin
if i>0 then
begin
if Trim(Cells[3, i]) = gg then
begin
gs1 := gs1 + 1;
cd1 := cd1 + cd
end
else
begin
with DM.OraTable2 do
begin
Close;
TableName:='002';
Filter:='';
Filtered:=False;
Open;
end;
DM.OraTable2.Append;
DM.OraTable2['num']:=Trim(xnum);
DM.OraTable2['rq']:=StrtoDate(xrq);
DM.OraTable2['yyyggg'] := gg;
DM.OraTable2['yyygcd'] := cd1;
DM.OraTable2['yyyggs'] := gs1;
DM.OraTable2['yyqsgxh'] := qsxh;
qsxh := qsxh + gs1;
gs1 := 1;
cd1 := cd;
gg := Cells[3, i];
end;
end;
end;
end;
end;
i := i + 1;
end;
if tjbz = 0 then
begin
DM.OraTable1.Post;
DM.OraTable2.Append;
DM.OraTable2['num']:=xnum;
DM.OraTable2['rq']:=StrtoDate(xrq);
DM.OraTable2['yyyggg']:=gg;
j := i;
while (Length(stringgrid1.Cells[2, i]) <> 0) and
(StrtoFloat(stringgrid1.Cells[2, i]) > 0) do
begin
if stringgrid1.Cells[1, j] = 'YG' then
begin
cd1 := cd1 + cd;
j := j + 1;
end;
end;
DM.OraTable2['yyygcd']:=cd1;
DM.OraTable2['yyyggs']:=gs1;
DM.OraTable2['yyqsgxh']:=qsxh;
DM.OraTable2.Post;
end;
end;
end;
messagedlg('数据保存完毕.....', mtinformation, [mbok], 0);
解决方案 »
- delphi寻找函数单元方法请教
- 救命!关于RAVE5的问题 !
- **求教:用delphi如何能获得执行sql语句后的结果文本?**
- 小弟欲做一个工资系统,但以前都没有做过,求大侠们路过发个源码让我学习一下。多谢!!
- 在ActionManager中,怎么样建立category
- 请问怎样在delphi7中使用控件拖动效果呀!
- 如果checkbox被选中保存到数据库为1否则为0,怎么实现呀?
- 如何指定一个SINGLE的小数位长
- 编写MTS点击run|install MTS Objects...菜单后提示“icrosoft transaction server is not installed”这是什么原因?
- 如何在打印报表中实现合计功能?
- 如何将子窗口右上角的关闭按钮灰掉?
- 局域网文件的拷贝
用stringgrid表格来显示数据库中相关表的字段,然后可以对其进行修改和保存?
那位能给指导指导呀?~!