Advertisement
Guest User

milcu

a guest
Oct 18th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.ComponentModel;
  7.  
  8. namespace lab4
  9. {
  10. class Persoana
  11. {
  12. private int index;
  13. private string Nume, Telefon, Adresa;
  14. private DateTime DataNasterii;
  15. private Categorie categorie;
  16. public Persoana(int ind,string num, DateTime datanas,string tel, string adr)
  17. {
  18. this.index = ind;
  19. this.Nume = num;
  20. this.DataNasterii = datanas;
  21. this.Telefon = tel;
  22. this.Adresa = adr;
  23. }
  24. public Persoana(int ind,string num, DateTime datanas,string tel,string adr, Categorie categorie) : this(ind,num, datanas,tel,adr)
  25. {
  26. this.categorie = categorie;
  27. }
  28. [Description("Numele complet al persoanei"), Category("Date personale")]
  29. public string Numee
  30. { get
  31. { return Nume; }
  32. }
  33. public DateTime Data
  34. {
  35. get { return DataNasterii; }
  36.  
  37. }
  38.  
  39. public string Telefonn
  40. {
  41. get { return Telefon; }
  42. set { Telefon = value; }
  43. }
  44.  
  45. public string Adresaa
  46. {
  47. get { return Adresa; }
  48. set { Adresa = value; }
  49. }
  50. public Categorie Categoriee
  51. {
  52. get { return categorie; }
  53. set { categorie = value; }
  54. }
  55. [Description("Index"), Browsable(false)]
  56. public int Index
  57. {
  58. get { return index; }
  59. }
  60. }
  61. enum Categorie: int{
  62. Prieteni,
  63. Colegi,
  64. Rude,
  65. Diversi
  66. };
  67. }
  68.  
  69.  
  70. clasa FORM
  71. using System;
  72. using System.Collections.Generic;
  73. using System.ComponentModel;
  74. using System.Data;
  75. using System.Drawing;
  76. using System.Linq;
  77. using System.Text;
  78. using System.Threading.Tasks;
  79. using System.Windows.Forms;
  80.  
  81. namespace lab4
  82. {
  83. public partial class Form1 : Form
  84. {
  85. List<Persoana> pers = new List<Persoana>();
  86. Persoana p;
  87. string nume, telefon, adresa;
  88. DateTime datanasterii;
  89. Categorie categ;
  90.  
  91. public Form1()
  92. {
  93. InitializeComponent();
  94. TreeNode parentNode = new TreeNode();
  95. parentNode.Name = "parinte_1";
  96. parentNode.Text = "Prieteni";
  97. treeView1.Nodes.Add(parentNode);
  98.  
  99. TreeNode childNode = new TreeNode();
  100. childNode.Name = "child_1";
  101. childNode.Text = "Alexandru Andreescu";
  102. parentNode.Nodes.Add(childNode);
  103.  
  104. TreeNode childNode1 = new TreeNode();
  105. childNode1.Name = "child_2";
  106. childNode1.Text = "Bogdan Barbu";
  107. parentNode.Nodes.Add(childNode1);
  108.  
  109. TreeNode parentNode1 = new TreeNode();
  110. parentNode1.Name = "parinte_2";
  111. parentNode1.Text = "Colegi";
  112. treeView1.Nodes.Add(parentNode1);
  113. TreeNode parentNode2 = new TreeNode();
  114. parentNode2.Name = "parinte_3";
  115. parentNode2.Text = "Rude";
  116. treeView1.Nodes.Add(parentNode2);
  117. TreeNode parentNode3 = new TreeNode();
  118. parentNode3.Name = "parinte_4";
  119. parentNode3.Text = "Diversi";
  120. treeView1.Nodes.Add(parentNode3);
  121. foreach (Persoana p in pers)
  122. {
  123. //p - utilizat pentru parcurgerea elementelor
  124. }
  125.  
  126. }
  127.  
  128. private void label1_Click(object sender, EventArgs e)
  129. {
  130.  
  131. }
  132.  
  133. private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  134. {
  135.  
  136. }
  137.  
  138. private void label2_Click(object sender, EventArgs e)
  139. {
  140.  
  141. }
  142.  
  143. private void propertyGrid1_Click(object sender, EventArgs e)
  144. {
  145.  
  146. }
  147.  
  148. private void textBox2_TextChanged(object sender, EventArgs e)
  149. {
  150.  
  151. }
  152.  
  153. private void textBox3_TextChanged(object sender, EventArgs e)
  154. {
  155.  
  156. }
  157.  
  158. private void textBox1_TextChanged(object sender, EventArgs e)
  159. {
  160.  
  161. }
  162.  
  163. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  164. {
  165. int index;
  166. if(comboBox1.SelectedItem=="Prieteni")
  167. {
  168. index = 1;
  169. }
  170. if(comboBox1.SelectedItem == "Colegi")
  171. { index = 2; }
  172. if(comboBox1.SelectedItem=="Rude")
  173. { index = 3; }
  174. if(comboBox1.SelectedItem=="Diversi")
  175. { index = 4; }
  176. }
  177.  
  178. private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
  179. {
  180.  
  181. }
  182.  
  183. private void button1_Click(object sender, EventArgs e)
  184. {
  185.  
  186. Persoana p = new Persoana(1,textBox1.Text, Convert.ToDateTime(dateTimePicker1.Value), textBox2.Text, textBox3.Text, (Categorie)comboBox1.SelectedIndex);
  187. pers.Add(p);
  188. propertyGrid1.SelectedObject = p;
  189. }
  190. }
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement