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