Form4.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 WindowsFormsApp22222
  11. {
  12. public partial class Form4 : Form
  13. {
  14. public Form4()
  15. {
  16. InitializeComponent();
  17. }
  18. public int Checked_RoleID { get; private set; }
  19. private void button1_Click(object sender, EventArgs e)
  20. {
  21. var db = new rewqEntities();
  22. if (radioButton1.Checked == true)
  23. {
  24. Checked_RoleID = 1;
  25. }
  26. else if (radioButton2.Checked == true)
  27. {
  28. Checked_RoleID = 2;
  29. }
  30. var data = new Users
  31. {
  32. Email = textBox1.Text,
  33. FirstName = textBox2.Text,
  34. LastName = textBox3.Text,
  35. OfficeID = int.Parse(comboBox1.Text),
  36. RoleID = Checked_RoleID,
  37. };
  38. db.Users.InsertOnSubmit(data);
  39. db.SubmitChanges();
  40. }
  41. private void button2_Click(object sender, EventArgs e)
  42. {
  43. Close();
  44. }
  45. }
  46. }