Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Vezba_09_2017
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void dodajToolStripMenuItem_Click(object sender, EventArgs e)
- {
- AddForm add = new AddForm();
- if(add.ShowDialog() == DialogResult.OK)
- {
- Predmet p = add.PodaciOPredmetu;
- listBox1.Items.Add(p);
- }
- }
- private void izmeniToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (listBox1.SelectedIndex < 0) return;
- Predmet p = (Predmet)listBox1.Items[listBox1.SelectedIndex];
- AddForm add = new AddForm();
- add.PodaciOPredmetu = p;
- add.ShowDialog();
- if (add.DialogResult == DialogResult.OK)
- {
- listBox1.Items[listBox1.SelectedIndex] = add.PodaciOPredmetu;
- }
- }
- private void obrišiToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (listBox1.SelectedIndex < 0) return;
- listBox1.Items.RemoveAt(listBox1.SelectedIndex);
- }
- private void obrišiSveToolStripMenuItem_Click(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- }
- private void eksportujToolStripMenuItem_Click(object sender, EventArgs e)
- {
- SaveFileDialog saveDialog = new SaveFileDialog();
- saveDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
- if (saveDialog.ShowDialog() == DialogResult.OK)
- {
- using (StreamWriter sw = new StreamWriter(saveDialog.FileName, false))
- foreach (Predmet predmet in listBox1.Items)
- sw.WriteLine(predmet.ToString());
- MessageBox.Show("Success");
- }
- }
- private void izlazToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Close();
- }
- private void oProgramuToolStripMenuItem_Click(object sender, EventArgs e)
- {
- MessageBox.Show("Editor predmeta.");
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Vezba_09_2017
- {
- public class Predmet
- {
- public string Naziv { get; set; }
- public string Nastavnik { get; set; }
- public string Udzbenik { get; set; }
- public int Casovi { get; set; }
- public override string ToString()
- {
- return Naziv;
- }
- }
- }
- 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 Vezba_09_2017
- {
- public partial class AddForm : Form
- {
- public Predmet PodaciOPredmetu { get; set; }
- public AddForm()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- PodaciOPredmetu = new Predmet();
- PodaciOPredmetu.Naziv = textBox1.Text;
- PodaciOPredmetu.Nastavnik = textBox2.Text;
- PodaciOPredmetu.Udzbenik = textBox3.Text;
- PodaciOPredmetu.Casovi = (int)numericUpDown1.Value;
- DialogResult = DialogResult.OK;
- Close();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- private void AddForm_Load(object sender, EventArgs e)
- {
- textBox1.Text = PodaciOPredmetu.Naziv;
- textBox2.Text = PodaciOPredmetu.Nastavnik;
- textBox3.Text = PodaciOPredmetu.Udzbenik;
- numericUpDown1.Value = PodaciOPredmetu.Casovi;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement