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 12 by yamat0jp, Sun Jul 24 06:09:44 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      IWFrame8.IWEdit1.Text := '0';
93    end;
94    
95  procedure TTopForm.ClearImage;  procedure TIWForm1.ClearImage;
96  var  var
97    i, j: integer;    i: Integer;
98      j: Integer;
99  begin  begin
100    for i := 0 to IWGrid1.ColumnCount - 1 do    for i := 0 to IWGrid1.RowCount - 1 do
101      for j := 0 to IWGrid1.RowCount - 1 do      for j := 0 to IWGrid1.ColumnCount - 1 do
102      begin        IWGrid1.Cell[i, j].Control.Free;
103        IWGrid1.Cell[j, i].Control.Free;    IWGrid1.RowCount := 0;
       IWGrid1.Cell[j, i].Control := nil;  
     end;  
104  end;  end;
105    
106  function TTopForm.GetPage: TPage;  function TIWForm1.GetPage: Boolean;
107  begin  begin
108    result := UserSession.FPage;    result := UserSession.FPage;
109  end;  end;
110    
111  procedure TTopForm.IWAppFormCreate(Sender: TObject);  function TIWForm1.GetThumbnail: Boolean;
112    begin
113      result := UserSession.FThumbnail;
114    end;
115    
116    procedure TIWForm1.IWAppFormCreate(Sender: TObject);
117  const  const
118    i = 150;    i = 120;
119  var  var
120    s: integer;    s: Integer;
121  begin  begin
122    s:=DM.FDTable3.FieldByName('BGCOLOR').AsInteger;    IWForm1 := Self;
123    IWLabel1.BGColor := s;    Page := UserSession.FPage;
124      Thumbnail := UserSession.FThumbnail;
125      s := DM.FDTable3.FieldByName('BGCOLOR').AsInteger;
126      IWLabel2.BGColor := s;
127    IWLabel3.BGColor := s;    IWLabel3.BGColor := s;
128    IWLabel5.BGColor := s;    IWLabel5.BGColor := s;
129    IWLabel6.BGColor := s;    IWLabel7.BGColor := s;
130    IWLabel8.BGColor := s;    IWLabel8.BGColor := s;
131    IWRegion1.Width := i;    IWRegion1.Width := i;
132    IWRegion2.Width := i;    IWRegion2.Width := i;
   IWRegion3.Width := i;  
133    IWRegion4.Width := i;    IWRegion4.Width := i;
134      IWRegion5.Width := i;
135      IWRegion6.Width := i;
136    IWRegion7.Width := i;    IWRegion7.Width := i;
137    IWRegion8.Width := i;    WebApplication.RegisterCallBack('callback', CallBack);
   Page := UserSession.FPage;  
138  end;  end;
139    
140  procedure TTopForm.IWAppFormDestroy(Sender: TObject);  procedure TIWForm1.IWAppFormRender(Sender: TObject);
 begin  
   ClearImage;  
 end;  
   
 procedure TTopForm.IWAppFormRender(Sender: TObject);  
141  var  var
142    s: string;    s: string;
143    i, j: integer;    i, j: Integer;
   x: Boolean;  
144  begin  begin
145    IWList1.Items.Clear;    IWList1.Items.Clear;
146    with DM.FDTable2 do    with DM.FDTable2 do
147      if RecordCount > 0 then    begin
148        if Filtered = true then
149      begin      begin
150        First;        FindFirst;
151        while Eof = false do        while Found = true do
152        begin        begin
153          s := FieldByName('CATEGORY').AsString;          s := FieldByName('CATEGORY').AsString;
154          if s = '' then          if s = '' then
155          begin          begin
156            Next;            FindNext;
157            continue;            continue;
158          end;          end;
159          if Filtered = true then          i := IWList1.Items.IndexOfName(s);
160          begin          if i = -1 then
161            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  
162          else          else
163          begin          begin
164            i := IWList1.Items.IndexOf(s);            j := IWList1.Items.ValueFromIndex[i].ToInteger + 1;
165            if i = -1 then            IWList1.Items[i] := s + '=' + j.ToString;
166              IWList1.Items.Add(s);          end;
167            FindNext;
168          end;
169        end
170        else
171        begin
172          First;
173          while Eof = false do
174          begin
175            s := FieldByName('CATEGORY').AsString;
176            if s = '' then
177            begin
178              Next;
179              continue;
180          end;          end;
181            i := IWList1.Items.IndexOf(s);
182            if i = -1 then
183              IWList1.Items.Add(s);
184          Next;          Next;
185        end;        end;
186      end;      end;
187      end;
188    if DM.FDTable2.Filtered = true then    if DM.FDTable2.Filtered = true then
189      for i := 0 to IWList1.Items.Count - 1 do      for i := 0 to IWList1.Items.Count - 1 do
190      begin      begin
# Line 167  begin Line 194  begin
194        else        else
195          IWList1.Items[i] := IWList1.Items.Names[i] + '(' + s + ')';          IWList1.Items[i] := IWList1.Items.Names[i] + '(' + s + ')';
196      end;      end;
197    IWList3.Items.Clear;    IWList2.Items.Clear;
198    if Page = Info then    with DM.FDQuery1 do
199    begin    begin
200      with DM.FDQuery1 do      SQL.Clear;
201        SQL.Add('select volume,name,price from cart_data join item_data');
202        SQL.Add(' on (cart_data.serial = item_data.serial)');
203        SQL.Add(' where number = :num;');
204        Params.ParamByName('num').AsInteger := UserSession.user_number;
205        Open;
206        First;
207        i := 0;
208        while Eof = false do
209      begin      begin
210        SQL.Clear;        s := Fields.Fields[0].AsString + 'x' + Fields.Fields[1].AsString;
211        SQL.Add('select volume,name,price from cart_data join item_data');        i := i + Fields.Fields[0].AsInteger * Fields.Fields[2].AsInteger;
212        SQL.Add(' on (cart_data.serial = item_data.serial)');        IWList2.Items.Add(s);
213        SQL.Add(' where number = :num;');        Next;
       Params.ParamByName('num').AsInteger := UserSession.user_number;  
       Open;  
       if RecordCount > 0 then  
       begin  
         First;  
         i := 0;  
         while Eof = false do  
         begin  
           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 + '円');  
       end;  
       Close;  
214      end;      end;
215      IWList2.Items.Clear;      IWList2.Items.Add(i.ToString + '円');
216      with DM.FDQuery1 do      Close;
217        IWList3.Items.Clear;
218        SQL.Clear;
219        SQL.Add('select name from recent_data join item_data');
220        SQL.Add(' on (recent_data.serial = item_data.serial)');
221        SQL.Add(' where number = :num;');
222        Params.ParamByName('num').AsInteger := UserSession.user_number;
223        Open;
224        First;
225        while Eof = false do
226      begin      begin
227        SQL.Clear;        IWList3.Items.Add(Fields.Fields[0].AsString);
228        SQL.Add('select name from recent_data join item_data');        Next;
       SQL.Add(' on (recent_data.serial = item_data.serial)');  
       SQL.Add(' where number = :num;');  
       //Params.ParamByName('num').AsInteger:=UserSession.user_number;  
       Open;  
       if RecordCount > 0 then  
       begin  
         First;  
         while Eof = false do  
         begin  
           IWList2.Items.Add(Fields.Fields[0].AsString);  
           Next;  
         end;  
       end;  
       Close;  
229      end;      end;
230        Close;
231    end;    end;
   x := Page = Info;  
   IWRegion4.Visible := x;  
   IWLabel2.Visible := x;  
   IWDBLabel1.Visible := x;  
   IWLink2.Visible := not x;  
232    LoadImage;    LoadImage;
233      if IWGrid1.Visible = true then
234        IWLabel6.Visible := Filter;
235  end;  end;
236    
237  procedure TTopForm.IWButton1Click(Sender: TObject);  procedure TIWForm1.IWButton1Click(Sender: TObject);
238  const  var
239    filter = 'NAME LIKE ''%s''';    i: Integer;
240  begin  begin
241    if IWEdit1.Text = '' then    IWFrame8IWLink1Click(Sender);
242      DM.FDTable2.Filtered := false    if IWEdit1.Text <> '' then
   else  
