| 7 |
IWVCLBaseControl, IWBaseControl, IWBaseHTMLControl, IWControl, IWCompGrids, |
IWVCLBaseControl, IWBaseControl, IWBaseHTMLControl, IWControl, IWCompGrids, |
| 8 |
IWDBGrids, IWCompButton, IWCompExtCtrls, IWVCLComponent, |
IWDBGrids, IWCompButton, IWCompExtCtrls, IWVCLComponent, |
| 9 |
IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout, |
IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout, |
| 10 |
IWTemplateProcessorHTML; |
IWTemplateProcessorHTML, PngImage, Data.DB; |
| 11 |
|
|
| 12 |
type |
type |
| 13 |
TCartForm = class(TIWAppForm) |
TCartForm = class(TIWAppForm) |
|
IWDBGrid1: TIWDBGrid; |
|
| 14 |
IWButton1: TIWButton; |
IWButton1: TIWButton; |
| 15 |
IWButton2: TIWButton; |
IWButton2: TIWButton; |
| 16 |
IWTemplateProcessorHTML1: TIWTemplateProcessorHTML; |
IWTemplateProcessorHTML1: TIWTemplateProcessorHTML; |
| 17 |
|
IWGrid1: TIWGrid; |
| 18 |
procedure IWAppFormCreate(Sender: TObject); |
procedure IWAppFormCreate(Sender: TObject); |
| 19 |
procedure IWAppFormDestroy(Sender: TObject); |
procedure IWAppFormDestroy(Sender: TObject); |
| 20 |
procedure IWButton1Click(Sender: TObject); |
procedure IWButton1Click(Sender: TObject); |
| 25 |
|
|
| 26 |
{$R *.dfm} |
{$R *.dfm} |
| 27 |
|
|
| 28 |
uses Unit4, Unit1, Unit8, ServerController; |
uses Unit3, Unit1, ServerController, Unit4; |
| 29 |
|
|
| 30 |
procedure TCartForm.IWAppFormCreate(Sender: TObject); |
procedure TCartForm.IWAppFormCreate(Sender: TObject); |
| 31 |
var |
var |
| 32 |
i: integer; |
i: integer; |
| 33 |
s, t: TIWDBGridColumn; |
s: TStream; |
| 34 |
|
png: TPngImage; |
| 35 |
|
img: TIWImageFile; |
| 36 |
j: integer; |
j: integer; |
| 37 |
begin |
begin |
| 38 |
with DM.FDQuery1 do |
with DM.FDQuery1 do |
| 39 |
begin |
begin |
| 40 |
SQL.Clear; |
SQL.Clear; |
| 41 |
SQL.Add('select name,maker,image,volume,price'); |
SQL.Add('select name,maker,thumbnail,volume,price'); |
| 42 |
SQL.Add(' from item_data join cart_data'); |
SQL.Add(' from item_data join cart_data'); |
| 43 |
SQL.Add(' on (item_data.serial = cart_data.serial) where number = :num;'); |
SQL.Add(' on (item_data.serial = cart_data.serial) where number = :num;'); |
| 44 |
Params.ParamByName('num').AsInteger := UserSession.user_number; |
Params.ParamByName('num').AsInteger := UserSession.user_number; |
| 45 |
Open; |
Open; |
| 46 |
end; |
end; |
| 47 |
for i := 0 to DM.FDQuery1.Fields.Count - 1 do |
IWGrid1.ColumnCount := DM.FDQuery1.Fields.Count; |
| 48 |
|
IWGrid1.RowCount := DM.FDQuery1.RecordCount; |
| 49 |
|
for i := 0 to IWGrid1.RowCount - 1 do |
| 50 |
begin |
begin |
| 51 |
s := IWDBGrid1.Columns.Add as TIWDBGridColumn; |
png := TPngImage.Create; |
| 52 |
if i = 2 then |
try |
| 53 |
begin |
for j := 0 to IWGrid1.ColumnCount - 1 do |
|
s.Title.Text := 'IMAGE'; |
|
|
for j := 1 to s.Collection.Count - 1 do |
|
| 54 |
begin |
begin |
| 55 |
t := s.Collection.Items[j] as TIWDBGridColumn; |
case j of |
| 56 |
t.Control := TIWImageFile.Create(IWDBGrid1); |
2: |
| 57 |
|
begin |
| 58 |
|
s := DM.FDQuery1.CreateBlobStream |
| 59 |
|
(DM.FDQuery1.FieldByName('THUMBNAIL'), bmRead); |
| 60 |
|
try |
| 61 |
|
png.LoadFromStream(s); |
| 62 |
|
img:=TIWImageFile.Create(IWGrid1); |
| 63 |
|
img.Picture.Assign(png); |
| 64 |
|
IWGrid1.Cell[i, j].Control :=img; |
| 65 |
|
finally |
| 66 |
|
s.Free; |
| 67 |
|
end; |
| 68 |
|
end; |
| 69 |
|
4: |
| 70 |
|
IWGrid1.Cell[i, j].Text := |
| 71 |
|
(DM.FDQuery1.Fields[3].AsInteger * DM.FDQuery1.Fields[4] |
| 72 |
|
.AsInteger).ToString; |
| 73 |
|
else |
| 74 |
|
IWGrid1.Cell[i, j].Text := DM.FDQuery1.Fields[j].AsString; |
| 75 |
|
end; |
| 76 |
end; |
end; |
| 77 |
end |
finally |
| 78 |
else |
png.Free; |
| 79 |
s.DataField := DM.FDQuery1.Fields[i].FieldName; |
end; |
| 80 |
|
DM.FDQuery1.Next; |
| 81 |
end; |
end; |
| 82 |
end; |
end; |
| 83 |
|
|
| 84 |
procedure TCartForm.IWAppFormDestroy(Sender: TObject); |
procedure TCartForm.IWAppFormDestroy(Sender: TObject); |
|
var |
|
|
i: integer; |
|
|
s: TIWDBGridColumn; |
|
| 85 |
begin |
begin |
| 86 |
DM.FDQuery1.Close; |
DM.FDQuery1.Close; |
|
s := IWDBGrid1.Columns.Items[2] as TIWDBGridColumn; |
|
|
for i := 0 to s.Collection.Count - 1 do |
|
|
s.Control.Free; |
|
| 87 |
end; |
end; |
| 88 |
|
|
| 89 |
procedure TCartForm.IWButton1Click(Sender: TObject); |
procedure TCartForm.IWButton1Click(Sender: TObject); |
| 92 |
if Sender = IWButton1 then |
if Sender = IWButton1 then |
| 93 |
TPayForm.Create(WebApplication).Show |
TPayForm.Create(WebApplication).Show |
| 94 |
else |
else |
| 95 |
TTopForm.Create(WebApplication).Show; |
TIWForm1.Create(WebApplication).Show; |
| 96 |
end; |
end; |
| 97 |
|
|
| 98 |
end. |
end. |