Добавил:
Upload
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:ВСРПП / Финансовый калькулятор / Финансовый калькулятор / Form1
.h#pragma once
namespace Финансовыйкалькулятор {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Сводка для Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
// настройка listView1 — увеличить ширину компонента
// на ширину вертикальной полосы прокрутки
int w = 0;
for (int i=0; i < listView1->Columns->Count; i++)
{
w += listView1->Columns[i]->Width;
if (listView1->BorderStyle == BorderStyle::Fixed3D)
w +=4;
listView1->Width = w + 17;
}
listView1->FullRowSelect = true;
}
protected:
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::ListView^ listView1;
protected:
private: System::Windows::Forms::ColumnHeader^ columnHeader1;
private: System::Windows::Forms::ColumnHeader^ columnHeader2;
private: System::Windows::Forms::ColumnHeader^ columnHeader3;
private: System::Windows::Forms::ColumnHeader^ columnHeader4;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private:
/// <summary>
/// Требуется переменная конструктора.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Обязательный метод для поддержки конструктора - не изменяйте
/// содержимое данного метода при помощи редактора кода.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->listView1 = (gcnew System::Windows::Forms::ListView());
this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader3 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader4 = (gcnew System::Windows::Forms::ColumnHeader());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->SuspendLayout();
//
// listView1
//
this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(4) {this->columnHeader1, this->columnHeader2,
this->columnHeader3, this->columnHeader4});
this->listView1->Location = System::Drawing::Point(80, 172);
this->listView1->Name = L"listView1";
this->listView1->Size = System::Drawing::Size(484, 157);
this->listView1->TabIndex = 0;
this->listView1->UseCompatibleStateImageBehavior = false;
this->listView1->View = System::Windows::Forms::View::Details;
//
// columnHeader1
//
this->columnHeader1->Text = L"Месяяяц";
this->columnHeader1->Width = 120;
//
// columnHeader2
//
this->columnHeader2->Text = L"Долг";
this->columnHeader2->Width = 120;
//
// columnHeader3
//
this->columnHeader3->Text = L"Процент";
this->columnHeader3->Width = 120;
//
// columnHeader4
//
this->columnHeader4->Text = L"Платеж";
this->columnHeader4->Width = 120;
//
// button1
//
this->button1->Location = System::Drawing::Point(19, 115);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(95, 30);
this->button1->TabIndex = 1;
this->button1->Text = L"ОК";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->BackColor = System::Drawing::Color::Transparent;
this->label1->Location = System::Drawing::Point(16, 22);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(44, 13);
this->label1->TabIndex = 2;
this->label1->Text = L"Сумма:";
//
// label2
//
this->label2->AutoSize = true;
this->label2->BackColor = System::Drawing::Color::Transparent;
this->label2->Location = System::Drawing::Point(16, 53);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(64, 13);
this->label2->TabIndex = 3;
this->label2->Text = L"Срок (мес):";
//
// label3
//
this->label3->AutoSize = true;
this->label3->BackColor = System::Drawing::Color::Transparent;
this->label3->Location = System::Drawing::Point(16, 86);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(77, 13);
this->label3->TabIndex = 4;
this->label3->Text = L"Проц. ставка:";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(130, 14);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(141, 20);
this->textBox1->TabIndex = 5;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(130, 53);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(141, 20);
this->textBox2->TabIndex = 6;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(130, 86);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(141, 20);
this->textBox3->TabIndex = 7;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->ClientSize = System::Drawing::Size(564, 331);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button1);
this->Controls->Add(this->listView1);
this->Name = L"Form1";
this->Text = L"Финансовый калькулятор";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
float value; // сумма кредита
int period; // срок
float rate; // процентная ставка
int month; // месяц платежа
float debt; // долг на начало текущего месяца
float interest; // плата за кредит (проценты на долг)
float paying; // сумма платежа
float suminterest; // общая плата за кредит
//срок
value = System::Convert::ToSingle(textBox1->Text);
//сумма
period = System::Convert::ToInt32(textBox2->Text);
// процентная ставка
rate = System::Convert::ToSingle(textBox3->Text);
month = 1;
debt = value; // долг на начало первого месяца
suminterest = 0;
for (int i = 0; i < period; i++)
{
interest = debt * (rate/12/100);
suminterest += interest;
paying = value/period + interest;
// добавить в listView1 элемент -
// строку (данные в первый столбец)
listView1->Items->Add(month.ToString());
// добавить в добавленную строку подэлементы -
// данные во второй, третий и четвертый столбцы
listView1->Items[i]->SubItems->Add(debt.ToString("c"));
listView1->Items[i]->SubItems->Add(interest.ToString("c"));
listView1->Items[i]->SubItems->Add(paying.ToString("c"));
month++;
debt = debt - value/period;
}
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
};
}
Соседние файлы в папке Финансовый калькулятор