你给我写信了啊,我好几天没有去看信了,刚才去看了你的问题是 关于DBGRID多选的。你看一下这个有没有帮助。注意: 要把DBGRID的OPTION属性里的dgMultiselect 为TRUEprocedure TForm1.Button1Click(Sender: TObject); var I: Integer; begin for I := 0 to DBGrid1.SelectedRows.Count - 1 do begin DBGrid1.DataSource.DataSet.Book := DBGrid1.SelectedRows.items[I]; ShowMessage(DBGrid1.DataSource.DataSet.Fields[0].AsString); end; end;
DBGRID的OPTION属性里的dgMultiselect 为TRUE 吗
var a1,a2,a3,StrSQL:string; I: Integer; begin if(Application.MessageBox('系统将登记该订单为有效,并修改库存,是否确认?','系统提示',MB_YESNO+MB_ICONQUESTION)<>IDNO) then begin for I := 0 to DBGrid1.SelectedRows.Count - 1 do begin DBGrid1.DataSource.DataSet.Book:= DBGrid1.SelectedRows.items[I]; with whdata.vsh_cgrk2 do begin first; while not eof do begin a1:=fieldbyname('商品编码').asstring; a2:=fieldbyname('数量').asstring; a3:=fieldbyname('进价').asstring; whdata.kc2.Close; whdata.kc2.SQL.Clear; whdata.kc2.SQL.Add('select * from kc_kc2 where prod_no='''+a1+''' and whouse_no='''+whdata.vsh_cgrk1.fieldbyname('whouse_no').AsString+''''); whdata.kc2.ExecSQL; whdata.kc2.Active:=true; StrSQL:=StrSQL+'update jh_cgrk1 set audi='''+wh_logon.user_name.Text+''',shrq='''+datetostr(DATE)+''' where no='''+whdata.vsh_cgrk1.fieldbyname('采购订单编号').AsString+''''; if not whdata.kc2.Eof then StrSQL:=StrSQL+'update kc_kc2 set amt=amt+'''+a2+''' where prod_no='''+a1+''' and WHOUSE='''+whdata.vsh_cgrk1.fieldbyname('库房').AsString+'''' else StrSQL:=StrSQL+'insert into KC_KC2(prod_no,whouse_no,amt,whouse,avg_price) values('''+a1+''','''+whdata.vsh_cgrk1.fieldbyname('whouse_no').AsString+''','+a2+','''+whdata.vsh_cgrk1.fieldbyname('库房').AsString+''','+a3+')'; next; end; end; end; end; whdata.sh_kc2.Close; whdata.sh_kc2.SQL.Clear; whdata.sh_kc2.SQL.Add(StrSQL); whdata.sh_kc2.ExecSQL; formcreate(nil); end;
关于DBGRID多选的。你看一下这个有没有帮助。注意: 要把DBGRID的OPTION属性里的dgMultiselect 为TRUEprocedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to DBGrid1.SelectedRows.Count - 1 do begin
DBGrid1.DataSource.DataSet.Book := DBGrid1.SelectedRows.items[I];
ShowMessage(DBGrid1.DataSource.DataSet.Fields[0].AsString);
end;
end;
I: Integer;
begin
if(Application.MessageBox('系统将登记该订单为有效,并修改库存,是否确认?','系统提示',MB_YESNO+MB_ICONQUESTION)<>IDNO) then
begin
for I := 0 to DBGrid1.SelectedRows.Count - 1 do
begin
DBGrid1.DataSource.DataSet.Book:= DBGrid1.SelectedRows.items[I];
with whdata.vsh_cgrk2 do
begin
first;
while not eof do
begin
a1:=fieldbyname('商品编码').asstring;
a2:=fieldbyname('数量').asstring;
a3:=fieldbyname('进价').asstring;
whdata.kc2.Close;
whdata.kc2.SQL.Clear;
whdata.kc2.SQL.Add('select * from kc_kc2 where prod_no='''+a1+''' and whouse_no='''+whdata.vsh_cgrk1.fieldbyname('whouse_no').AsString+'''');
whdata.kc2.ExecSQL;
whdata.kc2.Active:=true;
StrSQL:=StrSQL+'update jh_cgrk1 set audi='''+wh_logon.user_name.Text+''',shrq='''+datetostr(DATE)+''' where no='''+whdata.vsh_cgrk1.fieldbyname('采购订单编号').AsString+'''';
if not whdata.kc2.Eof then
StrSQL:=StrSQL+'update kc_kc2 set amt=amt+'''+a2+''' where prod_no='''+a1+''' and WHOUSE='''+whdata.vsh_cgrk1.fieldbyname('库房').AsString+''''
else
StrSQL:=StrSQL+'insert into KC_KC2(prod_no,whouse_no,amt,whouse,avg_price) values('''+a1+''','''+whdata.vsh_cgrk1.fieldbyname('whouse_no').AsString+''','+a2+','''+whdata.vsh_cgrk1.fieldbyname('库房').AsString+''','+a3+')';
next;
end;
end;
end;
end;
whdata.sh_kc2.Close;
whdata.sh_kc2.SQL.Clear;
whdata.sh_kc2.SQL.Add(StrSQL);
whdata.sh_kc2.ExecSQL;
formcreate(nil);
end;