Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void FormLogin_Load(object sender, EventArgs e)
- {
- button1.Enabled = false;
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- if (textBox1.TextLength > 0 && textBox2.TextLength>0)
- {
- button1.Enabled = true;
- }
- else
- {
- button1.Enabled = false;
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- progressBar1.Value++;
- if (progressBar1.Value == progressBar1.Maximum)
- {
- timer1.Stop();
- this.DialogResult = DialogResult.OK;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- timer1.Start();
- }
- }
- PP:
- private void Form1_Load(object sender, EventArgs e)
- {
- FormLogin log = new FormLogin();
- if (log.ShowDialog() == DialogResult.Cancel)
- {
- this.Close();
- }
- /* DateTime data = Convert.ToDateTime("0/0/0");
- listBox1.Items.Add(data);
- */
- parent1.Text = "An I";
- treeView1.Nodes.Add(parent1);
- TreeNode child;
- f (m.An == "I")
- {
- child = new TreeNode();
- child.Text = m.Denumire;
- parent1.Nodes.Add(child);
- foreach(Prezentare prez in lista_p)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = prez.Nr_prezentare;
- child.Nodes.Add(child2);
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- foreach (Materie mat in lista_m)
- {
- int nr_rest_mat = 0;
- foreach (Prezentare pr in mat.Prezentari)
- {
- if (pr.Nota_examen < 5)
- {
- nr_rest_mat++;
- }
- }
- if (nr_rest_mat >= 2)
- {
- listBox1.Items.Add(mat.Denumire);
- }
- }
- }
- CLASS:
- private string denumire;
- private List<Prezentare> prezentari;
- public Materie (string denumire, string an, double nota_lab, List<Prezentare> prezentari)
- {
- this.denumire = denumire;
- this.an = an;
- this.nota_lab = nota_lab;
- this.prezentari = prezentari;
- if (calculMedie() != 0)
- {
- nota_finala = (nota_lab + calculMedie()) / 2;
- }
- }
- [Description("Denumire materie"), Category("Informatii materie")]
- public string Denumire
- {
- get { return denumire; }
- }
- TEST2::
- namespace Test_florarie
- {
- public partial class Form1 : Form
- {
- private List<Floare> lista = new List<Floare>();
- private double total_vanzari = 0;
- System.IO.StreamReader file = new System.IO.StreamReader("fisier_plante.txt");
- private string linie;
- public Form1()
- {
- InitializeComponent();
- listBox1.MouseDoubleClick += new MouseEventHandler(listBox1_DoubleClick);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Floare f = new Floare(dateTimePicker1.Value, comboBox1.Text, Convert.ToDouble(textBox2.Text), textBox1.Text);
- lista.Add(f);
- listBox1.Items.Add(textBox1.Text);
- }
- private void listBox1_DoubleClick(object sender, MouseEventArgs e)
- {
- foreach (Floare f in lista)
- {
- if (listBox1.SelectedItem.ToString() == f.Denumire)
- {
- propertyGrid1.SelectedObject = f;
- if (f.calculZile() >= 3)
- {
- if (f.Categorie == "Flori taiate")
- {
- MessageBox.Show("Floarea este ofilita!!!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
- }
- if (f.Categorie == "Plante in ghiveci")
- {
- if (MessageBox.Show("Floarea trebuie udata!!!\n Doriti sa o udati?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
- {
- f.Data = DateTime.Now;
- }
- }
- }
- }
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- listBox1.Items.Add("\n");
- foreach (Floare f in lista)
- {
- if (string.Compare(f.Denumire, textBox3.Text) == 0)
- {
- listBox1.Items.Add(f.Denumire);
- }
- }
- }
- private void button4_Click(object sender, EventArgs e)
- {
- listBox1.SelectionMode = SelectionMode.One;
- if (this.listBox1.SelectedIndex >= 0)
- {
- foreach (Floare f in lista)
- {
- if (listBox1.SelectedItem.ToString() == f.Denumire)
- {
- total_vanzari += f.Pret;
- this.listBox1.Items.RemoveAt(this.listBox1.SelectedIndex);
- lista.Remove(f);
- break;
- }
- }
- }
- }
- private void button5_Click(object sender, EventArgs e)
- {
- textBox4.Clear();
- textBox4.AppendText(total_vanzari.ToString());
- }
- private void button2_Click(object sender, EventArgs e)
- {
- while ((linie = file.ReadLine()) != null)
- {
- String[] parts = linie.Split(';');
- Floare f = new Floare(Convert.ToDateTime(parts[1]), parts[2], Convert.ToDouble(parts[3]), parts[0]);
- lista.Add(f);
- listBox1.Items.Add(f.Denumire);
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- Login log = new Login();
- if (log.ShowDialog() == DialogResult.Cancel)
- this.Close();
- }
- }
- }
- TETS3::
- namespace Test_studenti_carti
- {
- public partial class Form1 : Form
- {
- System.IO.StreamReader file1 = new System.IO.StreamReader("fisier_studenti.txt");
- System.IO.StreamReader file2 = new System.IO.StreamReader("fisier_carti.txt");
- private String linie1;
- private String linie2;
- private List<Student> lista_s = new List<Student>();
- TreeNode parent1;
- TreeNode parent2;
- TreeNode parent3;
- TreeNode parent4;
- TreeNode nodSelectat = null;
- //int indexNodSelectat = 0;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- FormLogin log = new FormLogin();
- if(log.ShowDialog() == DialogResult.Cancel)
- {
- this.Close();
- }
- //creare noduri in TreeView
- parent1 = new TreeNode();
- parent1.Text = "Anul I";
- treeView1.Nodes.Add(parent1);
- parent2 = new TreeNode();
- parent2.Text = "Anul II";
- treeView1.Nodes.Add(parent2);
- parent3 = new TreeNode();
- parent3.Text = "Anul III";
- treeView1.Nodes.Add(parent3);
- parent4 = new TreeNode();
- parent4.Text = "Anul IV";
- treeView1.Nodes.Add(parent4);
- //citire din fisier
- while ((linie1 = file1.ReadLine()) != null)
- {
- string[] parts1 = linie1.Split(';');
- List<Carte> lista_c = new List<Carte>();
- while ((linie2 = file2.ReadLine()) != null)
- {
- string[] parts2 = linie2.Split(';');
- if (parts1[0] == parts2[0])
- {
- Carte c = new Carte(parts2[1], parts2[2], parts2[3], Convert.ToDateTime(parts2[4]), Convert.ToDateTime(parts2[5]));
- lista_c.Add(c);
- }
- }
- file2.DiscardBufferedData();
- file2.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
- Student s = new Student(parts1[1], parts1[2], parts1[3], parts1[4], Convert.ToDateTime(parts1[5]), lista_c);
- lista_s.Add(s);
- //adaugare student in TreeView in functie de an
- TreeNode child = new TreeNode();
- if (s.An == "I")
- {
- child.Text = s.Nume;
- parent1.Nodes.Add(child);
- foreach (Carte car in lista_c)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = car.Titlu;
- child.Nodes.Add(child2);
- }
- }
- if (s.An == "II")
- {
- child.Text = s.Nume;
- parent2.Nodes.Add(child);
- foreach (Carte car in lista_c)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = car.Titlu;
- child.Nodes.Add(child2);
- }
- }
- if (s.An == "III")
- {
- child.Text = s.Nume;
- parent3.Nodes.Add(child);
- foreach (Carte car in lista_c)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = car.Titlu;
- child.Nodes.Add(child2);
- }
- }
- if (s.An == "IV")
- {
- child.Text = s.Nume;
- parent4.Nodes.Add(child);
- foreach (Carte car in lista_c)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = car.Titlu;
- child.Nodes.Add(child2);
- }
- }
- }
- }
- private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
- {
- nodSelectat = e.Node;
- foreach (Student stud in lista_s)
- {
- if (e.Node.Text == stud.Nume)
- {
- //indexNodSelectat = e.Node.Index;
- propertyGrid1.SelectedObject = stud;
- break;
- }
- foreach (Carte car in stud.Carti)
- {
- if (e.Node.Text == car.Titlu)
- {
- //indexNodSelectat = e.Node.Index;
- propertyGrid1.SelectedObject = car;
- if (car.calculIntarziere() > 0)
- {
- propertyGrid1.ViewForeColor = Color.Red;
- break;
- }
- else
- {
- propertyGrid1.ViewForeColor = Color.Black;
- }
- }
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- foreach (Student stud in lista_s)
- {
- int nr_carti_termen_depasit = 0;
- foreach (Carte carte in stud.Carti)
- {
- if (carte.calculIntarziere() > 0)
- {
- nr_carti_termen_depasit++;
- }
- }
- if (nr_carti_termen_depasit > 0)
- {
- listBox1.Items.Add(stud.Nume + " " + nr_carti_termen_depasit + " carti");
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- foreach (Student stud in lista_s)
- {
- foreach (Carte car in stud.Carti)
- {
- if (nodSelectat.Text == car.Titlu)
- {
- stud.Carti.Remove(car);
- treeView1.Nodes.Remove(nodSelectat);
- propertyGrid1.SelectedObject = null;
- break;
- }
- }
- }
- }
- }
- }
- namespace Test_studenti_carti
- {
- public partial class Form1 : Form
- {
- System.IO.StreamReader file1 = new System.IO.StreamReader("fisier_studenti.txt");
- System.IO.StreamReader file2 = new System.IO.StreamReader("fisier_carti.txt");
- private String linie1;
- private String linie2;
- private List<Student> lista_s = new List<Student>();
- TreeNode parent1;
- TreeNode parent2;
- TreeNode parent3;
- TreeNode parent4;
- TreeNode nodSelectat = null;
- //int indexNodSelectat = 0;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- FormLogin log = new FormLogin();
- if(log.ShowDialog() == DialogResult.Cancel)
- {
- this.Close();
- }
- //creare noduri in TreeView
- parent1 = new TreeNode();
- parent1.Text = "Anul I";
- treeView1.Nodes.Add(parent1);
- parent2 = new TreeNode();
- parent2.Text = "Anul II";
- treeView1.Nodes.Add(parent2);
- parent3 = new TreeNode();
- parent3.Text = "Anul III";
- treeView1.Nodes.Add(parent3);
- parent4 = new TreeNode();
- parent4.Text = "Anul IV";
- treeView1.Nodes.Add(parent4);
- //citire din fisier
- while ((linie1 = file1.ReadLine()) != null)
- {
- string[] parts1 = linie1.Split(';');
- List<Carte> lista_c = new List<Carte>();
- while ((linie2 = file2.ReadLine()) != null)
- {
- string[] parts2 = linie2.Split(';');
- if (parts1[0] == parts2[0])
- {
- Carte c = new Carte(parts2[1], parts2[2], parts2[3], Convert.ToDateTime(parts2[4]), Convert.ToDateTime(parts2[5]));
- lista_c.Add(c);
- }
- }
- file2.DiscardBufferedData();
- file2.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
- Student s = new Student(parts1[1], parts1[2], parts1[3], parts1[4], Convert.ToDateTime(parts1[5]), lista_c);
- lista_s.Add(s);
- //adaugare student in TreeView in functie de an
- TreeNode child = new TreeNode();
- if (s.An == "I")
- {
- child.Text = s.Nume;
- parent1.Nodes.Add(child);
- foreach (Carte car in lista_c)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = car.Titlu;
- child.Nodes.Add(child2);
- }
- }
- if (s.An == "II")
- {
- child.Text = s.Nume;
- parent2.Nodes.Add(child);
- foreach (Carte car in lista_c)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = car.Titlu;
- child.Nodes.Add(child2);
- }
- }
- if (s.An == "III")
- {
- child.Text = s.Nume;
- parent3.Nodes.Add(child);
- foreach (Carte car in lista_c)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = car.Titlu;
- child.Nodes.Add(child2);
- }
- }
- if (s.An == "IV")
- {
- child.Text = s.Nume;
- parent4.Nodes.Add(child);
- foreach (Carte car in lista_c)
- {
- TreeNode child2 = new TreeNode();
- child2.Text = car.Titlu;
- child.Nodes.Add(child2);
- }
- }
- }
- }
- private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
- {
- nodSelectat = e.Node;
- foreach (Student stud in lista_s)
- {
- if (e.Node.Text == stud.Nume)
- {
- //indexNodSelectat = e.Node.Index;
- propertyGrid1.SelectedObject = stud;
- break;
- }
- foreach (Carte car in stud.Carti)
- {
- if (e.Node.Text == car.Titlu)
- {
- //indexNodSelectat = e.Node.Index;
- propertyGrid1.SelectedObject = car;
- if (car.calculIntarziere() > 0)
- {
- propertyGrid1.ViewForeColor = Color.Red;
- break;
- }
- else
- {
- propertyGrid1.ViewForeColor = Color.Black;
- }
- }
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- foreach (Student stud in lista_s)
- {
- int nr_carti_termen_depasit = 0;
- foreach (Carte carte in stud.Carti)
- {
- if (carte.calculIntarziere() > 0)
- {
- nr_carti_termen_depasit++;
- }
- }
- if (nr_carti_termen_depasit > 0)
- {
- listBox1.Items.Add(stud.Nume + " " + nr_carti_termen_depasit + " carti");
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- foreach (Student stud in lista_s)
- {
- foreach (Carte car in stud.Carti)
- {
- if (nodSelectat.Text == car.Titlu)
- {
- stud.Carti.Remove(car);
- treeView1.Nodes.Remove(nodSelectat);
- propertyGrid1.SelectedObject = null;
- break;
- }
- }
- }
- }
- }
- }
- TEST 4:::
- namespace MTP_L1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private List<Student> lista = new List<Student>();
- private void button1_Click(object sender, EventArgs e)
- {
- byte[] note = new byte[5];
- note[0] = Convert.ToByte(comboBox2.Text);
- note[1] = Convert.ToByte(comboBox3.Text);
- note[2] = Convert.ToByte(comboBox4.Text);
- note[3] = Convert.ToByte(comboBox5.Text);
- note[4] = Convert.ToByte(comboBox6.Text);
- Student s = new Student(Convert.ToByte(cmbAn.Text), note, txtNume.Text, (byte)numVarsta.Value);
- lista.Add(s);
- listBox1.Items.Add(s.AfisareStudent());
- }
- private void button3_Click(object sender, EventArgs e)
- {
- listBox1.Items.Add("\n");
- ComparaMedie cm = new ComparaMedie();
- lista.Sort(cm);
- foreach (Student s in lista)
- listBox1.Items.Add(s.AfisareStudent());
- }
- private void button2_Click(object sender, EventArgs e)
- {
- listBox1.Items.Add("\n");
- ComparaNume cn = new ComparaNume();
- lista.Sort(cn);
- foreach (Student s in lista)
- listBox1.Items.Add(s.AfisareStudent());
- }
- private void button4_Click(object sender, EventArgs e)
- {
- listBox1.Items.Add("\n");
- byte an = Convert.ToByte(comboBox7.Text);
- foreach (Student s in lista)
- if (s.AnStudiu == an)
- listBox1.Items.Add(s.AfisareStudent());
- }
- private void button5_Click(object sender, EventArgs e)
- {
- listBox1.Items.Add("\n");
- foreach (Student s in lista)
- if (string.Compare(s.NumeStudent, textBox2.Text) == 0)
- listBox1.Items.Add(s.AfisareStudent());
- }
- private void button6_Click(object sender, EventArgs e)
- {
- listBox1.SelectionMode = SelectionMode.MultiExtended;
- if (this.listBox1.SelectedIndex >= 0)
- this.listBox1.Items.RemoveAt(this.listBox1.SelectedIndex);
- }
- }
- }
- namespace MTP_L1
- {
- class ComparaMedie : IComparer<Student>
- {
- public int Compare(Student x, Student y)
- {
- if (x.Medie() > y.Medie())
- return 1;
- else if (x.Medie() == y.Medie())
- return 0;
- else
- return -1;
- }
- }
- }
- TEST5:::
- namespace MTP_L2
- {
- public partial class Form1 : Form
- {
- TreeNode parent1;
- TreeNode parent2;
- TreeNode parent3;
- TreeNode parent4;
- TreeNode nodDeSters = null;
- int indexDeSters = 0;
- int index = 0;
- List<Persoana> agenda = new List<Persoana>();
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- parent1 = new TreeNode();
- parent1.Text = "Prieteni";
- parent1.ImageIndex = 1;
- tvwAgenda.Nodes.Add(parent1);
- parent2 = new TreeNode();
- parent2.Text = "Colegi";
- parent2.ImageIndex = 2;
- tvwAgenda.Nodes.Add(parent2);
- parent3 = new TreeNode();
- parent3.Text = "Rude";
- parent3.ImageIndex = 3;
- tvwAgenda.Nodes.Add(parent3);
- parent4 = new TreeNode();
- parent4.Text = "Diversi";
- parent4.ImageIndex = 4;
- tvwAgenda.Nodes.Add(parent4);
- }
- private void buttonAdauga_Click(object sender, EventArgs e)
- {
- if (agenda.Exists(x => x.Nume.Equals(textBoxNume.Text)))
- {
- MessageBox.Show("Persoana pe care doriti sa o introduceti exista deja in agenda", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
- }
- else
- {
- index++;
- Persoana p = new Persoana(index, textBoxNume.Text, dateTimePicker1.Value, textBoxTelefon.Text, textBoxAdresa.Text, (Categorie)comboBoxCategorie.SelectedIndex);
- agenda.Add(p);
- TreeNode child = new TreeNode();
- if (comboBoxCategorie.Text == "Prieteni")
- {
- child.Name = index.ToString();
- child.Text = textBoxNume.Text;
- child.ImageIndex = 1;
- parent1.Nodes.Add(child);
- }
- if (comboBoxCategorie.Text == "Colegi")
- {
- child.Name = index.ToString();
- child.Text = textBoxNume.Text;
- child.ImageIndex = 2;
- parent2.Nodes.Add(child);
- }
- if (comboBoxCategorie.Text == "Rude")
- {
- child.Name = index.ToString();
- child.Text = textBoxNume.Text;
- child.ImageIndex = 3;
- parent3.Nodes.Add(child);
- }
- if (comboBoxCategorie.Text == "Diversi")
- {
- child.Name = index.ToString();
- child.Text = textBoxNume.Text;
- child.ImageIndex = 4;
- parent4.Nodes.Add(child);
- }
- }
- }
- private void tvwAgenda_AfterSelect(object sender, TreeViewEventArgs e)
- {
- nodDeSters = e.Node; //pentru selectia nodului de sters
- foreach (Persoana p in agenda)
- {
- if (e.Node.Text == p.Nume)
- {
- indexDeSters = Convert.ToInt16(e.Node.Name); //retine indexul nodului selectat
- propertyGrid1.SelectedObject = p;
- break;
- }
- }
- }
- private void buttonCauta_Click(object sender, EventArgs e)
- {
- foreach (Persoana p in agenda)
- {
- if (textBoxCautare.Text == p.Nume)
- {
- propertyGrid1.SelectedObject = p;
- break;
- }
- }
- }
- private void buttonSterge_Click(object sender, EventArgs e)
- {
- foreach (Persoana p in agenda)
- {
- if (indexDeSters == p.Index)
- {
- if (MessageBox.Show("Doriti sa stergeti persoana [" + p.Nume + "]?", "Intrebare", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
- {
- agenda.Remove(p); //sterge din lista
- tvwAgenda.Nodes.Remove(nodDeSters); //sterge nodul din treeview
- propertyGrid1.SelectedObject = null; //sterge informatiile din propertygrid
- break;
- }
- }
- }
- }
- string dir = Application.StartupPath;
- private void buttonSalveazaFisier_Click(object sender, EventArgs e)
- {
- StreamWriter sw = new StreamWriter(dir + "\\agenda.txt", true);
- foreach (Persoana p in agenda)
- {
- if (indexDeSters == p.Index) //indexul nodului selectat
- {
- sw.WriteLine("Nume: " + p.Nume);
- sw.WriteLine("Categorie: " + p.Categorie.ToString());
- sw.WriteLine("Data nasterii: " + p.DataNasterii);
- sw.WriteLine("Telefon: " + p.Telefon);
- sw.WriteLine("Adresa: " + p.Adresa);
- sw.WriteLine("----------------------------------------");
- sw.Close();
- break;
- }
- }
- //Process.Start("notepad.exe", dir + "\\agenda.txt"); // deschide fisierul de fiecare data cand salvez o persoana in el
- }
- }
- }
- namespace MTP_L2
- {
- enum Categorie : int
- {
- Prieteni,
- Colegi,
- Rude,
- Diversi
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment