Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


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

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