Develop and Download Open Source Software

Browse Subversion Repository

Diff of /Unit4.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5 by yamat0jp, Tue Dec 29 08:41:54 2015 UTC revision 12 by yamat0jp, Sun Jul 24 06:09:44 2016 UTC
# Line 6  uses Line 6  uses
6    Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWVCLComponent,    Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWVCLComponent,
7    IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout,    IWBaseLayoutComponent, IWBaseContainerLayout, IWContainerLayout,
8    IWTemplateProcessorHTML, Vcl.Controls, IWVCLBaseControl, IWBaseControl,    IWTemplateProcessorHTML, Vcl.Controls, IWVCLBaseControl, IWBaseControl,
9    IWBaseHTMLControl, IWControl, IWCompGrids, IWCompButton, Variants, IWCompLabel;    IWBaseHTMLControl, IWControl, IWCompGrids, IWCompButton, Variants,
10      IWCompLabel,
11      IWDBStdCtrls, PngImage, IWCompExtCtrls, Data.DB;
12    
13  type  type
14    TCartForm = class(TIWAppForm)    TCartForm = class(TIWAppForm)
# Line 27  implementation Line 29  implementation
29    
30  {$R *.dfm}  {$R *.dfm}
31    
32  uses Unit3, Unit7;  uses Unit3, Unit7, Unit6, ServerController;
33    
34  procedure TCartForm.IWAppFormCreate(Sender: TObject);  procedure TCartForm.IWAppFormCreate(Sender: TObject);
35  begin  begin
# Line 37  begin Line 39  begin
39      SQL.Add('select thumbnail,name,volume,price,number,serial from cart_data join item_data');      SQL.Add('select thumbnail,name,volume,price,number,serial from cart_data join item_data');
40      SQL.Add(' on (cart_data.serial = item_data.serial)');      SQL.Add(' on (cart_data.serial = item_data.serial)');
41      SQL.Add(' where number = :num');      SQL.Add(' where number = :num');
42      Params.ParamByName('num').AsInteger := DM.FDTable1.FieldByName('NUMBER')      Params.ParamByName('num').AsInteger := UserSession.user_number;
       .AsInteger;  
43    end;    end;
44  end;  end;
45    
46  procedure TCartForm.IWAppFormRender(Sender: TObject);  procedure TCartForm.IWAppFormRender(Sender: TObject);
47  var  var
48    i, j, k: Integer;    i, j, k: Integer;
49      s: TStream;
50      pic: TIWImage;
51      png: TPngImage;
52  begin  begin
53      for i := 0 to IWGrid1.RowCount - 1 do
54        IWGrid1.Cell[i, 0].Control.Free;
55      IWGrid1.RowCount := 0;
56    with DM.FDQuery1 do    with DM.FDQuery1 do
57    begin    begin
58      Open;      Open;
59      IWGrid1.RowCount := RecordCount;      IWGrid1.RowCount := RecordCount;
60      if IWGrid1.RowCount = 0 then      if IWGrid1.RowCount = 0 then
61        IWGrid1.Caption:='カートの中身がありません';        IWGrid1.Caption := 'カートの中身がありません';
62      First;      First;
63      i := 0;      i := 0;
64      k := 0;      k := 0;
65      while Eof = false do      png := TPngImage.Create;
66      begin      try
67        IWGrid1.Cell[i, 1].Text := Fields.Fields[1].AsString;        while Eof = false do
68        IWGrid1.Cell[i, 2].Text := Fields.Fields[2].AsString;        begin
69        j := Fields.Fields[2].AsInteger * Fields.Fields[3].AsInteger;          if Fields.Fields[0].AsBytes <> nil then
70        inc(k,j);          begin
71        IWGrid1.Cell[i, 3].Text := IntToStr(j);            s := CreateBlobStream(Fields.Fields[0], bmRead);
72        IWGrid1.Cell[i, 4].Text := '削除';            try
73        IWGrid1.Cell[i, 4].Clickable := true;              png.LoadFromStream(s);
74        Next;            finally
75        inc(i);              s.Free;
76              end;
77              pic := TIWImage.Create(IWGrid1);
78              pic.Picture.Assign(png);
79              IWGrid1.Cell[i, 0].Control := pic;
80            end;
81            IWGrid1.Cell[i, 1].Text := Fields.Fields[1].AsString;
82            IWGrid1.Cell[i, 2].Text := Fields.Fields[2].AsString;
83            j := Fields.Fields[2].AsInteger * Fields.Fields[3].AsInteger;
84            inc(k, j);
85            IWGrid1.Cell[i, 3].Text := IntToStr(j);
86            IWGrid1.Cell[i, 4].Text := '削除';
87            IWGrid1.Cell[i, 4].Clickable := true;
88            Next;
89            inc(i);
90          end;
91        finally
92          png.Free;
93      end;      end;
94    end;    end;
95    IWLabel1.Text:=IntToStr(Trunc(k*1.08));    IWLabel1.Text := Format('(合計) %d + (消費税) %d = %d円',
96        [k, Trunc(k * 0.08), Trunc(k * 1.08)]);
97  end;  end;
98    
99  procedure TCartForm.IWButton1Click(Sender: TObject);  procedure TCartForm.IWButton1Click(Sender: TObject);
100  begin  begin
101    if IWGrid1.RowCount > 0 then    if IWGrid1.RowCount > 0 then
102      TPayForm.Create(WebApplication).Show;      TPayForm.Create(WebApplication).Show;
103      if (UserSession.user_number <> 0) and
104        (DM.FDTable1.FieldByName('EMAIL').AsString = '') then
105        TUserForm.Create(WebApplication).Show;
106    Release;    Release;
107  end;  end;
108    
# Line 86  end; Line 114  end;
114  procedure TCartForm.IWGrid1CellClick(ASender: TObject;  procedure TCartForm.IWGrid1CellClick(ASender: TObject;
115    const ARow, AColumn: Integer);    const ARow, AColumn: Integer);
116  var  var
117    i, j: integer;    i, j: Integer;
118  begin  begin
119    with DM.FDQuery1 do    with DM.FDQuery1 do
120    begin    begin
121      RecNo:=ARow+1;      RecNo := ARow + 1;
122      i:=FieldByName('NUMBER').AsInteger;      i := FieldByName('NUMBER').AsInteger;
123      j:=FieldByName('SERIAL').AsInteger;      j := FieldByName('SERIAL').AsInteger;
124      SQL.Clear;      Open('select * from cart_data');
125      SQL.Add('select * from cart_data');      if Locate('NUMBER;SERIAL', VarArrayOf([i, j]), []) = true then
126      Open;        Delete;
     Locate('NUMBER;SERIAL',VarArrayOf([i,j]),[]);  
     Delete;  
127    end;    end;
128    IWAppFormCreate(ASender);    IWAppFormCreate(ASender);
129  end;  end;

Legend:
Removed from v.5  
changed lines
  Added in v.12

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