Добавил:
masterdos
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, ExtCtrls, DBCtrls, DBTables, DB,
Buttons;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
Table1: TTable;
DataSource1: TDataSource;
Label2: TLabel;
Query1: TQuery;
DBGrid2: TDBGrid;
DBGrid3: TDBGrid;
DBNavigator2: TDBNavigator;
BitBtn1: TBitBtn;
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.ListBox1Click(Sender: TObject);
begin
case listbox1.ItemIndex of
0:begin
with Query1 do
begin
if not(fileexists('tab.db')) then begin
Active:=False;
SQL.Clear;
sql.Add('Create table "tab.db"');
sql.Add('(Data char(15), Temperatura float(8), Region char(12))');
ExecSQL;
end
else begin
active:=false;
sql.clear;
sql.add('DELETE FROM "tab.db"');
execSQL;
end;
active:=false;
sql.Clear;
sql.Add('insert into "tab.db"(Data, Temperatura, Region)');
sql.add('select Data, Temperatura, Region');
sql.Add('from "pohoda.DB"');
sql.Add('where temperatura<5 and temperatura>0');
execsql;
active:=false;
sql.Clear;
sql.Add('select *');
sql.Add('from "tab.db"');
active:=true;
end;
end;
1:begin
with Query1 do
begin
active:=false;
sql.clear;
sql.Add('select Data, Opadu, Temperatura');
sql.Add('from "pohoda.DB"');
sql.Add('where Opadu="сніг" and temperatura<0');
active:=true;
end;
end;
2:begin
with Query1 do
begin
active:=false;
sql.clear;
sql.Add('select Region, Temperatura, Hmarnist, Opadu, Data');
sql.Add('from "pohoda.DB"');
sql.Add('where Region="Київ"');
active:=true;
end;
end;
3:begin
with Query1 do
begin
active:=false;
sql.clear;
sql.Add('insert into "pohoda.DB"');
sql.Add('values ("15/10/1993", -5, "Суми", "хмарно", "сніг")');
execsql;
active:=false;
sql.Clear;
sql.Add('select *');
sql.Add('from "pohoda.db"');
active:=true;
end;
end;
4:begin
with Query1 do
begin
active:=false;
sql.clear;
sql.Add('Delete');
sql.Add('from "pohoda.DB"');
sql.Add('where data="15/10/1993"');
execsql;
active:=false;
sql.Clear;
sql.Add('select *');
sql.Add('from "pohoda.db"');
active:=true;
end;
end;
5:begin
with query1 do
begin
active:=false;
sql.clear;
sql.Add('update "pohoda.DB"');
sql.Add('set Hmarnist="ясно"');
sql.Add('where temperatura>-2');
execsql;
active:=false;
sql.Clear;
sql.Add('select *');
sql.Add('from "pohoda.db"');
active:=true;
end;
end;
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, ExtCtrls, DBCtrls, DBTables, DB,
Buttons;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
Table1: TTable;
DataSource1: TDataSource;
Label2: TLabel;
Query1: TQuery;
DBGrid2: TDBGrid;
DBGrid3: TDBGrid;
DBNavigator2: TDBNavigator;
BitBtn1: TBitBtn;
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.ListBox1Click(Sender: TObject);
begin
case listbox1.ItemIndex of
0:begin
with Query1 do
begin
if not(fileexists('tab.db')) then begin
Active:=False;
SQL.Clear;
sql.Add('Create table "tab.db"');
sql.Add('(Data char(15), Temperatura float(8), Region char(12))');
ExecSQL;
end
else begin
active:=false;
sql.clear;
sql.add('DELETE FROM "tab.db"');
execSQL;
end;
active:=false;
sql.Clear;
sql.Add('insert into "tab.db"(Data, Temperatura, Region)');
sql.add('select Data, Temperatura, Region');
sql.Add('from "pohoda.DB"');
sql.Add('where temperatura<5 and temperatura>0');
execsql;
active:=false;
sql.Clear;
sql.Add('select *');
sql.Add('from "tab.db"');
active:=true;
end;
end;
1:begin
with Query1 do
begin
active:=false;
sql.clear;
sql.Add('select Data, Opadu, Temperatura');
sql.Add('from "pohoda.DB"');
sql.Add('where Opadu="сніг" and temperatura<0');
active:=true;
end;
end;
2:begin
with Query1 do
begin
active:=false;
sql.clear;
sql.Add('select Region, Temperatura, Hmarnist, Opadu, Data');
sql.Add('from "pohoda.DB"');
sql.Add('where Region="Київ"');
active:=true;
end;
end;
3:begin
with Query1 do
begin
active:=false;
sql.clear;
sql.Add('insert into "pohoda.DB"');
sql.Add('values ("15/10/1993", -5, "Суми", "хмарно", "сніг")');
execsql;
active:=false;
sql.Clear;
sql.Add('select *');
sql.Add('from "pohoda.db"');
active:=true;
end;
end;
4:begin
with Query1 do
begin
active:=false;
sql.clear;
sql.Add('Delete');
sql.Add('from "pohoda.DB"');
sql.Add('where data="15/10/1993"');
execsql;
active:=false;
sql.Clear;
sql.Add('select *');
sql.Add('from "pohoda.db"');
active:=true;
end;
end;
5:begin
with query1 do
begin
active:=false;
sql.clear;
sql.Add('update "pohoda.DB"');
sql.Add('set Hmarnist="ясно"');
sql.Add('where temperatura>-2');
execsql;
active:=false;
sql.Clear;
sql.Add('select *');
sql.Add('from "pohoda.db"');
active:=true;
end;
end;
end;
end;
end.
Соседние файлы в папке Діденко