Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-RHTQCBE;Initial Catalog = Studenci; Integrated Security = True");
- // SqlDataAdapter sda = new SqlDataAdapter("SELECT Role FROM Login WHERE Username= '" + textBox1.Text + "'AND Password = '" + textBox2.Text + "' ", con);
- DataTable dt = new System.Data.DataTable();
- DataRow toInsert = dt.NewRow();
- Studenci nowyStudent = new Studenci();
- nowyStudent.ST_Imie = textBox1.Text;
- nowyStudent.ST_Nazwisko = textBox2.Text;
- nowyStudent.ST_Adres = textBox3.Text;
- string data = textBox4.Text; // dd-MM-yyyy
- DateTime d;
- if (DateTime.TryParseExact(data, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out d))
- {
- nowyStudent.ST_Data_urodzenia = d;
- }
- decimal nrIndeksu;
- if (Decimal.TryParse(textBox5.Text, out nrIndeksu)){
- nowyStudent.ST_Nr_indeksu = nrIndeksu;
- }
- int nrSpecjalizacji;
- if (int.TryParse(textBox6.Text, out nrSpecjalizacji)) {
- nowyStudent.ID_Specjalizacji = nrSpecjalizacji;
- }
- int nrProjektu;
- if(int.TryParse(textBox7.Text, out nrProjektu))
- {
- nowyStudent.ID_Projektu = nrProjektu;
- }
- // db.Studenci.Add(nowyStudent);
- dt.Rows.Add(nowyStudent);
- //using method from
- var instance = new Form1("");
- instance.loadData();
- //Autor nowy = new Autor();
- //nowy.AUT_Imie = tbxImie.Text;
- //nowy.AUT_Nazwisko = tbxNazwisko.Text;
- //db.Autor.Add(nowy);
- //db.SaveChanges();
- //ZaladujDane();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement