- •Содержание
- •Введение
- •1.Обзор методов и алгоритмов решения поставленной задачи
- •1.1 Организация работы с файлами средствами c
- •2 Обоснование выбранных методов и алгоритмов
- •3 Описание программы для программиста
- •4 Описание алгоритмов решения задачи
- •Заключение
- •Литература
- •Приложение а – Листинг программы
- •Приложение б - Скриншоты с результатами работы
Приложение а – Листинг программы
//BaseFlats.h
#ifndef BASEFLATS_H
#define BASEFLATS_H
#include<stdio.h>
usingnamespace System::Windows::Forms;
usingnamespace System::Windows;
usingnamespace System;
class FlatBase // Базовый класс адресов
{
protected:
wchar_t Addr[260];
wchar_t Square[5];
wchar_t Price[10];
bool IsTel;
FILE *F;
public:
void uninit(); // Снятьпривязкукфайлу
virtuallong Size() = 0;// Количество записей в файле
virtualvoid input(int i, DataGridView^ dgv) = 0; // Заполняет поля объекта класса значениями из DataGridView
virtualvoid SaveToF() = 0; // Сохранение в файл одного объекта
virtualbool ReadFromF(int i) = 0; // Чтение i-гообъектаизфайла
virtualvoid view(int i, DataGridView^ dgv) = 0; // Отображаетданныеоб i-мобъектев DataGridView
virtualvoid init(char f = 'r') = 0;// Привязкакфайлу
};
class Flat : public FlatBase
{
private:
wchar_t NumOfRoom[3];
wchar_t Floor[3];
bool nalichremonta;
bool IsEmpty;
public:
virtuallong Size();
virtualvoid input(int i, DataGridView^ dgv);
virtualvoid SaveToF();
virtualbool ReadFromF(int i);
virtualvoid view(int i, DataGridView^ dgv);
virtualvoid init(char f = 'r');//значение параметра по умолчанию
};
class House : public FlatBase
{
private:
wchar_t NumOfFloors[3];
wchar_t TypeOfHeat[30];
wchar_t NumOfFlats[5];
wchar_t NumOfRooms[3];
bool Sewers;
public:
virtuallong Size();
virtualvoid input(int i, DataGridView^ dgv);
virtualvoid SaveToF();
virtualbool ReadFromF(int i);
virtualvoid view(int i, DataGridView^ dgv);
virtualvoid init(char f = 'r');
};
class Commercial : public FlatBase
{
private:
wchar_t NumOfFloors[3];
public:
virtuallong Size();
virtualvoid input(int i, DataGridView^ dgv);
virtualvoid SaveToF();
virtualbool ReadFromF(int i);
virtualvoid view(int i, DataGridView^ dgv);
virtualvoid init(char f = 'r');
};
class Human
{
private:
wchar_t FIO[100];
wchar_t Tel[20];
wchar_t Addr[260];
FILE *F;
public:
long Size();
void SaveToF();
bool ReadFromF(int i);
void init(char f = 'r');
void uninit();
void Input(String^ fio, String^ tel, String^ adr);// Заполнениеполейобъектаклассазначениями
String^ OutFIO(); // Возвращает ФИО
String^ OutTel(); // Возвращает Телефон
String^ OutAddr(); // ВозвращаетАдрес
};
class ContH
{
private:
ContH *next, *prev;// Указатели на следующий и предыдущий элементы списка
Human *H; // Указатель на объект класса Human
public:
ContH(); // Конструктор класса ContH
ContH * Add(Human * h); // Добавляет объект класса Human в список и возвращает указатель на следующий элемент списка
ContH * Del(); // Удаляет объект класса Human из списка и возвращает указатель на предыдущий элемент списка
ContH * Next(); // Возвращает указатель на следующий элемент списка
ContH * Prev(); // Возвращает указатель на предыдущий элемент списка
Human * Value(); // Возвращает указатель на объект класса Human
ContH * Item(int i, ContH * B);// Возвращает i-йэлементсписка
};
#endif
//BaseFlats.cpp
#include"stdafx.h"
#include"BaseFlats.h"
void FlatBase::uninit()
{
fclose(F);
}
// ------Описание методов класса Flat------
long Flat::Size()
{
F = fopen("Database\\Flats.f","rb");
long fle,flb;
fseek(F,0,2); // Установка указателя на конец файла
fle = ftell(F); // Возвращает значение установленного указателя
fseek(F,0,0); // Установка указателя на начало файла
flb = ftell(F);
fclose(F);
return (fle - flb)/sizeof(Flat);
}
void Flat::init(char f)
{
if (f == 'r') F = fopen("Database\\Flats.f","rb");
if (f == 'w') F = fopen("Database\\Flats.f","wb");
if (f == 'a') F = fopen("Database\\Flats.f","ab");
}
void Flat::input(int i, DataGridView ^dgv)// заполнениеизячеекдгввобъект
{
String^ s = dgv->Rows[i]->Cells[0]->Value->ToString();
for(int j=0;j<s->Length;j++) Addr[j] = s[j];
Addr[s->Length] = '\0';
s = dgv->Rows[i]->Cells[1]->Value->ToString();
for(int j=0;j<s->Length;j++) Square[j] = s[j];
Square[s->Length] = '\0';
s = dgv->Rows[i]->Cells[2]->Value->ToString();
for(int j=0;j<s->Length;j++) NumOfRoom[j] = s[j];
NumOfRoom[s->Length] = '\0';
s = dgv->Rows[i]->Cells[3]->Value->ToString();
for(int j=0;j<s->Length;j++) Floor[j] = s[j];
Floor[s->Length] = '\0';
IsTel = (bool)dgv->Rows[i]->Cells[4]->Value;
nalichremonta = (bool)dgv->Rows[i]->Cells[5]->Value;
IsEmpty = (bool)dgv->Rows[i]->Cells[6]->Value;
s = dgv->Rows[i]->Cells[7]->Value->ToString();
for(int j=0;j<s->Length;j++) Price[j] =s[j];
Price[s->Length] = '\0';
}
void Flat::view(int i, DataGridView ^ dgv)//изобъектавдгв
{
String ^ tmp = gcnew String(Addr);
dgv->Rows[i]->Cells[0]->Value = tmp;
tmp = gcnew String(Square);
dgv->Rows[i]->Cells[1]->Value = tmp;
tmp = gcnew String(NumOfRoom);
dgv->Rows[i]->Cells[2]->Value = tmp;
tmp = gcnew String(Floor);
dgv->Rows[i]->Cells[3]->Value = tmp;
dgv->Rows[i]->Cells[4]->Value = IsTel;
dgv->Rows[i]->Cells[5]->Value = nalichremonta;
dgv->Rows[i]->Cells[6]->Value = IsEmpty;
tmp = gcnew String(Price);
dgv->Rows[i]->Cells[7]->Value = tmp;
}
void Flat::SaveToF()
{
fwrite(this,sizeof(Flat),1,F);
}
bool Flat::ReadFromF(int k)
{
fseek(F,k*sizeof(Flat),0);
char *A;
A = newchar[sizeof(Flat)];
if(!fread(A,sizeof(Flat),1,F)) returnfalse;
int i = 4;
while (A[i]!='\0') {Addr[(i-4)/2] = A[i]+A[i+1]*256;i+=2;}
Addr[(i-4)/2] = '\0';
i = 524;// перескакиваем на следующее поле
while (A[i]!='\0') {Square[(i-524)/2] = A[i]+A[i+1]*256;i+=2;}
Square[(i-524)/2] = '\0';
i = 534;
while (A[i]!='\0') {Price[(i-534)/2] = A[i]+A[i+1]*256;i+=2;}
Price[(i-534)/2] = '\0';
IsTel = (bool)(A[554]);
i = 560;
while (A[i]!='\0') {NumOfRoom[(i-560)/2] = A[i]+A[i+1]*256;i+=2;}
NumOfRoom[(i-560)/2] = '\0';
i = 566;
while (A[i]!='\0') {Floor[(i-566)/2] = A[i]+A[i+1]*256;i+=2;}
Floor[(i-566)/2] = '\0';
nalichremonta = (bool)(A[572]);
IsEmpty = (bool)(A[573]);
returntrue;
}
// ------Описаниеметодовкласса House------
long House::Size()
{
F = fopen("Database\\Houses.hs","rb");
long fle,flb;
fseek(F,0,2);
fle = ftell(F);
fseek(F,0,0);
flb = ftell(F);
fclose(F);
return (fle - flb)/sizeof(House);
}
void House::init(char f)
{
if (f == 'r') F = fopen("Database\\Houses.hs","rb");
if (f == 'w') F = fopen("Database\\Houses.hs","wb");
if (f == 'a') F = fopen("Database\\Houses.hs","ab");
}
void House::SaveToF()
{
fwrite(this,sizeof(House),1,F);
}
bool House::ReadFromF(int k)
{
fseek(F,k*sizeof(House),0);
char *A;
A = newchar[sizeof(House)];
if(!fread(A,sizeof(House),1,F)) returnfalse;
int i = 4;
while (A[i]!='\0') {Addr[(i-4)/2] = A[i]+A[i+1]*256;i+=2;}
Addr[(i-4)/2] = '\0';
i = 524;
while (A[i]!='\0') {Square[(i-524)/2] = A[i]+A[i+1]*256;i+=2;}
Square[(i-524)/2] = '\0';
i = 534;
while (A[i]!='\0') {Price[(i-534)/2] = A[i]+A[i+1]*256;i+=2;}
Price[(i-534)/2] = '\0';
IsTel = (bool)(A[554]);
i = 560;
while (A[i]!='\0') {NumOfFloors[(i-560)/2] = A[i]+A[i+1]*256;i+=2;}
NumOfFloors[(i-560)/2] = '\0';
i = 566;
while (A[i]!='\0') {TypeOfHeat[(i-566)/2] = A[i]+A[i+1]*256;i+=2;}
TypeOfHeat[(i-566)/2] = '\0';
i = 626;
while (A[i]!='\0') {NumOfFlats[(i-626)/2] = A[i]+A[i+1]*256;i+=2;}
NumOfFlats[(i-626)/2] = '\0';
i = 636;
while (A[i]!='\0') {NumOfRooms[(i-636)/2] = A[i]+A[i+1]*256;i+=2;}
NumOfRooms[(i-636)/2] = '\0';
Sewers = (bool)A[642];
returntrue;
}
void House::view(int i, DataGridView^ dgv)
{
String ^ tmp = gcnew String(Addr);
dgv->Rows[i]->Cells[0]->Value = tmp;
tmp = gcnew String(Square);
dgv->Rows[i]->Cells[1]->Value = tmp;
tmp = gcnew String(NumOfFloors);
dgv->Rows[i]->Cells[2]->Value = tmp;
tmp = gcnew String(NumOfFlats);
dgv->Rows[i]->Cells[3]->Value = tmp;
tmp = gcnew String(NumOfRooms);
dgv->Rows[i]->Cells[4]->Value = tmp;
tmp = gcnew String(TypeOfHeat);
dgv->Rows[i]->Cells[5]->Value = tmp;
dgv->Rows[i]->Cells[6]->Value = Sewers;
dgv->Rows[i]->Cells[7]->Value = IsTel;
tmp = gcnew String(Price);
dgv->Rows[i]->Cells[8]->Value = tmp;
}
void House::input(int i,DataGridView^ dgv)
{
String^ s = dgv->Rows[i]->Cells[0]->Value->ToString();
for(int j=0;j<s->Length;j++) Addr[j] = s[j];
Addr[s->Length] = '\0';
s = dgv->Rows[i]->Cells[1]->Value->ToString();
for(int j=0;j<s->Length;j++) Square[j] = s[j];
Square[s->Length] = '\0';
s = dgv->Rows[i]->Cells[2]->Value->ToString();
for(int j=0;j<s->Length;j++) NumOfFloors[j] = s[j];
NumOfFloors[s->Length] = '\0';
s = dgv->Rows[i]->Cells[3]->Value->ToString();
for(int j=0;j<s->Length;j++) NumOfFlats[j] = s[j];
NumOfFlats[s->Length] = '\0';
s = dgv->Rows[i]->Cells[4]->Value->ToString();
for(int j=0;j<s->Length;j++) NumOfRooms[j] = s[j];
NumOfRooms[s->Length] = '\0';
s = dgv->Rows[i]->Cells[5]->Value->ToString();
for(int j=0;j<s->Length;j++) TypeOfHeat[j] = s[j];
TypeOfHeat[s->Length] = '\0';
Sewers = (bool)dgv->Rows[i]->Cells[6]->Value;
IsTel = (bool)dgv->Rows[i]->Cells[7]->Value;
s = dgv->Rows[i]->Cells[8]->Value->ToString();
for(int j=0;j<s->Length;j++) Price[j] =s[j];
Price[s->Length] = '\0';
}
// ------Описаниеметодовкласса Comercial------
long Commercial::Size()
{
F = fopen("Database\\Commercial.cm","rb");
long fle,flb;
fseek(F,0,2);
fle = ftell(F);
fseek(F,0,0);
flb = ftell(F);
fclose(F);
return (fle - flb)/sizeof(Commercial);
}
void Commercial::init(char f)
{
if (f == 'r') F = fopen("Database\\Commercial.cm","rb");
if (f == 'w') F = fopen("Database\\Commercial.cm","wb");
if (f == 'a') F = fopen("Database\\Commercial.cm","ab");
}
void Commercial::SaveToF()
{
fwrite(this,sizeof(Commercial),1,F);
}
void Commercial::view(int i, DataGridView^ dgv)
{
String ^ tmp = gcnew String(Addr);
dgv->Rows[i]->Cells[0]->Value = tmp;
tmp = gcnew String(NumOfFloors);
dgv->Rows[i]->Cells[1]->Value = tmp;
tmp = gcnew String(Square);
dgv->Rows[i]->Cells[2]->Value = tmp;
tmp = gcnew String(Price);
dgv->Rows[i]->Cells[3]->Value = tmp;
}
void Commercial::input(int i, DataGridView ^dgv)
{
String^ s = dgv->Rows[i]->Cells[0]->Value->ToString();
for(int j=0;j<s->Length;j++) Addr[j] = s[j];
Addr[s->Length] = '\0';
s = dgv->Rows[i]->Cells[1]->Value->ToString();
for(int j=0;j<s->Length;j++) NumOfFloors[j] = s[j];
NumOfFloors[s->Length] = '\0';
s = dgv->Rows[i]->Cells[2]->Value->ToString();
for(int j=0;j<s->Length;j++) Square[j] = s[j];
Square[s->Length] = '\0';
s = dgv->Rows[i]->Cells[3]->Value->ToString();
for(int j=0;j<s->Length;j++) Price[j] =s[j];
Price[s->Length] = '\0';
}
bool Commercial::ReadFromF(int k)
{
fseek(F,k*sizeof(Commercial),0);
char *A;
A = newchar[sizeof(Commercial)];
if(!fread(A,sizeof(Commercial),1,F)) returnfalse;
int i = 4;
while (A[i]!='\0') {Addr[(i-4)/2] = A[i]+A[i+1]*256;i+=2;}
Addr[(i-4)/2] = '\0';
i = 524;
while (A[i]!='\0') {Square[(i-524)/2] = A[i]+A[i+1]*256;i+=2;}
Square[(i-524)/2] = '\0';
i = 534;
while (A[i]!='\0') {Price[(i-534)/2] = A[i]+A[i+1]*256;i+=2;}
Price[(i-534)/2] = '\0';
i = 560;
while (A[i]!='\0') {NumOfFloors[(i-560)/2] = A[i]+A[i+1]*256;i+=2;}
NumOfFloors[(i-560)/2] = '\0';
returntrue;
}
// ------Описаниеметодовкласса Human------
void Human::init(char f)
{
if (f == 'r') F = fopen("Database\\Humans.hm","rb");
if (f == 'w') F = fopen("Database\\Humans.hm","wb");
if (f == 'a') F = fopen("Database\\Humans.hm","ab");
}
void Human::uninit()
{
fclose(F);
}
void Human::SaveToF()
{
fwrite(this,sizeof(Human),1,F);
}
bool Human::ReadFromF(int k)
{
fseek(F,k*sizeof(Human),0);
char *A;
A = newchar[sizeof(Human)];
if(!fread(A,sizeof(Human),1,F)) returnfalse;
int i = 0;
while (A[i]!='\0') {FIO[(i)/2] = A[i]+A[i+1]*256;i+=2;}
FIO[(i)/2] = '\0';
i = 200;
while (A[i]!='\0') {Tel[(i-200)/2] = A[i]+A[i+1]*256;i+=2;}
Tel[(i-200)/2] = '\0';
i = 240;
while (A[i]!='\0') {Addr[(i-240)/2] = A[i]+A[i+1]*256;i+=2;}
Addr[(i-240)/2] = '\0';
returntrue;
}
void Human::Input(String^ fio, String^ tel, String^ adr)
{
for(int i = 0;i<fio->Length;i++) FIO[i] = fio[i];//преобразование string в wchar_t
FIO[fio->Length] = '\0';
for(int i = 0;i<tel->Length;i++) Tel[i] = tel[i];
Tel[tel->Length] = '\0';
for(int i = 0;i<adr->Length;i++) Addr[i] = adr[i];
Addr[adr->Length] = '\0';
}
String^ Human::OutFIO()
{
returngcnew String(FIO);
}
String^ Human::OutTel()
{
returngcnew String(Tel);
}
String^ Human::OutAddr()
{
returngcnew String(Addr);
}
long Human::Size()
{
F = fopen("Database\\Humans.hm","rb");
long fle,flb;
fseek(F,0,2);
fle = ftell(F);
fseek(F,0,0);
flb = ftell(F);
fclose(F);
return (fle - flb)/sizeof(Human);
}
// ------Описание методов класса контейнера для клиентов------
ContH::ContH()
{
prev = next = nullptr;
H = new Human;
}
ContH * ContH::Add(Human * h)
{
ContH * t = new ContH;
this->H = h;
this->next = t;
t->next = nullptr;
t->prev = this;
return t;
}
ContH * ContH::Del()
{
ContH * t,*d;
d = this;
if(this->next == nullptr)
{
if(this->prev != nullptr)
{
t = d->prev;
t->next = nullptr;
delete d;
return t;
}
return d;
}
else
{
if(this->prev == nullptr)
{
t = d->next;
t->prev = nullptr;
delete d;
return t;
}
t = d->prev;
t->next = d->next;
t->next->prev = t;
delete d;
return t;
}
}
ContH * ContH::Next()
{
returnthis->next;
}
ContH * ContH::Prev()
{
returnthis->prev;
}
Human * ContH::Value()
{
return H;
}
ContH * ContH::Item(int i, ContH * B)
{
ContH * t = B;
for(int k=0;k<i;k++)
t = t->Next();
return t;
}
//Form1.h
#include"BaseFlats.h"
#include<string.h>
#pragmaonce
ContH *beg,*end;
namespace Flats {
usingnamespace System;
usingnamespace System::ComponentModel;
usingnamespace System::Collections;
usingnamespace System::Windows::Forms;
usingnamespace System::Data;
usingnamespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
publicrefclass Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
protected:
private: System::Windows::Forms::DataGridView^ dataGridView1;
private: System::Windows::Forms::DataGridView^ dataGridView2;
private: System::Windows::Forms::DataGridView^ dataGridView3;
private: System::Windows::Forms::TabControl^ tabControl1;
private: System::Windows::Forms::TabPage^ flatsPage;
private: System::Windows::Forms::TabPage^ housePage;
private: System::Windows::Forms::TabPage^ commPage;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column1;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column4;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column9;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column5;
private: System::Windows::Forms::DataGridViewCheckBoxColumn^ Column6;
private: System::Windows::Forms::DataGridViewCheckBoxColumn^ Column7;
private: System::Windows::Forms::DataGridViewCheckBoxColumn^ Column8;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column10;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn2;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn3;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn4;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn5;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn1;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column2;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn6;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn7;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn8;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn9;
private: System::Windows::Forms::DataGridViewCheckBoxColumn^ dataGridViewCheckBoxColumn1;
private: System::Windows::Forms::DataGridViewCheckBoxColumn^ Column3;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumn10;
private: System::Windows::Forms::ListBox^ listBox1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::MenuStrip^ menuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ saveToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ exitToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ edToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ editToolStripMenuItem;
private: System::Windows::Forms::Button^ bAdd1;
private: System::Windows::Forms::Button^ bEdit2;
private: System::Windows::Forms::Button^ bDel1;
private: System::Windows::Forms::Form^ f1;
private: System::Windows::Forms::TextBox^ tb1;
private: System::Windows::Forms::TextBox^ tb2;
private: System::Windows::Forms::TextBox^ tb3;
private: System::Windows::Forms::Button^ bAdd;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragmaregion Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
this->Column1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->Column4 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->Column9 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->Column5 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->Column6 = (gcnew System::Windows::Forms::DataGridViewCheckBoxColumn());
this->Column7 = (gcnew System::Windows::Forms::DataGridViewCheckBoxColumn());
this->Column8 = (gcnew System::Windows::Forms::DataGridViewCheckBoxColumn());
this->Column10 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridView2 = (gcnew System::Windows::Forms::DataGridView());
this->dataGridViewTextBoxColumn1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->Column2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridViewTextBoxColumn6 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridViewTextBoxColumn7 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridViewTextBoxColumn8 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridViewTextBoxColumn9 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridViewCheckBoxColumn1 = (gcnew System::Windows::Forms::DataGridViewCheckBoxColumn());
this->Column3 = (gcnew System::Windows::Forms::DataGridViewCheckBoxColumn());
this->dataGridViewTextBoxColumn10 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
this->flatsPage = (gcnew System::Windows::Forms::TabPage());
this->housePage = (gcnew System::Windows::Forms::TabPage());
this->commPage = (gcnew System::Windows::Forms::TabPage());
this->dataGridView3 = (gcnew System::Windows::Forms::DataGridView());
this->dataGridViewTextBoxColumn2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridViewTextBoxColumn3 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridViewTextBoxColumn4 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->dataGridViewTextBoxColumn5 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->listBox1 = (gcnew System::Windows::Forms::ListBox());
this->bEdit2 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->saveToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->edToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->editToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->bAdd1 = (gcnew System::Windows::Forms::Button());
this->bDel1 = (gcnew System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView2))->BeginInit();
this->tabControl1->SuspendLayout();
this->flatsPage->SuspendLayout();
this->housePage->SuspendLayout();
this->commPage->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView3))->BeginInit();
this->menuStrip1->SuspendLayout();
this->SuspendLayout();
//
// dataGridView1
//
this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(8) {this->Column1,
this->Column4, this->Column9, this->Column5, this->Column6, this->Column7, this->Column8, this->Column10});
this->dataGridView1->Location = System::Drawing::Point(0, 0);
this->dataGridView1->Name = L"dataGridView1";
this->dataGridView1->RowTemplate->Height = 24;
this->dataGridView1->Size = System::Drawing::Size(757, 308);
this->dataGridView1->TabIndex = 0;
this->dataGridView1->RowsAdded += gcnew System::Windows::Forms::DataGridViewRowsAddedEventHandler(this, &Form1::dataGridView1_RowsAdded);
//
// Column1
//
this->Column1->HeaderText = L"Адресквартиры";
this->Column1->Name = L"Column1";
this->Column1->Width = 305;
//
// Column4
//
this->Column4->HeaderText = L"Площадь";
this->Column4->Name = L"Column4";
this->Column4->Width = 75;
//
// Column9
//
this->Column9->HeaderText = L"Кол-вокомнат";
this->Column9->Name = L"Column9";
this->Column9->Width = 130;
//
// Column5
//
this->Column5->HeaderText = L"Этаж";
this->Column5->Name = L"Column5";
this->Column5->Width = 50;
//
// Column6
//
this->Column6->HeaderText = L"Телефон";
this->Column6->Name = L"Column6";
this->Column6->Width = 75;
//
// Column7
//
this->Column7->HeaderText = L"Ремонт";
this->Column7->Name = L"Column7";
this->Column7->Width = 65;
//
// Column8
//
this->Column8->HeaderText = L"Пустая";
this->Column8->Name = L"Column8";
this->Column8->Width = 60;
//
// Column10
//
this->Column10->HeaderText = L"Цена";
this->Column10->Name = L"Column10";
//
// dataGridView2
//
this->dataGridView2->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView2->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(9) {this->dataGridViewTextBoxColumn1,
this->Column2, this->dataGridViewTextBoxColumn6, this->dataGridViewTextBoxColumn7, this->dataGridViewTextBoxColumn8, this->dataGridViewTextBoxColumn9,
this->dataGridViewCheckBoxColumn1, this->Column3, this->dataGridViewTextBoxColumn10});
this->dataGridView2->Location = System::Drawing::Point(1, 0);
this->dataGridView2->Name = L"dataGridView2";
this->dataGridView2->RowTemplate->Height = 24;
this->dataGridView2->Size = System::Drawing::Size(756, 308);
this->dataGridView2->TabIndex = 1;
this->dataGridView2->RowsAdded += gcnew System::Windows::Forms::DataGridViewRowsAddedEventHandler(this, &Form1::dataGridView2_RowsAdded);
//
// dataGridViewTextBoxColumn1
//
this->dataGridViewTextBoxColumn1->HeaderText = L"Адрес";
this->dataGridViewTextBoxColumn1->Name = L"dataGridViewTextBoxColumn1";
this->dataGridViewTextBoxColumn1->Width = 305;
//
// Column2
//
this->Column2->HeaderText = L"Площадь";
this->Column2->Name = L"Column2";
this->Column2->Width = 75;
//
// dataGridViewTextBoxColumn6
//
this->dataGridViewTextBoxColumn6->HeaderText = L"Кол-воэтажей";
this->dataGridViewTextBoxColumn6->Name = L"dataGridViewTextBoxColumn6";
this->dataGridViewTextBoxColumn6->Width = 130;
//
// dataGridViewTextBoxColumn7
//
this->dataGridViewTextBoxColumn7->HeaderText = L"Кол-воквартир";
this->dataGridViewTextBoxColumn7->Name = L"dataGridViewTextBoxColumn7";
this->dataGridViewTextBoxColumn7->Width = 140;
//
// dataGridViewTextBoxColumn8
//
this->dataGridViewTextBoxColumn8->HeaderText = L"Кол-вокомнат";
this->dataGridViewTextBoxColumn8->Name = L"dataGridViewTextBoxColumn8";
this->dataGridViewTextBoxColumn8->Width = 130;
//
// dataGridViewTextBoxColumn9
//
this->dataGridViewTextBoxColumn9->HeaderText = L"Отопление";
this->dataGridViewTextBoxColumn9->Name = L"dataGridViewTextBoxColumn9";
//
// dataGridViewCheckBoxColumn1
//
this->dataGridViewCheckBoxColumn1->HeaderText = L"Канализация";
this->dataGridViewCheckBoxColumn1->Name = L"dataGridViewCheckBoxColumn1";
//
// Column3
//
this->Column3->HeaderText = L"Телефон";
this->Column3->Name = L"Column3";
this->Column3->Resizable = System::Windows::Forms::DataGridViewTriState::True;
this->Column3->SortMode = System::Windows::Forms::DataGridViewColumnSortMode::Automatic;
this->Column3->Width = 75;
//
// dataGridViewTextBoxColumn10
//
this->dataGridViewTextBoxColumn10->HeaderText = L"Цена";
this->dataGridViewTextBoxColumn10->Name = L"dataGridViewTextBoxColumn10";
//
// tabControl1
//
this->tabControl1->Controls->Add(this->flatsPage);
this->tabControl1->Controls->Add(this->housePage);
this->tabControl1->Controls->Add(this->commPage);
this->tabControl1->Location = System::Drawing::Point(12, 31);
this->tabControl1->Name = L"tabControl1";
this->tabControl1->SelectedIndex = 0;
this->tabControl1->Size = System::Drawing::Size(765, 337);
this->tabControl1->TabIndex = 4;
//
// flatsPage
//
this->flatsPage->AutoScroll = true;
this->flatsPage->Controls->Add(this->dataGridView1);
this->flatsPage->Location = System::Drawing::Point(4, 25);
this->flatsPage->Name = L"flatsPage";
this->flatsPage->Padding = System::Windows::Forms::Padding(3);
this->flatsPage->Size = System::Drawing::Size(757, 308);
this->flatsPage->TabIndex = 0;
this->flatsPage->Text = L"Квартиры";
this->flatsPage->UseVisualStyleBackColor = true;
//
// housePage
//
this->housePage->AutoScroll = true;
this->housePage->Controls->Add(this->dataGridView2);
this->housePage->Location = System::Drawing::Point(4, 25);
this->housePage->Name = L"housePage";
this->housePage->Padding = System::Windows::Forms::Padding(3);
this->housePage->Size = System::Drawing::Size(757, 308);
this->housePage->TabIndex = 1;
this->housePage->Text = L"Частныедома";
this->housePage->UseVisualStyleBackColor = true;
//
// commPage
//
this->commPage->AutoScroll = true;
this->commPage->Controls->Add(this->dataGridView3);
this->commPage->Location = System::Drawing::Point(4, 25);
this->commPage->Name = L"commPage";
this->commPage->Size = System::Drawing::Size(757, 308);
this->commPage->TabIndex = 2;
this->commPage->Text = L"Комерческиездания";
this->commPage->UseVisualStyleBackColor = true;
//
// dataGridView3
//
this->dataGridView3->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView3->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(4) {this->dataGridViewTextBoxColumn2,
this->dataGridViewTextBoxColumn3, this->dataGridViewTextBoxColumn4, this->dataGridViewTextBoxColumn5});
this->dataGridView3->Location = System::Drawing::Point(0, 0);
this->dataGridView3->Name = L"dataGridView3";
this->dataGridView3->RowTemplate->Height = 24;
this->dataGridView3->Size = System::Drawing::Size(757, 308);
this->dataGridView3->TabIndex = 2;
//
// dataGridViewTextBoxColumn2
//
this->dataGridViewTextBoxColumn2->HeaderText = L"Адресздания";
this->dataGridViewTextBoxColumn2->Name = L"dataGridViewTextBoxColumn2";
this->dataGridViewTextBoxColumn2->Width = 400;
//
// dataGridViewTextBoxColumn3
//
this->dataGridViewTextBoxColumn3->HeaderText = L"Кол-воэтажей";
this->dataGridViewTextBoxColumn3->Name = L"dataGridViewTextBoxColumn3";
this->dataGridViewTextBoxColumn3->Width = 130;
//
// dataGridViewTextBoxColumn4
//
this->dataGridViewTextBoxColumn4->HeaderText = L"Площадь";
this->dataGridViewTextBoxColumn4->Name = L"dataGridViewTextBoxColumn4";
//
// dataGridViewTextBoxColumn5
//
this->dataGridViewTextBoxColumn5->HeaderText = L"Цена";
this->dataGridViewTextBoxColumn5->Name = L"dataGridViewTextBoxColumn5";
//
// listBox1
//
this->listBox1->FormattingEnabled = true;
this->listBox1->ItemHeight = 16;
this->listBox1->Location = System::Drawing::Point(12, 374);
this->listBox1->Name = L"listBox1";
this->listBox1->Size = System::Drawing::Size(267, 84);
this->listBox1->TabIndex = 5;
this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::listBox1_SelectedIndexChanged);
//
// bEdit2
//
this->bEdit2->Location = System::Drawing::Point(558, 374);
this->bEdit2->Name = L"bEdit2";
this->bEdit2->Size = System::Drawing::Size(219, 27);
this->bEdit2->TabIndex = 6;
this->bEdit2->Text = L"Изменитьклиента";
this->bEdit2->UseVisualStyleBackColor = true;
this->bEdit2->Click += gcnew System::EventHandler(this, &Form1::bEdit2_Click);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(285, 376);
this->textBox1->Name = L"textBox1";
this->textBox1->ReadOnly = true;
this->textBox1->Size = System::Drawing::Size(267, 22);
this->textBox1->TabIndex = 7;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(285, 404);
this->textBox2->Name = L"textBox2";
this->textBox2->ReadOnly = true;
this->textBox2->Size = System::Drawing::Size(267, 22);
this->textBox2->TabIndex = 8;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(285, 432);
this->textBox3->Name = L"textBox3";
this->textBox3->ReadOnly = true;
this->textBox3->Size = System::Drawing::Size(267, 22);
this->textBox3->TabIndex = 9;
//
// menuStrip1
//
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->fileToolStripMenuItem,
this->edToolStripMenuItem});
this->menuStrip1->Location = System::Drawing::Point(0, 0);
this->menuStrip1->Name = L"menuStrip1";
this->menuStrip1->Size = System::Drawing::Size(789, 28);
this->menuStrip1->TabIndex = 10;
this->menuStrip1->Text = L"menuStrip1";
//
// fileToolStripMenuItem
//
this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->saveToolStripMenuItem,
this->exitToolStripMenuItem});
this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
this->fileToolStripMenuItem->Size = System::Drawing::Size(57, 24);
this->fileToolStripMenuItem->Text = L"Файл";
//
// saveToolStripMenuItem
//
this->saveToolStripMenuItem->Name = L"saveToolStripMenuItem";
this->saveToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::S));
this->saveToolStripMenuItem->Size = System::Drawing::Size(237, 24);
this->saveToolStripMenuItem->Text = L"Сохранитьбазу";
this->saveToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveToolStripMenuItem_Click);
//
// exitToolStripMenuItem
//
this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
this->exitToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::F4));
this->exitToolStripMenuItem->Size = System::Drawing::Size(237, 24);
this->exitToolStripMenuItem->Text = L"Выход";
this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::exitToolStripMenuItem_Click);
//
// edToolStripMenuItem
//
this->edToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->editToolStripMenuItem});
this->edToolStripMenuItem->Name = L"edToolStripMenuItem";
this->edToolStripMenuItem->Size = System::Drawing::Size(72, 24);
this->edToolStripMenuItem->Text = L"Правка";
//
// editToolStripMenuItem
//
this->editToolStripMenuItem->Name = L"editToolStripMenuItem";
this->editToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::E));
this->editToolStripMenuItem->Size = System::Drawing::Size(230, 24);
this->editToolStripMenuItem->Text = L"Редактировать";
this->editToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::editToolStripMenuItem_Click);
//
// bAdd1
//
this->bAdd1->Location = System::Drawing::Point(558, 404);
this->bAdd1->Name = L"bAdd1";
this->bAdd1->Size = System::Drawing::Size(219, 23);
this->bAdd1->TabIndex = 11;
this->bAdd1->Text = L"Добавитьклиента";
this->bAdd1->UseVisualStyleBackColor = true;
this->bAdd1->Click += gcnew System::EventHandler(this, &Form1::bAdd1_Click);
//
// bDel1
//
this->bDel1->Location = System::Drawing::Point(558, 432);
this->bDel1->Name = L"bDel1";
this->bDel1->Size = System::Drawing::Size(219, 23);
this->bDel1->TabIndex = 12;
this->bDel1->Text = L"Удалитьклиента";
this->bDel1->UseVisualStyleBackColor = true;
this->bDel1->Click += gcnew System::EventHandler(this, &Form1::bDel1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(789, 468);
this->Controls->Add(this->bDel1);
this->Controls->Add(this->bAdd1);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->bEdit2);
this->Controls->Add(this->listBox1);
this->Controls->Add(this->tabControl1);
this->Controls->Add(this->menuStrip1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
this->MainMenuStrip = this->menuStrip1;
this->Name = L"Form1";
this->Text = L"Недвижимость";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &Form1::Form1_FormClosed);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView2))->EndInit();
this->tabControl1->ResumeLayout(false);
this->flatsPage->ResumeLayout(false);
this->housePage->ResumeLayout(false);
this->commPage->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView3))->EndInit();
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragmaendregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
beg = new ContH; // Производим инициализацию списка клиентов
end = beg;
Flat F;// Загрузка Flat изфайла
int i = 0;
F.init();// привязкакфайлу
while(F.ReadFromF(i))
{
dataGridView1->Rows->Add();//добавление строки в дгв
F.view(i++,dataGridView1);//заполнение строки элементами
}
dataGridView1->ReadOnly = true;
F.uninit();
House H; // Загрузка House изфайла
i = 0;
H.init();
while(H.ReadFromF(i))
{
dataGridView2->Rows->Add();
H.view(i++,dataGridView2);
}
dataGridView2->ReadOnly = true;
H.uninit();
Commercial C;// Загрузка Commercial изфайла
i = 0;
C.init();
while(C.ReadFromF(i))
{
dataGridView3->Rows->Add();
C.view(i++,dataGridView3);
}
dataGridView3->ReadOnly = true;
C.uninit();
Human *hm; //Загрузка клиентов из файла в список
hm = new Human;
i=0;
hm->init();
while(hm->ReadFromF(i++))
{
end = end->Add(hm);
listBox1->Items->Add(hm->OutFIO()); // Отображение загруженного клиента в listBox1
hm->uninit();
hm = new Human;
hm->init();
}
hm->uninit();
}
private: System::Void dataGridView1_RowsAdded(System::Object^ sender, System::Windows::Forms::DataGridViewRowsAddedEventArgs^ e) {
dataGridView1->Rows[dataGridView1->RowCount-1]->Cells[4]->Value = false;
dataGridView1->Rows[dataGridView1->RowCount-1]->Cells[5]->Value = false;
dataGridView1->Rows[dataGridView1->RowCount-1]->Cells[6]->Value = false;
}
private: System::Void dataGridView2_RowsAdded(System::Object^ sender, System::Windows::Forms::DataGridViewRowsAddedEventArgs^ e) {
dataGridView2->Rows[dataGridView2->RowCount-1]->Cells[6]->Value = false;
dataGridView2->Rows[dataGridView2->RowCount-1]->Cells[7]->Value = false;
}
private: System::Void Form1_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e) {
while(beg!=end) // При закрытии формы происходит очистка динамически выделенной памяти
{
end = end->Del();
}
delete beg;
}
private: System::Void bEdit2_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox1->ReadOnly)
{
if(listBox1->SelectedIndex == -1) // Еслиэлемент listBox1 невыбранвыводимсообщениеобошибке
{
MessageBox^ mb;
mb->Show(gcnew String("Выберитеклиента!"),
gcnew String("Ошибка"),
MessageBoxButtons::OK,
MessageBoxIcon::Error,
MessageBoxDefaultButton::Button1,
MessageBoxOptions::DefaultDesktopOnly,
false);
return; // Возвращаем управление форме
}
textBox1->ReadOnly = false; // Снимаем с textBox-ов атрибут "только для чтения"
textBox2->ReadOnly = false;
textBox3->ReadOnly = false;
bEdit2->Text = "Применить";
}
else
{
textBox1->ReadOnly = true; // Устанавливаематрибут "толькодлячтения" на textBox-ы
textBox2->ReadOnly = true;
textBox3->ReadOnly = true;
bEdit2->Text = "Изменить клиента";
// Меняем данные о клиенте
beg->Item(listBox1->SelectedIndex,beg)->Value()->Input(textBox1->Text,textBox2->Text,textBox3->Text);
// Если ФИО было изменено, изменяем её и в listBox1
listBox1->Items[listBox1->SelectedIndex] = beg->Item(listBox1->SelectedIndex,beg)->Value()->OutFIO();
}
}
private: System::Void listBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
if(listBox1->SelectedIndex!=-1) // При выборе элемента listBox проиходит отображение клиента в textBox-ах
{
textBox1->Text = beg->Item(listBox1->SelectedIndex,beg)->Value()->OutFIO();
textBox2->Text = beg->Item(listBox1->SelectedIndex,beg)->Value()->OutTel();
textBox3->Text = beg->Item(listBox1->SelectedIndex,beg)->Value()->OutAddr();
}
}
private: System::Void editToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
if(dataGridView1->ReadOnly) // Устанавливаем и снимаем атрибут "только для чтения"
{ // длятаблицсданными
dataGridView1->ReadOnly = false;
dataGridView2->ReadOnly = false;
dataGridView3->ReadOnly = false;
editToolStripMenuItem->Text = "Снятьредактирование";
}
else
{
dataGridView1->ReadOnly = true;
dataGridView2->ReadOnly = true;
dataGridView3->ReadOnly = true;
editToolStripMenuItem->Text = "Редактировать";
}
}
private: System::Void exitToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
Form1::Close();
}
private: System::Void saveToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
Flat F; // Запись в файл Flat
F.init('w');
int i = 0;
for(;i<dataGridView1->RowCount-1;i++)
{
F.input(i,dataGridView1);
F.SaveToF();
}
F.uninit();
House H; // Записьвфайл House
H.init('w');
i = 0;
for(;i<dataGridView2->RowCount-1;i++)
{
H.input(i,dataGridView2);
H.SaveToF();
}
H.uninit();
Commercial C; // Записьвфайл Commercial
C.init('w');
i = 0;
for(;i<dataGridView3->RowCount-1;i++)
{
C.input(i,dataGridView3);
C.SaveToF();
}
C.uninit();
ContH * t; // Запись в файл клиентов
t = beg;
t->Value()->init('w');
while(t->Next()!=nullptr)
{
t->Value()->SaveToF();
t->Value()->uninit();
t = t->Next();
t->Value()->init('a');
}
t->Value()->uninit();
}
private: System::Void bAdd1_Click(System::Object^ sender, System::EventArgs^ e) {
f1 = gcnew Form();// Создаём форму для ввода нового клиента
f1->Text = "Добавить";
f1->Size = System::Drawing::Size(242,178);
tb1 = gcnew TextBox();
tb2 = gcnew TextBox();
tb3 = gcnew TextBox();
bAdd = gcnew Button();
bAdd->Text = "Добавить";
tb1->Size = System::Drawing::Size(197,22);
tb2->Size = System::Drawing::Size(197,22);
tb3->Size = System::Drawing::Size(197,22);
bAdd->Size = System::Drawing::Size(197,27);
bAdd->Click += gcnew System::EventHandler(this, &Form1::add_click);
tb1->Location = Point(12,12);
tb2->Location = Point(12,40);
tb3->Location = Point(12,68);
bAdd->Location = Point(12,96);
f1->Controls->Add(tb1);
f1->Controls->Add(tb2);
f1->Controls->Add(tb3);
f1->Controls->Add(bAdd);
f1->ShowDialog();
}
private: System::Void add_click(System::Object^ sender, System::EventArgs^ e)
{
Human *hm; // Добавление клиента в список
hm = new Human;
hm->Input(tb1->Text,tb2->Text,tb3->Text);
end = end->Add(hm);
listBox1->Items->Add(hm->OutFIO());
f1->Close();
}
private: System::Void bDel1_Click(System::Object^ sender, System::EventArgs^ e) {
if(listBox1->SelectedIndex == -1)
{
MessageBox^ mb;
mb->Show(gcnew String("Выберитеклиента!"),
gcnew String("Ошибка"),
MessageBoxButtons::OK,
MessageBoxIcon::Error,
MessageBoxDefaultButton::Button1,
MessageBoxOptions::DefaultDesktopOnly,
false);
return;
}
if(beg->Item(listBox1->SelectedIndex,beg)->Next() == nullptr) // Есливыбранныйэлементвконцесписка
{
end = end->Del(); // Удаляем последний элемент из списка
}
else
{
if(beg->Item(listBox1->SelectedIndex,beg)->Prev() == nullptr) // Если выбранный элемент в начале списка
{
beg = beg->Del(); // Удаляем первый элемент из списка
}
else
{
ContH *t;
t = beg->Item(listBox1->SelectedIndex,beg); // Удаляем элемент внутри списка
t = t->Del();
}
}
listBox1->Items->Clear(); // Очистка listBox1
ContH *t;
t = beg;
while(t->Next()!=nullptr) // Выводспискав listBox1(ужебезудалённогоэлемента)
{
listBox1->Items->Add(t->Value()->OutFIO());
t = t->Next();
}
}
};
}
