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 3 by yamat0jp, Sat Dec 26 07:30:17 2015 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, UserSessionUnit, PngImage, Data.DB,
13      IWCompListbox, IWBaseComponent, IWBaseHTMLComponent, IWBaseHTML40Component,
14      IWCompMenu, Vcl.Menus, System.Variants;
15    
16  type  type
17    TTopForm = class(TIWAppForm)    TIWForm1 = class(TIWAppForm)
18      IWRegion1: TIWRegion;      IWFrame1: TIWFrame1;
19        IWTemplateProcessorHTML1: TIWTemplateProcessorHTML;
20      IWLabel1: TIWLabel;      IWLabel1: TIWLabel;
     IWList1: TIWList;  
     IWLink1: TIWLink;  
     IWLabel2: TIWLabel;  
21      IWDBLabel1: TIWDBLabel;      IWDBLabel1: TIWDBLabel;
22      IWFrame1: TIWFrame1;      IWRegion1: TIWRegion;
23        IWRegion2: TIWRegion;
24        IWText1: TIWText;
25        IWGrid1: TIWGrid;
26      IWRegion3: TIWRegion;      IWRegion3: TIWRegion;
     IWLabel3: TIWLabel;  
     IWLabel4: TIWLabel;  
27      IWRegion4: TIWRegion;      IWRegion4: TIWRegion;
28      IWLabel5: TIWLabel;      IWLink1: TIWLink;
29      IWList2: TIWList;      IWLabel2: TIWLabel;
30      IWTemplateProcessorHTML1: TIWTemplateProcessorHTML;      IWList1: TIWList;
31      IWRegion2: TIWRegion;      IWLabel3: TIWLabel;
     IWLabel6: TIWLabel;  
     IWRegion6: TIWRegion;  
32      IWEdit1: TIWEdit;      IWEdit1: TIWEdit;
33      IWButton1: TIWButton;      IWButton1: TIWButton;
     IWImageFile1: TIWImageFile;  
     IWRegion7: TIWRegion;  
     IWLabel8: TIWLabel;  
     IWGrid1: TIWGrid;  
     IWTabControl1: TIWTabControl;  
     IWTabControl1Page0: TIWTabPage;  
     IWTabControl1Page1: TIWTabPage;  
     IWText1: TIWText;  
     IWRegion8: TIWRegion;  
34      IWEdit2: TIWEdit;      IWEdit2: TIWEdit;
35      IWEdit3: TIWEdit;      IWEdit3: TIWEdit;
     IWLabel9: TIWLabel;  
     IWList3: TIWList;  
36      IWLink2: TIWLink;      IWLink2: TIWLink;
37        IWRegion5: TIWRegion;
38        IWLabel7: TIWLabel;
39        IWRegion6: TIWRegion;
40        IWLabel8: TIWLabel;
41        IWList2: TIWList;
42        IWLabel4: TIWLabel;
43        IWImageFile1: TIWImageFile;
44        IWRegion7: TIWRegion;
45        IWLabel5: TIWLabel;
46        IWLabel6: TIWLabel;
47        IWList3: TIWList;
48      procedure IWAppFormRender(Sender: TObject);      procedure IWAppFormRender(Sender: TObject);
49      procedure IWLink1Click(Sender: TObject);      procedure IWLink2Click(Sender: TObject);
50      procedure IWAppFormCreate(Sender: TObject);      procedure IWAppFormCreate(Sender: TObject);
51      procedure IWButton1Click(Sender: TObject);      procedure IWButton1Click(Sender: TObject);
52      procedure IWAppFormDestroy(Sender: TObject);      procedure IWLink1Click(Sender: TObject);
     procedure IWLink2Click(Sender: TObject);  
53    private    private
     procedure SetPage(const Value: TPage);  
54      function GetPage: TPage;      function GetPage: TPage;
55        procedure SetPage(const Value: TPage);
56      procedure LoadImage;      procedure LoadImage;
57      procedure ClearImage;      procedure ClearImage;
58    public    public
# Line 74  implementation Line 63  implementation
63    
64  {$R *.dfm}  {$R *.dfm}
65    
66  uses Unit2, ServerController, Unit4, Unit6;  uses Unit3, ServerController, Unit6;
67    
68  procedure TTopForm.ClearImage;  procedure TIWForm1.ClearImage;
69  var  var
70    i, j: integer;    i: Integer;
71      j: Integer;
72  begin  begin
73    for i := 0 to IWGrid1.ColumnCount - 1 do    for i := 0 to IWGrid1.RowCount - 1 do
74      for j := 0 to IWGrid1.RowCount - 1 do      for j := 0 to IWGrid1.ColumnCount - 1 do
75      begin        IWGrid1.Cell[i, j].Control.Free;
       IWGrid1.Cell[j, i].Control.Free;  
       IWGrid1.Cell[j, i].Control := nil;  
     end;  
76  end;  end;
77    
78  function TTopForm.GetPage: TPage;  function TIWForm1.GetPage: TPage;
79  begin  begin
80    result := UserSession.FPage;    result := UserSession.FPage;
81  end;  end;
82    
83  procedure TTopForm.IWAppFormCreate(Sender: TObject);  procedure TIWForm1.IWAppFormCreate(Sender: TObject);
84  const  const
85    i = 150;    i = 120;
86  var  var
87    s: integer;    s: Integer;
88  begin  begin
89    s:=DM.FDTable3.FieldByName('BGCOLOR').AsInteger;    Page := UserSession.FPage;
90    IWLabel1.BGColor := s;    s := DM.FDTable3.FieldByName('BGCOLOR').AsInteger;
91      IWLabel2.BGColor := s;
92    IWLabel3.BGColor := s;    IWLabel3.BGColor := s;
93    IWLabel5.BGColor := s;    IWLabel5.BGColor := s;
   IWLabel6.BGColor := s;  
   IWLabel8.BGColor := s;  
94    IWRegion1.Width := i;    IWRegion1.Width := i;
95    IWRegion2.Width := i;    IWRegion2.Width := i;
   IWRegion3.Width := i;  
96    IWRegion4.Width := i;    IWRegion4.Width := i;
97      IWRegion5.Width := i;
98      IWRegion6.Width := i;
99    IWRegion7.Width := i;    IWRegion7.Width := i;
   IWRegion8.Width := i;  
   Page := UserSession.FPage;  
 end;  
   
 procedure TTopForm.IWAppFormDestroy(Sender: TObject);  
 begin  
   ClearImage;  
100  end;  end;
101    
102  procedure TTopForm.IWAppFormRender(Sender: TObject);  procedure TIWForm1.IWAppFormRender(Sender: TObject);
103  var  var
104    s: string;    s: string;
105    i, j: integer;    i, j: Integer;
   x: Boolean;  
106  begin  begin
107    IWList1.Items.Clear;    IWList1.Items.Clear;
108    with DM.FDTable2 do    with DM.FDTable2 do
109      if RecordCount > 0 then    begin
110        if Filtered = true then
111      begin      begin
112        First;        FindFirst;
113        while Eof = false do        while Found = true do
114        begin        begin
115          s := FieldByName('CATEGORY').AsString;          s := FieldByName('CATEGORY').AsString;
116          if s = '' then          if s = '' then
117          begin          begin
118            Next;            FindNext;
119            continue;            continue;
120          end;          end;
121          if Filtered = true then          i := IWList1.Items.IndexOfName(s);
122          begin          if i = -1 then
123            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  
124          else          else
125          begin          begin
126            i := IWList1.Items.IndexOf(s);            j := IWList1.Items.ValueFromIndex[i].ToInteger + 1;
127            if i = -1 then            IWList1.Items[i] := s + '=' + j.ToString;
             IWList1.Items.Add(s);  
128          end;          end;
129            FindNext;
130          end;
131        end
132        else
133        begin
134          First;
135          while Eof = false do
136          begin
137            s := FieldByName('CATEGORY').AsString;
138            if s = '' then
139            begin
140              Next;
141              continue;
142            end;
143            i := IWList1.Items.IndexOf(s);
144            if i = -1 then
145              IWList1.Items.Add(s);
146          Next;          Next;
147        end;        end;
148      end;      end;
149      end;
150    if DM.FDTable2.Filtered = true then    if DM.FDTable2.Filtered = true then
151      for i := 0 to IWList1.Items.Count - 1 do      for i := 0 to IWList1.Items.Count - 1 do
152      begin      begin
# Line 167  begin Line 156  begin
156        else        else
157          IWList1.Items[i] := IWList1.Items.Names[i] + '(' + s + ')';          IWList1.Items[i] := IWList1.Items.Names[i] + '(' + s + ')';
158      end;      end;
159    IWList3.Items.Clear;    IWList2.Items.Clear;
160    if Page = Info then    if Page = TPage.Info then
161    begin    begin
162      with DM.FDQuery1 do      with DM.FDQuery1 do
163      begin      begin
# Line 178  begin Line 167  begin
167        SQL.Add(' where number = :num;');        SQL.Add(' where number = :num;');
168        Params.ParamByName('num').AsInteger := UserSession.user_number;        Params.ParamByName('num').AsInteger := UserSession.user_number;
169        Open;        Open;
170        if RecordCount > 0 then        First;
171          i := 0;
172          while Eof = false do
173        begin        begin
174          First;          s := Fields.Fields[0].AsString + 'x' + Fields.Fields[1].AsString;
175          i := 0;          i := i + Fields.Fields[2].AsInteger;
176          while Eof = false do          IWList2.Items.Add(s);
177          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 + '円');  
178        end;        end;
179          IWList2.Items.Add(i.ToString + '円');
180        Close;        Close;
181      end;        IWList3.Items.Clear;
     IWList2.Items.Clear;  
     with DM.FDQuery1 do  
     begin  
