i earn 0.087 BTC each hour


SUBMITTED BY: Guest

DATE: Nov. 18, 2013, 8:48 p.m.

FORMAT: Text only

SIZE: 2.0 kB

HITS: 763

  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.Windows.Forms;
  9. using System.Data.SqlClient;
  10. namespace Gst_Stg_insertion
  11. {
  12. public partial class Insert : Form
  13. {
  14. public Insert()
  15. {
  16. InitializeComponent();
  17. }
  18. DataSet ds = new DataSet();
  19. SqlDataAdapter sqlda = new SqlDataAdapter("select * from stagiaire", "data source=.;initial catalog = ecole; integrated security = true");
  20. private void Form1_Load(object sender, EventArgs e)
  21. {
  22. sqlda.Fill(ds, "Stagiaire");
  23. MessageBox.Show(ds.Tables["Stagiaire"].Rows.Count.ToString());
  24. }
  25. private Boolean Rechercher(int co)
  26. {
  27. Boolean b = false;
  28. int i;
  29. DataRow dr;
  30. for (i = 0; i < ds.Tables["Stagiaire"].Rows.Count - 1; i++)
  31. {
  32. dr = ds.Tables["Stagiaire"].Rows[i];
  33. if (dr[0].Equals(co) == true) b = true;
  34. }
  35. return b;
  36. }
  37. private void btnAjou_Click(object sender, EventArgs e)
  38. {
  39. DataRow drw;
  40. Boolean b = Rechercher(int.Parse(this.txtCode.Text));
  41. if (b == false )
  42. {
  43. drw = ds.Tables["Stagiaire"].NewRow();
  44. drw[0] = int.Parse(txtCode.Text);
  45. drw[1] = this.txtNom.Text;
  46. drw[2] = this.txtPrenom.Text;
  47. drw[3] = this.txtcode_sp.Text;
  48. ds.Tables["Stagiaire"].Rows.Add(drw);
  49. MessageBox.Show("Ajoute(e) avec Success");
  50. }
  51. else
  52. MessageBox.Show("exist");
  53. }
  54. }
  55. }

comments powered by Disqus