AddClient.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Windows.Forms;
  5. namespace Servise.Forms.User
  6. {
  7. public partial class AddClient : Form
  8. {
  9. public AddClient()
  10. {
  11. InitializeComponent();
  12. }
  13. DataBase conect = new DataBase();
  14. private void saveClient_Click(object sender, EventArgs e)
  15. {
  16. conect.openConect();
  17. string nc = textNameClient.Text;
  18. string sc = textSurnameClient.Text;
  19. string pc = maskedPhoneClient.Text;
  20. var indert = "INSERT INTO client (name_client, surname_client, phone_client) VALUES ('" + nc + "','" + sc + "','" + pc + "');";
  21. var command = new SqlCommand(indert, conect.getConect());
  22. command.ExecuteNonQuery();
  23. Main.upd("SELECT * FROM client", dataClient, "id_client");
  24. conect.closeConect();
  25. }
  26. private void AddClient_Load(object sender, EventArgs e)
  27. {
  28. Main.upd("SELECT * FROM client", dataClient, "id_client");
  29. }
  30. private void AddClient_FormClosed(object sender, FormClosedEventArgs e)
  31. {
  32. Application.Exit();
  33. }
  34. private void button1_Click(object sender, EventArgs e)
  35. {
  36. if (textNameClient.Text == "")
  37. {
  38. textNameClient.Text = " ";
  39. }
  40. if (textSurnameClient.Text == "")
  41. {
  42. textSurnameClient.Text = " ";
  43. }
  44. if (maskedPhoneClient.Text == "")
  45. {
  46. maskedPhoneClient.Text = " ";
  47. }
  48. Main.upd("SELECT * FROM client where name_client LIKE '%" + textNameClient.Text + "%' or surname_client LIKE '%" + textSurnameClient.Text + "%' or phone_client LIKE '%" + maskedPhoneClient.Text + "%'", dataClient, "id_client");
  49. }
  50. private void button2_Click(object sender, EventArgs e)
  51. {
  52. this.Hide();
  53. Users goUser = new Users();
  54. goUser.Show();
  55. }
  56. private void label1_Click(object sender, EventArgs e)
  57. {
  58. }
  59. private void textSurnameClient_TextChanged(object sender, EventArgs e)
  60. {
  61. }
  62. }
  63. }