?? prelation.pas
字號:
unit PRelation;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, ADODB, ComCtrls, Grids, DBGrids, ExtCtrls, DBCtrls, ToolWin;
type
TFormRelation = class(TForm)
DBGridUsers: TDBGrid;
StatusBarProductCode: TStatusBar;
ADOTableUsers2: TADOTable;
DataSourceUsers: TDataSource;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ADOTableUsers: TADOQuery;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
procedure FormCreate(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure DBGridUsersTitleClick(Column: TColumn);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
private
bAsc:Boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
FormRelation: TFormRelation;
implementation
uses PDataModuleMain, PRelationNew, pCodeSearch, PRelationPrint,
PRelationEdit;
{$R *.DFM}
procedure TFormRelation.FormCreate(Sender: TObject);
begin
AdoTableUsers.Connection:=DataModuleMain.ADOConnectionBarCode;
//AdoTableUsers.TableName:='Relation';
AdoTableUsers.Open;
DbgridUsers.Columns.Items[0].Title.Caption:='編碼';
DbgridUsers.Columns.Items[1].Title.Caption:='品名代碼';
DbgridUsers.Columns.Items[2].Title.Caption:='加工代碼';
DbgridUsers.Columns.Items[3].Title.Caption:='檢驗代碼';
DbgridUsers.Columns.Items[4].Title.Caption:='包裝代碼';
DbgridUsers.Columns.Items[5].Title.Caption:='部件代碼';
StatusBarProductCode.SimpleText:='總數:'+IntToStr(AdoTableUsers.RecordCount);
end;
procedure TFormRelation.ToolButton1Click(Sender: TObject);
begin
if not assigned(FormRelationNew) then FormRelationNew:=TFormRelationNew.Create(Self);
FormRelationNew.Show;
//FormRelationNew.Free;
end;
procedure TFormRelation.ToolButton2Click(Sender: TObject);
begin
if Application.MessageBox('確定刪除此記錄嗎?','提示',MB_OKCANCEL + MB_DEFBUTTON1)=ID_CANCEL then
exit;
with ADOTableUsers do
begin
Delete;
end;
end;
procedure TFormRelation.DBGridUsersTitleClick(Column: TColumn);
var
sS:String;
sSql:String;
nI:integer;
begin
sS:=Column.FieldName;
ADOTableUsers.Close;
sSql:=ADOTableUsers.SQL.Text;
ADOTableUsers.sql.Clear;
nI:=Pos('order',sSql);
if nI=0 then begin
if bAsc then
sSql:=sSql+' order by '+sS +' DESC'
else
sSql:=sSql+' order by '+sS +' ASC'
end
else begin
if bAsc then
sSql:=Copy(sSql,1,nI-1)+ ' order by '+sS +' DESC'
else
sSql:=Copy(sSql,1,nI-1)+' order by '+sS +' ASC';
end;
ADOTableUsers.sql.Add(sSql);
bAsc:=not bAsc;
ADOTableUsers.Open;
DbgridUsers.Columns.Items[0].Title.Caption:='編碼';
DbgridUsers.Columns.Items[1].Title.Caption:='品名代碼';
DbgridUsers.Columns.Items[2].Title.Caption:='加工代碼';
DbgridUsers.Columns.Items[3].Title.Caption:='檢驗代碼';
DbgridUsers.Columns.Items[4].Title.Caption:='包裝代碼';
DbgridUsers.Columns.Items[5].Title.Caption:='部件代碼';
end;
procedure TFormRelation.ToolButton3Click(Sender: TObject);
begin
if not assigned(FormCodeSearch) then FormCodeSearch:=TFormCodeSearch.Create(Self);
FormCodeSearch.Show;
end;
procedure TFormRelation.ToolButton5Click(Sender: TObject);
begin
if not assigned(FormRelationPrint) then FormRelationPrint:=TFormRelationPrint.Create(Self);
FormRelationPrint.QuickRep1.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText1.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText2.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText3.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText4.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText5.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText6.DataSet:=ADOTableUsers;
FormRelationPrint.QuickRep1.Print;
end;
procedure TFormRelation.ToolButton6Click(Sender: TObject);
begin
if not assigned(FormRelationPrint) then FormRelationPrint:=TFormRelationPrint.Create(Self);
FormRelationPrint.QuickRep1.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText1.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText2.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText3.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText4.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText5.DataSet:=ADOTableUsers;
FormRelationPrint.QRDBText6.DataSet:=ADOTableUsers;
FormRelationPrint.QuickRep1.Preview;
end;
procedure TFormRelation.ToolButton4Click(Sender: TObject);
begin
if not assigned(FormRelationEdit) then FormRelationEdit:=TFormRelationEdit.Create(Self);
FormRelationEdit.Show;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -