Form2.cs 912 B

1234567891011121314151617181920212223242526272829303132333435
  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. namespace WindowsFormsApp1
  11. {
  12. public partial class Form2 : Form
  13. {
  14. public Form2()
  15. {
  16. InitializeComponent();
  17. }
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20. var db = new DataClasses1DataContext();
  21. var data = new Users
  22. {
  23. Login=textBox1.Text,
  24. Password=textBox2.Text
  25. };
  26. db.Users.InsertOnSubmit(data);
  27. db.SubmitChanges();
  28. MessageBox.Show("Пользователь успешно добавлен!");
  29. Form1 p = new Form1();
  30. p.Show();
  31. }
  32. }
  33. }