📄 uprovid.pas
字号:
unit Uprovid;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, Grids, StdCtrls, ExtCtrls, ComCtrls, ToolWin, DB, ADODB;
type
Tfrmprovid = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton3: TToolButton;
ToolButton2: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
StringGrid1: TStringGrid;
MenuImges: TImageList;
ADOQuery1: TADOQuery;
procedure FormCreate(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmprovid: Tfrmprovid;
implementation
uses Udatamodule, Upromod;
{$R *.dfm}
procedure Tfrmprovid.FormCreate(Sender: TObject);
var
arow,acol:integer;
begin
stringgrid1.Cells[0,0]:='供应商编号';
stringgrid1.Cells[1,0]:='供应商名称';
stringgrid1.Cells[2,0]:='地址';
stringgrid1.Cells[3,0]:='联系人';
stringgrid1.Cells[4,0]:='电话';
stringgrid1.Cells[5,0]:='开户行';
stringgrid1.Cells[6,0]:='帐号';
stringgrid1.Cells[7,0]:='税号';
stringgrid1.Cells[8,0]:='说明';
adoquery1.SQL.Text:='select * from provinfo order by provid';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
stringgrid1.RowCount:=adoquery1.RecordCount+1;
arow:=1;
while not adoquery1.Eof do
begin
for acol:=0 to stringgrid1.ColCount-1 do
stringgrid1.Cells[acol,arow]:=adoquery1.Fields[acol].AsString;
adoquery1.Next;
inc(arow);
end;
end;
adoquery1.Close;
end;
procedure Tfrmprovid.ToolButton1Click(Sender: TObject);
var
i,arow:integer;
sprovid:string;
begin
for i:=1 to stringgrid1.RowCount - 1 do
stringgrid1.Rows[i].Clear;
stringgrid1.RowCount:=2;
sprovid:=edit1.Text;
while length(sprovid) < 5 do sprovid:= '0'+sprovid;
adoquery1.SQL.Text:='select * from provinfo where 1=1';
if edit1.Text <> '' then
adoquery1.SQL.Add('and provid = '''+sprovid+'''');
if edit2.Text <> '' then
adoquery1.SQL.Add('and provname = '''+edit2.Text+'''');
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
stringgrid1.RowCount:=adoquery1.RecordCount+1;
arow:=1;
while not adoquery1.Eof do
begin
for i:=0 to stringgrid1.ColCount - 1 do
stringgrid1.Cells[i,arow]:=adoquery1.Fields[i].AsString;
adoquery1.Next;
inc(arow);
end;
end;
adoquery1.Close;
end;
procedure Tfrmprovid.ToolButton6Click(Sender: TObject);
var
i:integer;
begin
if ((stringgrid1.Row > 0) and (stringgrid1.Cells[0,stringgrid1.Row] <> '')) then
begin
if messagedlg('真的要删除吗?',mtconfirmation,[mbyes,mbno],0) = mryes then
begin
adoquery1.SQL.Text:='delete from provinfo where provid = '''+stringgrid1.Cells[0,stringgrid1.Row]+'''';
adoquery1.ExecSQL;
adoquery1.Close;
if stringgrid1.RowCount > 2 then
begin
for i:=stringgrid1.Row to stringgrid1.RowCount-2 do
stringgrid1.Rows[i]:=stringgrid1.Rows[i+1];
stringgrid1.Rows[stringgrid1.RowCount-1].Clear;
stringgrid1.RowCount:=stringgrid1.RowCount-1;
end
else
stringgrid1.Rows[1].Clear;
end;
end;
end;
procedure Tfrmprovid.ToolButton3Click(Sender: TObject);
begin
Application.CreateForm(Tfrmprovmod, frmprovmod);
frmprovmod.ShowModal;
frmprovmod.Release;
end;
procedure Tfrmprovid.ToolButton2Click(Sender: TObject);
begin
Application.CreateForm(Tfrmprovmod, frmprovmod);
if stringgrid1.Row > 0 then
begin
frmprovmod.Edit1.Enabled:=false;
frmprovmod.Edit1.Text:=stringgrid1.Cells[0,stringgrid1.Row];
frmprovmod.Edit2.Text:=stringgrid1.Cells[1,stringgrid1.Row];
frmprovmod.Edit3.Text:=stringgrid1.Cells[2,stringgrid1.Row];
frmprovmod.Edit4.Text:=stringgrid1.Cells[3,stringgrid1.Row];
frmprovmod.Edit5.Text:=stringgrid1.Cells[4,stringgrid1.Row];
frmprovmod.Edit6.Text:=stringgrid1.Cells[5,stringgrid1.Row];
frmprovmod.Edit7.Text:=stringgrid1.Cells[6,stringgrid1.Row];
frmprovmod.Edit8.Text:=stringgrid1.Cells[7,stringgrid1.Row];
frmprovmod.Edit9.Text:=stringgrid1.Cells[8,stringgrid1.Row];
end;
frmprovmod.ShowModal;
frmprovmod.Release;
end;
procedure Tfrmprovid.ToolButton7Click(Sender: TObject);
begin
self.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -