Список использованных источников
1 Архангельский, А.Я., Тагин, М.А. Программирование в C++Builder 6 и 2006 [Текст] / М..: ООО “Бином-Пресс”, 2002. - 1184 с.
2 Архангельский, А.Я. Компоненты общего назначения библиотеки Delphi 5.0 [Текст] / А.Я. Архангельский - М.: Бином, 2001. - 416 с.
3 Архангельский, А.Я. Программирование в Delphi 6 [Текст] / А.Я. Архангельский - С.-П.: Бином, 2002. - 1120 с.
Приложение А
Текст программы
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "stdio.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
int row = 1;
int rowtab = -1;
class Ta
public:
AnsiString Naimenovanie, Date1, Kod, Price, Quantity;
FILE *f;
void input(AnsiString, AnsiString, AnsiString, AnsiString, AnsiString);
void sozdanie_form();
void add();
void clear();
void delet();
void close();
void form_save();
void all();
void search();
void plus();
};
void Ta::input(AnsiString Naimenovanie, AnsiString Date, AnsiString Kod, AnsiString Price, AnsiString Quantity)
this->Naimenovanie = Naimenovanie ;
this->Date1 = Date1 ;
this->Kod = Kod;
this->Price = Price;
this->Quantity = Quantity;
void Ta::sozdanie_form()
Form1->DataGrid1->RowCount = 1;
Form1->DataGrid1->Cells[0][0] = "Наименование";
Form1->DataGrid1->Cells[1][0] = "Дата поступления";
Form1->DataGrid1->Cells[2][0] = "Код товара";
Form1->DataGrid1->Cells[3][0] = "Цена";
Form1->DataGrid1->Cells[4][0] = "Количество";
char a1[50];
char b1[50];
char c1[50];
char d1[50];
char e1[50];
if ((this->f = fopen("salon.txt","rb")) != NULL)
f = fopen("salon.txt","rb");
while(!(feof(this->f)))
fread(a1,sizeof(char),50,this->f);
fread(b1,sizeof(char),50,this->f);
fread(c1,sizeof(char),50,this->f);
fread(d1,sizeof(char),50,this->f);
fread(e1,sizeof(char),50,this->f);
this->Naimenovanie = a1;
this->Date1 = b1;
this->Kod = c1;
this->Price = d1;
this->Quantity = e1;
if (!(feof(this->f)))
row++;
Form1->DataGrid1->RowCount = row;
Form1->DataGrid1->Cells[0][row - 1] = this->Naimenovanie;
Form1->DataGrid1->Cells[1][row - 1] = this->Date1;
Form1->DataGrid1->Cells[2][row - 1] = this->Kod;
Form1->DataGrid1->Cells[3][row - 1] = this->Price;
Form1->DataGrid1->Cells[4][row - 1] = this->Quantity;
else {this->f = fopen("salon.txt","wb");};
fclose(this->f);
void Ta::add()
Form1->DataGrid1->Cells[0][Form1->DataGrid1->RowCount] = Form1->Edit1->Text;
Form1->DataGrid1->Cells[1][Form1->DataGrid1->RowCount] = Form1->Edit2->Text;
Form1->DataGrid1->Cells[2][Form1->DataGrid1->RowCount] = Form1->Edit3->Text;
Form1->DataGrid1->Cells[3][Form1->DataGrid1->RowCount] = Form1->Edit4->Text;
Form1->DataGrid1->Cells[4][Form1->DataGrid1->RowCount] = Form1->Edit5->Text;
Form1->Edit1->Clear();
Form1->Edit2->Clear();
Form1->Edit3->Clear();
Form1->Edit4->Clear();
Form1->Edit5->Clear();
void Ta::form_save()
this->f = fopen("salon.txt", "w+b");
char one[50];
char two[50];
char three[50];
char four[50];
char five[50];
for(int i = 1; i < row; i++)
AnsiString a1 = Form1->DataGrid1->Cells[0][i];
AnsiString a2 = Form1->DataGrid1->Cells[1][i];
AnsiString a3 = Form1->DataGrid1->Cells[2][i];
AnsiString a4 = Form1->DataGrid1->Cells[3][i];
AnsiString a5 = Form1->DataGrid1->Cells[4][i];
strncpy(one,a1.c_str(),50);
strncpy(two,a2.c_str(),50);
strncpy(three,a3.c_str(),50);
strncpy(four,a4.c_str(),50);
strncpy(five,a5.c_str(),50);
fwrite(one,sizeof(char),50,this->f);
fwrite(two,sizeof(char),50,this->f);
fwrite(three,sizeof(char),50,this->f);
fwrite(four,sizeof(char),50,this->f);
fwrite(five,sizeof(char),50,this->f);
void Ta::delet()
int k = 0;
k++;
if (Form1->DataGrid1->RowCount == 1)ShowMessage( "Таблица пуста" );
else
Form1->DataGrid1->Cells[0][rowtab] = Form1->DataGrid1->Cells[0][k];
Form1->DataGrid1->Cells[1][rowtab] = Form1->DataGrid1->Cells[1][k];
Form1->DataGrid1->Cells[2][rowtab] = Form1->DataGrid1->Cells[2][k];
Form1->DataGrid1->Cells[3][rowtab] = Form1->DataGrid1->Cells[3][k];
Form1->DataGrid1->Cells[4][rowtab] = Form1->DataGrid1->Cells[4][k];
Form1->DataGrid1->Cells[5][rowtab] = Form1->DataGrid1->Cells[5][k];
Form1->DataGrid1->RowCount--;
void Ta::all()
Form1->Label6->Caption = "Количество записей в базе " + IntToStr(k);
void Ta::search()
for (int i = 1; i < row; i++)
if ((Form1->DataGrid1->Cells[0][i] == Form1->Edit1->Text)||(Form1->DataGrid1->Cells[1][i] == Form1->Edit2->Text)||(Form1->DataGrid1->Cells[2][i] == Form1->Edit3->Text)||(Form1->DataGrid1->Cells[3][i] == Form1->Edit4->Text)||(Form1->DataGrid1->Cells[4][i] == Form1->Edit5->Text))
Form1->SearchGrid1->Cells[0][k] = Form1->DataGrid1->Cells[0][i];
Form1->SearchGrid1->Cells[1][k] = Form1->DataGrid1->Cells[1][i];
Form1->SearchGrid1->Cells[2][k] = Form1->DataGrid1->Cells[2][i];
Form1->SearchGrid1->Cells[3][k] = Form1->DataGrid1->Cells[3][i];
Form1->SearchGrid1->Cells[4][k] = Form1->DataGrid1->Cells[4][i];
Form1->SearchGrid1->Cells[5][k] = Form1->DataGrid1->Cells[5][i];
Form1->SearchGrid1->RowCount = k;
Form1->SearchGrid1->Visible = True;
void Ta::plus()
float k = StrToFloat(Form1->Edit6->Text);
k = k/100;
Form1->DataGrid1->Cells[3][i] = ((float)((int)((Form1->DataGrid1->Cells[3][i]*(1 + k))*100))/100);
void __fastcall TForm1::AddClick(TObject *Sender)
Ta a;
a.add();
void __fastcall TForm1::SaveClick(TObject *Sender)
a.form_save();
void __fastcall TForm1::FormCreate(TObject *Sender)
a.sozdanie_form();
void __fastcall TForm1::DeleteClick(TObject *Sender)
a.delet();
void __fastcall TForm1::SearchClick(TObject *Sender)
a.search();
void __fastcall TForm1::NumberClick(TObject *Sender)
a.all();
void __fastcall TForm1::plusClick(TObject *Sender)
a.plus();
void __fastcall TForm1::DataGrid1SelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
rowtab = ARow;
Страницы: 1, 2, 3