243    begin    begin
244      DM.FDTable2.filter := Format(filter, ['%' + IWEdit1.Text + '%']);      DM.FDTable2.Filter := 'NAME like ' + QuotedStr('%' + IWEdit1.Text + '%');
245      DM.FDTable2.Filtered := true;      DM.FDTable2.Filtered := true;
246      IWLabel9.Text := IWEdit1.Text + 'を検索しています';      i := DM.FDTable2.RecordCount;
247        IWLabel6.Caption := Format(IWEdit1.Text + 'を検索しています:%d件', [i]);
248        if i = 0 then
249          DM.FDTable2.Filtered := false;
250        Filter := true;
251      end
252      else
253      begin
254        DM.FDTable2.Filtered := false;
255        Filter := false;
256    end;    end;
   IWLabel9.Visible := DM.FDTable2.Filtered;  
257  end;  end;
258    
259  procedure TTopForm.IWLink1Click(Sender: TObject);  procedure TIWForm1.IWFrame8IWButton1Click(Sender: TObject);
260  const  var
261    filter = 'EMAIL = ''%s'' and PASSWORD = ''%s''';    i, j: Integer;
262      s: string;
263    begin
264      if TryStrToInt(IWFrame8.IWEdit1.Text, i) = false then
265      begin
266        WebApplication.ShowMessage('個数が不正です');
267        Exit;
268      end;
269      if i = 0 then
270      begin
271        WebApplication.ShowMessage('1個以上のご注文が必要です');
272        Exit;
273      end;
274      s := WebApplication.Request.CookieFields.Values['user_cookie'];
275      if s = '' then
276      begin
277        DM.FDTable1.Last;
278        j := DM.FDTable1.FieldByName('NUMBER').AsInteger + 1;
279        while DM.FDTable1.Lookup('NUMBER', j, 'NUMBER') = j do
280          inc(j);
281        UserSession.user_number := j;
282        DM.FDTable1.AppendRecord([nil, nil, nil, nil, nil, nil,
283          UserSession.user_number, Date]);
284        WebApplication.Response.Cookies.AddCookie('user_cookie',
285          UserSession.user_number.ToString, '/', Date + 10);
286      end;
287      with DM.FDQuery1 do
288      begin
289        Open('select * from cart_data;');
290        if Locate('NUMBER;SERIAL', VarArrayOf([UserSession.user_number,
291          UserSession.Serial]), []) = true then
292        begin
293          Edit;
294          FieldByName('VOLUME').AsInteger := FieldByName('VOLUME').AsInteger + i;
295          Post;
296        end
297        else
298          AppendRecord([nil, i, UserSession.user_number, UserSession.Serial]);
299      end;
300      WebApplication.ShowConfirm('カートに移動しますか', 'callback', '移動', 'はい', 'いいえ');
301    end;
302    
303    procedure TIWForm1.IWFrame8IWLink1Click(Sender: TObject);
304    begin
305      Thumbnail := true;
306    end;
307    
308    procedure TIWForm1.IWGrid1CellClick(ASender: TObject;
309      const ARow, AColumn: Integer);
310    begin
311      Thumbnail := false;
312      IWFrame8.IWEdit1.Text := '1';
313      UserSession.Serial := Integer(IWGrid1.Cell[ARow, AColumn].Tag);
314    end;
315    
316    procedure TIWForm1.IWLink1Click(Sender: TObject);
317    begin
318      TUserForm.Create(WebApplication).Show;
319    end;
320    
321    procedure TIWForm1.IWLink2Click(Sender: TObject);
322    var
323      i: Integer;
324  begin  begin
325    case Page of    if Page = true then
326      Main:    begin
327        i := UserSession.user_number;
328        if (DM.FDTable1.Locate('EMAIL;PASSWORD',
329          VarArrayOf([IWEdit2.Text, UserSession.hash(IWEdit3.Text)]),
330          [loCaseInsensitive]) = true) and
331          (DM.FDTable1.FieldByName('EMAIL').AsString <> '') then
332        begin
333          IWEdit2.Text := '';
334          UserSession.user_number := DM.FDTable1.FieldByName('NUMBER').AsInteger;
335          if i <> 0 then
336        begin        begin
337          DM.FDTable1.filter := Format(filter, [IWEdit2.Text, IWEdit3.Text]);          with DM.FDQuery1 do
         DM.FDTable1.Filtered := true;  
         if DM.FDTable1.RecordCount = 1 then  
338          begin          begin
339            IWLink1.Caption := 'ログアウト';            Open('select * from user_data where number = :num',[i]);
340            Page := Info;            Delete;
341            UserSession.user_number := DM.FDTable1.FieldByName('NUMBER')            Open('select number from cart_data where number = :num;',[i]);
342              .AsInteger;            First;
343            IWEdit2.Text := '';            while Eof = false do
344              begin
345                Edit;
346                FieldByName('number').AsInteger := UserSession.user_number;
347                Next;
348              end;
349          end;          end;
         IWEdit3.Text := '';  
       end;  
     Info:  
       begin  
         DM.FDTable1.Filtered := false;  
         IWLink1.Caption := 'ログイン';  
         Page := Main;  
         DM.FDQuery1.Params.ParamByName('num').AsInteger := 0;  
350        end;        end;
351          Page := false;
352        end;
353        IWEdit3.Text := '';
354      end
355      else
356        Page := true;
357    end;
358    
359    procedure TIWForm1.IWLink3Click(Sender: TObject);
360    begin
361      with TMyPage.Create(WebApplication) do
362      begin
363        Form := Self;
364        Show;
365    end;    end;
   IWLabel9.Visible := UserSession.user_number <> 0;  
366  end;  end;
367    
368  procedure TTopForm.IWLink2Click(Sender: TObject);  procedure TIWForm1.IWLink4Click(Sender: TObject);
369  begin  begin
370    UserSession.FPage := Info;    TCartForm.Create(WebApplication).Show;
371    TUserForm.Create(WebApplication).Show;  end;
372    
373    procedure TIWForm1.IWLink5Click(Sender: TObject);
374    begin
375      TIWForm10.Create(WebApplication).Show;
376  end;  end;
377    
378  procedure TTopForm.LoadImage;  procedure TIWForm1.IWLink6Click(Sender: TObject);
379    begin
380      Page := true;
381      TAdminPage.Create(WebApplication).Show;
382    end;
383    
384    procedure TIWForm1.LoadImage;
385  var  var
386    i, j, k: integer;    s: TStream;
387    png: TPngImage;    png: TPngImage;
388    pic: TIWImageFile;    pic: TIWImage;
389    st: TStream;    i: Integer;
390      j: Integer;
391      x: Boolean;
392      t: string;
393  label label1;  label label1;
394  begin  begin
395    ClearImage;    ClearImage;
396    if DM.FDTable2.RecordCount > 0 then    png := TPngImage.Create;
397    begin    try
398      IWGrid1.RowCount := (DM.FDTable2.RecordCount div IWGrid1.ColumnCount) + 1;      if Thumbnail = true then
399      k := 1;      begin
400      DM.FDTable2.Last;        i := DM.FDTable2.RecordCount div IWGrid1.ColumnCount;
401      png := TPngImage.Create;        if DM.FDTable2.RecordCount mod IWGrid1.ColumnCount > 0 then
402      try          inc(i);
403          IWGrid1.RowCount := i;
404          if DM.FDTable2.Filtered = false then
405            DM.FDTable2.Last
406          else
407            DM.FDTable2.FindLast;
408        for i := 0 to IWGrid1.RowCount - 1 do        for i := 0 to IWGrid1.RowCount - 1 do
       begin  
409          for j := 0 to IWGrid1.ColumnCount - 1 do          for j := 0 to IWGrid1.ColumnCount - 1 do
410          begin          begin
411            st := DM.FDTable2.CreateBlobStream            if DM.FDTable2.Filtered = false then
412              (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);            begin
413            try              if DM.FDTable2.Bof = true then
414              png.LoadFromStream(st);                goto label1;
415              pic := TIWImageFile.Create(Self);            end
416              else if DM.FDTable2.Found = false then
417                goto label1;
418              if DM.FDTable2.FieldByName('THUMBNAIL').AsBytes <> nil then
419              begin
420                s := DM.FDTable2.CreateBlobStream
421                  (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
422                try
423                  png.LoadFromStream(s);
424                finally
425                  s.Free;
426                end;
427                pic := TIWImage.Create(IWGrid1);
428              pic.Picture.Assign(png);              pic.Picture.Assign(png);
429              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;  
430            end;            end;
431            if DM.FDTable2.Bof = true then            t := DM.FDTable2.FieldByName('NAME').AsString;
432              goto label1;            if Length(t) > 10 then
433                t := Copy(t, 1, 8) + '..';
434              IWGrid1.Cell[i, j].Tag :=
435                Pointer(DM.FDTable2.FieldByName('SERIAL').AsInteger);
436              IWGrid1.Cell[i, j].Text := t;
437              IWGrid1.Cell[i, j].Alignment := taCenter;
438              IWGrid1.Cell[i, j].Clickable := true;
439              if DM.FDTable2.Filtered = false then
440                DM.FDTable2.Prior
441              else
442                DM.FDTable2.FindPrior;
443          end;          end;
       end;  
444      label1:      label1:
445      finally      end
446        png.Free;      else if (DM.FDTable2.Locate('SERIAL', UserSession.Serial, []) = true) and
447      end;        (DM.FDTable2.FieldByName('THUMBNAIL').AsBytes <> nil) then
448    end      begin
449    else        s := DM.FDTable2.CreateBlobStream
450      IWGrid1.RowCount := 0;          (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
451    st := nil;        try
452            png.LoadFromStream(s);
453            IWFrame8.IWImage1.Picture.Assign(png);
454          finally
455            s.Free;
456          end;
457        end
458        else
459          IWFrame8.IWImage1.Picture.Assign(nil);
460      finally
461        png.Free;
462      end;
463    png := nil;    png := nil;
464      s := nil;
465    Randomize;    Randomize;
466      if DM.FDTable2.Filtered = true then
467      begin
468        x := true;
469        DM.FDTable2.Filtered := false;
470      end
471      else
472        x := false;
473    DM.FDTable2.Last;    DM.FDTable2.Last;
474      if DM.FDTable2.Bof = true then
475        Exit;
476    DM.FDTable2.MoveBy(-Random(DM.FDTable2.RecordCount div 5));    DM.FDTable2.MoveBy(-Random(DM.FDTable2.RecordCount div 5));
477    st := DM.FDTable2.CreateBlobStream    if DM.FDTable2.FieldByName('THUMBNAIL').AsBytes <> nil then
478      (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);    begin
479    png := TPngImage.Create;      s := DM.FDTable2.CreateBlobStream
480    try        (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
481      png.LoadFromStream(st);      png := TPngImage.Create;
482      IWImageFile1.Picture.Assign(png);      try
483    finally        png.LoadFromStream(s);
484      st.Free;        IWImage1.Picture.Assign(png);
485      png.Free;      finally
486          png.Free;
487          s.Free;
488        end;
489    end;    end;
490      if x = true then
491        DM.FDTable2.Filtered := true;
492    IWLabel4.Caption := DM.FDTable2.FieldByName('NAME').AsString;    IWLabel4.Caption := DM.FDTable2.FieldByName('NAME').AsString;
493  end;  end;
494    
495  procedure TTopForm.SetPage(const Value: TPage);  procedure TIWForm1.SetPage(const Value: Boolean);
 var  
   s: string;  
496  begin  begin
497    UserSession.FPage := Value;    UserSession.FPage := Value;
498    case Value of    IWRegion7.Visible := not Value;
499      Main:    IWDBLabel1.Visible := not Value;
500        s := 'toppage.htm';    IWLink3.Visible := not Value;
501      Info:    IWLink1.Visible := Value;
502        s := 'mypage.htm';    IWText1.Visible := Value;
503      if Value = false then
504      begin
505        IWLabel1.Caption := 'ようこそ';
506        IWLink2.Caption := 'ログアウト';
507        WebApplication.Response.Cookies.AddCookie('user_cookie',
508          UserSession.user_number.ToString, '/', Date + 10);
509      end
510      else
511      begin
512        IWLabel1.Caption := 'ようこそゲスト様';
513        IWLink2.Caption := 'ログイン';
514        Thumbnail := true;
515        IWText1.Text := '';
516        DM.FDTable2.Filtered := false;
517        Filter := false;
518        if DM.FDTable1.FieldByName('EMAIL').AsString <> '' then
519        begin
520          WebApplication.Response.Cookies.AddCookie('user_cookie', '0', '/', Date - 1);
521          UserSession.user_number := 0;
522        end;
523    end;    end;
524    IWTemplateProcessorHTML1.Templates.Default := s;  end;
525    
526    procedure TIWForm1.SetThumbnail(const Value: Boolean);
527    begin
528      UserSession.FThumbnail := Value;
529      IWGrid1.Visible := Value;
530      IWFrame8.Visible := not Value;
531  end;  end;
532    
533  initialization  initialization
534    
535  TTopForm.SetAsMainForm;  TIWForm1.SetAsMainForm;
536    
537  end.  end.

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

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