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.Windows.Forms;
- using System.Data.OleDb;
- namespace bilet1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- OleDbConnection conn;
- private void Form1_Shown(object sender, EventArgs e)
- {
- string cs = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=bilet1.accdb;Persist Security Info=True";
- conn = new OleDbConnection(cs);
- conn.Open();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string nume = textBox1.Text;
- string bloc = textBox3.Text;
- int nra = int.Parse(textBox4.Text);
- int a;
- if (radioButton1.Checked == true) a = 1;
- else a = 0;
- string q = "INSERT INTO locatari(Nume, Nr_bloc, Nr_ap, Angajat) VALUES ";
- q = q + "('" + nume + "','" + bloc + "','" + nra + "','" + a + "')";
- OleDbCommand c = new OleDbCommand(q,conn);
- c.ExecuteNonQuery();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- OleDbCommand c = new OleDbCommand("SELECT * FROM locatari WHERE Angajat = True", conn);
- OleDbDataAdapter da = new OleDbDataAdapter(c);
- DataTable t = new DataTable();
- da.Fill(t);
- dataGridView1.DataSource = t;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement