hit free BTC


SUBMITTED BY: Guest

DATE: Nov. 18, 2013, 10 p.m.

FORMAT: Text only

SIZE: 6.7 kB

HITS: 725

  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 FrmGSTFULL : Form
  13. {
  14. public FrmGSTFULL()
  15. {
  16. InitializeComponent();
  17. }
  18. int i = 0;
  19. DataSet ds = new DataSet();
  20. SqlDataAdapter sqlda = new SqlDataAdapter("select * from stagiaire", "data source=.;initial catalog = ecole; integrated security = true");
  21. private void FrmGSTFULL_Load(object sender, EventArgs e)
  22. {
  23. sqlda.Fill(ds, "Stagiaire");
  24. MessageBox.Show(ds.Tables["Stagiaire"].Rows.Count.ToString());
  25. }
  26. //private Boolean Rechercher(int co)
  27. //{
  28. // Boolean b = false;
  29. // int i;
  30. // DataRow dr;
  31. // for (i = 0; i < ds.Tables["Stagiaire"].Rows.Count - 1; i++)
  32. // {
  33. // dr = ds.Tables["Stagiaire"].Rows[i];
  34. // if (dr[0].Equals(co) == true) b = true;
  35. // }
  36. // return b;
  37. //}
  38. private void btnvider_Click(object sender, EventArgs e)
  39. {
  40. this.txtCode.Clear();
  41. this.txtNom.Clear();
  42. this.txtPrenom.Clear();
  43. this.txtcodesp.Clear();
  44. this.txtrow.Clear();
  45. }
  46. private void btnajout_Click(object sender, EventArgs e)
  47. {
  48. DataRow drw;
  49. int b = Rechercher(int.Parse(this.txtCode.Text));
  50. if (b == -1)
  51. {
  52. drw = ds.Tables["Stagiaire"].NewRow();
  53. drw[0] = int.Parse(txtCode.Text);
  54. drw[1] = this.txtNom.Text;
  55. drw[2] = this.txtPrenom.Text;
  56. drw[3] = this.txtcodesp.Text;
  57. ds.Tables["Stagiaire"].Rows.Add(drw);
  58. MessageBox.Show("Ajoute(e) avec Success");
  59. }
  60. else
  61. MessageBox.Show("exist");
  62. }
  63. private void btnprem_Click(object sender, EventArgs e)
  64. {
  65. i = 0;
  66. if (ds.Tables["Stagiaire"].Rows[i].RowState.ToString() != "Deleted")
  67. {
  68. txtCode.Text = ds.Tables["Stagiaire"].Rows[i][0].ToString();
  69. txtNom.Text = ds.Tables["Stagiaire"].Rows[i][1].ToString();
  70. txtPrenom.Text = ds.Tables["Stagiaire"].Rows[i][2].ToString();
  71. txtcodesp.Text = ds.Tables["Stagiaire"].Rows[i][3].ToString();
  72. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  73. }
  74. else
  75. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  76. }
  77. private void btnprec_Click(object sender, EventArgs e)
  78. {
  79. if (i > 0)
  80. {
  81. i--;
  82. txtCode.Text = ds.Tables["Stagiaire"].Rows[i][0].ToString();
  83. txtNom.Text = ds.Tables["Stagiaire"].Rows[i][1].ToString();
  84. txtPrenom.Text = ds.Tables["Stagiaire"].Rows[i][2].ToString();
  85. txtcodesp.Text = ds.Tables["Stagiaire"].Rows[i][3].ToString();
  86. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  87. }
  88. }
  89. private void btndern_Click(object sender, EventArgs e)
  90. {
  91. i = ds.Tables["Stagiaire"].Rows.Count - 1;
  92. txtCode.Text = ds.Tables["Stagiaire"].Rows[i][0].ToString();
  93. txtNom.Text = ds.Tables["Stagiaire"].Rows[i][1].ToString();
  94. txtPrenom.Text = ds.Tables["Stagiaire"].Rows[i][2].ToString();
  95. txtcodesp.Text = ds.Tables["Stagiaire"].Rows[i][3].ToString();
  96. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  97. }
  98. private void bntsuiv_Click(object sender, EventArgs e)
  99. {
  100. if (i < ds.Tables["Stagiaire"].Rows.Count - 1)
  101. {
  102. i++;
  103. txtCode.Text = ds.Tables["Stagiaire"].Rows[i][0].ToString();
  104. txtNom.Text = ds.Tables["Stagiaire"].Rows[i][1].ToString();
  105. txtPrenom.Text = ds.Tables["Stagiaire"].Rows[i][2].ToString();
  106. txtcodesp.Text = ds.Tables["Stagiaire"].Rows[i][3].ToString();
  107. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  108. }
  109. }
  110. private int Rechercher(int co)
  111. {
  112. int pos = -1;
  113. int i;
  114. DataRow dr;
  115. for (i = 0; i < ds.Tables["Stagiaire"].Rows.Count - 1; i++)
  116. {
  117. dr = ds.Tables["Stagiaire"].Rows[i];
  118. if (dr[0].Equals(co) == true) pos = i;
  119. }
  120. return pos;
  121. }
  122. private void btnupgrd_Click(object sender, EventArgs e)
  123. {
  124. SqlCommandBuilder sqlBd = new SqlCommandBuilder(sqlda);
  125. sqlda.Update(ds,"Stagiaire");
  126. MessageBox.Show("Mise A jour Avec Success");
  127. }
  128. private void btnmodif_Click(object sender, EventArgs e)
  129. {
  130. int p = Rechercher(int.Parse(this.txtCode.Text));
  131. if (p != -1)
  132. {
  133. ds.Tables["Stagiaire"].Rows[p][0] = this.txtCode.Text;
  134. ds.Tables["Stagiaire"].Rows[p][1] = this.txtNom.Text;
  135. ds.Tables["Stagiaire"].Rows[p][2] = this.txtPrenom.Text;
  136. ds.Tables["Stagiaire"].Rows[p][3] = this.txtcodesp.Text;
  137. MessageBox.Show("Modifie(é) avec Success");
  138. }
  139. else
  140. MessageBox.Show("Non Trouve(e)");
  141. }
  142. private void btnsupp_Click_1(object sender, EventArgs e)
  143. {
  144. int posi = Rechercher(int.Parse(this.txtCode.Text));
  145. if (posi != -1)
  146. {
  147. ds.Tables["Stagiaire"].Rows[posi].Delete();
  148. MessageBox.Show("Suppression avec Success");
  149. }
  150. else MessageBox.Show("Stagiaire(e) Non Trouve(e)");
  151. }
  152. }
  153. }

comments powered by Disqus