ПЗ (1229304), страница 10
Текст из файла (страница 10)
fprintf(LogFile,"\n%s %s ",where.t_str(),what.t_str());
fprintf(LogFile,"%d:%d:%d(%d)",time.wHour,time.wMinute,
time.wSecond,time.wMilliseconds); //время
}
fclose(LogFile);
}
//---------------------------------------------------------------------------
UnicodeString Read_From_Text(UnicodeString tx,UnicodeString s)
{
int a = 0, b = tx.Pos(s), c = 1;
try
{
if (b==0) return 0;
while (tx[b+s.Length()+c] == ' ') {c++;}
for (int i=b+s.Length()+c;i<=tx.Length();i++)
{
if ((tx[i] == '\n') || (tx[i] == ' ')) break;
a++;
}
}
catch(...){ShowMessage("Ошибка в Read_From_Text " + s);}
return (tx.SubString(b+s.Length()+c,a));
}
//---------------------------------------------------------------------------
void Receive_Inf(UnicodeString tx)
{
try
{
Name_of_client = Read_From_Text(tx,"My_Name");
Number_Client = StrToInt(Read_From_Text(tx,"Number_Client"));
//---------------------------------------------------------------------------
cur_cash = StrToFloat(Read_From_Text(tx,"cur_cash"));
inv = StrToInt(Read_From_Text(tx,"inv"));
pow_cur_lev = StrToFloat(Read_From_Text(tx,"pow_cur_lev"));
pow_inc_price = StrToFloat(Read_From_Text(tx,"pow_inc_price"));
SRW_level = StrToFloat(Read_From_Text(tx,"SRW_level"));
SRW_inc_price = StrToInt(Read_From_Text(tx,"SRW_inc_price"));
inv_SRW = StrToInt(Read_From_Text(tx,"inv_SRW"));
marketing = StrToInt(Read_From_Text(tx,"marketing"));
st_inner_price = StrToInt(Read_From_Text(tx,"st_inner_price"));
planed_output = StrToInt(Read_From_Text(tx,"planed_output"));
pow_use_lev = StrToInt(Read_From_Text(tx,"pow_use_lev"));
cur_inn_price = StrToFloat(Read_From_Text(tx,"cur_inn_price"));
trg_output = StrToFloat(Read_From_Text(tx,"trg_output"));
amort_perc = StrToInt(Read_From_Text(tx,"amort_perc"));
pow_load = StrToFloat(Read_From_Text(tx,"pow_load"));
cur_amort_perc = StrToFloat(Read_From_Text(tx,"cur_amort_perc"));
max_occupy = StrToFloat(Read_From_Text(tx,"max_occupy"));
cur_occupy = StrToFloat(Read_From_Text(tx,"cur_occupy"));
step_occupy = StrToFloat(Read_From_Text(tx,"step_occupy"));
bank_perc = StrToInt(Read_From_Text(tx,"bank_perc"));
repayment = StrToInt(Read_From_Text(tx,"repayment"));
attractivness = StrToFloat(Read_From_Text(tx,"attractivness"));
price_prod = StrToInt(Read_From_Text(tx,"price_prod"));
store = StrToInt(Read_From_Text(tx,"store"));
gross_profit = StrToFloat(Read_From_Text(tx,"gross_profit"));
sold = StrToInt(Read_From_Text(tx,"sold"));
part_sold = StrToFloat(Read_From_Text(tx,"part_sold"));
NoBuy = StrToInt(Read_From_Text(tx,"nobuy"));
tax = StrToFloat(Read_From_Text(tx,"tax"));
V_market = StrToInt(Read_From_Text(tx,"V_market"));
Timer = StrToFloat(Read_From_Text(tx,"timer"));
}
catch(...) {Application->MessageBoxA(L"Ошибка в Receiev_Inf",L"Ошибка",MB_ICONWARNING);}
}
void Receive_Inf2(UnicodeString tx)
{
try
{
cur_cash2 = StrToFloat(Read_From_Text(tx,"cur_cash"));
inv2 = StrToInt(Read_From_Text(tx,"inv"));
pow_cur_lev2 = StrToFloat(Read_From_Text(tx,"pow_cur_lev"));
pow_inc_price2 = StrToFloat(Read_From_Text(tx,"pow_inc_price"));
SRW_level2 = StrToFloat(Read_From_Text(tx,"SRW_level"));
SRW_inc_price2 = StrToInt(Read_From_Text(tx,"SRW_inc_price"));
inv_SRW2 = StrToInt(Read_From_Text(tx,"inv_SRW"));
marketing2 = StrToInt(Read_From_Text(tx,"marketing"));
st_inner_price2 = StrToInt(Read_From_Text(tx,"st_inner_price"));
planed_output2 = StrToInt(Read_From_Text(tx,"planed_output"));
pow_use_lev2 = StrToInt(Read_From_Text(tx,"pow_use_lev"));
cur_inn_price2 = StrToFloat(Read_From_Text(tx,"cur_inn_price"));
trg_output2 = StrToFloat(Read_From_Text(tx,"trg_output"));
amort_perc2 = StrToInt(Read_From_Text(tx,"amort_perc"));
pow_load2 = StrToFloat(Read_From_Text(tx,"pow_load"));
cur_amort_perc2 = StrToFloat(Read_From_Text(tx,"cur_amort_perc"));
max_occupy2 = StrToFloat(Read_From_Text(tx,"max_occupy"));
cur_occupy2 = StrToFloat(Read_From_Text(tx,"cur_occupy"));
step_occupy2 = StrToFloat(Read_From_Text(tx,"step_occupy"));
bank_perc2 = StrToInt(Read_From_Text(tx,"bank_perc"));
repayment2 = StrToInt(Read_From_Text(tx,"repayment"));
attractivness2 = StrToFloat(Read_From_Text(tx,"attractivness"));
price_prod2 = StrToInt(Read_From_Text(tx,"price_prod"));
store2 = StrToInt(Read_From_Text(tx,"store"));
gross_profit2 = StrToFloat(Read_From_Text(tx,"gross_profit"));
sold2 = StrToInt(Read_From_Text(tx,"sold"));
part_sold2 = StrToFloat(Read_From_Text(tx,"part_sold"));
NoBuy2 = StrToInt(Read_From_Text(tx,"nobuy"));
tax2 = StrToFloat(Read_From_Text(tx,"tax"));
V_market2 = StrToInt(Read_From_Text(tx,"V_market"));
}
catch(...) {Application->MessageBoxA(L"Ошибка в Receiev_Inf",L"Ошибка",MB_ICONWARNING);}
}
//---------------------------------------------------------------------------
UnicodeString Form_Report(UnicodeString str)
{
UnicodeString report;
report =
"******************************************\r\n"
"Инвестиции в фонды:\t\t" + IntToStr(inv) + "\r\n"
"Ст-ть 1-цы прироста фондов:\t" + FloatToStr(pow_inc_price) + "\r\n"
"Тек. ур-нь мощности фондов:\t" + FloatToStr(pow_cur_lev) + "\r\n"
"---------------------------------------------------------------\r\n"
"Инвестиции в НИР:\t\t" + IntToStr(inv_SRW) + "\r\n"
"Ст-ть 1-цы прироста НИР:\t\t" + IntToStr(SRW_inc_price) + "\r\n"
"Тек. ур-нь НИР:\t\t\t" + FloatToStr(SRW_level) + "\r\n"
"---------------------------------------------------------------\r\n"
"Вложения в рекламу:\t\t" + IntToStr(marketing) + "\r\n"
"Привлекательность товара:\t\t" + FloatToStr(attractivness) + "\r\n"
"******************************************\r\n"
"Кол-во покупателей:\t\t" + IntToStr(V_market) + "\r\n"
"Запланированно выпустить:\t" + IntToStr(planed_output) + "\r\n"
"Выпущенно:\t\t\t" + IntToStr(pow_use_lev) + "\r\n"
"Себест-ть товара:\t\t\t" + FloatToStr(cur_inn_price) + "\r\n"
"Ст-ть всей продукции:\t\t" + FloatToStr(trg_output) + "\r\n"
"---------------------------------------------------------------\r\n"
"Задолжность банку:\t\t" + FloatToStr(cur_occupy) + "\r\n"
"Банковский процент:\t\t" + IntToStr(bank_perc) + "\r\n"
"Выплачено банку:\t\t\t" + IntToStr(repayment) + "\r\n"
"Занято на этом шаге:\t\t" + FloatToStr(step_occupy) + "\r\n"
"---------------------------------------------------------------\r\n"
"Цена на товар:\t\t\t" + IntToStr(price_prod) + "\r\n"
"Продано штук:\t\t\t" + IntToStr(sold) + "\r\n"
"Валовая прибыль:\t\t\t" + FloatToStr(gross_profit) + "\r\n"
"Неудовл. обращений:\t\t" + IntToStr(NoBuy) + "\r\n"
"Кол-во продукции на складе:\t" + IntToStr(store) + "\r\n"
"---------------------------------------------------------------\r\n"
"Чистая прибыль:\t\t\t"
+ FloatToStr(gross_profit - gross_profit*tax/100) + "\r\n"
"Текущая наличность:\t\t" + FloatToStr(cur_cash);
return report;
}
//---------------------------------------------------------------------------
UnicodeString Send_Inf()
{
UnicodeString s="";
inv = StrToInt(Form1->LEFond->Text);
inv_SRW = StrToInt(Form1->LENIR->Text);
marketing = StrToInt(Form1->LEMark->Text);
planed_output = StrToInt(Form1->LabeledEdit4->Text);
repayment = StrToInt(Form1->LabeledEdit5->Text);
price_prod = StrToInt(Form1->LabeledEdit6->Text);
s = "My_Name " + Name_of_client + " "
"Number_Client " + Number_Client + " \r\n "
"cur_cash " + FloatToStr(cur_cash) + " \r\n "
"inv " + IntToStr(inv) + " \r\n "
"pow_cur_lev " + FloatToStr(pow_cur_lev) + " \r\n "
"inv_SRW " + IntToStr(inv_SRW) + " \r\n "
"SRW_level " + FloatToStr(SRW_level) + " \r\n "
"SRW_inc_price " + IntToStr(SRW_inc_price) + " \r\n "
"marketing " + IntToStr(marketing) + " \r\n "
"planed_output " + IntToStr(planed_output) + " \r\n "
"trg_output " + FloatToStr(trg_output) + " \r\n "
"cur_occupy " + FloatToStr(cur_occupy) + " \r\n "
"pow_use_lev " + IntToStr(pow_use_lev) + " \r\n "
"cur_amort_perc "+ FloatToStr(cur_amort_perc) + " \r\n "
"repayment " + IntToStr(repayment) + " \r\n "
"price_prod " + IntToStr(price_prod) + " \r\n "
"store " + IntToStr(store) + " \r\n";
return s;
}
//---------------------------------------------------------------------------
bool NoMoney()
{
try
{
int money = StrToInt(Form1->LEFond->Text) +
StrToInt(Form1->LENIR->Text) +
StrToInt(Form1->LEMark->Text);
if (money > (cur_cash+max_occupy))
{
Application->MessageBox(L"Не хватает денежных средств",
L"Обратите внимание на наличность", MB_ICONWARNING);
return 1;
}
}catch(...){}
return 0;
}
//---------------------------------------------------------------------------
void Plot()
{
Form1->Series1->Clear();
Form1->Series1->Add(100-(part_sold*100-1),"Конкуренты ",clWhite);
Form1->Series1->Add((part_sold*100-1),Name_of_client,clGreen);
}
//---------------------------------------------------------------------------
void NullFields()
{
Form1->LEFond->Text = 0; Form1->LabeledEdit4->Text = 0;
Form1->LENIR->Text = 0; Form1->LabeledEdit5->Text = 0;
Form1->LEMark->Text = 0; Form1->LabeledEdit6->Text = 0;
}
//---------------------------------------------------------------------------
bool MsgBlockServ(UnicodeString kod)
{
UnicodeString code = Read_From_Text(kod,"kod");
if (code == "20001")
{
Application->MessageBox(L"Неверная симуляция",
L"В доступе отказанно", MB_ICONERROR);
return true;
}
if (code == "20002")
{
Application->MessageBox(L"Измените имя",
L"В доступе отказанно", MB_ICONERROR);
return true;
}
if (code == "20003")
{
Application->MessageBox(L"Превышен лимит игроков",
L"В доступе отказанно", MB_ICONERROR);
return true;
}
if (code == "20004")
{
Application->MessageBox(L"Вы отключены от сервера",
L"Ошибка", MB_ICONERROR);
return true;
}
if (code == "20005")
{
Application->MessageBox(L"Вы обанкротились",
L"Завершение", MB_ICONINFORMATION);
return true;
}
return false;
}
//---------------------------------------------------------------------------
UnicodeString Begin_Date(UnicodeString str)
{
UnicodeString report;
report =
"******************************\r\n"
"Денежные средства:\t\t" + FloatToStr(cur_cash) + "\r\n"
"Начальная стоимость товара:\t" + IntToStr(st_inner_price) + "\r\n"
"Нач. процент амортизации:\t\t" + IntToStr(amort_perc) + "\r\n"















