OSDN Git Service

すっきりしましたが トラブルの疑惑を抱えています
[newbbs/newbbs.git] / tool / Unit2.pas
1 unit Unit2;
2
3 interface
4
5 uses
6   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
7   System.Classes, Vcl.Graphics,
8   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option,
9   FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
10   FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.MySQL,
11   FireDAC.Phys.MySQLDef, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
12   FireDAC.DApt, Vcl.ExtDlgs, Vcl.StdCtrls, Vcl.ExtCtrls, Data.DB,
13   FireDAC.Comp.DataSet, FireDAC.Comp.Client, System.Rtti,
14   System.Bindings.Outputs, Vcl.Bind.Editors, Data.Bind.EngExt,
15   Vcl.Bind.DBEngExt, Data.Bind.Components, Data.Bind.DBScope,
16   FireDAC.VCLUI.Wait, FireDAC.Comp.UI, Vcl.DBCtrls, Jpeg, Vcl.Grids,
17   Vcl.DBGrids,
18   FireDAC.Phys.IB, FireDAC.Phys.IBDef, FireDAC.Phys.FB, FireDAC.Phys.FBDef;
19
20 type
21   TForm1 = class(TForm)
22     FDConnection1: TFDConnection;
23     FDTable1: TFDTable;
24     Button1: TButton;
25     Button2: TButton;
26     Button3: TButton;
27     Edit1: TEdit;
28     Label1: TLabel;
29     OpenPictureDialog1: TOpenPictureDialog;
30     BindSourceDB1: TBindSourceDB;
31     BindingsList1: TBindingsList;
32     LinkPropertyToFieldCaption: TLinkPropertyToField;
33     LinkControlToField2: TLinkControlToField;
34     FDGUIxWaitCursor1: TFDGUIxWaitCursor;
35     DBNavigator1: TDBNavigator;
36     DataSource1: TDataSource;
37     DBGrid1: TDBGrid;
38     FDTable1ID: TIntegerField;
39     FDTable1NAME: TWideStringField;
40     FDTable1SOURCE: TBlobField;
41     Button4: TButton;
42     procedure Button1Click(Sender: TObject);
43     procedure Button4Click(Sender: TObject);
44     procedure Button3Click(Sender: TObject);
45     procedure FormCreate(Sender: TObject);
46   private
47     { Private \90é\8c¾ }
48   public
49     { Public \90é\8c¾ }
50   end;
51
52 var
53   Form1: TForm1;
54
55 implementation
56
57 {$R *.dfm}
58
59 procedure TForm1.Button1Click(Sender: TObject);
60 var
61   i: Integer;
62   t: TStream;
63 begin
64   with FDTable1 do
65   begin
66     for i := 1 to 10 do
67     begin
68       t := TResourceStream.Create(HInstance, 'Resource_' + i.ToString,
69         RT_RCDATA);
70       AppendRecord([i, Format('slide%d.jpg', [i])]);
71       Edit;
72       FDTable1SOURCE.LoadFromStream(t);
73       Post;
74       t.Free;
75     end;
76     ApplyUpdates;
77     Reconcile;
78     CommitUpdates;
79   end;
80 end;
81
82 procedure TForm1.Button3Click(Sender: TObject);
83 var
84   s: TStream;
85   j: TJpegImage;
86 begin
87   s := FDTable1.CreateBlobStream(FDTable1.FieldByName('source'), bmRead);
88   j := TJpegImage.Create;
89   j.LoadFromStream(s);
90   Canvas.Draw(0, 0, j);
91   s.Free;
92   j.Free;
93 end;
94
95 procedure TForm1.Button4Click(Sender: TObject);
96 begin
97   with FDTable1 do
98   begin
99     repeat
100       Delete;
101     until (Bof = true) and (Eof = true);
102     ApplyUpdates;
103     Reconcile;
104     CommitUpdates;
105   end;
106 end;
107
108 procedure TForm1.FormCreate(Sender: TObject);
109 begin
110   if FDTable1.Exists = false then
111   begin
112     FDTable1.Close;
113     FDTable1.CreateTable;
114     FDTable1.Open;
115   end;
116 end;
117
118 end.