182        SQL.Clear;        SQL.Clear;
183        SQL.Add('select name from recent_data join item_data');        SQL.Add('select name from recent_data join item_data');
184        SQL.Add(' on (recent_data.serial = item_data.serial)');        SQL.Add(' on (recent_data.serial = item_data.serial)');
185        SQL.Add(' where number = :num;');        SQL.Add(' where number = :num;');
186        //Params.ParamByName('num').AsInteger:=UserSession.user_number;        Params.ParamByName('num').AsInteger := UserSession.user_number;
187        Open;        Open;
188        if RecordCount > 0 then        First;
189          while Eof = false do
190        begin        begin
191          First;          IWList3.Items.Add(Fields.Fields[0].AsString);
192          while Eof = false do          Next;
         begin  
           IWList2.Items.Add(Fields.Fields[0].AsString);  
           Next;  
         end;  
193        end;        end;
194        Close;        Close;
195      end;      end;
196    end;    end;
   x := Page = Info;  
   IWRegion4.Visible := x;  
   IWLabel2.Visible := x;  
   IWDBLabel1.Visible := x;  
   IWLink2.Visible := not x;  
197    LoadImage;    LoadImage;
198  end;  end;
199    
200  procedure TTopForm.IWButton1Click(Sender: TObject);  procedure TIWForm1.IWButton1Click(Sender: TObject);
 const  
   filter = 'NAME LIKE ''%s''';  
201  begin  begin
202    if IWEdit1.Text = '' then    DM.FDTable2.Filtered := false;
203      DM.FDTable2.Filtered := false    if IWEdit1.Text <> '' then
   else  
204    begin    begin
205      DM.FDTable2.filter := Format(filter, ['%' + IWEdit1.Text + '%']);      DM.FDTable2.Filter := 'NAME like ' + QuotedStr('%'+IWEdit1.Text+'%');
206      DM.FDTable2.Filtered := true;      DM.FDTable2.Filtered := true;
207      IWLabel9.Text := IWEdit1.Text + 'を検索しています';      IWLabel6.Caption := IWEdit1.Text + 'を検索しています';
208    end;    end;
209    IWLabel9.Visible := DM.FDTable2.Filtered;    IWLabel6.Visible := DM.FDTable2.Filtered;
210  end;  end;
211    
212  procedure TTopForm.IWLink1Click(Sender: TObject);  procedure TIWForm1.IWLink1Click(Sender: TObject);
213  const  begin
214    filter = 'EMAIL = ''%s'' and PASSWORD = ''%s''';    TUserForm.Create(WebApplication).Show;
215    end;
216    
217    procedure TIWForm1.IWLink2Click(Sender: TObject);
218  begin  begin
219    case Page of    case Page of
220      Main:      Main:
221        begin        begin
222          DM.FDTable1.filter := Format(filter, [IWEdit2.Text, IWEdit3.Text]);          if DM.FDTable1.Locate('EMAIL;PASSWORD',
223          DM.FDTable1.Filtered := true;            VarArrayOf([IWEdit2.Text, IWEdit3.Text]), [loCaseInsensitive]) = true
224          if DM.FDTable1.RecordCount = 1 then          then
225          begin          begin
           IWLink1.Caption := 'ログアウト';  
226            Page := Info;            Page := Info;
227            UserSession.user_number := DM.FDTable1.FieldByName('NUMBER')            UserSession.user_number := DM.FDTable1.FieldByName('NUMBER')
228              .AsInteger;              .AsInteger;
# Line 259  begin Line 233  begin
233      Info:      Info:
234        begin        begin
235          DM.FDTable1.Filtered := false;          DM.FDTable1.Filtered := false;
         IWLink1.Caption := 'ログイン';  
236          Page := Main;          Page := Main;
         DM.FDQuery1.Params.ParamByName('num').AsInteger := 0;  
237        end;        end;
238    end;    end;
   IWLabel9.Visible := UserSession.user_number <> 0;  
239  end;  end;
240    
241  procedure TTopForm.IWLink2Click(Sender: TObject);  procedure TIWForm1.LoadImage;
 begin  
   UserSession.FPage := Info;  
   TUserForm.Create(WebApplication).Show;  
 end;  
   
 procedure TTopForm.LoadImage;  
242  var  var
243    i, j, k: integer;    s: TStream;
244    png: TPngImage;    png: TPngImage;
245    pic: TIWImageFile;    pic: TIWImageFile;
246    st: TStream;    i: Integer;
247      j: Integer;
248      k: Integer;
249  label label1;  label label1;
250  begin  begin
251    ClearImage;    ClearImage;
252    if DM.FDTable2.RecordCount > 0 then    exit;
253    begin    png:=TPngImage.Create;
254      IWGrid1.RowCount := (DM.FDTable2.RecordCount div IWGrid1.ColumnCount) + 1;    try
255        IWGrid1.RowCount := DM.FDTable2.RecordCount div IWGrid1.ColumnCount;
256      k := 1;      k := 1;
257      DM.FDTable2.Last;      for i := 0 to IWGrid1.RowCount - 1 do
258      png := TPngImage.Create;        for j := 0 to IWGrid1.ColumnCount - 1 do
     try  
       for i := 0 to IWGrid1.RowCount - 1 do  
259        begin        begin
260          for j := 0 to IWGrid1.ColumnCount - 1 do          s := DM.FDTable2.CreateBlobStream
261          begin            (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
262            st := DM.FDTable2.CreateBlobStream          try
263              (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);            png.LoadFromStream(s);
264            try            pic := TIWImageFile.Create(IWGrid1);
265              png.LoadFromStream(st);            pic.Picture.Assign(png);
266              pic := TIWImageFile.Create(Self);            IWGrid1.Cell[i, j].Control := pic;
267              pic.Picture.Assign(png);            IWGrid1.Cell[i, j].Text := k.ToString;
268              IWGrid1.Cell[i, j].Control := pic;            inc(k);
269              IWGrid1.Cell[i, j].Text := k.ToString;          finally
270              inc(k);            s.Free;
             DM.FDTable2.Prior;  
           finally  
             st.Free;  
           end;  
           if DM.FDTable2.Bof = true then  
             goto label1;  
271          end;          end;
272            if DM.FDTable2.Bof = true then
273              goto label1;
274        end;        end;
275      label1:    label1:
276      finally    finally
277        png.Free;      png.Free;
278      end;    end;
   end  
   else  
     IWGrid1.RowCount := 0;  
   st := nil;  
279    png := nil;    png := nil;
280      s := nil;
281    Randomize;    Randomize;
282    DM.FDTable2.Last;    DM.FDTable2.Last;
283    DM.FDTable2.MoveBy(-Random(DM.FDTable2.RecordCount div 5));    DM.FDTable2.MoveBy(-Random(DM.FDTable2.RecordCount div 5));
284    st := DM.FDTable2.CreateBlobStream    s := DM.FDTable2.CreateBlobStream
285      (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);      (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
286    png := TPngImage.Create;    png := TPngImage.Create;
287    try    try
288      png.LoadFromStream(st);      png.LoadFromStream(s);
289      IWImageFile1.Picture.Assign(png);      IWImageFile1.Picture.Assign(png);
290    finally    finally
     st.Free;  
291      png.Free;      png.Free;
292        s.Free;
293    end;    end;
294    IWLabel4.Caption := DM.FDTable2.FieldByName('NAME').AsString;    IWLabel4.Caption := DM.FDTable2.FieldByName('NAME').AsString;
295  end;  end;
296    
297  procedure TTopForm.SetPage(const Value: TPage);  procedure TIWForm1.SetPage(const Value: TPage);
298  var  var
299    s: string;    x: Boolean;
300  begin  begin
301    UserSession.FPage := Value;    UserSession.FPage := Value;
302    case Value of    x := Value = Info;
303      Main:    IWRegion7.Visible := x;
304        s := 'toppage.htm';    IWLabel6.Visible := x;
305      Info:    IWDBLabel1.Visible := x;
306        s := 'mypage.htm';    IWLink1.Visible := not x;
307      IWText1.Visible := not x;
308      if x = true then
309      begin
310        IWLabel1.Caption := 'ようこそ';
311        IWLink2.Caption := 'ログアウト';
312      end
313      else
314      begin
315        IWLabel1.Caption := 'ようこそゲスト様';
316        IWLink2.Caption := 'ログイン';
317    end;    end;
   IWTemplateProcessorHTML1.Templates.Default := s;  
318  end;  end;
319    
320  initialization  initialization
321    
322  TTopForm.SetAsMainForm;  TIWForm1.SetAsMainForm;
323    
324  end.  end.

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

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