-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm6.cs
84 lines (70 loc) · 2.59 KB
/
Form6.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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.SqlClient;
namespace SzkoleniaBHP
{
public partial class dodajPracowika : Form
{
public dodajPracowika()
{
InitializeComponent();
}
private void save_Click(object sender, EventArgs e)
{
dodaj();
}
void dodaj()
{
SqlConnection polczenie = new SqlConnection();
polczenie.ConnectionString = "Data Source=DESKTOP-CAJMLL5,1433;Initial Catalog=szkoleniaBHP;User ID=sa;Password=Tommys#1978;";
/*
autoNR = ;
nazwa = textBox1.Text;
ulica = textBox2;
nr = textBox3.Text;
kod = textBox4.Text;
miasto = textBox5.Text;
wojewodztwo = textBox6.Text;
telefon = textBox7.Text;
fax = textBox8.Text;
www = textBox9.Text;
email = textBox10.Text;
notatki = textBox11.Text;
*/
string addFirm = "INSERT INTO PRACOWNIK(IMIE, NAZWISKO, ULICA, NR, KODPOCZTOWY, MIASTO, WOJEWODZTWO, TELEFON, EMAIL, NOTATKI, NAZWA, FIRMYID) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + textBox6.Text + "', '" + textBox7.Text + "', '" + textBox8.Text + "', '" + textBox9.Text + "', '" + textBox10.Text + "', '" + textBox11.Text + "', '" + textBox12.Text + "');";
try
{
SqlCommand command = new SqlCommand(addFirm, polczenie);
polczenie.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
MessageBox.Show(String.Format("{0}, {1}",
reader[0], reader[1]));
MessageBox.Show("Poprawnie dodano firmę" + textBox1.Text.ToString());
}
}
}
catch (Exception ex)
{
string error = string.Format("Błąd: " + ex.Message);
MessageBox.Show(error, "Bład", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
polczenie.Close();
}
}
private void dodajPracowika_Load(object sender, EventArgs e)
{
}
}
}