برنامج مواقيت الصلاة لكل ولايات الوطن ( للجزائر فقط )
#18
وجدت قاعدة بيانات ضخمة وخفيفة
كود :
https://bitbucket.org/a_atalla/belal/src/b44c245eeaea1d5a4fa39c3720e5c97144002c93/db/CountriesDB?at=master
تحتوي على

[صورة: mhei.png]

اما الاستخدام
[صورة: 22x9.png]
PHP كود :
type
 Tcityinfo 
= record
 Lon
:string;
 
Lat:string;
 
Zone:string;
 
end;
var
  
Form1: TForm1;
  
cityName,countryName:string;
implementation
 
Function countriesTable():TStringList;
var
    
SQLiteDataBase:TSQLiteDatabase;
    
SQLiteTable:TSQLiteTable;
    
i:integer;
begin
Result
:=TStringList.Create;
try
SQLiteDatabase := TSQLiteDatabase.Create(ExtractFilePath(ParamStr(0))+'CountriesDB');
SQLIteTable := SQLiteDatabase.GetTable('SELECT countryName from countriesTable order by countryName');
if 
SQLIteTable.Count > 0 then begin
 
for i := 0 to SQLiteTable.Count -1 do begin
    Result
.Add(SQLIteTable.FieldAsString(SQLIteTable.FieldIndex['countryName']));
    
SQLIteTable.Next;
  
end;
end else Result.Add('قاعدة البيانات فارغة');
SQLIteTable.Free;
SQLiteDatabase.Free;
except on e:exception do Result.Add('خطا في تحميل قاعدة البيانات'); end;
end;

 Function 
citiesTable(city:string):Tcityinfo;
var
    
SQLiteDataBase:TSQLiteDatabase;
    
SQLiteTable:TSQLiteTable;
    
i:integer;
begin

try
SQLiteDatabase := TSQLiteDatabase.Create(ExtractFilePath(ParamStr(0))+'CountriesDB');
SQLIteTable := SQLiteDatabase.GetTable('SELECT longitude,latitude,timeZone,cityName from citiesTable where cityName like '+QuotedStr('%'+city+'%'));
cityName:= SQLIteTable.FieldByName['cityName'];
Form1.stat1.SimpleText:=countryName+'/'+cityName;
if 
SQLIteTable.Count > 0 then begin
 
for i := 0 to SQLiteTable.Count -1 do begin
   
{ Result.Add(SQLIteTable.FieldAsString(SQLIteTable.FieldIndex['longitude']));
    
Result.Add(SQLIteTable.FieldAsString(SQLIteTable.FieldIndex['latitude']));
     
Result.Add(SQLIteTable.FieldAsString(SQLIteTable.FieldIndex['timeZone']));
     }
     {--------------------------------------------------- }
     
Result.Lon:= SQLIteTable.FieldAsString(SQLIteTable.FieldIndex['longitude']);
     
Result.Lat:= SQLIteTable.FieldAsString(SQLIteTable.FieldIndex['latitude']);
     
Result.Zone:= SQLIteTable.FieldAsString(SQLIteTable.FieldIndex['timeZone']);
     {---------------------------------------------------}
    
SQLIteTable.Next;
  
end;
end ;//else Result.Add('قاعدة البيانات فارغة');
SQLIteTable.Free;
SQLiteDatabase.Free;
except //on e:exception do Result.Add('خطا في تحميل قاعدة البيانات');
 
end;
end;

 Function 
listCities(country:string):TStringList;
var
    
SQLiteDataBase:TSQLiteDatabase;
    
SQLiteTable:TSQLiteTable;
    
i:integer;
    
countryNO:string;
begin
Result
:=TStringList.Create;
try
SQLiteDatabase := TSQLiteDatabase.Create(ExtractFilePath(ParamStr(0))+'CountriesDB');
SQLIteTable := SQLiteDatabase.GetTable('SELECT * from countriesTable where countryName like '+QuotedStr('%'+country+'%'));
countryNO:= SQLIteTable.FieldByName['countryNO']; countryName:= SQLIteTable.FieldByName['countryName'];
Form1.stat1.SimpleText:=countryName;
SQLIteTable := SQLiteDatabase.GetTable('SELECT cityName  from citiesTable where countryNO='+QuotedStr(countryNO)+' order by cityName');
if 
SQLIteTable.Count > 0 then begin
 
for i := 0 to SQLiteTable.Count -1 do begin
    Result
.Add(SQLIteTable.FieldAsString(SQLIteTable.FieldIndex['cityName']));
    
SQLIteTable.Next;

  
end;
end else Result.Add('قاعدة البيانات فارغة');
SQLIteTable.Free;
SQLiteDatabase.Free;
except on e:exception do Result.Add('خطا في تحميل قاعدة البيانات'); end;
end;
{
$R *.dfm}

procedure TForm1.edt1Change(Sender: TObject);
var 
info:Tcityinfo;
begin
   info
:=citiesTable(edt1.Text);     //
 
lbl1.Caption:= info.Lon;
 
lbl2.Caption:= info.lat;
 
lbl3.Caption:= info.Zone;
 
lst2.ItemIndex:=lst2.Items.IndexOf(cityName);
end;

procedure TForm1.edt2Change(Sender: TObject);
begin
lst2
.Clear;
lst2.Items.AddStrings(listCities(edt2.Text));
lst1.ItemIndex:=lst1.Items.IndexOf(countryName);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
lst1
.Items.AddStrings(countriesTable);
stat1.SimplePanel:=True;
end;

procedure TForm1.lst1Click(Sender: TObject);
begin
lst2
.Clear;
lst2.Items.AddStrings(listCities(lst1.Items[lst1.ItemIndex]));
end;

procedure TForm1.lst2Click(Sender: TObject);
var 
info:Tcityinfo;
begin

  info
:=citiesTable(lst2.Items[lst2.ItemIndex]);     //
 
lbl1.Caption:= info.Lon;
 
lbl2.Caption:= info.lat;
 
lbl3.Caption:= info.Zone;
end; 
الوحدة المستخدمة
SQLiteTable3
الرد


الردود في هذا الموضوع
برنامج مواقيت الصلاة لكل ولايات الوطن ( للجزائر فقط ) - بواسطة onexite - 08-09-2013, 09:20 AM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم