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

📄 ulinkman.pas

📁 一个基于不需引擎的文件管理系统,使用了许多界面比较好的控件
💻 PAS
字号:
unit uLinkMan;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, RzEdit, Buttons, TB2Dock, TB2ToolWindow, TBX,RzPanel, Mask,
  ExtCtrls, RzLabel, RzBorder, ExtDlgs,DB,uBasefrm, TBXDkPanels,uIHintInf,
  ActnList,JPEG;

type
  TLinkManfrm = class(TBaseForm)
    TBXToolWindow1: TTBXToolWindow;
    edRemark: TRzMemo;
    Label1: TLabel;
    edName: TRzEdit;
    Label2: TLabel;
    edPhone: TRzEdit;
    Label3: TLabel;
    edAddress: TRzEdit;
    Label4: TLabel;
    edFax: TRzEdit;
    Label5: TLabel;
    edEMail: TRzEdit;
    RzPanel1: TRzPanel;
    RzBorder1: TRzBorder;
    ImgMan: TImage;
    RzLabel1: TRzLabel;
    Open1: TOpenPictureDialog;
    TBXButton1: TTBXButton;
    TBXButton2: TTBXButton;
    ActionList1: TActionList;
    Action1: TAction;
    Action2: TAction;
    TBXLink1: TTBXLink;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ImgManDblClick(Sender: TObject);
    procedure TBXButton1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBXButton2Click(Sender: TObject);
    procedure TBXLink1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure InsData(AType:cmdType;AID:integer);
  end;

implementation

uses uSECData, uMain;

{$R *.dfm}

procedure TLinkManfrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=cafree;
end;

procedure TLinkManfrm.ImgManDblClick(Sender: TObject);
var
  r:TRect;
  tmpImage:TImage;
begin
  if Open1.Execute then
  begin
    windows.LockWindowUpdate(self.Handle);
    tmpImage:=TImage.Create(nil);
    try
      tmpImage.Picture.LoadFromFile(Open1.FileName);

      r:=Rect(0,0,ImgMan.Width,ImgMan.Height);
      if ImgMan.Picture.Graphic<>nil then
        ImgMan.Picture.Assign(nil);
      ImgMan.Canvas.StretchDraw(r,tmpImage.Picture.Graphic);
    finally
      tmpImage.Free;
      windows.LockWindowUpdate(0);
    end;
  end;
end;

procedure TLinkManfrm.InsData(AType: cmdType; AID: integer);
var
  x:TMemoryStream;
  Jpg:TJpegImage;
  B:TBitmap;
begin
  x:=TMemoryStream.Create;
  Jpg:=TJpegImage.Create;
  try
    {if (ImgMan.Picture.Graphic is TBitmap)
      or (ImgMan.Picture.Graphic is TJpegImage) then
    begin
      Jpg.Assign(ImgMan.Picture.Graphic);
    end
    else
    begin
      r.Top:=0;
      r.Left:=0;
      r.Right:=ImgMan.Height;
      r.Bottom:=ImgMan.Width;
      B:=TBitmap.Create;
      B.Width:=r.Right;
      B.Height:=r.Bottom;
      B.Canvas.Draw(0,0,ImgMan.Picture.Graphic);
      Jpg.Assign(B);
      B.Free;
    end; }
    B:=TBitmap.Create;
    B.Assign(ImgMan.Picture.Graphic);
    Jpg.Assign(B);
    Jpg.SaveToStream(x);
    SECData.qryTmp.Close;
    SECData.qryTmp.SQL.Clear;
    if ImgMan.Picture.Graphic<>nil then
    begin
      if AType=cdAdd then
        SECData.qryTmp.SQL.Text:='insert into linkman(ID,Name,Address,Phone,Fax,EMail,Image,Remark)'+#13+
                                 'values(:ID,:Name,:Address,:Phone,:Fax,:EMail,:Image,:Remark)'
      else if AType=cdEdit then
        SECData.qryTmp.SQL.Text:='Update LinkMan'+#13+
                                 'set Name=:Name,'+#13+
                                 '    Address=:Address,'+#13+
                                 '    Phone=:Phone,'+#13+
                                 '    Fax=:Fax,'+#13+
                                 '    EMail=:EMail,'+#13+
                                 '    Image=:Image,'+#13+
                                 '    ReMark=:ReMark'+#13+
                                 'where ID=:ID';

    end
    else
    begin
      if AType=cdAdd then
        SECData.qryTmp.SQL.Text:='insert into linkman(ID,Name,Address,Phone,Fax,EMail,Remark)'+#13+
                                 'values(:ID,:Name,:Address,:Phone,:Fax,:EMail,:Remark)'
      else if AType=cdEdit then
        SECData.qryTmp.SQL.Text:='Update LinkMan'+#13+
                                 'set Name=:Name,'+#13+
                                 '    Address=:Address,'+#13+
                                 '    Phone=:Phone,'+#13+
                                 '    Fax=:Fax,'+#13+
                                 '    EMail=:EMail,'+#13+
                                 '    ReMark=:ReMark'+#13+
                                 'where ID=:ID';
    end;
    if AType=cdAdd then
      SECData.qryTmp.ParamByName('ID').AsInteger:=mainfrm.OprList.GetMaxID('LinkMan')
    else if AType=cdEdit then
      SECData.qryTmp.ParamByName('ID').AsInteger:=AID;
    SecData.qryTmp.ParamByName('Name').AsString:=edName.Text;
    SecData.qryTmp.ParamByName('Address').AsString:=edAddress.Text;
    SecData.qryTmp.ParamByName('Phone').AsString:=edPhone.Text;
    SecData.qryTmp.ParamByName('Fax').AsString:=edFax.Text;
    SecData.qryTmp.ParamByName('EMail').AsString:=edEMail.Text;
    if ImgMan.Picture.Graphic<>nil then
      SecData.qryTmp.ParamByName('Image').LoadFromStream(x,ftBlob);
    SecData.qryTmp.ParamByName('ReMark').AsString:=edReMark.Text;
    SecData.qryTmp.ExecSQL;
  finally
    x.Free;
    Jpg.Free;
  end;
end;

procedure TLinkManfrm.TBXButton1Click(Sender: TObject);
begin
  if trim(edName.Text)='' then
  begin
    MessageBox(Handle, '必须键入名称。', '错误', MB_ICONHAND);
    exit;
  end;
  InsData(TheCmd,ID);
  ModalResult:=mrOk;
end;

procedure TLinkManfrm.FormShow(Sender: TObject);
var
  x:TStream;
  Jpg:TJpegImage;
begin
  if TheCmd=cdEdit then
  begin
    Jpg:=TJpegImage.Create;

    ID:=PLinkManData(Data)^.ID;
    edName.Text:=PLinkManData(Data)^.Name;
    edPhone.Text:=PLinkManData(Data)^.Phone;
    edFax.Text:=PLinkManData(Data)^.Fax;
    edEMail.Text:=PLinkManData(Data)^.EMail;
    edAddress.Text:=PLinkManData(Data)^.Address;

    SECData.qryTmp.Close;
    SECData.qryTmp.SQL.Clear;
    SECData.qryTmp.SQL.Text:='Select Image,Remark from linkman'+#13+
                             'where ID=:ID';
    SECData.qryTmp.ParamByName('ID').AsInteger:=PLinkManData(Data)^.ID;
    SECData.qryTmp.Open;
    x:=SECData.qryTmp.CreateBlobStream(SECData.qryTmp.Fields[0],bmRead);
    Jpg.LoadFromStream(x);
    try
      if x.Size=0 then
        ImgMan.Picture.Assign(nil)
      else
        ImgMan.Picture.Assign(Jpg); 
      edReMark.Text:=SECData.qryTmp.Fields[1].AsString;
    finally
      x.Free;
      Jpg.Free;
      SECData.qryTmp.Close;
    end;
  end;
end;

procedure TLinkManfrm.TBXButton2Click(Sender: TObject);
begin
  ModalResult:=mrCancel;
end;

procedure TLinkManfrm.TBXLink1Click(Sender: TObject);
begin
  ImgMan.Picture.Assign(nil);

  SecData.qryTmp.Close;
  SecData.qryTmp.SQL.Clear;
  SecData.qryTmp.SQL.Text:='update linkman set Image=null where ID=:ID';
  SecData.qryTmp.ParamByName('ID').AsInteger:=ID;
  SecData.qryTmp.ExecSQL;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -