linkedin facebook linkedin facebook nod32

Delphi tilida dorixona uchun dastur tuzish usuli

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2014-10-27

Delphi tilida dorixonalar uchun dastur tuzish usuli

Dastur dizayni rasm 1. keltirilgan

 

rasm 1.

Dastur kodi quyida keltirilgan

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBCtrls, StdCtrls, Grids, DBGrids, ExtCtrls, InspectorBar,
BaseGrid, AdvGrid, dbadvgrd, ImgList, GX_Outlook, ComCtrls, Mask, Buttons,
ExtDlgs,db, QRCtrls, QuickRpt, jpeg;

type
TForm1 = class(TForm)
menubar: TFEGXOutlookBar;
Panel1: TPanel;
StatusBar1: TStatusBar;
PageControl1: TPageControl;
TabSheet2: TTabSheet;
ImageList1: TImageList;
TabSheet1: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
DBEdit6: TDBEdit;
DBMemo1: TDBMemo;
pic: TDBImage;
DBNavigator1: TDBNavigator;
OpenPictureDialog1: TOpenPictureDialog;
DBGrid1: TDBGrid;
DBMemo2: TDBMemo;
DBImage1: TDBImage;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Edit1: TEdit;
Edit2: TEdit;
DBGrid2: TDBGrid;
DBMemo3: TDBMemo;
DBImage2: TDBImage;
MaskEdit1: TMaskEdit;
MaskEdit2: TMaskEdit;
MaskEdit3: TMaskEdit;
Label14: TLabel;
DBEdit7: TDBEdit;
Label18: TLabel;
DBEdit8: TDBEdit;
Label19: TLabel;
Edit5: TEdit;
Label20: TLabel;
Edit6: TEdit;
BitBtn2: TBitBtn;
DBAdvStringGrid1: TDBAdvStringGrid;
Button1: TButton;
Button3: TButton;
Button4: TButton;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure menubarItemClick(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
procedure picClick(Sender: TObject);
procedure TabSheet2Show(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure MaskEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit2Change(Sender: TObject);
procedure MaskEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure MaskEdit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit5KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BitBtn2Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
i: integer;
implementation

uses Unit2, print, Unit3;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
menubar.SelectedItem:=0;
DBAdvStringGrid1.fields.Add.Title:=' ';
for i:=1 to 5 do DBAdvStringGrid1.Fields.Add.Title:='a';
end;

procedure TForm1.menubarItemClick(Sender: TObject);
begin
if menubar.SelectedItem<5 then
PageControl1.ActivePageIndex:=menubar.SelectedItem else
begin
if menubar.SelectedItem=5 then
WinExec(pchar('winhlp32.exe '+ExtractFilePath(Application.ExeName)+'APTEKAR.HLP'),SW_SHOW);
if menubar.SelectedItem=6 then
Form3.ShowModal;
menubar.SelectedItem:=0;
PageControl1.ActivePageIndex:=0;
end;
end;

procedure TForm1.PageControl1Change(Sender: TObject);
const
tabs: array[0..4]of string=('Ko''rish','Qidirish','Sotish','Kiritish','Hisobot');
begin
menubar.SelectedItem:=PageControl1.ActivePageIndex;
Form1.HelpKeyword:=tabs[PageControl1.ActivePageIndex];
if PageControl1.ActivePageIndex<>4 then
DBAdvStringGrid1.Datasource:=nil;
end;

procedure TForm1.picClick(Sender: TObject);
var
s: TMemoryStream;
begin
if not OpenPictureDialog1.Execute then exit;
pic.Picture.LoadFromFile(OpenPictureDialog1.FileName);
s:=TMemoryStream.Create;
pic.Picture.Graphic.SaveToStream(s);
datas.Table1.Edit;
(datas.Table1.fieldbyname('Rasmi') as TBlobField).LoadFromStream(s);
datas.Table1.Post;
s.Free;
end;

procedure TForm1.TabSheet2Show(Sender: TObject);
begin
datas.Table1.Filter:='';
datas.Table1.Filtered:=true;
end;

procedure TForm1.Edit1Change(Sender: TObject);

begin
if Length(Edit1.Text)<>0 then
datas.Table1.Filter:='Nom = '+QuotedStr(Edit1.Text+'*')
else datas.Table1.Filter:='';
end;

procedure TForm1.Edit2Change(Sender: TObject);
begin
if Length(Edit2.Text)<>0 then
datas.Table1.Filter:='FNom = '+QuotedStr(Edit2.Text+'*')
else datas.Table1.Filter:='';
end;

 

procedure TForm1.MaskEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
try
if key= vk_Return then datas.Table1.Filter:='Chyil = '+QuotedStr(MaskEdit1.Text)
except
datas.Table1.Filter:='';
end;
end;

 

procedure TForm1.MaskEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
try
if key= vk_Return then datas.Table1.Filter:='Smuddat = '+QuotedStr(MaskEdit2.Text)
except
datas.Table1.Filter:='';
end;
end;

procedure TForm1.MaskEdit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
try
if key= vk_Return then datas.Table1.Filter:='Kkun = '+QuotedStr(MaskEdit3.Text)
except
datas.Table1.Filter:='';
end;
end;

procedure TForm1.Edit5KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
sum: real;
begin
try
sum:=StrToFloat(Edit5.Text)*datas.Table1.Fieldbyname('Narxi').AsFloat;
except
sum:=0;
end;
Edit6.Text:=FloatToStr(sum);

end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
if StrToFloat(Edit5.Text)>datas.Table1.FieldByName('Soni').AsVariant then begin
ShowMessage('Bazada '+FloatToStr(datas.Table1.FieldByName('Soni').AsVariant)+
' ta qolgan!');
exit;
end;
datas.Table2.Insert;
datas.Table2.FieldByName('Nom').AsString:=datas.Table1.fieldbyname('Nom').AsString;
datas.Table2.FieldByName('Sson').AsFloat:=StrToFloat(Edit5.Text);
datas.Table2.FieldByName('Kun').AsDateTime:=Date;
datas.Table2.FieldByName('Vaq').AsDateTime:=Time;
datas.Table2.FieldByName('Sum').AsFloat:=StrToFloat(Edit6.Text);
datas.Table2.Post;
datas.Table1.Edit;
datas.Table1.FieldByName('Soni').AsVariant:=datas.Table1.FieldByName('Soni').AsVariant-StrToFloat(Edit5.Text);
datas.Table1.FieldByName('Ssoni').AsVariant:=datas.Table1.FieldByName('Ssoni').AsVariant+StrToFloat(Edit5.Text);
datas.Table1.Post;
datas.Table1.Filtered:=false;
PageControl1.ActivePageIndex:=0;
menubar.SelectedItem:=0;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
datas.Table1.Filtered:=false;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Pr: TPagePreview;
begin
Pr:= TPagePreview.CreatePreview(self,DBAdvStringGrid1);
try
pr.ShowModal;
finally
pr.Free;
end;
end;

procedure TForm1.Button3Click(Sender: TObject);
const
nomlar:array[1..2,1..5]of string[15] =
(('Nomi','Firma nomi','Keltirilgan kun','Soni','Narxi'),
('Nom','FNom','Kkun','Soni','Narxi'));
begin
with DBAdvStringGrid1 do
begin
for i:=1 to 5 do Fields.Items[i].FieldName:=nomlar[2,i];
for i:=1 to 5 do Fields.items[i].Title:=nomlar[1,i];
Datasource:=datas.DataSource1;
AutoSize:=true;
QSort;
end;
end;

procedure TForm1.Button4Click(Sender: TObject);
const
nomlar:array[1..2,1..5]of string[15] =
(('Nomi','Sotilgan soni','Sotilgan kuni','Sotilgan vaqti','Summa'),
('Nom','Sson','Kun','Vaq','Sum'));
begin
with DBAdvStringGrid1 do
begin
for i:=1 to 5 do Fields.items[i].Title:=nomlar[1,i];
for i:=1 to 5 do Fields.Items[i].FieldName:=nomlar[2,i];
Datasource:=datas.DataSource2;
AutoSize:=true;
QSort;
end;
end;

end.

3109 marta o`qildi.

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений