Advertisement
Guest User

Untitled

a guest
May 29th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.IO;
  10. using System.Windows.Forms;
  11.  
  12.  
  13. namespace WindowsFormsApplication1
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public abstract class Płyta
  18. {
  19. public string autor;
  20. public string tytul;
  21. public string cena;
  22.  
  23. protected Płyta(string autor, string tytul, string cena)
  24. {
  25. this.autor = autor;
  26. this.tytul = tytul;
  27. this.cena = cena;
  28.  
  29. }
  30.  
  31.  
  32. public abstract void Pokaz();
  33.  
  34. }
  35.  
  36.  
  37. sealed public class CD : Płyta
  38. {
  39.  
  40. public CD(string autor, string tytul, string cena)
  41. : base(autor, tytul, cena)
  42. {
  43.  
  44. }
  45.  
  46.  
  47. public override void Pokaz()
  48. {
  49. System.Console.WriteLine("CD Autor:" + autor + " Tytul " + tytul + " Cena " + cena);
  50. }
  51.  
  52. }
  53.  
  54. sealed public class DVD : Płyta
  55. {
  56.  
  57. public DVD(string autor, string tytul, string cena)
  58. : base(autor, tytul, cena)
  59. {
  60.  
  61. }
  62.  
  63.  
  64. public override void Pokaz()
  65. {
  66. System.Console.WriteLine("DVD Autor:" + autor + " Tytul " + tytul + " Cena " + cena);
  67. }
  68.  
  69. }
  70.  
  71. DataTable table1 = new DataTable("lista");
  72. DataSet set = new DataSet("lista2");
  73. public Form1()
  74. {
  75. InitializeComponent();
  76.  
  77. table1.Columns.Add("Autor");//dodanie kolumny autor
  78. table1.Columns.Add("Tytul");//dodanie kolumny tytul
  79. table1.Columns.Add("Cena"); //dodanie kolumny cena
  80. set.Tables.Add(table1); //chyba dodanie tabeli do DateSet
  81. }
  82.  
  83. private void button1_Click(object sender, EventArgs e)
  84. {
  85.  
  86.  
  87. string autor_temp = this.textBox1.Text;//pobranie wartosci z pol tekstowych
  88. string tytul_temp = this.textBox2.Text;//pobranie wartosci z pol tekstowych
  89. string cena_temp = this.textBox3.Text;//pobranie wartosci z pol tekstowych
  90.  
  91. table1.Rows.Add(autor_temp, tytul_temp, cena_temp); //dodanie do tabeli pobranych wartosci
  92. dataGridView1.DataSource = table1; //wyswietlenie w dataGridView
  93.  
  94.  
  95. using (StreamWriter ff = new StreamWriter(@"c:\temp\lab4_z2_out.txt")) // zapis do pliku
  96. { ff.Write(set.GetXml()); } //konwersja na XML'a
  97. }
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement