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.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public abstract class Płyta
- {
- public string autor;
- public string tytul;
- public string cena;
- protected Płyta(string autor, string tytul, string cena)
- {
- this.autor = autor;
- this.tytul = tytul;
- this.cena = cena;
- }
- public abstract void Pokaz();
- }
- sealed public class CD : Płyta
- {
- public CD(string autor, string tytul, string cena)
- : base(autor, tytul, cena)
- {
- }
- public override void Pokaz()
- {
- System.Console.WriteLine("CD Autor:" + autor + " Tytul " + tytul + " Cena " + cena);
- }
- }
- sealed public class DVD : Płyta
- {
- public DVD(string autor, string tytul, string cena)
- : base(autor, tytul, cena)
- {
- }
- public override void Pokaz()
- {
- System.Console.WriteLine("DVD Autor:" + autor + " Tytul " + tytul + " Cena " + cena);
- }
- }
- DataTable table1 = new DataTable("lista");
- DataSet set = new DataSet("lista2");
- public Form1()
- {
- InitializeComponent();
- table1.Columns.Add("Autor");//dodanie kolumny autor
- table1.Columns.Add("Tytul");//dodanie kolumny tytul
- table1.Columns.Add("Cena"); //dodanie kolumny cena
- set.Tables.Add(table1); //chyba dodanie tabeli do DateSet
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string autor_temp = this.textBox1.Text;//pobranie wartosci z pol tekstowych
- string tytul_temp = this.textBox2.Text;//pobranie wartosci z pol tekstowych
- string cena_temp = this.textBox3.Text;//pobranie wartosci z pol tekstowych
- table1.Rows.Add(autor_temp, tytul_temp, cena_temp); //dodanie do tabeli pobranych wartosci
- dataGridView1.DataSource = table1; //wyswietlenie w dataGridView
- using (StreamWriter ff = new StreamWriter(@"c:\temp\lab4_z2_out.txt")) // zapis do pliku
- { ff.Write(set.GetXml()); } //konwersja na XML'a
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement