Смекни!
smekni.com

Структура иерархии классов "Экран курсового проектирования" (стр. 6 из 8)

this->checkBox1->UseVisualStyleBackColor = true;

this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);

//

// Form1

//

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->BackColor = System::Drawing::Color::White;

this->ClientSize = System::Drawing::Size(944, 762);

this->Controls->Add(this->checkBox1);

this->Controls->Add(this->listBox2);

this->Controls->Add(this->listBox1);

this->Controls->Add(this->button2);

this->Controls->Add(this->button1);

this->Controls->Add(this->button7);

this->Controls->Add(this->button6);

this->Controls->Add(this->button5);

this->Controls->Add(this->button4);

this->Controls->Add(this->dataGridView1);

this->Controls->Add(this->menuStrip1);

this->Location = System::Drawing::Point(388, 613);

this->MainMenuStrip = this->menuStrip1;

this->MinimumSize = System::Drawing::Size(960, 800);

this->Name = L"Form1";

this->Text = L"Form1";

this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);

this->Shown += gcnew System::EventHandler(this, &Form1::button7_Click);

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->EndInit();

this->menuStrip1->ResumeLayout(false);

this->menuStrip1->PerformLayout();

this->ResumeLayout(false);

this->PerformLayout();

}

#pragma endregion

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

System::Windows::Forms::DialogResult dialres;

Form2 ^newdlg=gcnew Form2();

dialres=newdlg->ShowDialog();

if(dialres==System::Windows::Forms::DialogResult::OK){

Student->SetName(newdlg->textBox1->Text);

Student->SetControl(System::Convert::ToInt16(newdlg->textBox4->Text),0);

Student->SetControl(System::Convert::ToInt16(newdlg->textBox7->Text),1);

Student->SetControl(System::Convert::ToInt16(newdlg->textBox10->Text),2);

Student->SetControlScore(System::Convert::ToInt16(newdlg->textBox17->Text));

Student->SetFact(System::Convert::ToInt16(newdlg->textBox3->Text),0);

Student->SetFact(System::Convert::ToInt16(newdlg->textBox6->Text),1);

Student->SetFact(System::Convert::ToInt16(newdlg->textBox9->Text),2);

Student->SetPlan(System::Convert::ToInt16(newdlg->textBox2->Text),0);

Student->SetPlan(System::Convert::ToInt16(newdlg->textBox5->Text),1);

Student->SetPlan(System::Convert::ToInt16(newdlg->textBox8->Text),2);

Student->SetTest(newdlg->textBox11->Text);

Student->SetTestF(newdlg->textBox12->Text);

Student->SetRevision(newdlg->textBox13->Text);

Student->SetRevisionF(newdlg->textBox14->Text);

Student->SetProtection(newdlg->textBox15->Text);

Student->SetProtectionF(newdlg->textBox16->Text);

dataGridView1->Rows->Add(Student->TName,Student->Plan[0],Student->Fact[0],Student->Control[0],

Student->Plan[1],Student->Fact[1],Student->Control[1],Student->Plan[2],Student->Fact[2],

Student->Control[2],Student->Test,Student->TestF,Student->Revision,Student->RevisionF,

Student->Protection,Student->ProtectionF,Student->ControlScore);

CountDataGrid++;

button1->Enabled=true;

checkBox1->Enabled=true;

MessageBox::Show("Записьдобавлена!","Information",MessageBoxButtons::OK,MessageBoxIcon::Information);

return;

}

}

private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

this->Close();

}

private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {

System::Windows::Forms::DialogResult dialres;

dialres=MessageBox::Show("Выточнохотитеудалитьзапись?","Удалить?",MessageBoxButtons::OKCancel,MessageBoxIcon::Warning);

if(dialres==System::Windows::Forms::DialogResult::OK){

if(this->dataGridView1->SelectedRows->Count > 0 &&

this->dataGridView1->SelectedRows[0]->Index !=

this->dataGridView1->Rows->Count){

this->dataGridView1->Rows->RemoveAt(this->dataGridView1->SelectedRows[0]->Index);

CountDataGrid--;

if(CountDataGrid==0){

button1->Enabled=false;

button2->Enabled=false;

button6->Enabled=false;

checkBox1->Enabled=false;

}

MessageBox::Show("Записьудалена!","Information",MessageBoxButtons::OK,MessageBoxIcon::Information);

}

else{

MessageBox::Show("Невыделенаудаляемаястрока!","Ошибка",MessageBoxButtons::OK,MessageBoxIcon::Error);

}

}

}

private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {

System::Windows::Forms::DialogResult dialres;

Start ^newdlg=gcnew Start();

dialres=newdlg->ShowDialog();

if(dialres==System::Windows::Forms::DialogResult::OK){

this->Text=newdlg->textBox1->Text;

Screen.SetName(newdlg->textBox1->Text);

Screen.SetComposition(newdlg->textBox2->Text);

Screen.SetDate(newdlg->textBox3->Text);

listBox1->Items->Add(Screen.TName);

listBox2->Items->Add("Состав приемной комиссии: ");

listBox2->Items->Add(Screen.Composition);

listBox2->Items->Add("Дата утверждения: ");

listBox2->Items->Add(Screen.Date);

}

}

private: System::Void aboutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {

System::Diagnostics::Process::Start("Help.chm");

}

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

System::Windows::Forms::DialogResult dialres;

Search ^newdlg=gcnew Search();

dialres=newdlg->ShowDialog();

if(dialres==System::Windows::Forms::DialogResult::OK){

System::String ^srh;

srh=newdlg->textBox1->Text;

if(CountDataGrid!=0){

for(int i=0; i<CountDataGrid; i++){

for(int j=0; j<dataGridView1->ColumnCount; j++){

if(System::Convert::ToString(dataGridView1->Rows[i]->Cells[j]->Value)==srh){

dataGridView1->CurrentCell=dataGridView1->Rows[i]->Cells[j];

System::Windows::Forms::DialogResult dl;

dl=MessageBox::Show("Искатьдалее?","Continue?",MessageBoxButtons::OKCancel,MessageBoxIcon::Question);

if(dl==System::Windows::Forms::DialogResult::Cancel){

break;

4 }

}

}

}

MessageBox::Show("Поискзавершен!","Information",MessageBoxButtons::OK,MessageBoxIcon::Information);

}

}

}

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

System::Windows::Forms::DialogResult dl;

dl=MessageBox::Show("Редактироватьзапись?","Изменить?",MessageBoxButtons::OKCancel,MessageBoxIcon::Question);

if(dl==System::Windows::Forms::DialogResult::OK){

if(this->dataGridView1->SelectedRows->Count > 0 &&

this->dataGridView1->SelectedRows[0]->Index !=

this->dataGridView1->Rows->Count){

System::Windows::Forms::DialogResult dialres;

Form2 ^newdlg=gcnew Form2();

newdlg->textBox1->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[0]->Value);

newdlg->textBox2->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[1]->Value);

newdlg->textBox3->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[2]->Value);

newdlg->textBox4->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[3]->Value);

newdlg->textBox5->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[4]->Value);

newdlg->textBox6->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[5]->Value);

newdlg->textBox7->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[6]->Value);

newdlg->textBox8->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[7]->Value);

newdlg->textBox9->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[8]->Value);

newdlg->textBox10->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[9]->Value);

newdlg->textBox11->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[10]->Value);

newdlg->textBox12->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[11]->Value);

newdlg->textBox13->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[12]->Value);

newdlg->textBox14->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[13]->Value);

newdlg->textBox15->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[14]->Value);

newdlg->textBox16->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[15]->Value);

newdlg->textBox17->Text=System::Convert::ToString(this->dataGridView1->SelectedRows[0]->Cells[16]->Value);

dialres=newdlg->ShowDialog();

if(dialres==System::Windows::Forms::DialogResult::OK){

this->dataGridView1->SelectedRows[0]->Cells[0]->Value=newdlg->textBox1->Text;

this->dataGridView1->SelectedRows[0]->Cells[1]->Value=newdlg->textBox2->Text;

this->dataGridView1->SelectedRows[0]->Cells[2]->Value=newdlg->textBox3->Text;

this->dataGridView1->SelectedRows[0]->Cells[3]->Value=newdlg->textBox4->Text;

this->dataGridView1->SelectedRows[0]->Cells[4]->Value=newdlg->textBox5->Text;

this->dataGridView1->SelectedRows[0]->Cells[5]->Value=newdlg->textBox6->Text;

this->dataGridView1->SelectedRows[0]->Cells[6]->Value=newdlg->textBox7->Text;

this->dataGridView1->SelectedRows[0]->Cells[7]->Value=newdlg->textBox8->Text;

this->dataGridView1->SelectedRows[0]->Cells[8]->Value=newdlg->textBox9->Text;

this->dataGridView1->SelectedRows[0]->Cells[9]->Value=newdlg->textBox10->Text;

this->dataGridView1->SelectedRows[0]->Cells[10]->Value=newdlg->textBox11->Text;

this->dataGridView1->SelectedRows[0]->Cells[11]->Value=newdlg->textBox12->Text;

this->dataGridView1->SelectedRows[0]->Cells[12]->Value=newdlg->textBox13->Text;

this->dataGridView1->SelectedRows[0]->Cells[13]->Value=newdlg->textBox14->Text;

this->dataGridView1->SelectedRows[0]->Cells[14]->Value=newdlg->textBox15->Text;

this->dataGridView1->SelectedRows[0]->Cells[15]->Value=newdlg->textBox16->Text;

this->dataGridView1->SelectedRows[0]->Cells[16]->Value=newdlg->textBox17->Text;

}

MessageBox::Show("Записьотредактирована!","Information",MessageBoxButtons::OK,MessageBoxIcon::Information);

}

else{

MessageBox::Show("Невыделенаредактируемаястрока!","Ошибка",MessageBoxButtons::OK,MessageBoxIcon::Error);

}

}

}

private: System::Void aboutToolStripMenuItem1_Click(System::Object^ sender, System::EventArgs^ e) {

MessageBox::Show("&bsol;"&bsol;Экранкурсовогопроектирования&bsol;"&bsol; Версия 1.0","Опрограмме",MessageBoxButtons::OK,MessageBoxIcon::Information);

}

private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {

if(checkBox1->Checked==true&&CountDataGrid!=0){

button2->Enabled=true;

button6->Enabled=true;

dataGridView1->RowHeadersVisible=true;

}

if(checkBox1->Checked==false&&CountDataGrid!=0){

dataGridView1->RowHeadersVisible=false;

button2->Enabled=false;

button6->Enabled=false;

}

}

};

}

ФайлForm2.h. Окнодобавления/редактированиязаписей.

#pragma once

#include "TStudent.h"

namespace WindowsFormApplicationC {

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

using namespace System::IO;

public ref class Form2 : public System::Windows::Forms::Form

{

public:

Form2(void)

{

InitializeComponent();

}

protected:

~Form2()

{

if (components)

{

delete components;

}

}

public: System::Windows::Forms::TextBox^ textBox1;

protected:

public: System::Windows::Forms::TextBox^ textBox2;

public: System::Windows::Forms::TextBox^ textBox3;

public: System::Windows::Forms::TextBox^ textBox4;

public: System::Windows::Forms::TextBox^ textBox5;

public: System::Windows::Forms::TextBox^ textBox6;

public: System::Windows::Forms::TextBox^ textBox7;

public: System::Windows::Forms::TextBox^ textBox8;

public: System::Windows::Forms::TextBox^ textBox9;

public: System::Windows::Forms::TextBox^ textBox10;

public: System::Windows::Forms::TextBox^ textBox11;

public: System::Windows::Forms::TextBox^ textBox12;

public: System::Windows::Forms::TextBox^ textBox13;

public: System::Windows::Forms::TextBox^ textBox14;

public: System::Windows::Forms::TextBox^ textBox15;

public: System::Windows::Forms::TextBox^ textBox16;

private: System::Windows::Forms::Button^ button1;

private: System::Windows::Forms::Button^ button2;

private: System::Windows::Forms::Button^ button3;

public: System::Windows::Forms::TextBox^ textBox17;

private: System::Windows::Forms::Label^ label1;

private: System::Windows::Forms::Label^ label2;

private: System::Windows::Forms::Label^ label3;

private: System::Windows::Forms::Label^ label4;

private: System::Windows::Forms::Label^ label5;

private: System::Windows::Forms::Label^ label6;

private: System::Windows::Forms::Label^ label7;

private: System::Windows::Forms::Label^ label8;

private: System::Windows::Forms::Label^ label9;

private: System::Windows::Forms::Label^ label10;

private: System::Windows::Forms::Label^ label11;

private: System::Windows::Forms::Label^ label12;

private: System::Windows::Forms::Label^ label13;

private: System::Windows::Forms::Label^ label14;

private: System::Windows::Forms::Label^ label15;

private: System::Windows::Forms::Label^ label16;

private: System::Windows::Forms::Label^ label17;

private: System::Windows::Forms::Label^ label18;

private: System::Windows::Forms::Label^ label19;

private: System::Windows::Forms::Label^ label20;

private: System::Windows::Forms::Button^ button4;

private:

System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code

void InitializeComponent(void)

{

this->textBox1 = (gcnew System::Windows::Forms::TextBox());

this->textBox2 = (gcnew System::Windows::Forms::TextBox());

this->textBox3 = (gcnew System::Windows::Forms::TextBox());

this->textBox4 = (gcnew System::Windows::Forms::TextBox());

this->textBox5 = (gcnew System::Windows::Forms::TextBox());

this->textBox6 = (gcnew System::Windows::Forms::TextBox());

this->textBox7 = (gcnew System::Windows::Forms::TextBox());

this->textBox8 = (gcnew System::Windows::Forms::TextBox());

this->textBox9 = (gcnew System::Windows::Forms::TextBox());

this->textBox10 = (gcnew System::Windows::Forms::TextBox());

this->textBox11 = (gcnew System::Windows::Forms::TextBox());

this->textBox12 = (gcnew System::Windows::Forms::TextBox());