Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  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. using System.Data.SqlClient;
  11.  
  12. namespace WindowsFormsApp6
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23. Form2 dlg = new Form2();
  24. if (dlg.ShowDialog() != DialogResult.OK)
  25. {
  26. Application.Exit();
  27. }
  28. string connetionString = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Student\source\repos\WindowsFormsApp6\WindowsFormsApp6\PacientiSpital.mdf; Integrated Security = True";
  29. SqlConnection cnn = new SqlConnection(connetionString);
  30. cnn.Open();
  31. string tabel_date = "select * from Pacienti";
  32. SqlDataAdapter da = new SqlDataAdapter(tabel_date, connetionString);
  33. DataSet ds = new DataSet();
  34. da.Fill(ds, "Pacienti");
  35. dataGridView1.DataSource = ds.Tables["Pacienti"].DefaultView;
  36. cnn.Close();
  37. }
  38.  
  39. private void button3_Click(object sender, EventArgs e)
  40. {
  41.  
  42. }
  43.  
  44. private void button2_Click(object sender, EventArgs e)
  45. {
  46. Form3 dlg = new Form3();
  47. if (dlg.ShowDialog() != DialogResult.OK)
  48. {
  49. Application.Exit();
  50. }
  51. }
  52.  
  53. private void button1_Click(object sender, EventArgs e)
  54. {
  55. string get_id_string = "SELECT * FROM Pacienti where Nume=" + "'" + textBoxCauta.Text + "'";
  56. MessageBox.Show("Pacientul" + get_id_string + "a fost gasit");
  57. }
  58.  
  59. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  60. {
  61.  
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement