#pragma hdrstop
#include "Unit1.h"
#include "Unit3.h"
#include "Unit4.h"
#include "Unit5.h"
#include "Unit6.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm4 *Form4;
TSearchRec obn;
AnsiString amu;
//---------------------------------------------------------------------------
__fastcall TForm4::TForm4(TComponent* Owner)
: TForm(Owner)
{if (FindFirst("base/*.info",faAnyFile, obn)==0)
{
ComboBox1->Items->Add(obn.Name);
while (FindNext(obn) == 0)
{
ComboBox1->Items->Add(obn.Name);
}
ComboBox1->ItemIndex = 0;
Memo1->Text =ComboBox1->Items->Strings[0];
}
}
//---------------------------------------------------------------------------
void __fastcall TForm4::Button3Click(TObject *Sender)
{
Form4->Visible=false;
Form6->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm4::ComboBox1Change(TObject *Sender)
{
int n = ComboBox1->ItemIndex;
AnsiString amu;
amu="base/"+ComboBox1->Items->Strings[n];
Memo1->Lines->LoadFromFile(amu);
}
//---------------------------------------------------------------------------
void __fastcall TForm4::BitBtn1Click(TObject *Sender) //+
{
Form4->Visible=false;
Form6->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm4::BitBtn3Click(TObject *Sender) // delet
{
int n=ComboBox1->ItemIndex;
AnsiString delate;
delate="base/"+ComboBox1->Items->Strings[n];
if (MessageDlg("Ma'lumotlar o'chirilayapti, rozimisiz?",mtConfirmation,mbYesNoCancel,0)==6)
{DeleteFile(delate);
Memo1->Text=" ";
ComboBox1->Text=" ";}
}
//---------------------------------------------------------------------------
void __fastcall TForm4::BitBtn2Click(TObject *Sender) //obnavit
{
ComboBox1->Items->Clear();
if (FindFirst("Base/*.info",faAnyFile, obn)==0)
{
ComboBox1->Items->Add(obn.Name);
while (FindNext(obn) == 0)
{
ComboBox1->Items->Add(obn.Name);
}
ComboBox1->ItemIndex = 0;
Memo1->Text = ComboBox1->Items->Strings[0];
Memo1->Text=" ";
ComboBox1->Text=" ";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm4::BitBtn4Click(TObject *Sender) //exit
{
Form4->Visible=false;
Form5->Visible=true;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit6.h"
#include "Unit4.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm6 *Form6;
//---------------------------------------------------------------------------
__fastcall TForm6::TForm6(TComponent* Owner)
: TForm(Owner)
{RichEdit1->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm6::Button1Click(TObject *Sender)
{
Form6->Visible=false;
Form4->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm6::Button2Click(TObject *Sender)
{
Edit1->Text="";
RichEdit1->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm6::Button3Click(TObject *Sender)
{
int xayat;
AnsiString keraga;
keraga = "base/"+Edit1->Text + ".info";
if ( FileExists(keraga) )
xayat = FileOpen(keraga,fmOpenWrite);
else
xayat = FileCreate(keraga);
FileClose(xayat);
if (Edit1->Text != "" )
{RichEdit1->Lines->SaveToFile(keraga);
MessageBoxA(Form6->Handle, "Ma'lumotlar bazaga yuklandi!", "Xabar", 0);
}
else
{MessageBoxA(Form6->Handle, "Fayl nomi xato!", "Xabar", 0);
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
#include "Unit3.h"
#include "Unit4.h"
#include "Unit5.h"
#include "Unit6.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm5 *Form5;
//---------------------------------------------------------------------------
__fastcall TForm5::TForm5(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm5::Button1Click(TObject *Sender)
{
Form1->Close();
Form3->Close();
Form4->Close();
Form5->Close();
Form6->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm5::Button2Click(TObject *Sender)
{
Form5->Visible=false;
Form1->Visible=true;
}
//---------------------------------------------------------------------------
2.6 Ma’lumotlar bazasi.
Dasturni yaratish jarayonida ma’lumotlar bazasi sifatida tashqi fayldan foydalanildi.
Buning uchun maxsus papka (katalog) ochildi va unga dastur ichidan aftomatik ravishda yo’l belgilandi:
int xayat;
AnsiString keraga;
keraga = "base/"+Edit1->Text + ".info";
if ( FileExists(keraga) )
xayat = FileOpen(keraga,fmOpenWrite);
else
xayat = FileCreate(keraga);
FileClose(xayat);
Har bir yangi qo’shilgan fayl *.info kengaytmasi bilan o’sha papkaga yuklanadi. Ikkita bir xil nomdagi fayl xosil bo’lsa avvalgi fayl aftomatik ravishda o’chib ketadi.
Ma’lumotlarni dasturiy ravishda o’chirganda ham ma’lumotlar saqlanayotgan fayl o’chib ketadi:
void __fastcall TForm4::BitBtn3Click(TObject *Sender)
{
int n=ComboBox1->ItemIndex;
AnsiString delate;
delate="base/"+ComboBox1->Items->Strings[n];
if (MessageDlg("Ma'lumotlar o'chirilayapti, rozimisiz?",mtConfirmation,mbYesNoCancel,0)==6)
{DeleteFile(delate);
Memo1->Text=" ";
ComboBox1->Text=" ";}
}
Do'stlaringiz bilan baham: