unit Main; interface uses WebCore, WebUI, WebForms, WebCtrls, WebData, WebGrids, WebLabels, WebIcons, WebEdits; type TForm1 = class(TForm) IPCountry: TDataSet; Grid1: TGrid; GridColumn1: TGridColumn; GridColumn2: TGridColumn; RowsLabel: TLabel; CountryComboBox: TButtonComboBox; Label1: TLabel; Countries: TDataSet; procedure IPCountryAfterLoad(Sender: TObject); procedure IPCountryLoadError(Sender: TObject; const ErrorMsg: String); procedure CountryComboBoxChange(Sender: TObject); procedure Form1Show(Sender: TObject); procedure CountriesAfterLoad(Sender: TObject); procedure CountriesLoadError(Sender: TObject; const ErrorMsg: String); procedure IPCountryCalculateRow(Sender: TObject; Column: TDataColumn); private StartTime: DateTime; EndTime: DateTime; procedure LoadRows; public { Public declarations } end; var Form1: TForm1; implementation function IntToIPAddress(Value: Integer): String; begin Result:=IntToStr((Value shr 24) and $FF)+'.'+ IntToStr((Value shr 16) and $FF)+'.'+ IntToStr((Value shr 8) and $FF)+'.'+ IntToStr(Value and $FF); end; procedure TForm1.LoadRows; begin ShowProgress('Loading rows...'); StartTime:=Time; IPCountry.Params.Values['Country']:=QuotedStr(CountryComboBox.Text); Database.LoadRows(IPCountry); end; procedure TForm1.IPCountryAfterLoad(Sender: TObject); begin EndTime:=Time; RowsLabel.Caption:=IntToStr(IPCountry.RowCount)+' rows loaded in '+IntToStr(EndTime-StartTime)+' msecs'; HideProgress; end; procedure TForm1.IPCountryLoadError(Sender: TObject; const ErrorMsg: String); begin RowsLabel.Caption:='Error loading rows: '+ErrorMsg; HideProgress; end; procedure TForm1.CountryComboBoxChange(Sender: TObject); begin LoadRows; end; procedure TForm1.Form1Show(Sender: TObject); begin Database.LoadRows(Countries); end; procedure TForm1.CountriesAfterLoad(Sender: TObject); begin CountryComboBox.Items.BeginUpdate; try with Countries do begin while (not EOF) do begin CountryComboBox.Items.Add(Columns['CountryName'].AsString); Next; end; end; finally CountryComboBox.Items.EndUpdate; end; end; procedure TForm1.CountriesLoadError(Sender: TObject; const ErrorMsg: String); begin ShowMessage('Error loading country names: '+ErrorMsg); end; procedure TForm1.IPCountryCalculateRow(Sender: TObject; Column: TDataColumn); begin if (Column.Name='IPAddressFrom') then TDataSet(Sender).Columns['DotIPAddressFrom'].AsString:=IntToIPAddress(Column.AsInteger) else if (Column.Name='IPAddressTo') then TDataSet(Sender).Columns['DotIPAddressTo'].AsString:=IntToIPAddress(Column.AsInteger); end; end.