Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.25 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.Windows.Forms;
  9. using MySql.Data.MySqlClient;
  10. using System.Threading;
  11.  
  12. namespace Rpg_Papier
  13. {
  14. public partial class Form9 : Form
  15. {
  16.  
  17. public Form9()
  18. {
  19.  
  20. InitializeComponent();
  21. TxtB_Password.PasswordChar = '*';
  22. this.Focus();
  23. ControlBox = false;
  24. }
  25. protected override void WndProc(ref Message m)
  26. {
  27. base.WndProc(ref m);
  28. }
  29.  
  30.  
  31. public int Compteur = 0;
  32. public static string NomPerso;
  33. public string LoginPerso;
  34. public static string AgePerso;
  35. public static string GenrePerso;
  36. public static string Arme = "sword";
  37. public static int degatArme = 10;
  38. public static string Artefact;
  39. public static int effetArtefact;
  40. public static string consumable;
  41. public static int effetconsumable;
  42. public static string NomBoss;
  43. public static int DegatTourJoueur;
  44. public static int DegatTourBoss;
  45. public static int PvJoueur = 100;
  46. public static int PvBoss = 100;
  47. public static int ChoixArme;
  48. public static int ChoixArtefact;
  49. public static int ChoixPotion;
  50. public static int PvFB = 1000;
  51.  
  52. PremierNiveau f1 = new PremierNiveau();
  53. Creation f3 = new Creation();
  54. private void Form1_Load(object sender, EventArgs e)
  55. {
  56. this.Btn_Connection.FlatAppearance.BorderSize = 0;
  57.  
  58. }
  59.  
  60.  
  61. private void Btn_Fermer_Click(object sender, EventArgs e)
  62. {
  63. Application.Exit();
  64. }
  65.  
  66. private void Btn_Create_Click(object sender, EventArgs e)
  67. {
  68. Creation f3 = new Creation();
  69. f3.ShowDialog();
  70. }
  71.  
  72. private void Lb_Titre_Click(object sender, EventArgs e)
  73. {
  74. //MessageBox.Show("i am a message");
  75. }
  76.  
  77. private void Btn_Connection_Click(object sender, EventArgs e)
  78. {
  79. this.Focus();
  80. if (TxtB_Username.Text == "" && TxtB_Password.Text == "")
  81. {
  82. this.Focus();
  83. MessageBox.Show("Entrer un nom et un mot de passe " );
  84. this.Focus();
  85. }
  86. else if ( TxtB_Username.Text == "")
  87. {
  88. this.Focus();
  89. MessageBox.Show("Entrer un nom ");
  90. this.Focus();
  91. }
  92. else if (TxtB_Password.Text == "")
  93. {
  94. this.Focus();
  95. MessageBox.Show("Entrer un mot de passe ");
  96. this.Focus();
  97. }
  98. else
  99. {
  100. try
  101. {
  102.  
  103. string MaConnexion = "data source=localhost;database=BD_RPGPAPIER;username=root;password=";
  104. MySqlConnection Ma_Connexion = new MySqlConnection(MaConnexion);
  105. MySqlCommand Ma_Commande = new MySqlCommand("select * from tbl_perso where PERSO_USER_NOM='" + this.TxtB_Username.Text + "' and PERSO_USER_PASSWORD='" + this.TxtB_Password.Text + "' ;", Ma_Connexion);
  106. MySqlDataReader Mon_Lecteur;
  107.  
  108.  
  109. Ma_Connexion.Open();
  110. Mon_Lecteur = Ma_Commande.ExecuteReader();
  111.  
  112. while (Mon_Lecteur.Read())
  113. {
  114. Console.WriteLine(Mon_Lecteur[Compteur]);
  115. Compteur++;
  116. }
  117.  
  118.  
  119. if (Compteur == 1)
  120. {
  121. //MessageBox.Show("Nom d'utilisateur et mot de passe correct ");
  122. label1.Text = "Connexion Établi.";
  123. int i;
  124. for (i = 0; i < 1; i++)
  125. {
  126.  
  127. Console.Write(i);
  128. Thread.Sleep(100);
  129.  
  130. Compteur = 0;
  131. // TxtB_Username.Text = "";
  132. TxtB_Password.Text = "";
  133.  
  134. LoginPerso = TxtB_Username.Text;
  135. string connexionF2 = "Data source=localhost;database=BD_RPGPAPIER;username=root;password=";
  136. string demande = "SELECT PERSO_NOM FROM tbl_perso WHERE `PERSO_USER_NOM`='" + LoginPerso + "';";
  137. MySqlConnection connexion2 = new MySqlConnection(connexionF2);
  138. MySqlCommand Commande2 = new MySqlCommand(demande, connexion2);
  139. MySqlDataReader myReader;
  140. connexion2.Open();
  141. myReader = Commande2.ExecuteReader();
  142. while (myReader.Read())
  143. {
  144. NomPerso = myReader.GetString("PERSO_NOM");
  145. }
  146. connexion2.Close();
  147.  
  148. string connexionF3 = "Data source=localhost;database=BD_RPGPAPIER;username=root;password=";
  149. string demande3 = "SELECT PERSO_AGE FROM tbl_perso WHERE `PERSO_USER_NOM`='" + LoginPerso + "';";
  150. MySqlConnection connexion3 = new MySqlConnection(connexionF3);
  151. MySqlCommand Commande3 = new MySqlCommand(demande3, connexion3);
  152. MySqlDataReader myReader3;
  153. connexion3.Open();
  154. myReader3 = Commande3.ExecuteReader();
  155. while (myReader3.Read())
  156. {
  157. AgePerso = myReader3.GetString("PERSO_AGE");
  158. }
  159. connexion3.Close();
  160.  
  161. string connexionF4 = "Data source=localhost;database=BD_RPGPAPIER;username=root;password=";
  162. string demande4 = "SELECT PERSO_SEXE FROM tbl_perso WHERE `PERSO_USER_NOM`='" + LoginPerso + "';";
  163. MySqlConnection connexion4 = new MySqlConnection(connexionF4);
  164. MySqlCommand Commande4 = new MySqlCommand(demande4, connexion4);
  165. MySqlDataReader myReader4;
  166. connexion4.Open();
  167. myReader4 = Commande4.ExecuteReader();
  168. while (myReader4.Read())
  169. {
  170. GenrePerso = myReader4.GetString("PERSO_SEXE");
  171. }
  172. connexion4.Close();
  173.  
  174. this.Hide();
  175. CharacterScreen f2 = new CharacterScreen();
  176. f2.ShowDialog();
  177. this.Focus();
  178.  
  179.  
  180.  
  181.  
  182. }
  183. }
  184. else if (Compteur > 1)
  185. {
  186.  
  187. // MessageBox.Show("Utilisateur et mot de passe Dupliqué");
  188. label1.Text = "Erreur de connexion vérifier \n les informations.";
  189. }
  190.  
  191. else
  192. {
  193. // MessageBox.Show("Nom d'utilisateur et mot de passe incorrect \n Resssayer ");
  194. label1.Text = "Erreur de connexion vérifier \n les informations que vous avez entréer .";
  195.  
  196. }
  197. Ma_Connexion.Close();
  198. this.Focus();
  199.  
  200. }
  201. catch (Exception ex)
  202. {
  203.  
  204. MessageBox.Show(ex.Message);
  205. }
  206.  
  207. }
  208. this.Focus();
  209.  
  210. }
  211.  
  212. private void label1_Click(object sender, EventArgs e)
  213. {
  214.  
  215. }
  216.  
  217. private void button1_Click(object sender, EventArgs e)
  218. {
  219. //f1.ShowDialog();
  220. }
  221.  
  222. private void button1_Click_1(object sender, EventArgs e)
  223. {
  224. f1.ShowDialog();
  225. }
  226.  
  227.  
  228. }
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement