Develop and Download Open Source Software

Browse Subversion Repository

Diff of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by yamat0jp, Sun Nov 22 11:18:44 2015 UTC revision 10 by yamat0jp, Sat Jan 16 23:06:35 2016 UTC
# Line 3  unit Unit1; Line 3  unit Unit1;
3  interface  interface
4    
5  uses  uses
6    Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWHTMLControls,    Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWVCLComponent,
   IWVCLBaseControl, IWBaseControl, IWBaseHTMLControl, IWControl, IWCompLabel,  
   Vcl.Controls, Vcl.Forms, IWVCLBaseContainer, IWContainer, IWHTMLContainer,  
   IWHTML40Container, IWRegion, FireDAC.Stan.Intf, FireDAC.Stan.Option,  
   FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,  
   FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.IB,  
   FireDAC.Phys.IBDef, Data.DB, FireDAC.Comp.Client, Datasnap.DBClient,  
   Datasnap.Provider, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,  
   FireDAC.DApt, FireDAC.Comp.DataSet, IWCompGrids, IWDBGrids, IWCompEdit,  
   IWDBStdCtrls, IWCompExtCtrls, IWDBExtCtrls, Unit3, IWVCLComponent,  
7    IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout,    IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout,
8    IWTemplateProcessorHTML, Data.Bind.EngExt, Vcl.Bind.DBEngExt, System.Rtti,    IWTemplateProcessorHTML, Vcl.Controls, Vcl.Forms, Unit2, IWVCLBaseContainer,
9    System.Bindings.Outputs, Vcl.Bind.Editors, Data.Bind.Components,    IWContainer, IWHTMLContainer, IWHTML40Container, IWRegion, IWDBStdCtrls,
10    Data.Bind.DBScope, IWCompListbox, IWCompButton, Web.HTTPApp, Web.HTTPProd,    IWVCLBaseControl, IWBaseControl, IWBaseHTMLControl, IWControl, IWCompLabel,
11    Vcl.ImgList, IWImageList, PngImage, IWCompTabControl, IWCompMemo, IWCompText,    IWCompGrids, IWCompText, IWCompTabControl, IWCompButton, IWCompEdit,
12    UserSessionUnit;    IWHTMLControls, IWCompExtCtrls, PngImage, Data.DB,
13      IWCompListbox, IWBaseComponent, IWBaseHTMLComponent, IWBaseHTML40Component,
14      IWCompMenu, Vcl.Menus, System.Variants, Vcl.Dialogs, System.UITypes, Unit8;
15    
16  type  type
17    TTopForm = class(TIWAppForm)    TIWForm1 = class(TIWAppForm)
18      IWRegion1: TIWRegion;      IWTemplateProcessorHTML1: TIWTemplateProcessorHTML;
19      IWLabel1: TIWLabel;      IWLabel1: TIWLabel;
     IWList1: TIWList;  
     IWLink1: TIWLink;  
     IWLabel2: TIWLabel;  
20      IWDBLabel1: TIWDBLabel;      IWDBLabel1: TIWDBLabel;
21      IWFrame1: TIWFrame1;      IWRegion1: TIWRegion;
22        IWRegion2: TIWRegion;
23        IWText1: TIWText;
24        IWGrid1: TIWGrid;
25      IWRegion3: TIWRegion;      IWRegion3: TIWRegion;
     IWLabel3: TIWLabel;  
     IWLabel4: TIWLabel;  
26      IWRegion4: TIWRegion;      IWRegion4: TIWRegion;
27      IWLabel5: TIWLabel;      IWLink1: TIWLink;
28      IWList2: TIWList;      IWLabel2: TIWLabel;
29      IWTemplateProcessorHTML1: TIWTemplateProcessorHTML;      IWList1: TIWList;
30      IWRegion2: TIWRegion;      IWLabel3: TIWLabel;
     IWLabel6: TIWLabel;  
     IWRegion6: TIWRegion;  
31      IWEdit1: TIWEdit;      IWEdit1: TIWEdit;
32      IWButton1: TIWButton;      IWButton1: TIWButton;
     IWImageFile1: TIWImageFile;  
     IWRegion7: TIWRegion;  
     IWLabel8: TIWLabel;  
     IWGrid1: TIWGrid;  
     IWTabControl1: TIWTabControl;  
     IWTabControl1Page0: TIWTabPage;  
     IWTabControl1Page1: TIWTabPage;  
     IWText1: TIWText;  
     IWRegion8: TIWRegion;  
33      IWEdit2: TIWEdit;      IWEdit2: TIWEdit;
34      IWEdit3: TIWEdit;      IWEdit3: TIWEdit;
     IWLabel9: TIWLabel;  
     IWList3: TIWList;  
35      IWLink2: TIWLink;      IWLink2: TIWLink;
36        IWRegion5: TIWRegion;
37        IWLabel7: TIWLabel;
38        IWRegion6: TIWRegion;
39        IWLabel8: TIWLabel;
40        IWList2: TIWList;
41        IWLabel4: TIWLabel;
42        IWRegion7: TIWRegion;
43        IWLabel5: TIWLabel;
44        IWLabel6: TIWLabel;
45        IWList3: TIWList;
46        IWImage1: TIWImage;
47        IWFrame8: TIWFrame8;
48        IWLink4: TIWLink;
49        IWLink3: TIWLink;
50        IWLink5: TIWLink;
51        IWFrame1: TIWFrame1;
52        IWLink6: TIWLink;
53      procedure IWAppFormRender(Sender: TObject);      procedure IWAppFormRender(Sender: TObject);
54      procedure IWLink1Click(Sender: TObject);      procedure IWLink2Click(Sender: TObject);
55      procedure IWAppFormCreate(Sender: TObject);      procedure IWAppFormCreate(Sender: TObject);
56      procedure IWButton1Click(Sender: TObject);      procedure IWButton1Click(Sender: TObject);
57      procedure IWAppFormDestroy(Sender: TObject);      procedure IWLink1Click(Sender: TObject);
58      procedure IWLink2Click(Sender: TObject);      procedure IWGrid1CellClick(ASender: TObject; const ARow, AColumn: Integer);
59        procedure IWFrame8IWButton1Click(Sender: TObject);
60        procedure IWFrame8IWLink1Click(Sender: TObject);
61        procedure IWLink4Click(Sender: TObject);
62        procedure IWLink3Click(Sender: TObject);
63        procedure IWLink5Click(Sender: TObject);
64        procedure IWLink6Click(Sender: TObject);
65    private    private
66      procedure SetPage(const Value: TPage);      Filter: Boolean;
67      function GetPage: TPage;      function GetPage: Boolean;
68        procedure SetPage(const Value: Boolean);
69      procedure LoadImage;      procedure LoadImage;
70      procedure ClearImage;      procedure ClearImage;
71        function GetThumbnail: Boolean;
72        procedure CallBack(EventParams: TStringList);
73        procedure SetThumbnail(const Value: Boolean);
74    public    public
75      property Page: TPage read GetPage write SetPage;      property Page: Boolean read GetPage write SetPage;
76        property Thumbnail: Boolean read GetThumbnail write SetThumbnail;
77    end;    end;
78    
79    var
80      IWForm1: TIWForm1;
81    
82  implementation  implementation
83    
84  {$R *.dfm}  {$R *.dfm}
85    
86  uses Unit2, ServerController, Unit4, Unit6;  uses Unit3, ServerController, Unit6, Unit4, Unit9, Unit10, Unit5;
87    
88    procedure TIWForm1.CallBack(EventParams: TStringList);
89    begin
90      if SameText(EventParams.Values['RetValue'], 'true') = true then
91        TCartForm.Create(WebApplication).Show;
92    end;
93    
94  procedure TTopForm.ClearImage;  procedure TIWForm1.ClearImage;
95  var  var
96    i, j: integer;    i: Integer;
97      j: Integer;
98  begin  begin
99    for i := 0 to IWGrid1.ColumnCount - 1 do    for i := 0 to IWGrid1.RowCount - 1 do
100      for j := 0 to IWGrid1.RowCount - 1 do      for j := 0 to IWGrid1.ColumnCount - 1 do
101      begin        IWGrid1.Cell[i, j].Control.Free;
102        IWGrid1.Cell[j, i].Control.Free;    IWGrid1.RowCount := 0;
       IWGrid1.Cell[j, i].Control := nil;  
     end;  
103  end;  end;
104    
105  function TTopForm.GetPage: TPage;  function TIWForm1.GetPage: Boolean;
106  begin  begin
107    result := UserSession.FPage;    result := UserSession.FPage;
108  end;  end;
109    
110  procedure TTopForm.IWAppFormCreate(Sender: TObject);  function TIWForm1.GetThumbnail: Boolean;
111    begin
112      result := UserSession.FThumbnail;
113    end;
114    
115    procedure TIWForm1.IWAppFormCreate(Sender: TObject);
116  const  const
117    i = 150;    i = 120;
118  var  var
119    s: integer;    s: Integer;
120  begin  begin
121    s:=DM.FDTable3.FieldByName('BGCOLOR').AsInteger;    IWForm1 := Self;
122    IWLabel1.BGColor := s;    Page := UserSession.FPage;
123      Thumbnail := UserSession.FThumbnail;
124      s := DM.FDTable3.FieldByName('BGCOLOR').AsInteger;
125      IWLabel2.BGColor := s;
126    IWLabel3.BGColor := s;    IWLabel3.BGColor := s;
127    IWLabel5.BGColor := s;    IWLabel5.BGColor := s;
128    IWLabel6.BGColor := s;    IWLabel7.BGColor := s;
129    IWLabel8.BGColor := s;    IWLabel8.BGColor := s;
130    IWRegion1.Width := i;    IWRegion1.Width := i;
131    IWRegion2.Width := i;    IWRegion2.Width := i;
   IWRegion3.Width := i;  
132    IWRegion4.Width := i;    IWRegion4.Width := i;
133      IWRegion5.Width := i;
134      IWRegion6.Width := i;
135    IWRegion7.Width := i;    IWRegion7.Width := i;
136    IWRegion8.Width := i;    WebApplication.RegisterCallBack('callback', CallBack);
   Page := UserSession.FPage;  
137  end;  end;
138    
139  procedure TTopForm.IWAppFormDestroy(Sender: TObject);  procedure TIWForm1.IWAppFormRender(Sender: TObject);
 begin  
   ClearImage;  
 end;  
   
 procedure TTopForm.IWAppFormRender(Sender: TObject);  
140  var  var
141    s: string;    s: string;
142    i, j: integer;    i, j: Integer;
   x: Boolean;  
143  begin  begin
144    IWList1.Items.Clear;    IWList1.Items.Clear;
145    with DM.FDTable2 do    with DM.FDTable2 do
146      if RecordCount > 0 then    begin
147        if Filtered = true then
148      begin      begin
149        First;        FindFirst;
150        while Eof = false do        while Found = true do
151        begin        begin
152          s := FieldByName('CATEGORY').AsString;          s := FieldByName('CATEGORY').AsString;
153          if s = '' then          if s = '' then
154          begin          begin
155            Next;            FindNext;
156            continue;            continue;
157          end;          end;
158          if Filtered = true then          i := IWList1.Items.IndexOfName(s);
159          begin          if i = -1 then
160            i := IWList1.Items.IndexOfName(s);            IWList1.Items.Add(s + '=1')
           if i = -1 then  
             IWList1.Items.Add(s + '=1')  
           else  
           begin  
             j := IWList1.Items.ValueFromIndex[i].ToInteger + 1;  
             IWList1.Items[i] := s + '=' + j.ToString;  
           end;  
         end  
161          else          else
162          begin          begin
163            i := IWList1.Items.IndexOf(s);            j := IWList1.Items.ValueFromIndex[i].ToInteger + 1;
164            if i = -1 then            IWList1.Items[i] := s + '=' + j.ToString;
165              IWList1.Items.Add(s);          end;
166            FindNext;
167          end;
168        end
169        else
170        begin
171          First;
172          while Eof = false do
173          begin
174            s := FieldByName('CATEGORY').AsString;
175            if s = '' then
176            begin
177              Next;
178              continue;
179          end;          end;
180            i := IWList1.Items.IndexOf(s);
181            if i = -1 then
182              IWList1.Items.Add(s);
183          Next;          Next;
184        end;        end;
185      end;      end;
186      end;
187    if DM.FDTable2.Filtered = true then    if DM.FDTable2.Filtered = true then
188      for i := 0 to IWList1.Items.Count - 1 do      for i := 0 to IWList1.Items.Count - 1 do
189      begin      begin
# Line 167  begin Line 193  begin
193        else        else
194          IWList1.Items[i] := IWList1.Items.Names[i] + '(' + s + ')';          IWList1.Items[i] := IWList1.Items.Names[i] + '(' + s + ')';
195      end;      end;
196    IWList3.Items.Clear;    IWList2.Items.Clear;
197    if Page = Info then    if Page = false then
198    begin    begin
199      with DM.FDQuery1 do      with DM.FDQuery1 do
200      begin      begin
# Line 178  begin Line 204  begin
204        SQL.Add(' where number = :num;');        SQL.Add(' where number = :num;');
205        Params.ParamByName('num').AsInteger := UserSession.user_number;        Params.ParamByName('num').AsInteger := UserSession.user_number;
206        Open;        Open;
207        if RecordCount > 0 then        First;
208          i := 0;
209          while Eof = false do
210        begin        begin
211          First;          s := Fields.Fields[0].AsString + 'x' + Fields.Fields[1].AsString;
212          i := 0;          i := i + Fields.Fields[0].AsInteger * Fields.Fields[2].AsInteger;
213          while Eof = false do          IWList2.Items.Add(s);
214          begin          Next;
           s := Fields.Fields[0].AsString + 'x' + Fields.Fields[1].AsString;  
           inc(i, Fields.Fields[2].AsInteger);  
           IWList3.Items.Add(s);  
           Next;  
         end;  
         IWList3.Items.Add(i.ToString + '円');  
215        end;        end;
216          IWList2.Items.Add(i.ToString + '円');
217        Close;        Close;
218      end;        IWList3.Items.Clear;
     IWList2.Items.Clear;  
     with DM.FDQuery1 do  
     begin  
219        SQL.Clear;        SQL.Clear;
220        SQL.Add('select name from recent_data join item_data');        SQL.Add('select name from recent_data join item_data');
221        SQL.Add(' on (recent_data.serial = item_data.serial)');        SQL.Add(' on (recent_data.serial = item_data.serial)');
222        SQL.Add(' where number = :num;');        SQL.Add(' where number = :num;');
223        //Params.ParamByName('num').AsInteger:=UserSession.user_number;        Params.ParamByName('num').AsInteger := UserSession.user_number;
224        Open;        Open;
225        if RecordCount > 0 then        First;
226          while Eof = false do
227        begin        begin
228          First;          IWList3.Items.Add(Fields.Fields[0].AsString);
229          while Eof = false do          Next;
         begin  
           IWList2.Items.Add(Fields.Fields[0].AsString);  
           Next;  
         end;  
230        end;        end;
231        Close;        Close;
232      end;      end;
233    end;    end;
   x := Page = Info;  
   IWRegion4.Visible := x;  
   IWLabel2.Visible := x;  
   IWDBLabel1.Visible := x;  
   IWLink2.Visible := not x;  
234    LoadImage;    LoadImage;
235      if IWGrid1.Visible = true then
236        IWLabel6.Visible := Filter;
237  end;  end;
238    
239  procedure TTopForm.IWButton1Click(Sender: TObject);  procedure TIWForm1.IWButton1Click(Sender: TObject);
240  const  var
241    filter = 'NAME LIKE ''%s''';    i: Integer;
242  begin  begin
243    if IWEdit1.Text = '' then    IWFrame8IWLink1Click(Sender);
244      DM.FDTable2.Filtered := false    if IWEdit1.Text <> '' then
   else  
245    begin    begin
246      DM.FDTable2.filter := Format(filter, ['%' + IWEdit1.Text + '%']);      DM.FDTable2.Filter := 'NAME like ' + QuotedStr('%' + IWEdit1.Text + '%');
247      DM.FDTable2.Filtered := true;      DM.FDTable2.Filtered := true;
248      IWLabel9.Text := IWEdit1.Text + 'を検索しています';      i := DM.FDTable2.RecordCount;
249        IWLabel6.Caption := Format(IWEdit1.Text + 'を検索しています:%d件', [i]);
250        if i = 0 then
251          DM.FDTable2.Filtered := false;
252        Filter := true;
253      end
254      else
255      begin
256        DM.FDTable2.Filtered := false;
257        Filter := false;
258    end;    end;
   IWLabel9.Visible := DM.FDTable2.Filtered;  
259  end;  end;
260    
261  procedure TTopForm.IWLink1Click(Sender: TObject);  procedure TIWForm1.IWFrame8IWButton1Click(Sender: TObject);
262  const  var
263    filter = 'EMAIL = ''%s'' and PASSWORD = ''%s''';    i: Integer;
264  begin  begin
265    case Page of    if TryStrToInt(IWFrame8.IWEdit1.Text, i) = false then
266      Main:    begin
267        begin      WebApplication.ShowMessage('個数が不正です');
268          DM.FDTable1.filter := Format(filter, [IWEdit2.Text, IWEdit3.Text]);      Exit;
269          DM.FDTable1.Filtered := true;    end;
270          if DM.FDTable1.RecordCount = 1 then    if i = 0 then
271          begin    begin
272            IWLink1.Caption := 'ログアウト';      WebApplication.ShowMessage('1個以上のご注文が必要です');
273            Page := Info;      Exit;
274            UserSession.user_number := DM.FDTable1.FieldByName('NUMBER')    end;
275              .AsInteger;    with DM.FDQuery1 do
276            IWEdit2.Text := '';    begin
277          end;      SQL.Clear;
278          IWEdit3.Text := '';      SQL.Add('select * from cart_data;');
279        end;      Open;
280      Info:      if Locate('NUMBER;SERIAL', VarArrayOf([UserSession.user_number,
281        begin        UserSession.Serial]), []) = true then
282          DM.FDTable1.Filtered := false;      begin
283          IWLink1.Caption := 'ログイン';        Edit;
284          Page := Main;        FieldByName('VOLUME').AsInteger := FieldByName('VOLUME').AsInteger + i;
285          DM.FDQuery1.Params.ParamByName('num').AsInteger := 0;        Post;
286        end;      end
287        else
288          AppendRecord([nil, i, UserSession.user_number, UserSession.Serial]);
289    end;    end;
290    IWLabel9.Visible := UserSession.user_number <> 0;    IWFrame8.IWEdit1.Text := '0';
291      WebApplication.ShowConfirm('カートに移動しますか', 'callback', '移動', 'はい', 'いいえ');
292    end;
293    
294    procedure TIWForm1.IWFrame8IWLink1Click(Sender: TObject);
295    begin
296      Thumbnail := true;
297    end;
298    
299    procedure TIWForm1.IWGrid1CellClick(ASender: TObject;
300      const ARow, AColumn: Integer);
301    begin
302      Thumbnail := false;
303      IWFrame8.IWEdit1.Text := '1';
304      UserSession.Serial := Integer(IWGrid1.Cell[ARow, AColumn].Tag);
305  end;  end;
306    
307  procedure TTopForm.IWLink2Click(Sender: TObject);  procedure TIWForm1.IWLink1Click(Sender: TObject);
308  begin  begin
   UserSession.FPage := Info;  
309    TUserForm.Create(WebApplication).Show;    TUserForm.Create(WebApplication).Show;
310  end;  end;
311    
312  procedure TTopForm.LoadImage;  procedure TIWForm1.IWLink2Click(Sender: TObject);
313    begin
314      if Page = true then
315      begin
316        if DM.FDTable1.Locate('EMAIL;PASSWORD',
317          VarArrayOf([IWEdit2.Text, IWEdit3.Text]), [loCaseInsensitive]) = true then
318        begin
319          Page := false;
320          IWEdit2.Text := '';
321        end;
322        IWEdit3.Text := '';
323      end
324      else
325        Page := true;
326    end;
327    
328    procedure TIWForm1.IWLink3Click(Sender: TObject);
329    begin
330      with TMyPage.Create(WebApplication) do
331      begin
332        Form := Self;
333        Show;
334      end;
335    end;
336    
337    procedure TIWForm1.IWLink4Click(Sender: TObject);
338    begin
339      TCartForm.Create(WebApplication).Show;
340    end;
341    
342    procedure TIWForm1.IWLink5Click(Sender: TObject);
343    begin
344      TIWForm10.Create(WebApplication).Show;
345    end;
346    
347    procedure TIWForm1.IWLink6Click(Sender: TObject);
348    begin
349      Page:=true;
350      TIWForm3.Create(WebApplication).Show;
351    end;
352    
353    procedure TIWForm1.LoadImage;
354  var  var
355    i, j, k: integer;    s: TStream;
356    png: TPngImage;    png: TPngImage;
357    pic: TIWImageFile;    pic: TIWImage;
358    st: TStream;    i: Integer;
359      j: Integer;
360      x: Boolean;
361      t: string;
362  label label1;  label label1;
363  begin  begin
364    ClearImage;    ClearImage;
365    if DM.FDTable2.RecordCount > 0 then    png := TPngImage.Create;
366    begin    try
367      IWGrid1.RowCount := (DM.FDTable2.RecordCount div IWGrid1.ColumnCount) + 1;      if Thumbnail = true then
368      k := 1;      begin
369      DM.FDTable2.Last;        i := DM.FDTable2.RecordCount div IWGrid1.ColumnCount;
370      png := TPngImage.Create;        if DM.FDTable2.RecordCount mod IWGrid1.ColumnCount > 0 then
371      try          inc(i);
372          IWGrid1.RowCount := i;
373          if DM.FDTable2.Filtered = false then
374            DM.FDTable2.Last
375          else
376            DM.FDTable2.FindLast;
377        for i := 0 to IWGrid1.RowCount - 1 do        for i := 0 to IWGrid1.RowCount - 1 do
       begin  
