object NavigatorBindSourceDB12: TBindNavigator
Position.X = 160.000000000000000000
Position.Y = 392.000000000000000000
- Size.Width = 241.000000000000000000
+ Size.Width = 240.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder = 12
- DataSource = BindSourceDB12
+ DataSource = BindSourceDB1
xRadius = 4.000000000000000000
yRadius = 4.000000000000000000
end
+ object Button1: TButton
+ Position.X = 432.000000000000000000
+ Position.Y = 136.000000000000000000
+ TabOrder = 23
+ Text = 'Button1'
+ OnClick = Button1Click
+ end
+ object Label1: TLabel
+ Position.X = 64.000000000000000000
+ Position.Y = 48.000000000000000000
+ end
+ object OpenDialog1: TOpenDialog
+ Left = 496
+ Top = 312
+ end
object FDTable1: TFDTable
Active = True
+ BeforeInsert = FDTable1BeforeInsert
+ AfterInsert = FDTable1AfterInsert
+ AfterPost = FDTable1AfterPost
Connection = FDConnection1
+ UpdateOptions.AssignedValues = [uvRefreshMode]
UpdateOptions.UpdateTableName = 'kainushi.images'
TableName = 'kainushi.images'
Left = 296
'User_Name=kainushi'
'Password=admin'
'Server=localhost'
+ 'CharacterSet=utf8'
'DriverID=MySQL')
Connected = True
Left = 360
Top = 5
object LinkPropertyToFieldBitmap: TLinkPropertyToField
Category = #12463#12452#12483#12463' '#12496#12452#12531#12487#12451#12531#12464
- DataSource = BindSourceDB12
+ DataSource = BindSourceDB1
FieldName = 'source'
Component = Image1
ComponentProperty = 'Bitmap'
end
object LinkControlToField1: TLinkControlToField
Category = #12463#12452#12483#12463' '#12496#12452#12531#12487#12451#12531#12464
- DataSource = BindSourceDB12
+ DataSource = BindSourceDB1
FieldName = 'name'
Control = Edit1
Track = False
end
+ object LinkPropertyToFieldText: TLinkPropertyToField
+ Category = #12463#12452#12483#12463' '#12496#12452#12531#12487#12451#12531#12464
+ DataSource = BindSourceDB1
+ FieldName = 'id'
+ Component = Label1
+ ComponentProperty = 'Text'
+ end
end
object FDGUIxWaitCursor1: TFDGUIxWaitCursor
Provider = 'FMX'
Left = 408
Top = 224
end
- object BindSourceDB12: TBindSourceDB
+ object BindSourceDB1: TBindSourceDB
DataSet = FDTable1
ScopeMappings = <>
- Left = 304
- Top = 280
+ Left = 384
+ Top = 288
end
end
interface
uses
- System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
- FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Ani, FMX.Layouts, FMX.Gestures,
+ System.SysUtils, System.Types, System.UITypes, System.Classes,
+ System.Variants,
+ FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Ani, FMX.Layouts,
+ FMX.Gestures,
FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
FireDAC.Stan.Async, FireDAC.DApt, FireDAC.UI.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Phys, FireDAC.Phys.MySQL, FireDAC.Phys.MySQLDef,
- Data.Bind.Controls, Data.Bind.EngExt, Fmx.Bind.DBEngExt, System.Rtti,
- System.Bindings.Outputs, Fmx.Bind.Editors, Data.Bind.Components, Data.DB,
- FMX.Controls.Presentation, FMX.Edit, Fmx.Bind.Navigator, Data.Bind.DBScope,
+ Data.Bind.Controls, Data.Bind.EngExt, FMX.Bind.DBEngExt, System.Rtti,
+ System.Bindings.Outputs, FMX.Bind.Editors, Data.Bind.Components, Data.DB,
+ FMX.Controls.Presentation, FMX.Edit, FMX.Bind.Navigator, Data.Bind.DBScope,
FireDAC.Comp.Client, FireDAC.Comp.DataSet, FMX.Objects, FMX.StdCtrls,
FireDAC.FMXUI.Wait, FireDAC.Comp.UI;
Edit1: TEdit;
BindingsList1: TBindingsList;
FDGUIxWaitCursor1: TFDGUIxWaitCursor;
- BindSourceDB12: TBindSourceDB;
+ BindSourceDB1: TBindSourceDB;
NavigatorBindSourceDB12: TBindNavigator;
LinkPropertyToFieldBitmap: TLinkPropertyToField;
LinkControlToField1: TLinkControlToField;
+ Button1: TButton;
+ OpenDialog1: TOpenDialog;
+ Label1: TLabel;
+ LinkPropertyToFieldText: TLinkPropertyToField;
+ procedure Button1Click(Sender: TObject);
+ procedure FDTable1BeforeInsert(DataSet: TDataSet);
+ procedure FDTable1AfterInsert(DataSet: TDataSet);
procedure FormCreate(Sender: TObject);
+ procedure FDTable1AfterPost(DataSet: TDataSet);
private
- FGestureOrigin: TPointF;
- FGestureInProgress: Boolean;
+ pos: integer;
{ private \90é\8c¾ }
public
{ public \90é\8c¾ }
{$R *.fmx}
+procedure TForm2.Button1Click(Sender: TObject);
+var
+ s: TStream;
+begin
+ case FDTable1.State of
+ dsInsert, dsEdit:
+ if OpenDialog1.Execute = true then
+ begin
+ Image1.Bitmap.LoadFromFile(OpenDialog1.FileName);
+ s := FDTable1.CreateBlobStream(FDTable1.FieldByName('source'), bmWrite);
+ try
+ Image1.Bitmap.SaveToStream(s);
+ finally
+ s.Free;
+ end;
+ end;
+ end;
+end;
+
+procedure TForm2.FDTable1AfterInsert(DataSet: TDataSet);
+begin
+ FDTable1.FieldByName('id').AsInteger := pos;
+ FDTable1.FieldByName('name').AsString := 'slide' + pos.ToString + '.jpg';
+end;
+
+procedure TForm2.FDTable1AfterPost(DataSet: TDataSet);
+begin
+ FDTable1.Refresh;
+end;
+
+procedure TForm2.FDTable1BeforeInsert(DataSet: TDataSet);
+begin
+ FDTable1.Last;
+ pos := FDTable1.FieldByName('id').AsInteger + 1;
+end;
+
procedure TForm2.FormCreate(Sender: TObject);
begin
FDTable1.Refresh;