-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form7.cs
135 lines (114 loc) · 3.98 KB
/
Form7.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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 addSzkolenie : Form
{
public addSzkolenie()
{
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;";
polczenie.Open();
/*
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;
*/
dateTimePicker1.CustomFormat = "yyyy.MM.dd";
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker2.CustomFormat = "yyyy.MM.dd";
dateTimePicker2.Format = DateTimePickerFormat.Custom;
string addFirm = "INSERT INTO SZKOLENIA(IMIE, NAZWISKO, OKRES_WAŻNOŚCI, EGZAMIN, OCENA, KOMISJA, PRACOWNIKID, TYP, DATA_SZKOLENIA, FIRMYID) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "', '" + dateTimePicker2.Text + "', '" + egzaminBox2.Text + "', '" + ocenaBox3.Text + "', '" + textBox6.Text + "', '" + textBox7.Text + "', '" + comboBox1.Text + "', '" + dateTimePicker1.Text + "', '" + textBox10.Text + "');";
MessageBox.Show(addFirm);
try
{
SqlCommand command = new SqlCommand(addFirm, polczenie);
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 button1_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
egzaminBox2.Items.Equals(0);
ocenaBox3.Items.Equals(0);
textBox6.Clear();
textBox7.Clear();
textBox10.Clear();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
//nic
}
public string ls()
{
listaSzkolen ls = new listaSzkolen();
textBox1.Text = ls.ans();
textBox2.Text = ls.ann();
textBox10.Text = ls.anm();
return textBox1.Text;
}
public string lp()
{
ListaPracowników lp = new ListaPracowników();
textBox1.Text = lp.anp();
textBox2.Text = lp.anr();
return textBox1.Text;
}
public void addSzkolenie_Load(object sender, EventArgs e)
{
if (textBox1.Text != null)
{
ls();
}
else
{
textBox1.Text = null;
textBox2.Text = null;
lp();
}
}
}
}