Advertisement
fursty

TSP KASETA

Dec 3rd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. ========================= Domain.cs
  2.  
  3. using System;
  4.  
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace Kaseti
  11. {
  12. class Domain
  13. {
  14.  
  15. string Title;
  16.  
  17. public string Title1
  18. {
  19. get { return Title; }
  20. set { Title = value; }
  21. }
  22. string zanr;
  23.  
  24. public string zanr1
  25. {
  26. get { return zanr; }
  27. set { zanr= value; }
  28. }
  29. string rezisior;
  30.  
  31. public string rezisior1
  32. {
  33. get { return rezisior; }
  34. set { rezisior = value; }
  35. }
  36.  
  37.  
  38. }
  39. }
  40.  
  41.  
  42.  
  43. ============================ Person.cs
  44.  
  45.  
  46.  
  47. using System;
  48. using System.Collections.Generic;
  49. using System.Linq;
  50. using System.Text;
  51.  
  52. namespace Kaseti
  53. {
  54. class Person
  55. {
  56.  
  57. public string Title1 { get; set; }
  58. public string zanr1 { get; set; }
  59. public string rezisior1 { get; set; }
  60.  
  61. }
  62. }
  63.  
  64.  
  65.  
  66.  
  67. ==================================== Broker.cs
  68.  
  69. using System;
  70. using System.Collections.Generic;
  71. using System.Linq;
  72. using System.Text;
  73. using System.Threading.Tasks;
  74. using System.Data.OleDb;
  75. using System.Data;
  76. using System.Windows.Forms;
  77.  
  78. namespace Kaseti
  79. {
  80. class Broker
  81. {
  82. OleDbConnection connection;
  83. OleDbCommand command;
  84. private void ConnectTo()
  85. {
  86. connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\student\\Documents\\kaseti.accdb");
  87. command = connection.CreateCommand();
  88. }
  89. public Broker()
  90. {
  91. ConnectTo();
  92. }
  93.  
  94. public void Insert(Person p)
  95. {
  96. try
  97. {
  98.  
  99. command.CommandText = "INSERT INTO Kaseti( [Title], [zanr], [rezisior]) VALUES ("+ "'" + p.Title1 + "'" + "," + "'" + p.zanr1 + "'" + "," + "'" + p.rezisior1 + "'" + ")";
  100. command.CommandType = CommandType.Text;
  101.  
  102. connection.Open();
  103. command.ExecuteNonQuery();
  104. }
  105. catch (Exception)
  106. {
  107.  
  108. MessageBox.Show("Некоректни данни! Моля въведете отново!");
  109. }
  110. finally
  111. {
  112. if (connection != null)
  113. {
  114. connection.Close();
  115. }
  116. }
  117. }
  118. }
  119. }
  120.  
  121.  
  122.  
  123.  
  124. ============================= Form1.cs
  125.  
  126.  
  127.  
  128. using System;
  129. using System.Collections.Generic;
  130. using System.ComponentModel;
  131. using System.Data;
  132. using System.Drawing;
  133. using System.Linq;
  134. using System.Text;
  135. using System.Threading.Tasks;
  136. using System.Windows.Forms;
  137.  
  138.  
  139. namespace Kaseti
  140. {
  141. public partial class Form1 : Form
  142. {
  143. Broker b = new Broker();
  144.  
  145. public Form1()
  146. {
  147. InitializeComponent();
  148. }
  149.  
  150. private void Form1_Load(object sender, EventArgs e)
  151. {
  152.  
  153. label2.Text = "title";
  154. label3.Text = "zanr";
  155. label4.Text = "resisior";
  156. }
  157.  
  158. private void button1_Click_1(object sender, EventArgs e)
  159. {
  160. Person p = new Person();
  161.  
  162. p.Title1 = textBox2.Text;
  163. p.zanr1 = textBox3.Text;
  164. p.rezisior1 = textBox4.Text;
  165. b.Insert(p);
  166. }
  167.  
  168.  
  169. }
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement