⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prelation.pas

📁 BarCodePrint条码打印机打印管理
💻 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 + -