Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "ArrPersonas.h"
- //#include <stdio.h>
- //
- //ArrPersonas::ArrPersonas(void)
- //{ arreglo=NULL;
- // N= new int;
- // *N=0;
- //}
- //ArrPersonas::~ArrPersonas(void)
- //{ //ELIMINAMOS CADA UNO DE LOS OBJETOS DEL ARREGLO
- // for (int i=0;i<*N;i++)
- // delete arreglo[i];
- //
- // delete N;
- //}
- //Persona** ArrPersonas::Crear_Arreglo()
- //{
- // return new Persona*[*N+1];
- //}
- //
- //void ArrPersonas::Agregar( Persona *Dato)
- //{
- // Persona** auxiliar=Crear_Arreglo();
- // if (auxiliar!=NULL)
- // {
- // for (int i=0;i<*N;i++)
- // auxiliar[i] = arreglo[i];
- //
- // auxiliar[*N]=Dato;
- // *N=*N+1;
- //
- // if (arreglo!=NULL)
- // delete arreglo;
- //
- // arreglo=auxiliar;
- //
- // }
- //}
- #pragma once
- #include <stdio.h>
- #include "Persona.h"
- class ArrPersonas
- {
- private:
- Persona **arreglo;
- int *N;
- public:
- ArrPersonas(void);
- ~ArrPersonas(void);
- Persona** Crear_Arreglo();
- void Agregar( Persona *Dato);
- void Eliminar(int indice);
- Persona** Mayores25anhos(int *cantidad);
- Persona** ConLetraAenelNombre(int *cantidad);
- int Retornar_N();
- Persona* Retorna_dato_en_arreglo( int indice);
- };
- int ArrPersonas::Retornar_N()
- {
- return *N;
- }
- Persona* ArrPersonas::Retorna_dato_en_arreglo( int indice)
- {
- return arreglo[indice];
- }
- ArrPersonas::ArrPersonas(void)
- { arreglo=NULL;
- N= new int;
- *N=0;
- }
- ArrPersonas::~ArrPersonas(void)
- { //ELIMINAMOS CADA UNO DE LOS OBJETOS DEL ARREGLO
- for (int i=0;i<*N;i++)
- delete arreglo[i];
- delete N;
- }
- Persona** ArrPersonas::Crear_Arreglo()
- {
- return new Persona*[*N+1];
- }
- void ArrPersonas::Agregar( Persona *Dato)
- {
- Persona** auxiliar=Crear_Arreglo();
- if (auxiliar!=NULL)
- {
- for (int i=0;i<*N;i++)
- auxiliar[i] = arreglo[i];
- auxiliar[*N]=Dato;
- *N=*N+1;
- if (arreglo!=NULL)
- delete arreglo;
- arreglo=auxiliar;
- }
- }
- void ArrPersonas::Eliminar(int indice)
- {
- Persona** auxiliar =new Persona*[*N-1];
- if (auxiliar!=NULL)
- {
- //sobre la izquierda del indice a eliminar;
- for (int i=0;i<=indice-1;i++)
- auxiliar[i]=arreglo[i];
- //sobre la derecha del indice a eliminar;
- for (int i=indice+1;i<*N;i++)
- auxiliar[i-1]=arreglo[i];
- *N=*N-1;
- if (arreglo!=NULL)
- delete arreglo;
- arreglo=auxiliar;
- }
- }
- Persona** ArrPersonas::Mayores25anhos(int *cantidad)
- {
- for (int i=0;i<*N;i++)
- if (arreglo[i]->Retornar_Edad()>25)
- *cantidad=*cantidad+1;
- if (*cantidad>0)
- { Persona** auxiliar=new Persona*[*cantidad];
- int h=0;
- for (int i=0;i<*N;i++)
- if (arreglo[i]->Retornar_Edad()>25)
- {
- auxiliar[h]=arreglo[i];
- h++;
- }
- return auxiliar;
- }
- else
- return NULL;
- /*for (int i=0;i<*N;i++)
- if (arreglo[i]->Retornar_Edad()>25)
- *cantidad=*cantidad+1;
- if (*cantidad>0)
- { Persona** auxiliar=new Persona*[*cantidad];
- int h=0;
- for (int i=0;i<*N;i++)
- if (arreglo[i]->Retornar_Edad()>25)
- {
- auxiliar[h]=arreglo[i];
- h++;
- }
- return auxiliar;
- }
- else
- return NULL;*/
- }
- Persona** ArrPersonas::ConLetraAenelNombre(int *cantidad)
- {
- for (int i=0;i<*N;i++)
- if (arreglo[i]->Retornar_Nombre()[0]=='A' || arreglo[i]->Retornar_Nombre()[0]=='a')
- *cantidad=*cantidad+1;
- if (*cantidad>0)
- { Persona** auxiliar=new Persona*[*cantidad];
- int h=0;
- for (int i=0;i<*N;i++)
- if (arreglo[i]->Retornar_Nombre()[0]=='A' || arreglo[i]->Retornar_Nombre()[0]=='a')
- {
- auxiliar[h]=arreglo[i];
- h++;
- }
- return auxiliar;
- }
- else
- return NULL;
- }
- #include "MyForm.h"
- using namespace System;
- using namespace System ::Windows::Forms;
- [STAThread]
- void main(array<String^>^ arg)
- {
- Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false);
- Application::Run( gcnew POO1::MyForm());
- }
- #pragma once
- namespace POO1 {
- #include "ArrPersonas.h"; //Un arreglo de Objetos Persona
- #include "Persona.h"; //UN SOLO OBJETO PERSONA
- #include <stdio.h>;
- 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>
- /// Summary for MyForm
- /// </summary>
- public ref class MyForm : public System::Windows::Forms::Form
- {
- public:
- MyForm(void)
- {
- InitializeComponent();
- objeto_ArrPersona=new ArrPersonas();
- }
- protected:
- ~MyForm()
- {
- if (components)
- {
- delete components;
- }
- delete objeto_ArrPersona;
- }
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- ArrPersonas *objeto_ArrPersona;
- Persona *objeto_Persona;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::ListBox^ listBox1;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::ListBox^ listBox2;
- private: System::Windows::Forms::GroupBox^ groupBox2;
- private: System::Windows::Forms::Button^ button3;
- private: System::Windows::Forms::ListBox^ listBox3;
- private: System::Windows::Forms::Button^ button4;
- System::ComponentModel::Container ^components;
- #pragma region 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->button1 = (gcnew System::Windows::Forms::Button());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->listBox1 = (gcnew System::Windows::Forms::ListBox());
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->textBox2 = (gcnew System::Windows::Forms::TextBox());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->listBox2 = (gcnew System::Windows::Forms::ListBox());
- this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->listBox3 = (gcnew System::Windows::Forms::ListBox());
- this->button4 = (gcnew System::Windows::Forms::Button());
- this->groupBox1->SuspendLayout();
- this->groupBox2->SuspendLayout();
- this->SuspendLayout();
- //
- // button1
- //
- this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->button1->Location = System::Drawing::Point(42, 99);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(61, 30);
- this->button1->TabIndex = 0;
- this->button1->Text = L"Crear";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label1->Location = System::Drawing::Point(5, 15);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(65, 20);
- this->label1->TabIndex = 1;
- this->label1->Text = L"Nombre";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label2->Location = System::Drawing::Point(8, 55);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(47, 20);
- this->label2->TabIndex = 2;
- this->label2->Text = L"Edad";
- //
- // listBox1
- //
- this->listBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox1->FormattingEnabled = true;
- this->listBox1->ItemHeight = 20;
- this->listBox1->Location = System::Drawing::Point(12, 169);
- this->listBox1->Name = L"listBox1";
- this->listBox1->Size = System::Drawing::Size(214, 244);
- this->listBox1->TabIndex = 3;
- this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::listBox1_SelectedIndexChanged);
- //
- // textBox1
- //
- this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->textBox1->Location = System::Drawing::Point(78, 14);
- this->textBox1->MaxLength = 99;
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(148, 26);
- this->textBox1->TabIndex = 4;
- this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox1_KeyPress);
- //
- // textBox2
- //
- this->textBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->textBox2->Location = System::Drawing::Point(78, 55);
- this->textBox2->MaxLength = 2;
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(44, 26);
- this->textBox2->TabIndex = 5;
- this->textBox2->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox2_KeyPress);
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label3->Location = System::Drawing::Point(8, 146);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(152, 20);
- this->label3->TabIndex = 6;
- this->label3->Text = L"Todas las Personas:";
- //
- // groupBox1
- //
- this->groupBox1->Controls->Add(this->button2);
- this->groupBox1->Controls->Add(this->listBox2);
- this->groupBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->groupBox1->Location = System::Drawing::Point(232, 13);
- this->groupBox1->Name = L"groupBox1";
- this->groupBox1->Size = System::Drawing::Size(229, 400);
- this->groupBox1->TabIndex = 7;
- this->groupBox1->TabStop = false;
- this->groupBox1->Text = L"Mayores de 25 años";
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(15, 357);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(208, 37);
- this->button2->TabIndex = 1;
- this->button2->Text = L"Filtrar";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
- //
- // listBox2
- //
- this->listBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox2->FormattingEnabled = true;
- this->listBox2->ItemHeight = 20;
- this->listBox2->Location = System::Drawing::Point(15, 27);
- this->listBox2->Name = L"listBox2";
- this->listBox2->Size = System::Drawing::Size(208, 324);
- this->listBox2->TabIndex = 0;
- //
- // groupBox2
- //
- this->groupBox2->Controls->Add(this->button3);
- this->groupBox2->Controls->Add(this->listBox3);
- this->groupBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->groupBox2->Location = System::Drawing::Point(467, 13);
- this->groupBox2->Name = L"groupBox2";
- this->groupBox2->Size = System::Drawing::Size(229, 400);
- this->groupBox2->TabIndex = 8;
- this->groupBox2->TabStop = false;
- this->groupBox2->Text = L"Nombre inicia con letra \"A\"";
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(9, 357);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(214, 37);
- this->button3->TabIndex = 1;
- this->button3->Text = L"Filtrar";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
- //
- // listBox3
- //
- this->listBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox3->FormattingEnabled = true;
- this->listBox3->ItemHeight = 20;
- this->listBox3->Location = System::Drawing::Point(6, 25);
- this->listBox3->Name = L"listBox3";
- this->listBox3->Size = System::Drawing::Size(217, 324);
- this->listBox3->TabIndex = 0;
- //
- // button4
- //
- this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->button4->Location = System::Drawing::Point(121, 99);
- this->button4->Name = L"button4";
- this->button4->Size = System::Drawing::Size(75, 30);
- this->button4->TabIndex = 9;
- this->button4->Text = L"Eliminar";
- this->button4->UseVisualStyleBackColor = true;
- this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(699, 424);
- this->Controls->Add(this->button4);
- this->Controls->Add(this->groupBox2);
- this->Controls->Add(this->groupBox1);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->listBox1);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->button1);
- this->Name = L"MyForm";
- this->Text = L"MyForm";
- this->groupBox1->ResumeLayout(false);
- this->groupBox2->ResumeLayout(false);
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- void Insertar_Datos_Persona_en_ListBox()
- { listBox1->Items->Clear();
- if (objeto_ArrPersona->Retornar_N()>0)
- { for (int i=0;i<objeto_ArrPersona->Retornar_N();i++)
- { objeto_Persona= objeto_ArrPersona->Retorna_dato_en_arreglo(i);
- //Convertimos de char* a String^
- System::String ^nombre="Nombre : " +gcnew System::String(objeto_Persona->Retornar_Nombre()) +
- " Edad : " + objeto_Persona->Retornar_Edad().ToString() ;
- listBox1->Items->Add(nombre);
- }
- }
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- if (textBox1->Text->Length>0 && textBox2->Text->Length>0)
- { objeto_Persona= new Persona();
- int miedad=Convert::ToInt32(textBox2->Text); objeto_Persona->Cambiar_Edad(miedad);
- char*minombre; minombre=new char[100];
- sprintf(minombre,"%s",textBox1->Text);//Convierte de St ring^ a char*
- objeto_Persona->Cambiar_Nombre(minombre);
- objeto_ArrPersona->Agregar(objeto_Persona);
- textBox1->Clear();
- textBox2->Clear();
- }
- else
- objeto_Persona= NULL;
- Insertar_Datos_Persona_en_ListBox();
- }
- private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
- if (listBox1->SelectedIndex!=-1)
- {
- objeto_ArrPersona->Eliminar(listBox1->SelectedIndex);
- listBox1->SelectedIndex=-1;
- Insertar_Datos_Persona_en_ListBox();
- textBox1->Clear();
- textBox2->Clear();
- }
- }
- private: System::Void listBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
- if (listBox1->SelectedIndex!=-1)
- {
- objeto_Persona=objeto_ArrPersona->Retorna_dato_en_arreglo(listBox1->SelectedIndex);
- textBox1->Text= gcnew System::String(objeto_Persona->Retornar_Nombre());
- textBox2->Text= objeto_Persona->Retornar_Edad().ToString();
- }
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- int *cantidad;
- cantidad=new int;
- *cantidad=0;
- //int cantidad=0;
- Persona** arr_masde25 = objeto_ArrPersona->Mayores25anhos(cantidad);
- MessageBox::Show(""+*cantidad, "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- listBox2->Items->Clear();
- if (arr_masde25 !=NULL)
- {
- //for (int i=0;i<*cantidad;i++)
- for (int i=0;i<*cantidad;i++)
- {
- System::String ^nombre= "Nombre: " +gcnew System::String(arr_masde25[i]->Retornar_Nombre());
- listBox2->Items->Add(nombre);
- }
- }
- }
- private: System::Void textBox2_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (!(Char::IsNumber(e->KeyChar)) && (e->KeyChar != char(Keys::Back)))
- {
- MessageBox::Show("Solo se permiten numeros", "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- e->Handled = true;
- return;
- }
- }
- private: System::Void textBox1_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (!(Char::IsLetter(e->KeyChar)) && (e->KeyChar != char(Keys::Back)) && !(Char::IsSeparator(e->KeyChar)))
- {
- MessageBox::Show("Solo se permiten letras", "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- e->Handled = true;
- return;
- }
- }
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
- /* int *cantidad;
- cantidad=new int;
- *cantidad=0;
- Persona** arr_letraA = objeto_ArrPersona->ConLetraAenelNombre(cantidad);
- listBox3->Items->Clear();
- if (arr_letraA !=NULL)
- {
- for (int i=0;i<*cantidad;i++)
- {
- System::String ^nombre= "Nombre: " +gcnew System::String(arr_letraA[i]->Retornar_Nombre());
- listBox3->Items->Add(nombre);
- }
- }*/
- }
- };
- }
- #pragma once
- namespace POO1 {
- #include "ArrPersonas.h"; //Un arreglo de Objetos Persona
- #include "Persona.h"; //UN SOLO OBJETO PERSONA
- #include <stdio.h>;
- 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>
- /// Summary for MyForm
- /// </summary>
- public ref class MyForm : public System::Windows::Forms::Form
- {
- public:
- MyForm(void)
- {
- InitializeComponent();
- objeto_ArrPersona=new ArrPersonas();
- }
- protected:
- ~MyForm()
- {
- if (components)
- {
- delete components;
- }
- delete objeto_ArrPersona;
- }
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- ArrPersonas *objeto_ArrPersona;
- Persona *objeto_Persona;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::ListBox^ listBox1;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::ListBox^ listBox2;
- private: System::Windows::Forms::GroupBox^ groupBox2;
- private: System::Windows::Forms::Button^ button3;
- private: System::Windows::Forms::ListBox^ listBox3;
- private: System::Windows::Forms::Button^ button4;
- System::ComponentModel::Container ^components;
- #pragma region 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->button1 = (gcnew System::Windows::Forms::Button());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->listBox1 = (gcnew System::Windows::Forms::ListBox());
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->textBox2 = (gcnew System::Windows::Forms::TextBox());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->listBox2 = (gcnew System::Windows::Forms::ListBox());
- this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->listBox3 = (gcnew System::Windows::Forms::ListBox());
- this->button4 = (gcnew System::Windows::Forms::Button());
- this->groupBox1->SuspendLayout();
- this->groupBox2->SuspendLayout();
- this->SuspendLayout();
- //
- // button1
- //
- this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->button1->Location = System::Drawing::Point(42, 99);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(61, 30);
- this->button1->TabIndex = 0;
- this->button1->Text = L"Crear";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label1->Location = System::Drawing::Point(5, 15);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(65, 20);
- this->label1->TabIndex = 1;
- this->label1->Text = L"Nombre";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label2->Location = System::Drawing::Point(8, 55);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(47, 20);
- this->label2->TabIndex = 2;
- this->label2->Text = L"Edad";
- //
- // listBox1
- //
- this->listBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox1->FormattingEnabled = true;
- this->listBox1->ItemHeight = 20;
- this->listBox1->Location = System::Drawing::Point(12, 169);
- this->listBox1->Name = L"listBox1";
- this->listBox1->Size = System::Drawing::Size(214, 244);
- this->listBox1->TabIndex = 3;
- this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::listBox1_SelectedIndexChanged);
- //
- // textBox1
- //
- this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->textBox1->Location = System::Drawing::Point(78, 14);
- this->textBox1->MaxLength = 99;
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(148, 26);
- this->textBox1->TabIndex = 4;
- this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox1_KeyPress);
- //
- // textBox2
- //
- this->textBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->textBox2->Location = System::Drawing::Point(78, 55);
- this->textBox2->MaxLength = 2;
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(44, 26);
- this->textBox2->TabIndex = 5;
- this->textBox2->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox2_KeyPress);
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label3->Location = System::Drawing::Point(8, 146);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(152, 20);
- this->label3->TabIndex = 6;
- this->label3->Text = L"Todas las Personas:";
- //
- // groupBox1
- //
- this->groupBox1->Controls->Add(this->button2);
- this->groupBox1->Controls->Add(this->listBox2);
- this->groupBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->groupBox1->Location = System::Drawing::Point(232, 13);
- this->groupBox1->Name = L"groupBox1";
- this->groupBox1->Size = System::Drawing::Size(229, 400);
- this->groupBox1->TabIndex = 7;
- this->groupBox1->TabStop = false;
- this->groupBox1->Text = L"Mayores de 25 años";
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(15, 357);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(208, 37);
- this->button2->TabIndex = 1;
- this->button2->Text = L"Filtrar";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
- //
- // listBox2
- //
- this->listBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox2->FormattingEnabled = true;
- this->listBox2->ItemHeight = 20;
- this->listBox2->Location = System::Drawing::Point(15, 27);
- this->listBox2->Name = L"listBox2";
- this->listBox2->Size = System::Drawing::Size(208, 324);
- this->listBox2->TabIndex = 0;
- //
- // groupBox2
- //
- this->groupBox2->Controls->Add(this->button3);
- this->groupBox2->Controls->Add(this->listBox3);
- this->groupBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->groupBox2->Location = System::Drawing::Point(467, 13);
- this->groupBox2->Name = L"groupBox2";
- this->groupBox2->Size = System::Drawing::Size(229, 400);
- this->groupBox2->TabIndex = 8;
- this->groupBox2->TabStop = false;
- this->groupBox2->Text = L"Nombre inicia con letra \"A\"";
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(9, 357);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(214, 37);
- this->button3->TabIndex = 1;
- this->button3->Text = L"Filtrar";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
- //
- // listBox3
- //
- this->listBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox3->FormattingEnabled = true;
- this->listBox3->ItemHeight = 20;
- this->listBox3->Location = System::Drawing::Point(6, 25);
- this->listBox3->Name = L"listBox3";
- this->listBox3->Size = System::Drawing::Size(217, 324);
- this->listBox3->TabIndex = 0;
- //
- // button4
- //
- this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->button4->Location = System::Drawing::Point(121, 99);
- this->button4->Name = L"button4";
- this->button4->Size = System::Drawing::Size(75, 30);
- this->button4->TabIndex = 9;
- this->button4->Text = L"Eliminar";
- this->button4->UseVisualStyleBackColor = true;
- this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(699, 424);
- this->Controls->Add(this->button4);
- this->Controls->Add(this->groupBox2);
- this->Controls->Add(this->groupBox1);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->listBox1);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->button1);
- this->Name = L"MyForm";
- this->Text = L"MyForm";
- this->groupBox1->ResumeLayout(false);
- this->groupBox2->ResumeLayout(false);
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- void Insertar_Datos_Persona_en_ListBox()
- { listBox1->Items->Clear();
- if (objeto_ArrPersona->Retornar_N()>0)
- { for (int i=0;i<objeto_ArrPersona->Retornar_N();i++)
- { objeto_Persona= objeto_ArrPersona->Retorna_dato_en_arreglo(i);
- //Convertimos de char* a String^
- System::String ^nombre="Nombre : " +gcnew System::String(objeto_Persona->Retornar_Nombre()) +
- " Edad : " + objeto_Persona->Retornar_Edad().ToString() ;
- listBox1->Items->Add(nombre);
- }
- }
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- if (textBox1->Text->Length>0 && textBox2->Text->Length>0)
- { objeto_Persona= new Persona();
- int miedad=Convert::ToInt32(textBox2->Text); objeto_Persona->Cambiar_Edad(miedad);
- char*minombre; minombre=new char[100];
- sprintf(minombre,"%s",textBox1->Text);//Convierte de St ring^ a char*
- objeto_Persona->Cambiar_Nombre(minombre);
- objeto_ArrPersona->Agregar(objeto_Persona);
- textBox1->Clear();
- textBox2->Clear();
- }
- else
- objeto_Persona= NULL;
- Insertar_Datos_Persona_en_ListBox();
- }
- private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
- if (listBox1->SelectedIndex!=-1)
- {
- objeto_ArrPersona->Eliminar(listBox1->SelectedIndex);
- listBox1->SelectedIndex=-1;
- Insertar_Datos_Persona_en_ListBox();
- textBox1->Clear();
- textBox2->Clear();
- }
- }
- private: System::Void listBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
- if (listBox1->SelectedIndex!=-1)
- {
- objeto_Persona=objeto_ArrPersona->Retorna_dato_en_arreglo(listBox1->SelectedIndex);
- textBox1->Text= gcnew System::String(objeto_Persona->Retornar_Nombre());
- textBox2->Text= objeto_Persona->Retornar_Edad().ToString();
- }
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- int *cantidad;
- cantidad=new int;
- *cantidad=0;
- //int cantidad=0;
- Persona** arr_masde25 = objeto_ArrPersona->Mayores25anhos(cantidad);
- MessageBox::Show(""+*cantidad, "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- listBox2->Items->Clear();
- if (arr_masde25 !=NULL)
- {
- //for (int i=0;i<*cantidad;i++)
- for (int i=0;i<*cantidad;i++)
- {
- System::String ^nombre= "Nombre: " +gcnew System::String(arr_masde25[i]->Retornar_Nombre());
- listBox2->Items->Add(nombre);
- }
- }
- }
- private: System::Void textBox2_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (!(Char::IsNumber(e->KeyChar)) && (e->KeyChar != char(Keys::Back)))
- {
- MessageBox::Show("Solo se permiten numeros", "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- e->Handled = true;
- return;
- }
- }
- private: System::Void textBox1_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (!(Char::IsLetter(e->KeyChar)) && (e->KeyChar != char(Keys::Back)) && !(Char::IsSeparator(e->KeyChar)))
- {
- MessageBox::Show("Solo se permiten letras", "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- e->Handled = true;
- return;
- }
- }
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
- /* int *cantidad;
- cantidad=new int;
- *cantidad=0;
- Persona** arr_letraA = objeto_ArrPersona->ConLetraAenelNombre(cantidad);
- listBox3->Items->Clear();
- if (arr_letraA !=NULL)
- {
- for (int i=0;i<*cantidad;i++)
- {
- System::String ^nombre= "Nombre: " +gcnew System::String(arr_letraA[i]->Retornar_Nombre());
- listBox3->Items->Add(nombre);
- }
- }*/
- }
- };
- }
- #pragma once
- namespace POO1 {
- #include "ArrPersonas.h"; //Un arreglo de Objetos Persona
- #include "Persona.h"; //UN SOLO OBJETO PERSONA
- #include <stdio.h>;
- 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>
- /// Summary for MyForm
- /// </summary>
- public ref class MyForm : public System::Windows::Forms::Form
- {
- public:
- MyForm(void)
- {
- InitializeComponent();
- objeto_ArrPersona=new ArrPersonas();
- }
- protected:
- ~MyForm()
- {
- if (components)
- {
- delete components;
- }
- delete objeto_ArrPersona;
- }
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- ArrPersonas *objeto_ArrPersona;
- Persona *objeto_Persona;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::ListBox^ listBox1;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::ListBox^ listBox2;
- private: System::Windows::Forms::GroupBox^ groupBox2;
- private: System::Windows::Forms::Button^ button3;
- private: System::Windows::Forms::ListBox^ listBox3;
- private: System::Windows::Forms::Button^ button4;
- System::ComponentModel::Container ^components;
- #pragma region 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->button1 = (gcnew System::Windows::Forms::Button());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->listBox1 = (gcnew System::Windows::Forms::ListBox());
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->textBox2 = (gcnew System::Windows::Forms::TextBox());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->listBox2 = (gcnew System::Windows::Forms::ListBox());
- this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->listBox3 = (gcnew System::Windows::Forms::ListBox());
- this->button4 = (gcnew System::Windows::Forms::Button());
- this->groupBox1->SuspendLayout();
- this->groupBox2->SuspendLayout();
- this->SuspendLayout();
- //
- // button1
- //
- this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->button1->Location = System::Drawing::Point(42, 99);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(61, 30);
- this->button1->TabIndex = 0;
- this->button1->Text = L"Crear";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label1->Location = System::Drawing::Point(5, 15);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(65, 20);
- this->label1->TabIndex = 1;
- this->label1->Text = L"Nombre";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label2->Location = System::Drawing::Point(8, 55);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(47, 20);
- this->label2->TabIndex = 2;
- this->label2->Text = L"Edad";
- //
- // listBox1
- //
- this->listBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox1->FormattingEnabled = true;
- this->listBox1->ItemHeight = 20;
- this->listBox1->Location = System::Drawing::Point(12, 169);
- this->listBox1->Name = L"listBox1";
- this->listBox1->Size = System::Drawing::Size(214, 244);
- this->listBox1->TabIndex = 3;
- this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::listBox1_SelectedIndexChanged);
- //
- // textBox1
- //
- this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->textBox1->Location = System::Drawing::Point(78, 14);
- this->textBox1->MaxLength = 99;
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(148, 26);
- this->textBox1->TabIndex = 4;
- this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox1_KeyPress);
- //
- // textBox2
- //
- this->textBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->textBox2->Location = System::Drawing::Point(78, 55);
- this->textBox2->MaxLength = 2;
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(44, 26);
- this->textBox2->TabIndex = 5;
- this->textBox2->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox2_KeyPress);
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label3->Location = System::Drawing::Point(8, 146);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(152, 20);
- this->label3->TabIndex = 6;
- this->label3->Text = L"Todas las Personas:";
- //
- // groupBox1
- //
- this->groupBox1->Controls->Add(this->button2);
- this->groupBox1->Controls->Add(this->listBox2);
- this->groupBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->groupBox1->Location = System::Drawing::Point(232, 13);
- this->groupBox1->Name = L"groupBox1";
- this->groupBox1->Size = System::Drawing::Size(229, 400);
- this->groupBox1->TabIndex = 7;
- this->groupBox1->TabStop = false;
- this->groupBox1->Text = L"Mayores de 25 años";
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(15, 357);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(208, 37);
- this->button2->TabIndex = 1;
- this->button2->Text = L"Filtrar";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
- //
- // listBox2
- //
- this->listBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox2->FormattingEnabled = true;
- this->listBox2->ItemHeight = 20;
- this->listBox2->Location = System::Drawing::Point(15, 27);
- this->listBox2->Name = L"listBox2";
- this->listBox2->Size = System::Drawing::Size(208, 324);
- this->listBox2->TabIndex = 0;
- //
- // groupBox2
- //
- this->groupBox2->Controls->Add(this->button3);
- this->groupBox2->Controls->Add(this->listBox3);
- this->groupBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->groupBox2->Location = System::Drawing::Point(467, 13);
- this->groupBox2->Name = L"groupBox2";
- this->groupBox2->Size = System::Drawing::Size(229, 400);
- this->groupBox2->TabIndex = 8;
- this->groupBox2->TabStop = false;
- this->groupBox2->Text = L"Nombre inicia con letra \"A\"";
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(9, 357);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(214, 37);
- this->button3->TabIndex = 1;
- this->button3->Text = L"Filtrar";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
- //
- // listBox3
- //
- this->listBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->listBox3->FormattingEnabled = true;
- this->listBox3->ItemHeight = 20;
- this->listBox3->Location = System::Drawing::Point(6, 25);
- this->listBox3->Name = L"listBox3";
- this->listBox3->Size = System::Drawing::Size(217, 324);
- this->listBox3->TabIndex = 0;
- //
- // button4
- //
- this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->button4->Location = System::Drawing::Point(121, 99);
- this->button4->Name = L"button4";
- this->button4->Size = System::Drawing::Size(75, 30);
- this->button4->TabIndex = 9;
- this->button4->Text = L"Eliminar";
- this->button4->UseVisualStyleBackColor = true;
- this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(699, 424);
- this->Controls->Add(this->button4);
- this->Controls->Add(this->groupBox2);
- this->Controls->Add(this->groupBox1);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->listBox1);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->button1);
- this->Name = L"MyForm";
- this->Text = L"MyForm";
- this->groupBox1->ResumeLayout(false);
- this->groupBox2->ResumeLayout(false);
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- void Insertar_Datos_Persona_en_ListBox()
- { listBox1->Items->Clear();
- if (objeto_ArrPersona->Retornar_N()>0)
- { for (int i=0;i<objeto_ArrPersona->Retornar_N();i++)
- { objeto_Persona= objeto_ArrPersona->Retorna_dato_en_arreglo(i);
- //Convertimos de char* a String^
- System::String ^nombre="Nombre : " +gcnew System::String(objeto_Persona->Retornar_Nombre()) +
- " Edad : " + objeto_Persona->Retornar_Edad().ToString() ;
- listBox1->Items->Add(nombre);
- }
- }
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- if (textBox1->Text->Length>0 && textBox2->Text->Length>0)
- { objeto_Persona= new Persona();
- int miedad=Convert::ToInt32(textBox2->Text); objeto_Persona->Cambiar_Edad(miedad);
- char*minombre; minombre=new char[100];
- sprintf(minombre,"%s",textBox1->Text);//Convierte de St ring^ a char*
- objeto_Persona->Cambiar_Nombre(minombre);
- objeto_ArrPersona->Agregar(objeto_Persona);
- textBox1->Clear();
- textBox2->Clear();
- }
- else
- objeto_Persona= NULL;
- Insertar_Datos_Persona_en_ListBox();
- }
- private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
- if (listBox1->SelectedIndex!=-1)
- {
- objeto_ArrPersona->Eliminar(listBox1->SelectedIndex);
- listBox1->SelectedIndex=-1;
- Insertar_Datos_Persona_en_ListBox();
- textBox1->Clear();
- textBox2->Clear();
- }
- }
- private: System::Void listBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
- if (listBox1->SelectedIndex!=-1)
- {
- objeto_Persona=objeto_ArrPersona->Retorna_dato_en_arreglo(listBox1->SelectedIndex);
- textBox1->Text= gcnew System::String(objeto_Persona->Retornar_Nombre());
- textBox2->Text= objeto_Persona->Retornar_Edad().ToString();
- }
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- int *cantidad;
- cantidad=new int;
- *cantidad=0;
- //int cantidad=0;
- Persona** arr_masde25 = objeto_ArrPersona->Mayores25anhos(cantidad);
- MessageBox::Show(""+*cantidad, "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- listBox2->Items->Clear();
- if (arr_masde25 !=NULL)
- {
- //for (int i=0;i<*cantidad;i++)
- for (int i=0;i<*cantidad;i++)
- {
- System::String ^nombre= "Nombre: " +gcnew System::String(arr_masde25[i]->Retornar_Nombre());
- listBox2->Items->Add(nombre);
- }
- }
- }
- private: System::Void textBox2_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (!(Char::IsNumber(e->KeyChar)) && (e->KeyChar != char(Keys::Back)))
- {
- MessageBox::Show("Solo se permiten numeros", "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- e->Handled = true;
- return;
- }
- }
- private: System::Void textBox1_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (!(Char::IsLetter(e->KeyChar)) && (e->KeyChar != char(Keys::Back)) && !(Char::IsSeparator(e->KeyChar)))
- {
- MessageBox::Show("Solo se permiten letras", "Advertencia", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
- e->Handled = true;
- return;
- }
- }
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
- /* int *cantidad;
- cantidad=new int;
- *cantidad=0;
- Persona** arr_letraA = objeto_ArrPersona->ConLetraAenelNombre(cantidad);
- listBox3->Items->Clear();
- if (arr_letraA !=NULL)
- {
- for (int i=0;i<*cantidad;i++)
- {
- System::String ^nombre= "Nombre: " +gcnew System::String(arr_letraA[i]->Retornar_Nombre());
- listBox3->Items->Add(nombre);
- }
- }*/
- }
- };
- }
- //#include "Persona.h"
- //#include <string.h>
- //
- //Persona::Persona(void)
- //{
- // Edad=0;
- // Nombre=new char[100];
- //}
- //Persona::~Persona(void)
- //{
- // delete[] Nombre;
- //}
- //void Persona::Cambiar_Edad(int nuevo_valor)
- //{
- // Edad=nuevo_valor;
- //}
- //int Persona::Retornar_Edad()
- //{
- // return Edad;
- //}
- //void Persona::Cambiar_Nombre(char* nuevo_valor)
- //{
- // strcpy(Nombre,nuevo_valor);
- //}
- //char* Persona::Retornar_Nombre()
- //{
- // return Nombre;
- //}
- #pragma once
- #include <string.h>
- class Persona
- {
- private:
- char* Nombre;
- int Edad;
- public:
- Persona(void); //Constructor
- ~Persona(void); //Destructor
- void Cambiar_Edad(int nuevo_valor);
- int Retornar_Edad();
- void Cambiar_Nombre(char* nuevo_valor);
- char* Retornar_Nombre();
- };
- Persona::Persona(void)
- {
- Edad=0;
- Nombre=new char[100];
- }
- Persona::~Persona(void)
- {
- delete[] Nombre;
- }
- void Persona::Cambiar_Edad(int nuevo_valor)
- {
- Edad=nuevo_valor;
- }
- int Persona::Retornar_Edad()
- {
- return Edad;
- }
- void Persona::Cambiar_Nombre(char* nuevo_valor)
- {
- strcpy(Nombre,nuevo_valor);
- }
- char* Persona::Retornar_Nombre()
- {
- return Nombre;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement