Главная Случайная страница Контакты | Мы поможем в написании вашей работы! | ||
|
Класс CCena предназначен для создания и ведения базы справочных данных: расценки работ.
//Файл Cena.h – см. п. 4.2.
//Файл Cena.cpp
#include "stdafx.h"
#include "Pr.h"
#include "Cena.h"
extern CString CenaFile; //объявл. переменной имени файла
CCena::CCena()
{
Vid="";
Rascenka="";
fact_kol=0;
}
CCena::~CCena()
{
}
void CCena::ZapisZap(int nomer)
{
CFile file(CenaFile, CFile::modeWrite|CFile::modeCreate|
CFile::modeNoTruncate);
try
{
file.Seek(nomer*15,CFile::begin);
file.Write(LPCTSTR(Vid),5);
file.Write(LPCTSTR(Rascenka),10);
}
catch (CFileException *e)
{
char pMsg[255];
if(e->GetErrorMessage(pMsg,255))
AfxMessageBox(pMsg);
}
file.Close();
return;
}
void CCena::ChtenieZap(int nomer)
{
CFile file(CenaFile, CFile::modeRead | CFile::modeNoTruncate);
char buf[10];
try
{
file.Seek(nomer*15,CFile::begin);
file.Read(buf,5);
Vid=CString(buf);
file.Read(buf,10);
Rascenka=CString(buf);
}
catch (CFileException *e)
{
char pMsg[255];
if(e->GetErrorMessage(pMsg,255))
AfxMessageBox(pMsg);
}
file.Close();
return;
}
void CCena::Sozdanie()
{
int nom;
nom=dob_ind(Vid);
ZapisZap(nom);
return;
}
void CCena::Init()
{
int pr=0;
int i=0;
CFile file (CenaFile, CFile::modeRead|CFile::modeCreate|
CFile::modeNoTruncate);
DWORD nom;
nom=file.GetLength();
nom=nom/15;
file.Close();
for(i=0;i<int(nom);i++)
{
ChtenieZap(i);
init_ind(i,Vid);
if (Vid!="")
{
fact_kol++;
pr=1;
}
}
init_kol(nom);
return;
}
void CCena::Zamena(int nomer)
{
ZapisZap(nomer);
cor_ind(nomer,Vid);
}
void CCena::Udalenie(int nomer)
{
Vid="";
ZapisZap(nomer);
cor_ind(nomer,Vid);
}
Дата публикования: 2014-11-26; Прочитано: 202 | Нарушение авторского права страницы | Мы поможем в написании вашей работы!