Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (hide annotations) (download) (as text)
Tue Dec 29 08:41:54 2015 UTC (8 years, 3 months ago) by yamat0jp
File MIME type: text/x-pascal
File size: 12076 byte(s)
だんだんとできてきました
1 yamat0jp 1 unit Unit1;
2    
3     interface
4    
5     uses
6 yamat0jp 2 Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWVCLComponent,
7     IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout,
8     IWTemplateProcessorHTML, Vcl.Controls, Vcl.Forms, Unit2, IWVCLBaseContainer,
9     IWContainer, IWHTMLContainer, IWHTML40Container, IWRegion, IWDBStdCtrls,
10 yamat0jp 1 IWVCLBaseControl, IWBaseControl, IWBaseHTMLControl, IWControl, IWCompLabel,
11 yamat0jp 2 IWCompGrids, IWCompText, IWCompTabControl, IWCompButton, IWCompEdit,
12 yamat0jp 3 IWHTMLControls, IWCompExtCtrls, UserSessionUnit, PngImage, Data.DB,
13     IWCompListbox, IWBaseComponent, IWBaseHTMLComponent, IWBaseHTML40Component,
14 yamat0jp 5 IWCompMenu, Vcl.Menus, System.Variants, Unit8, Vcl.Dialogs;
15 yamat0jp 1
16     type
17 yamat0jp 2 TIWForm1 = class(TIWAppForm)
18     IWFrame1: TIWFrame1;
19     IWTemplateProcessorHTML1: TIWTemplateProcessorHTML;
20     IWLabel1: TIWLabel;
21     IWDBLabel1: TIWDBLabel;
22 yamat0jp 1 IWRegion1: TIWRegion;
23 yamat0jp 2 IWRegion2: TIWRegion;
24     IWText1: TIWText;
25     IWGrid1: TIWGrid;
26     IWRegion3: TIWRegion;
27     IWRegion4: TIWRegion;
28 yamat0jp 1 IWLink1: TIWLink;
29     IWLabel2: TIWLabel;
30 yamat0jp 2 IWList1: TIWList;
31 yamat0jp 1 IWLabel3: TIWLabel;
32     IWEdit1: TIWEdit;
33     IWButton1: TIWButton;
34 yamat0jp 2 IWEdit2: TIWEdit;
35     IWEdit3: TIWEdit;
36     IWLink2: TIWLink;
37     IWRegion5: TIWRegion;
38     IWLabel7: TIWLabel;
39     IWRegion6: TIWRegion;
40     IWLabel8: TIWLabel;
41     IWList2: TIWList;
42     IWLabel4: TIWLabel;
43 yamat0jp 1 IWRegion7: TIWRegion;
44 yamat0jp 2 IWLabel5: TIWLabel;
45     IWLabel6: TIWLabel;
46 yamat0jp 1 IWList3: TIWList;
47 yamat0jp 5 IWImage1: TIWImage;
48     IWFrame8: TIWFrame8;
49     IWLink3: TIWLink;
50     IWLink4: TIWLink;
51 yamat0jp 1 procedure IWAppFormRender(Sender: TObject);
52 yamat0jp 2 procedure IWLink2Click(Sender: TObject);
53 yamat0jp 1 procedure IWAppFormCreate(Sender: TObject);
54     procedure IWButton1Click(Sender: TObject);
55 yamat0jp 2 procedure IWLink1Click(Sender: TObject);
56 yamat0jp 5 procedure IWGrid1CellClick(ASender: TObject; const ARow, AColumn: Integer);
57     procedure IWFrame8IWButton1Click(Sender: TObject);
58     procedure IWFrame8IWLink1Click(Sender: TObject);
59     procedure IWLink3Click(Sender: TObject);
60     procedure IWLink4Click(Sender: TObject);
61 yamat0jp 1 private
62 yamat0jp 5 Filter: Boolean;
63 yamat0jp 2 function GetPage: TPage;
64 yamat0jp 1 procedure SetPage(const Value: TPage);
65     procedure LoadImage;
66     procedure ClearImage;
67     public
68     property Page: TPage read GetPage write SetPage;
69     end;
70    
71     implementation
72    
73     {$R *.dfm}
74    
75 yamat0jp 5 uses Unit3, ServerController, Unit6, Unit4;
76 yamat0jp 1
77 yamat0jp 2 procedure TIWForm1.ClearImage;
78 yamat0jp 1 var
79 yamat0jp 2 i: Integer;
80     j: Integer;
81 yamat0jp 1 begin
82 yamat0jp 2 for i := 0 to IWGrid1.RowCount - 1 do
83     for j := 0 to IWGrid1.ColumnCount - 1 do
84     IWGrid1.Cell[i, j].Control.Free;
85 yamat0jp 5 IWGrid1.RowCount := 0;
86 yamat0jp 1 end;
87    
88 yamat0jp 2 function TIWForm1.GetPage: TPage;
89 yamat0jp 1 begin
90     result := UserSession.FPage;
91     end;
92    
93 yamat0jp 2 procedure TIWForm1.IWAppFormCreate(Sender: TObject);
94 yamat0jp 3 const
95     i = 120;
96     var
97     s: Integer;
98 yamat0jp 1 begin
99     Page := UserSession.FPage;
100 yamat0jp 3 s := DM.FDTable3.FieldByName('BGCOLOR').AsInteger;
101     IWLabel2.BGColor := s;
102     IWLabel3.BGColor := s;
103     IWLabel5.BGColor := s;
104 yamat0jp 4 IWLabel7.BGColor := s;
105     IWLabel8.BGColor := s;
106 yamat0jp 3 IWRegion1.Width := i;
107     IWRegion2.Width := i;
108     IWRegion4.Width := i;
109     IWRegion5.Width := i;
110     IWRegion6.Width := i;
111     IWRegion7.Width := i;
112 yamat0jp 1 end;
113    
114 yamat0jp 2 procedure TIWForm1.IWAppFormRender(Sender: TObject);
115 yamat0jp 1 var
116     s: string;
117 yamat0jp 2 i, j: Integer;
118 yamat0jp 1 begin
119     IWList1.Items.Clear;
120     with DM.FDTable2 do
121 yamat0jp 2 begin
122 yamat0jp 3 if Filtered = true then
123 yamat0jp 1 begin
124 yamat0jp 3 FindFirst;
125     while Found = true do
126 yamat0jp 1 begin
127 yamat0jp 3 s := FieldByName('CATEGORY').AsString;
128     if s = '' then
129     begin
130     FindNext;
131     continue;
132     end;
133 yamat0jp 2 i := IWList1.Items.IndexOfName(s);
134     if i = -1 then
135     IWList1.Items.Add(s + '=1')
136 yamat0jp 1 else
137     begin
138 yamat0jp 2 j := IWList1.Items.ValueFromIndex[i].ToInteger + 1;
139     IWList1.Items[i] := s + '=' + j.ToString;
140 yamat0jp 1 end;
141 yamat0jp 3 FindNext;
142     end;
143     end
144     else
145     begin
146     First;
147     while Eof = false do
148 yamat0jp 2 begin
149 yamat0jp 3 s := FieldByName('CATEGORY').AsString;
150     if s = '' then
151     begin
152     Next;
153     continue;
154     end;
155 yamat0jp 2 i := IWList1.Items.IndexOf(s);
156     if i = -1 then
157     IWList1.Items.Add(s);
158 yamat0jp 3 Next;
159 yamat0jp 1 end;
160     end;
161 yamat0jp 2 end;
162 yamat0jp 1 if DM.FDTable2.Filtered = true then
163     for i := 0 to IWList1.Items.Count - 1 do
164     begin
165     s := IWList1.Items.ValueFromIndex[i];
166     if s = '1' then
167     IWList1.Items[i] := IWList1.Items.Names[i]
168     else
169     IWList1.Items[i] := IWList1.Items.Names[i] + '(' + s + ')';
170     end;
171 yamat0jp 2 IWList2.Items.Clear;
172     if Page = TPage.Info then
173 yamat0jp 1 begin
174     with DM.FDQuery1 do
175     begin
176     SQL.Clear;
177     SQL.Add('select volume,name,price from cart_data join item_data');
178     SQL.Add(' on (cart_data.serial = item_data.serial)');
179     SQL.Add(' where number = :num;');
180     Params.ParamByName('num').AsInteger := UserSession.user_number;
181     Open;
182 yamat0jp 2 First;
183     i := 0;
184     while Eof = false do
185 yamat0jp 1 begin
186 yamat0jp 2 s := Fields.Fields[0].AsString + 'x' + Fields.Fields[1].AsString;
187 yamat0jp 4 i := i + Fields.Fields[0].AsInteger * Fields.Fields[2].AsInteger;
188 yamat0jp 2 IWList2.Items.Add(s);
189     Next;
190 yamat0jp 1 end;
191 yamat0jp 2 IWList2.Items.Add(i.ToString + '�~');
192 yamat0jp 1 Close;
193 yamat0jp 2 IWList3.Items.Clear;
194 yamat0jp 1 SQL.Clear;
195     SQL.Add('select name from recent_data join item_data');
196     SQL.Add(' on (recent_data.serial = item_data.serial)');
197     SQL.Add(' where number = :num;');
198 yamat0jp 2 Params.ParamByName('num').AsInteger := UserSession.user_number;
199 yamat0jp 1 Open;
200 yamat0jp 2 First;
201     while Eof = false do
202 yamat0jp 1 begin
203 yamat0jp 2 IWList3.Items.Add(Fields.Fields[0].AsString);
204     Next;
205 yamat0jp 1 end;
206     Close;
207     end;
208     end;
209 yamat0jp 5 if IWGrid1.Visible = true then
210     begin
211     IWLabel6.Visible := Filter;
212     LoadImage;
213     end
214     else
215     DM.FDTable2.Locate('SERIAL', UserSession.Serial, []);
216 yamat0jp 1 end;
217    
218 yamat0jp 2 procedure TIWForm1.IWButton1Click(Sender: TObject);
219 yamat0jp 5 var
220     i: Integer;
221 yamat0jp 1 begin
222 yamat0jp 5 IWFrame8IWLink1Click(Sender);
223 yamat0jp 3 if IWEdit1.Text <> '' then
224 yamat0jp 1 begin
225 yamat0jp 4 DM.FDTable2.Filter := 'NAME like ' + QuotedStr('%' + IWEdit1.Text + '%');
226 yamat0jp 1 DM.FDTable2.Filtered := true;
227 yamat0jp 5 i := DM.FDTable2.RecordCount;
228     IWLabel6.Caption := Format(IWEdit1.Text + '����������������:%d��', [i]);
229     if i = 0 then
230     DM.FDTable2.Filtered := false;
231     Filter := true;
232     end
233     else
234     begin
235     DM.FDTable2.Filtered := false;
236     Filter := false;
237 yamat0jp 1 end;
238     end;
239    
240 yamat0jp 5 procedure TIWForm1.IWFrame8IWButton1Click(Sender: TObject);
241     var
242     i: Integer;
243     begin
244     if TryStrToInt(IWFrame8.IWEdit1.Text, i) = false then
245     begin
246     WebApplication.ShowMessage('�������s������');
247     Exit;
248     end;
249     if i = 0 then
250     begin
251     WebApplication.ShowMessage('�P�����������������K�v����');
252     Exit;
253     end;
254     with DM.FDQuery1 do
255     begin
256     SQL.Clear;
257     SQL.Add('select * from cart_data;');
258     Open;
259     if Locate('NUMBER;SERIAL', VarArrayOf([UserSession.user_number,
260     UserSession.Serial]), []) = true then
261     begin
262     Edit;
263     FieldByName('VOLUME').AsInteger := FieldByName('VOLUME').AsInteger + i;
264     Post;
265     end
266     else
267     AppendRecord([nil, i, UserSession.user_number, UserSession.Serial]);
268     end;
269     IWFrame8.IWEdit1.Text := '0';
270     if MessageDlg('�J�[�g��������������', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
271     TCartForm.Create(WebApplication).Show;
272     end;
273    
274     procedure TIWForm1.IWFrame8IWLink1Click(Sender: TObject);
275     begin
276     UserSession.Thumbnail := true;
277     IWFrame8.Visible := false;
278     IWGrid1.Visible := true;
279     end;
280    
281     procedure TIWForm1.IWGrid1CellClick(ASender: TObject;
282     const ARow, AColumn: Integer);
283     begin
284     UserSession.Thumbnail := false;
285     IWFrame8.Visible := true;
286     IWFrame8.IWEdit1.Text := '1';
287     IWLabel6.Visible := false;
288     IWGrid1.Visible := false;
289     UserSession.Serial := Integer(IWGrid1.Cell[ARow, AColumn].Tag);
290     end;
291    
292 yamat0jp 2 procedure TIWForm1.IWLink1Click(Sender: TObject);
293     begin
294 yamat0jp 5 with TUserForm.Create(WebApplication) do
295     begin
296     Form := Self;
297     Show;
298     end;
299 yamat0jp 2 end;
300    
301     procedure TIWForm1.IWLink2Click(Sender: TObject);
302 yamat0jp 1 begin
303     case Page of
304     Main:
305     begin
306 yamat0jp 3 if DM.FDTable1.Locate('EMAIL;PASSWORD',
307     VarArrayOf([IWEdit2.Text, IWEdit3.Text]), [loCaseInsensitive]) = true
308     then
309 yamat0jp 1 begin
310     Page := Info;
311     UserSession.user_number := DM.FDTable1.FieldByName('NUMBER')
312     .AsInteger;
313     IWEdit2.Text := '';
314     end;
315     IWEdit3.Text := '';
316     end;
317     Info:
318     begin
319     DM.FDTable1.Filtered := false;
320     Page := Main;
321 yamat0jp 5 UserSession.user_number := 0;
322 yamat0jp 1 end;
323     end;
324     end;
325    
326 yamat0jp 5 procedure TIWForm1.IWLink3Click(Sender: TObject);
327     begin
328     WebApplication.ShowMessage('�n�j���N���b�N����������������');
329     Page := Main;
330     DM.FDTable1.Delete;
331     end;
332    
333     procedure TIWForm1.IWLink4Click(Sender: TObject);
334     begin
335     TCartForm.Create(WebApplication).Show;
336     end;
337    
338 yamat0jp 2 procedure TIWForm1.LoadImage;
339 yamat0jp 1 var
340 yamat0jp 2 s: TStream;
341 yamat0jp 1 png: TPngImage;
342 yamat0jp 5 pic: TIWImage;
343 yamat0jp 2 i: Integer;
344     j: Integer;
345 yamat0jp 5 x: Boolean;
346     t: string;
347 yamat0jp 3 label label1;
348 yamat0jp 1 begin
349     ClearImage;
350 yamat0jp 4 png := TPngImage.Create;
351 yamat0jp 2 try
352 yamat0jp 5 i := DM.FDTable2.RecordCount div IWGrid1.ColumnCount;
353     if DM.FDTable2.RecordCount mod IWGrid1.ColumnCount > 0 then
354     inc(i);
355     IWGrid1.RowCount := i;
356     if DM.FDTable2.Filtered = false then
357     DM.FDTable2.Last
358     else
359     DM.FDTable2.FindLast;
360 yamat0jp 2 for i := 0 to IWGrid1.RowCount - 1 do
361     for j := 0 to IWGrid1.ColumnCount - 1 do
362 yamat0jp 1 begin
363 yamat0jp 5 if DM.FDTable2.Filtered = false then
364     begin
365     if DM.FDTable2.Bof = true then
366     goto label1;
367     end
368     else if DM.FDTable2.Found = false then
369     goto label1;
370     if DM.FDTable2.FieldByName('THUMBNAIL').AsBytes <> nil then
371     begin
372     s := DM.FDTable2.CreateBlobStream
373     (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
374     try
375     png.LoadFromStream(s);
376     finally
377     s.Free;
378     end;
379 yamat0jp 1 end;
380 yamat0jp 5 t := DM.FDTable2.FieldByName('NAME').AsString;
381     if Length(t) > 10 then
382     t := Copy(t, 1, 8) + '..';
383     pic := TIWImage.Create(IWGrid1);
384     pic.Picture.Assign(png);
385     IWGrid1.Cell[i, j].Control := pic;
386     IWGrid1.Cell[i, j].Tag :=
387     Pointer(DM.FDTable2.FieldByName('SERIAL').AsInteger);
388     IWGrid1.Cell[i, j].Text := t;
389     IWGrid1.Cell[i, j].Alignment := taCenter;
390     IWGrid1.Cell[i, j].Clickable := true;
391     if DM.FDTable2.Filtered = false then
392     DM.FDTable2.Prior
393     else
394     DM.FDTable2.FindPrior;
395 yamat0jp 1 end;
396 yamat0jp 3 label1:
397 yamat0jp 1 finally
398     png.Free;
399     end;
400 yamat0jp 3 png := nil;
401     s := nil;
402     Randomize;
403 yamat0jp 5 if DM.FDTable2.Filtered = true then
404     begin
405     x := true;
406     DM.FDTable2.Filtered := false;
407     end
408     else
409     x := false;
410 yamat0jp 3 DM.FDTable2.Last;
411 yamat0jp 5 if DM.FDTable2.Bof = true then
412     Exit;
413 yamat0jp 3 DM.FDTable2.MoveBy(-Random(DM.FDTable2.RecordCount div 5));
414 yamat0jp 5 if DM.FDTable2.FieldByName('THUMBNAIL').AsBytes <> nil then
415 yamat0jp 4 begin
416     s := DM.FDTable2.CreateBlobStream
417     (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
418     png := TPngImage.Create;
419     try
420     png.LoadFromStream(s);
421 yamat0jp 5 IWImage1.Picture.Assign(png);
422 yamat0jp 4 finally
423     png.Free;
424     s.Free;
425     end;
426 yamat0jp 3 end;
427 yamat0jp 5 if x = true then
428     DM.FDTable2.Filtered := true;
429 yamat0jp 3 IWLabel4.Caption := DM.FDTable2.FieldByName('NAME').AsString;
430 yamat0jp 1 end;
431    
432 yamat0jp 2 procedure TIWForm1.SetPage(const Value: TPage);
433 yamat0jp 1 var
434 yamat0jp 2 x: Boolean;
435 yamat0jp 1 begin
436     UserSession.FPage := Value;
437 yamat0jp 2 x := Value = Info;
438     IWRegion7.Visible := x;
439     IWDBLabel1.Visible := x;
440 yamat0jp 5 IWLink3.Visible := x;
441 yamat0jp 2 IWLink1.Visible := not x;
442     IWText1.Visible := not x;
443     if x = true then
444     begin
445     IWLabel1.Caption := '��������';
446     IWLink2.Caption := '���O�A�E�g';
447     end
448     else
449     begin
450     IWLabel1.Caption := '���������Q�X�g�l';
451     IWLink2.Caption := '���O�C��';
452 yamat0jp 1 end;
453     end;
454    
455     initialization
456    
457 yamat0jp 2 TIWForm1.SetAsMainForm;
458 yamat0jp 1
459     end.

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