Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 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.Windows.Forms;
  10. using System.Data.OleDb;
  11.  
  12. namespace bilet1
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20. OleDbConnection conn;
  21. private void Form1_Shown(object sender, EventArgs e)
  22. {
  23.  
  24. string cs = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=bilet1.accdb;Persist Security Info=True";
  25. conn = new OleDbConnection(cs);
  26. conn.Open();
  27. }
  28.  
  29. private void button1_Click(object sender, EventArgs e)
  30. {
  31. string nume = textBox1.Text;
  32. string bloc = textBox3.Text;
  33. int nra = int.Parse(textBox4.Text);
  34. int a;
  35. if (radioButton1.Checked == true) a = 1;
  36. else a = 0;
  37. string q = "INSERT INTO locatari(Nume, Nr_bloc, Nr_ap, Angajat) VALUES ";
  38. q = q + "('" + nume + "','" + bloc + "','" + nra + "','" + a + "')";
  39.  
  40. OleDbCommand c = new OleDbCommand(q,conn);
  41. c.ExecuteNonQuery();
  42. }
  43.  
  44. private void button2_Click(object sender, EventArgs e)
  45. {
  46. OleDbCommand c = new OleDbCommand("SELECT * FROM locatari WHERE Angajat = True", conn);
  47. OleDbDataAdapter da = new OleDbDataAdapter(c);
  48. DataTable t = new DataTable();
  49. da.Fill(t);
  50. dataGridView1.DataSource = t;
  51. }
  52.  
  53. private void Form1_Load(object sender, EventArgs e)
  54. {
  55.  
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement