Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (show annotations) (download) (as text)
Fri Aug 5 10:33:26 2016 UTC (7 years, 8 months ago) by yamat0jp
File MIME type: text/x-pascal
File size: 14699 byte(s)
TDataSetNotifyEventの切り替え方法がはっきりわかりませんでしたが適当に実装しました。
1 unit Unit1;
2
3 interface
4
5 uses
6 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 IWVCLBaseControl, IWBaseControl, IWBaseHTMLControl, IWControl, IWCompLabel,
11 IWCompGrids, IWCompText, IWCompTabControl, IWCompButton, IWCompEdit,
12 IWHTMLControls, IWCompExtCtrls, PngImage, Data.DB,
13 IWCompListbox, IWBaseComponent, IWBaseHTMLComponent, IWBaseHTML40Component,
14 IWCompMenu, Vcl.Menus, System.Variants, Vcl.Dialogs, System.UITypes, Unit8;
15
16 type
17 TIWForm1 = class(TIWAppForm)
18 IWTemplateProcessorHTML1: TIWTemplateProcessorHTML;
19 IWLabel1: TIWLabel;
20 IWDBLabel1: TIWDBLabel;
21 IWRegion1: TIWRegion;
22 IWRegion2: TIWRegion;
23 IWText1: TIWText;
24 IWGrid1: TIWGrid;
25 IWRegion3: TIWRegion;
26 IWRegion4: TIWRegion;
27 IWLink1: TIWLink;
28 IWLabel2: TIWLabel;
29 IWList1: TIWList;
30 IWLabel3: TIWLabel;
31 IWEdit1: TIWEdit;
32 IWButton1: TIWButton;
33 IWEdit2: TIWEdit;
34 IWEdit3: TIWEdit;
35 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 IWLink7: TIWLink;
54 procedure IWAppFormRender(Sender: TObject);
55 procedure IWLink2Click(Sender: TObject);
56 procedure IWAppFormCreate(Sender: TObject);
57 procedure IWButton1Click(Sender: TObject);
58 procedure IWLink1Click(Sender: TObject);
59 procedure IWGrid1CellClick(ASender: TObject; const ARow, AColumn: Integer);
60 procedure IWFrame8IWButton1Click(Sender: TObject);
61 procedure IWFrame8IWLink1Click(Sender: TObject);
62 procedure IWLink4Click(Sender: TObject);
63 procedure IWLink3Click(Sender: TObject);
64 procedure IWLink5Click(Sender: TObject);
65 procedure IWLink6Click(Sender: TObject);
66 private
67 Filter: Boolean;
68 function GetPage: Boolean;
69 procedure SetPage(const Value: Boolean);
70 procedure LoadImage;
71 procedure ClearImage;
72 function GetThumbnail: Boolean;
73 procedure CallBack(EventParams: TStringList);
74 procedure SetThumbnail(const Value: Boolean);
75 public
76 property Page: Boolean read GetPage write SetPage;
77 property Thumbnail: Boolean read GetThumbnail write SetThumbnail;
78 end;
79
80 var
81 IWForm1: TIWForm1;
82
83 implementation
84
85 {$R *.dfm}
86
87 uses Unit3, ServerController, Unit6, Unit4, Unit9, Unit10, Unit5, Unit11;
88
89 procedure TIWForm1.CallBack(EventParams: TStringList);
90 begin
91 if SameText(EventParams.Values['RetValue'], 'true') = true then
92 TCartForm.Create(WebApplication).Show;
93 IWFrame8.IWEdit1.Text := '0';
94 end;
95
96 procedure TIWForm1.ClearImage;
97 var
98 i: Integer;
99 j: Integer;
100 begin
101 for i := 0 to IWGrid1.RowCount - 1 do
102 for j := 0 to IWGrid1.ColumnCount - 1 do
103 IWGrid1.Cell[i, j].Control.Free;
104 IWGrid1.RowCount := 0;
105 end;
106
107 function TIWForm1.GetPage: Boolean;
108 begin
109 result := UserSession.FPage;
110 end;
111
112 function TIWForm1.GetThumbnail: Boolean;
113 begin
114 result := UserSession.FThumbnail;
115 end;
116
117 procedure TIWForm1.IWAppFormCreate(Sender: TObject);
118 const
119 i = 120;
120 var
121 s: Integer;
122 begin
123 IWForm1 := Self;
124 Page := UserSession.FPage;
125 Thumbnail := UserSession.FThumbnail;
126 s := DM.FDTable3.FieldByName('BGCOLOR').AsInteger;
127 IWLabel2.BGColor := s;
128 IWLabel3.BGColor := s;
129 IWLabel5.BGColor := s;
130 IWLabel7.BGColor := s;
131 IWLabel8.BGColor := s;
132 IWRegion1.Width := i;
133 IWRegion2.Width := i;
134 IWRegion4.Width := i;
135 IWRegion5.Width := i;
136 IWRegion6.Width := i;
137 IWRegion7.Width := i;
138 WebApplication.RegisterCallBack('callback', CallBack);
139 end;
140
141 procedure TIWForm1.IWAppFormRender(Sender: TObject);
142 var
143 s: string;
144 i, j: Integer;
145 begin
146 IWList1.Items.Clear;
147 with DM.FDTable2 do
148 begin
149 if Filtered = true then
150 begin
151 FindFirst;
152 while Found = true do
153 begin
154 s := FieldByName('CATEGORY').AsString;
155 if s = '' then
156 begin
157 FindNext;
158 continue;
159 end;
160 i := IWList1.Items.IndexOfName(s);
161 if i = -1 then
162 IWList1.Items.Add(s + '=1')
163 else
164 begin
165 j := IWList1.Items.ValueFromIndex[i].ToInteger + 1;
166 IWList1.Items[i] := s + '=' + j.ToString;
167 end;
168 FindNext;
169 end;
170 end
171 else
172 begin
173 First;
174 while Eof = false do
175 begin
176 s := FieldByName('CATEGORY').AsString;
177 if s = '' then
178 begin
179 Next;
180 continue;
181 end;
182 i := IWList1.Items.IndexOf(s);
183 if i = -1 then
184 IWList1.Items.Add(s);
185 Next;
186 end;
187 end;
188 end;
189 if DM.FDTable2.Filtered = true then
190 for i := 0 to IWList1.Items.Count - 1 do
191 begin
192 s := IWList1.Items.ValueFromIndex[i];
193 if s = '1' then
194 IWList1.Items[i] := IWList1.Items.Names[i]
195 else
196 IWList1.Items[i] := IWList1.Items.Names[i] + '(' + s + ')';
197 end;
198 IWList2.Items.Clear;
199 with DM.FDQuery1 do
200 begin
201 SQL.Clear;
202 SQL.Add('select volume,name,price from cart_data,item_data');
203 SQL.Add(' where cart_data.serial = item_data.serial');
204 SQL.Add(' and number = :num;');
205 ParamByName('num').AsInteger := UserSession.user_number;
206 Open;
207 First;
208 i := 0;
209 while Eof = false do
210 begin
211 s := Fields.Fields[0].AsString + 'x' + Fields.Fields[1].AsString;
212 i := i + Fields.Fields[0].AsInteger * Fields.Fields[2].AsInteger;
213 IWList2.Items.Add(s);
214 Next;
215 end;
216 IWList2.Items.Add(i.ToString + '�~');
217 Close;
218 IWList3.Items.Clear;
219 SQL.Clear;
220 SQL.Add('select name from recent_data,item_data');
221 SQL.Add(' where recent_data.serial = item_data.serial');
222 SQL.Add(' and number = :num;');
223 ParamByName('num').AsInteger := UserSession.user_number;
224 Open;
225 First;
226 while Eof = false do
227 begin
228 IWList3.Items.Add(Fields.Fields[0].AsString);
229 Next;
230 end;
231 Close;
232 end;
233 LoadImage;
234 if IWGrid1.Visible = true then
235 IWLabel6.Visible := Filter
236 else
237 DM.FDTable2.Locate('SERIAL',UserSession.Serial);
238 end;
239
240 procedure TIWForm1.IWButton1Click(Sender: TObject);
241 var
242 i: Integer;
243 begin
244 IWFrame8IWLink1Click(Sender);
245 if IWEdit1.Text <> '' then
246 begin
247 DM.FDTable2.Filter := 'NAME like ' + QuotedStr('%' + IWEdit1.Text + '%');
248 DM.FDTable2.Filtered := true;
249 i := DM.FDTable2.RecordCount;
250 IWLabel6.Caption := Format(IWEdit1.Text + '����������������:%d��', [i]);
251 if i = 0 then
252 DM.FDTable2.Filtered := false;
253 Filter := true;
254 end
255 else
256 begin
257 DM.FDTable2.Filtered := false;
258 Filter := false;
259 end;
260 end;
261
262 procedure TIWForm1.IWFrame8IWButton1Click(Sender: TObject);
263 var
264 i, j: Integer;
265 s: string;
266 begin
267 if TryStrToInt(IWFrame8.IWEdit1.Text, i) = false then
268 begin
269 WebApplication.ShowMessage('�������s������');
270 Exit;
271 end;
272 if i = 0 then
273 begin
274 WebApplication.ShowMessage('�P�����������������K�v����');
275 Exit;
276 end;
277 s := WebApplication.Request.CookieFields.Values['user_cookie'];
278 if s = '' then
279 begin
280 DM.FDTable1.Last;
281 j := DM.FDTable1.FieldByName('NUMBER').AsInteger + 1;
282 while DM.FDTable1.Lookup('NUMBER', j, 'NUMBER') = j do
283 inc(j);
284 UserSession.user_number := j;
285 DM.FDTable1.AppendRecord([nil, nil, nil, nil, nil, nil,
286 UserSession.user_number, Date]);
287 WebApplication.Response.Cookies.AddCookie('user_cookie',
288 UserSession.user_number.ToString, '/', Date + 10);
289 end;
290 with DM.FDQuery1 do
291 begin
292 Open('select * from cart_data;');
293 if Locate('NUMBER;SERIAL', VarArrayOf([UserSession.user_number,
294 UserSession.Serial]), []) = true then
295 begin
296 Edit;
297 FieldByName('VOLUME').AsInteger := FieldByName('VOLUME').AsInteger + i;
298 Post;
299 end
300 else
301 AppendRecord([nil, i, UserSession.user_number, UserSession.Serial]);
302 end;
303 WebApplication.ShowConfirm('�J�[�g��������������', 'callback', '����', '����', '������');
304 end;
305
306 procedure TIWForm1.IWFrame8IWLink1Click(Sender: TObject);
307 begin
308 Thumbnail := true;
309 end;
310
311 procedure TIWForm1.IWGrid1CellClick(ASender: TObject;
312 const ARow, AColumn: Integer);
313 begin
314 Thumbnail := false;
315 UserSession.Serial := Integer(IWGrid1.Cell[ARow, AColumn].Tag);
316 end;
317
318 procedure TIWForm1.IWLink1Click(Sender: TObject);
319 begin
320 TUserForm.Create(WebApplication).Show;
321 end;
322
323 procedure TIWForm1.IWLink2Click(Sender: TObject);
324 var
325 i: Integer;
326 begin
327 if Page = true then
328 begin
329 i := UserSession.user_number;
330 if (DM.FDTable1.Locate('EMAIL;PASSWORD',
331 VarArrayOf([IWEdit2.Text, UserSession.hash(IWEdit3.Text)]),
332 [loCaseInsensitive]) = true) and
333 (DM.FDTable1.FieldByName('EMAIL').AsString <> '') then
334 begin
335 IWEdit2.Text := '';
336 UserSession.user_number := DM.FDTable1.FieldByName('NUMBER').AsInteger;
337 if i <> 0 then
338 begin
339 with DM.FDQuery1 do
340 begin
341 Open('select * from user_data where number = :num', [i]);
342 Delete;
343 Open('select number from cart_data where number = :num;', [i]);
344 First;
345 while Eof = false do
346 begin
347 Edit;
348 FieldByName('number').AsInteger := UserSession.user_number;
349 Next;
350 end;
351 end;
352 end;
353 Page := false;
354 end;
355 IWEdit3.Text := '';
356 end
357 else
358 Page := true;
359 end;
360
361 procedure TIWForm1.IWLink3Click(Sender: TObject);
362 begin
363 with TMyPage.Create(WebApplication) do
364 begin
365 Form := Self;
366 Show;
367 end;
368 end;
369
370 procedure TIWForm1.IWLink4Click(Sender: TObject);
371 begin
372 TCartForm.Create(WebApplication).Show;
373 end;
374
375 procedure TIWForm1.IWLink5Click(Sender: TObject);
376 begin
377 TIWForm10.Create(WebApplication).Show;
378 end;
379
380 procedure TIWForm1.IWLink6Click(Sender: TObject);
381 begin
382 Page := true;
383 if Sender = IWLink6 then
384 TAdminPage.Create(WebApplication).Show
385 else
386 TAdminFile.Create(WebApplication).Show;
387 end;
388
389 procedure TIWForm1.LoadImage;
390 var
391 s: TStream;
392 png: TPngImage;
393 pic: TIWImage;
394 i: Integer;
395 j: Integer;
396 t: string;
397 label label1;
398 begin
399 ClearImage;
400 png := TPngImage.Create;
401 try
402 if Thumbnail = true then
403 begin
404 i := DM.FDTable2.RecordCount div IWGrid1.ColumnCount;
405 if DM.FDTable2.RecordCount mod IWGrid1.ColumnCount > 0 then
406 inc(i);
407 IWGrid1.RowCount := i;
408 if DM.FDTable2.Filtered = false then
409 DM.FDTable2.Last
410 else
411 DM.FDTable2.FindLast;
412 for i := 0 to IWGrid1.RowCount - 1 do
413 for j := 0 to IWGrid1.ColumnCount - 1 do
414 begin
415 if DM.FDTable2.Filtered = false then
416 begin
417 if DM.FDTable2.Bof = true then
418 goto label1;
419 end
420 else if DM.FDTable2.Found = false then
421 goto label1;
422 if DM.FDTable2.FieldByName('THUMBNAIL').IsNull = false then
423 begin
424 s := DM.FDTable2.CreateBlobStream
425 (DM.FDTable2.FieldByName('THUMBNAIL'), bmRead);
426 try
427 png.LoadFromStream(s);
428 finally
429 s.Free;
430 end;
431 pic := TIWImage.Create(IWGrid1);
432 pic.Picture.Assign(png);
433 IWGrid1.Cell[i, j].Control := pic;
434 end;
435 t := DM.FDTable2.FieldByName('NAME').AsString;
436 if Length(t) > 10 then
437 t := Copy(t, 1, 8) + '..';
438 IWGrid1.Cell[i, j].Tag :=
439 Pointer(DM.FDTable2.FieldByName('SERIAL').AsInteger);
440 IWGrid1.Cell[i, j].Text := t;
441 IWGrid1.Cell[i, j].Alignment := taCenter;
442 IWGrid1.Cell[i, j].Clickable := true;
443 if DM.FDTable2.Filtered = false then
444 DM.FDTable2.Prior
445 else
446 DM.FDTable2.FindPrior;
447 end;
448 label1:
449 end
450 else if DM.FDTable2.Locate('SERIAL', UserSession.Serial, []) = true then
451 if DM.FDTable2.FieldByName('IMAGE').IsNull = false then
452 begin
453 s := DM.FDTable2.CreateBlobStream
454 (DM.FDTable2.FieldByName('IMAGE'), bmRead);
455 try
456 png.LoadFromStream(s);
457 finally
458 s.Free;
459 end;
460 IWFrame8.IWImage1.Picture.Assign(png);
461 end
462 else
463 IWFrame8.IWImage1.Picture.Assign(nil);
464 finally
465 png.Free;
466 end;
467 Randomize;
468 DM.FDTableView.Filter := 'DATE > '+QuotedStr(DateTimeToStr(Date-10));
469 DM.FDTableView.First;
470 DM.FDTableView.MoveBy(Random(DM.FDTableView.RecordCount));
471 if DM.FDTableView.FieldByName('THUMBNAIL').IsNull = false then
472 begin
473 s := DM.FDTableView.CreateBlobStream
474 (DM.FDTableView.FieldByName('THUMBNAIL'), bmRead);
475 png := TPngImage.Create;
476 try
477 png.LoadFromStream(s);
478 IWImage1.Picture.Assign(png);
479 finally
480 png.Free;
481 s.Free;
482 end;
483 end;
484 IWLabel4.Caption := DM.FDTableView.FieldByName('NAME').AsString;
485 end;
486
487 procedure TIWForm1.SetPage(const Value: Boolean);
488 begin
489 UserSession.FPage := Value;
490 IWRegion7.Visible := not Value;
491 IWDBLabel1.Visible := not Value;
492 IWLink3.Visible := not Value;
493 IWLink1.Visible := Value;
494 IWText1.Visible := Value;
495 if Value = false then
496 begin
497 IWLabel1.Caption := '��������';
498 IWLink2.Caption := '���O�A�E�g';
499 WebApplication.Response.Cookies.AddCookie('user_cookie',
500 UserSession.user_number.ToString, '/', Date + 10);
501 end
502 else
503 begin
504 IWLabel1.Caption := '���������Q�X�g�l';
505 IWLink2.Caption := '���O�C��';
506 Thumbnail := true;
507 IWText1.Text := '';
508 DM.FDTable2.Filtered := false;
509 Filter := false;
510 if DM.FDTable1.FieldByName('EMAIL').AsString <> '' then
511 begin
512 WebApplication.Response.Cookies.AddCookie('user_cookie', '0', '/',
513 Date - 1);
514 UserSession.user_number := 0;
515 end;
516 end;
517 end;
518
519 procedure TIWForm1.SetThumbnail(const Value: Boolean);
520 begin
521 UserSession.FThumbnail := Value;
522 IWGrid1.Visible := Value;
523 IWFrame8.Visible := not Value;
524 end;
525
526 initialization
527
528 TIWForm1.SetAsMainForm;
529
530 end.

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