easy btc earning


SUBMITTED BY: Guest

DATE: Nov. 18, 2013, 9:31 p.m.

FORMAT: Text only

SIZE: 7.4 kB

HITS: 830

  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.DeleteCommand = new SqlCommand();
  24. //sqlda.DeleteCommand.Connection = sqlda.SelectCommand.Connection;
  25. //sqlda.DeleteCommand.CommandText = "Delete from stagiaire where code=@code";
  26. //SqlParameter par1 = new SqlParameter();
  27. //par1.ParameterName ="@code";
  28. //par1.Direction=ParameterDirection.Input ;
  29. //par1.DbType=DbType.Int32;
  30. //sqlda.DeleteCommand.Parameters.Add(par1);
  31. //sqlda.Fill(ds, "Stagiaire");
  32. //MessageBox.Show(ds.Tables["Stagiaire"].Rows.Count.ToString());
  33. //////SqlCommandBuilder sqlcb = new SqlCommandBuilder(sqlda);
  34. //////MessageBox.Show(sqlcb.GetUpdateCommand().CommandText);
  35. }
  36. //private Boolean Rechercher(int co)
  37. //{
  38. // Boolean b = false;
  39. // int i;
  40. // DataRow dr;
  41. // for (i = 0; i < ds.Tables["Stagiaire"].Rows.Count - 1; i++)
  42. // {
  43. // dr = ds.Tables["Stagiaire"].Rows[i];
  44. // if (dr[0].Equals(co) == true) b = true;
  45. // }
  46. // return b;
  47. //}
  48. private void btnvider_Click(object sender, EventArgs e)
  49. {
  50. this.txtCode.Clear();
  51. this.txtNom.Clear();
  52. this.txtPrenom.Clear();
  53. this.txtcodesp.Clear();
  54. this.txtrow.Clear();
  55. }
  56. private void btnajout_Click(object sender, EventArgs e)
  57. {
  58. DataRow drw;
  59. int b = Rechercher(int.Parse(this.txtCode.Text));
  60. if (b == -1)
  61. {
  62. drw = ds.Tables["Stagiaire"].NewRow();
  63. drw[0] = int.Parse(txtCode.Text);
  64. drw[1] = this.txtNom.Text;
  65. drw[2] = this.txtPrenom.Text;
  66. drw[3] = this.txtcodesp.Text;
  67. ds.Tables["Stagiaire"].Rows.Add(drw);
  68. MessageBox.Show("Ajoute(e) avec Success");
  69. }
  70. else
  71. MessageBox.Show("exist");
  72. }
  73. private void btnprem_Click(object sender, EventArgs e)
  74. {
  75. i = 0;
  76. if (ds.Tables["Stagiaire"].Rows[i].RowState.ToString() != "Deleted")
  77. {
  78. txtCode.Text = ds.Tables["Stagiaire"].Rows[i][0].ToString();
  79. txtNom.Text = ds.Tables["Stagiaire"].Rows[i][1].ToString();
  80. txtPrenom.Text = ds.Tables["Stagiaire"].Rows[i][2].ToString();
  81. txtcodesp.Text = ds.Tables["Stagiaire"].Rows[i][3].ToString();
  82. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  83. }
  84. else
  85. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  86. }
  87. private void btnprec_Click(object sender, EventArgs e)
  88. {
  89. if (i > 0)
  90. {
  91. i--;
  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. }
  99. private void btndern_Click(object sender, EventArgs e)
  100. {
  101. i = ds.Tables["Stagiaire"].Rows.Count - 1;
  102. txtCode.Text = ds.Tables["Stagiaire"].Rows[i][0].ToString();
  103. txtNom.Text = ds.Tables["Stagiaire"].Rows[i][1].ToString();
  104. txtPrenom.Text = ds.Tables["Stagiaire"].Rows[i][2].ToString();
  105. txtcodesp.Text = ds.Tables["Stagiaire"].Rows[i][3].ToString();
  106. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  107. }
  108. private void bntsuiv_Click(object sender, EventArgs e)
  109. {
  110. if (i < ds.Tables["Stagiaire"].Rows.Count - 1)
  111. {
  112. i++;
  113. txtCode.Text = ds.Tables["Stagiaire"].Rows[i][0].ToString();
  114. txtNom.Text = ds.Tables["Stagiaire"].Rows[i][1].ToString();
  115. txtPrenom.Text = ds.Tables["Stagiaire"].Rows[i][2].ToString();
  116. txtcodesp.Text = ds.Tables["Stagiaire"].Rows[i][3].ToString();
  117. this.txtrow.Text = ds.Tables["Stagiaire"].Rows[i].RowState.ToString();
  118. }
  119. }
  120. private int Rechercher(int co)
  121. {
  122. int pos = -1;
  123. int i;
  124. DataRow dr;
  125. for (i = 0; i < ds.Tables["Stagiaire"].Rows.Count - 1; i++)
  126. {
  127. dr = ds.Tables["Stagiaire"].Rows[i];
  128. if (dr[0].Equals(co) == true) pos = i;
  129. }
  130. return pos;
  131. }
  132. private void btnupgrd_Click(object sender, EventArgs e)
  133. {
  134. SqlCommandBuilder sqlBd = new SqlCommandBuilder(sqlda);
  135. sqlda.Update(ds,"Stagiaire");
  136. MessageBox.Show("Mise A jour Avec Success");
  137. }
  138. private void btnmodif_Click(object sender, EventArgs e)
  139. {
  140. int p = Rechercher(int.Parse(this.txtCode.Text));
  141. if (p != -1)
  142. {
  143. ds.Tables["Stagiaire"].Rows[p][0] = this.txtCode.Text;
  144. ds.Tables["Stagiaire"].Rows[p][1] = this.txtNom.Text;
  145. ds.Tables["Stagiaire"].Rows[p][2] = this.txtPrenom.Text;
  146. ds.Tables["Stagiaire"].Rows[p][3] = this.txtcodesp.Text;
  147. MessageBox.Show("Modifie(é) avec Success");
  148. }
  149. else
  150. MessageBox.Show("Non Trouve(e)");
  151. }
  152. private void btnsupp_Click_1(object sender, EventArgs e)
  153. {
  154. int posi = Rechercher(int.Parse(this.txtCode.Text));
  155. if (posi != -1)
  156. {
  157. ds.Tables["Stagiaire"].Rows[posi].Delete();
  158. MessageBox.Show("Suppression avec Success");
  159. }
  160. else MessageBox.Show("Stagiaire(e) Non Trouve(e)");
  161. }
  162. }
  163. }

comments powered by Disqus