378          for j := 0 to IWGrid1.ColumnCount - 1 do          for j := 0 to IWGrid1.ColumnCount - 1 do
379          begin          begin
380            st := DM.FDTable2.CreateBlobStream            if DM.FDTable2.Filtered = false then
381              (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);            begin
382            try              if DM.FDTable2.Bof = true then
383              png.LoadFromStream(st);                goto label1;
384              pic := TIWImageFile.Create(Self);            end
385              else if DM.FDTable2.Found = false then
386                goto label1;
387              if DM.FDTable2.FieldByName('THUMBNAIL').AsBytes <> nil then
388              begin
389                s := DM.FDTable2.CreateBlobStream
390                  (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
391                try
392                  png.LoadFromStream(s);
393                finally
394                  s.Free;
395                end;
396                pic := TIWImage.Create(IWGrid1);
397              pic.Picture.Assign(png);              pic.Picture.Assign(png);
398              IWGrid1.Cell[i, j].Control := pic;              IWGrid1.Cell[i, j].Control := pic;
             IWGrid1.Cell[i, j].Text := k.ToString;  
             inc(k);  
             DM.FDTable2.Prior;  
           finally  
             st.Free;  
399            end;            end;
400            if DM.FDTable2.Bof = true then            t := DM.FDTable2.FieldByName('NAME').AsString;
401              goto label1;            if Length(t) > 10 then
402                t := Copy(t, 1, 8) + '..';
403              IWGrid1.Cell[i, j].Tag :=
404                Pointer(DM.FDTable2.FieldByName('SERIAL').AsInteger);
405              IWGrid1.Cell[i, j].Text := t;
406              IWGrid1.Cell[i, j].Alignment := taCenter;
407              IWGrid1.Cell[i, j].Clickable := true;
408              if DM.FDTable2.Filtered = false then
409                DM.FDTable2.Prior
410              else
411                DM.FDTable2.FindPrior;
412          end;          end;
       end;  
413      label1:      label1:
414      finally      end
415        png.Free;      else if (DM.FDTable2.Locate('SERIAL', UserSession.Serial, []) = true) and
416      end;        (DM.FDTable2.FieldByName('THUMBNAIL').AsBytes <> nil) then
417    end      begin
418    else        s := DM.FDTable2.CreateBlobStream
419      IWGrid1.RowCount := 0;          (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
420    st := nil;        try
421            png.LoadFromStream(s);
422            IWFrame8.IWImage1.Picture.Assign(png);
423          finally
424            s.Free;
425          end;
426        end
427        else
428          IWFrame8.IWImage1.Picture.Assign(nil);
429      finally
430        png.Free;
431      end;
432    png := nil;    png := nil;
433      s := nil;
434    Randomize;    Randomize;
435      if DM.FDTable2.Filtered = true then
436      begin
437        x := true;
438        DM.FDTable2.Filtered := false;
439      end
440      else
441        x := false;
442    DM.FDTable2.Last;    DM.FDTable2.Last;
443      if DM.FDTable2.Bof = true then
444        Exit;
445    DM.FDTable2.MoveBy(-Random(DM.FDTable2.RecordCount div 5));    DM.FDTable2.MoveBy(-Random(DM.FDTable2.RecordCount div 5));
446    st := DM.FDTable2.CreateBlobStream    if DM.FDTable2.FieldByName('THUMBNAIL').AsBytes <> nil then
447      (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);    begin
448    png := TPngImage.Create;      s := DM.FDTable2.CreateBlobStream
449    try        (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
450      png.LoadFromStream(st);      png := TPngImage.Create;
451      IWImageFile1.Picture.Assign(png);      try
452    finally        png.LoadFromStream(s);
453      st.Free;        IWImage1.Picture.Assign(png);
454      png.Free;      finally
455          png.Free;
456          s.Free;
457        end;
458    end;    end;
459      if x = true then
460        DM.FDTable2.Filtered := true;
461    IWLabel4.Caption := DM.FDTable2.FieldByName('NAME').AsString;    IWLabel4.Caption := DM.FDTable2.FieldByName('NAME').AsString;
462  end;  end;
463    
464  procedure TTopForm.SetPage(const Value: TPage);  procedure TIWForm1.SetPage(const Value: Boolean);
 var  
   s: string;  
465  begin  begin
466    UserSession.FPage := Value;    UserSession.FPage := Value;
467    case Value of    IWRegion7.Visible := not Value;
468      Main:    IWDBLabel1.Visible := not Value;
469        s := 'toppage.htm';    IWLink3.Visible := not Value;
470      Info:    IWLink1.Visible := Value;
471        s := 'mypage.htm';    IWText1.Visible := Value;
472      if Value = false then
473      begin
474        IWLabel1.Caption := 'ようこそ';
475        IWLink2.Caption := 'ログアウト';
476        UserSession.user_number := DM.FDTable1.FieldByName('NUMBER').AsInteger;
477      end
478      else
479      begin
480        IWLabel1.Caption := 'ようこそゲスト様';
481        IWLink2.Caption := 'ログイン';
482        Thumbnail := true;
483        IWText1.Text := '';
484        DM.FDTable2.Filtered := false;
485        Filter := false;
486        UserSession.user_number:=0;
487    end;    end;
488    IWTemplateProcessorHTML1.Templates.Default := s;  end;
489    
490    procedure TIWForm1.SetThumbnail(const Value: Boolean);
491    begin
492      UserSession.FThumbnail := Value;
493      IWGrid1.Visible := Value;
494      IWFrame8.Visible := not Value;
495  end;  end;
496    
497  initialization  initialization
498    
499  TTopForm.SetAsMainForm;  TIWForm1.SetAsMainForm;
500    
501  end.  end.

Legend:
Removed from v.1  
changed lines
  Added in v.10

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26