Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.ComponentModel;
- namespace lab4
- {
- class Persoana
- {
- private int index;
- private string Nume, Telefon, Adresa;
- private DateTime DataNasterii;
- private Categorie categorie;
- public Persoana(int ind,string num, DateTime datanas,string tel, string adr)
- {
- this.index = ind;
- this.Nume = num;
- this.DataNasterii = datanas;
- this.Telefon = tel;
- this.Adresa = adr;
- }
- public Persoana(int ind,string num, DateTime datanas,string tel,string adr, Categorie categorie) : this(ind,num, datanas,tel,adr)
- {
- this.categorie = categorie;
- }
- [Description("Numele complet al persoanei"), Category("Date personale")]
- public string Numee
- { get
- { return Nume; }
- }
- public DateTime Data
- {
- get { return DataNasterii; }
- }
- public string Telefonn
- {
- get { return Telefon; }
- set { Telefon = value; }
- }
- public string Adresaa
- {
- get { return Adresa; }
- set { Adresa = value; }
- }
- public Categorie Categoriee
- {
- get { return categorie; }
- set { categorie = value; }
- }
- [Description("Index"), Browsable(false)]
- public int Index
- {
- get { return index; }
- }
- }
- enum Categorie: int{
- Prieteni,
- Colegi,
- Rude,
- Diversi
- };
- }
- clasa FORM
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace lab4
- {
- public partial class Form1 : Form
- {
- List<Persoana> pers = new List<Persoana>();
- Persoana p;
- string nume, telefon, adresa;
- DateTime datanasterii;
- Categorie categ;
- public Form1()
- {
- InitializeComponent();
- TreeNode parentNode = new TreeNode();
- parentNode.Name = "parinte_1";
- parentNode.Text = "Prieteni";
- treeView1.Nodes.Add(parentNode);
- TreeNode childNode = new TreeNode();
- childNode.Name = "child_1";
- childNode.Text = "Alexandru Andreescu";
- parentNode.Nodes.Add(childNode);
- TreeNode childNode1 = new TreeNode();
- childNode1.Name = "child_2";
- childNode1.Text = "Bogdan Barbu";
- parentNode.Nodes.Add(childNode1);
- TreeNode parentNode1 = new TreeNode();
- parentNode1.Name = "parinte_2";
- parentNode1.Text = "Colegi";
- treeView1.Nodes.Add(parentNode1);
- TreeNode parentNode2 = new TreeNode();
- parentNode2.Name = "parinte_3";
- parentNode2.Text = "Rude";
- treeView1.Nodes.Add(parentNode2);
- TreeNode parentNode3 = new TreeNode();
- parentNode3.Name = "parinte_4";
- parentNode3.Text = "Diversi";
- treeView1.Nodes.Add(parentNode3);
- foreach (Persoana p in pers)
- {
- //p - utilizat pentru parcurgerea elementelor
- }
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
- {
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void propertyGrid1_Click(object sender, EventArgs e)
- {
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox3_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- int index;
- if(comboBox1.SelectedItem=="Prieteni")
- {
- index = 1;
- }
- if(comboBox1.SelectedItem == "Colegi")
- { index = 2; }
- if(comboBox1.SelectedItem=="Rude")
- { index = 3; }
- if(comboBox1.SelectedItem=="Diversi")
- { index = 4; }
- }
- private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Persoana p = new Persoana(1,textBox1.Text, Convert.ToDateTime(dateTimePicker1.Value), textBox2.Text, textBox3.Text, (Categorie)comboBox1.SelectedIndex);
- pers.Add(p);
- propertyGrid1.SelectedObject = p;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement