Muhammad Al-Xorazmiynomidagi Toshkent axborot texnologiyalari universiteti farg‘ona filiali Kompyuter injinering fakuteti Kompyuter injinering yo’nalishi 714-21 guruh talabasi Ubaydullayev Sardorbekning Dasturlash II fanidan Bajardi :Ubaydullayev Sardorbek Qabul qildi: Xoshimov Bahodir
Kontakt
1_rasm: Kontakt xosil qilish jarayoni. Birinchi bo’lib formani xosil qilib olamiz so’gra BorderIconsni maximaizni false qilamiz, keyin Borderstyleni ham bsSingle qilib olamiz.Forma tayyor bo’lgandan keyin pannel1ni tashlab olamiz va Alignni Altop qilib olamiz, keyin SpeedButton tashlab olamiz.Pannel2ni ham tashlab olib Alignni AlBottom qilib qo’yamiz va o’zimizga keraklicha SpeedButton tashlab olovramiz.
2_rasm: Familiya Ism Telefon raqam kirish joyi.Bu jarayonda ham birinchi bo’lib formani xosil qilib olamiz so’gra BorderIconsni maximaizni false qilamiz, keyin Borderstyleni ham bsSingle qilib olamiz.Forma tayyor bo’lgandan keyin 3ta SpeedButton tashlab olamiz captionini o’zgartirib olamiz va 3ta Edit ham tashlab olganimizdan keyin uni ham Textni tozalab qo’yamiz.
3_rasm: Kontakt saqlash jarayoni.
4_rasm: Kontaktga nomer saqlagan xolati. KONTAKT DASTURINI KOD QISMI
//---------------------------------------------------------------------------
#include #pragma hdrstop
#include "Unit1.h"
#include "Unit5.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm" TForm1 *Form1;
bool yuklandi = false;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
if (!FileExists("kontaktlar.dat") && !yuklandi) {
ListBox1->Items->LoadFromFile("kontaklar.dat"); yuklandi = true;
}
ListBox1->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
Form5->eFam->Text = "";
Form5->eIsm->Text = "";
Form5->eTel->Text = "";
Form5->Caption = ".:: Yangi kontakt qo'shish ::.";
Form5->eFam->ReadOnly = false;
Form5->eIsm->ReadOnly = false;
Form5->eTel->ReadOnly = false;
Form5->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton5Click(TObject *Sender)
{
if (ListBox1->Items->Count < 2) {
ShowMessage(" Tahrirlash uchun ma'lumot yo'q");
}else if (ListBox1->ItemIndex == -1) {
ShowMessage(" Tahrirlash uchun kontaktni tanlang");
}else {
index = (ListBox1->ItemIndex %2 == 0 ) ? ListBox1->ItemIndex : ListBox1->ItemIndex - 1;
String fi = ListBox1->Items->Strings[index];
String tel = ListBox1->Items->Strings[index + 1]; String fam, ism; int probelPosition = fi.Pos(" "); fam = fi.SubString(1, probelPosition - 1);
ism = fi.SubString(probelPosition + 1, fi.Length() - probelPosition);
Form5->eFam->Text = fam;
Form5->eIsm->Text = fam;
Form5->eTel->Text = fam;
Form5->Caption = ".:: Kontakt tahrirlash ::.";
Form5->eFam->ReadOnly = false;
Form5->eIsm->ReadOnly = false;
Form5->eTel->ReadOnly = false;
Form5->ShowModal();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton3Click(TObject *Sender)
{
if (ListBox1->Items->Count < 2) {
ShowMessage(" Ko'rish uchun ma'lumot yo'q");
}else if (ListBox1->ItemIndex == -1) {
ShowMessage(" Ko'rish uchun kontaktni tanlang");
}else {
index = (ListBox1->ItemIndex %2 == 0 ) ? ListBox1->ItemIndex : ListBox1->ItemIndex - 1;
String fi = ListBox1->Items->Strings[index];
String tel = ListBox1->Items->Strings[index + 1]; String fam, ism; int probelPosition = fi.Pos(" "); fam = fi.SubString(1, probelPosition - 1);
ism = fi.SubString(probelPosition + 1, fi.Length() - probelPosition);
Form5->eFam->Text = fam;
Form5->eIsm->Text = fam;
Form5->eTel->Text = fam;
Form5->Caption = ".:: Kontaktni ko'rish ::.";
Form5->eFam->ReadOnly = true;
Form5->eIsm->ReadOnly = true;
Form5->eTel->ReadOnly = true;
Form5->ShowModal();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton4Click(TObject *Sender)
{
if (ListBox1->Items->Count < 2) {
ShowMessage(" O'chirish uchun ma'lumot yo'q");
}else if (ListBox1->ItemIndex == -1) {
ShowMessage(" O'chirish uchun kontaktni tanlang");
}else {
index = (ListBox1->ItemIndex %2 == 0 ) ? ListBox1->ItemIndex : ListBox1->ItemIndex - 1; int res = MessageDlg("Chindan ham o'chirmoqchimisiz?", mtWarning, TMsgDlgButtons()< ListBox1->Items->Delete(index + 1);
ListBox1->Items->Delete(index);
Form1->ListBox1->Items->SaveToFile("kontaktlar.dat");
ShowMessage(" O'chirildi. ");
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
if (Edit1->Text.Trim() != "") {
bool topildi = false;
for (int i = ListBox1->ItemIndex+1; i Items->Count; i++) { if (ListBox1->Items->Strings[i].Pos(Edit1->Text.Trim()) > 0) { ListBox1->ItemIndex = i; topildi = true;
return;
}
}
if (!topildi && ListBox1->ItemIndex != 0) { for (int i = 0; i Items->Count; i++) { if (ListBox1->Items->Strings[i].Pos(Edit1->Text.Trim()) > 0) {
ListBox1->ItemIndex = i; topildi = true; return;
}
}
}
}
}
//--------------------------------------------------------------------------
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
SpeedButton1->Click();
}
//---------------------------------------------------------------------------
Kodni ikkinchi qism:
//---------------------------------------------------------------------------
#include #pragma hdrstop
#include "Unit5.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm5 *Form5;
//---------------------------------------------------------------------------
__fastcall TForm5::TForm5(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm5::SpeedButton1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm5::SpeedButton2Click(TObject *Sender)
{
String fam, ism, tel; fam = eFam->Text.Trim(); ism = eIsm->Text.Trim(); tel = eTel->Text.Trim(); if (fam == "") {
ShowMessage("Familiyani kiriting."); eFam->SetFocus();
}else if (ism == "") {
ShowMessage("Ismni kiriting."); eIsm->SetFocus();
}else if (tel == "") {
ShowMessage("Telefon raqamni kiriting."); eTel->SetFocus();
}else {
if (Form5->Caption == ".:: Yangi kontakt qo'shish::."){
//qo'shish
Form1->ListBox1->Items->Add(fam + " " + ism);
Form1->ListBox1->Items->Add(tel); Form1->ListBox1->Items->SaveToFile("kontaktlar.dat");
} else {
//tahrirlash
Form1->ListBox1->Items->Strings[Form1->index] = fam + " " + ism;
Form1->ListBox1->Items->Strings[Form1->index + 1] = tel;
Form1->ListBox1->Items->SaveToFile("kontaktlar.dat");
}
Close();
}
}
//---------------------------------------------------------------------------