Advertisement
Guest User

Untitled

a guest
Nov 28th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. #include "EasyLogin.Form1.h"
  2.  
  3.  
  4. namespace EasyLogin
  5. {
  6.  
  7. Form1::Form1()
  8. {
  9. InitializeComponent();
  10.  
  11. }
  12.  
  13. void Form1::button1_Click(void *sender, EventArgs *e)
  14. {
  15. bool dologin = Login(textBox1->Text, textBox2->Text);
  16. if (dologin == true)
  17. {
  18. MessageBox::Show(L"Logged in!");
  19. }
  20. else if (dologin == false)
  21. {
  22. MessageBox::Show(L"Username and/or password is incorrect.");
  23. }
  24. else
  25. {
  26. MessageBox::Show(L"Error5 please check ur mom.");
  27. }
  28. }
  29.  
  30. bool Form1::Login(const std::wstring &username, const std::wstring &password)
  31. {
  32.  
  33. if (username == L"" || username == L"" || username == L" ")
  34. {
  35. return false;
  36. }
  37. else if (password == L"" || password == L"" || password == L" ")
  38. {
  39. return false;
  40. }
  41.  
  42. WebClient *client = new WebClient();
  43. std::wstring userdb = client->DownloadString(LR"()");
  44. std::wstring passdb = client->DownloadString(LR"()");
  45.  
  46. if (userdb.find(username) != std::wstring::npos)
  47. {
  48. if (passdb.find(password) != std::wstring::npos)
  49. {
  50. userdb = L"";
  51. passdb = L"";
  52. return true;
  53. }
  54. else
  55. {
  56. userdb = L"";
  57. passdb = L"";
  58. return false;
  59. }
  60. }
  61. else
  62. {
  63. userdb = L"";
  64. passdb = L"";
  65. return false;
  66. }
  67. return false;
  68. }
  69.  
  70. void Form1::Dispose(bool disposing)
  71. {
  72. if (disposing && (components != nullptr))
  73. {
  74. delete components;
  75. }
  76. //C# TO C++ CONVERTER NOTE: There is no explicit call to the base class destructor in C++:
  77. // base.Dispose(disposing);
  78. }
  79.  
  80. void Form1::InitializeComponent()
  81. {
  82. this->textBox1 = new System::Windows::Forms::TextBox();
  83. this->textBox2 = new System::Windows::Forms::TextBox();
  84. this->label1 = new System::Windows::Forms::Label();
  85. this->label2 = new System::Windows::Forms::Label();
  86. this->label3 = new System::Windows::Forms::Label();
  87. this->button1 = new System::Windows::Forms::Button();
  88. this->SuspendLayout();
  89. //
  90. // textBox1
  91. //
  92. this->textBox1->Location = System::Drawing::Point(95, 48);
  93. this->textBox1->Name = L"textBox1";
  94. this->textBox1->Size = System::Drawing::Size(100, 22);
  95. this->textBox1->TabIndex = 0;
  96. //
  97. // textBox2
  98. //
  99. this->textBox2->Location = System::Drawing::Point(95, 106);
  100. this->textBox2->Name = L"textBox2";
  101. this->textBox2->PasswordChar = L'*';
  102. this->textBox2->Size = System::Drawing::Size(100, 22);
  103. this->textBox2->TabIndex = 1;
  104. //
  105. // label1
  106. //
  107. this->label1->AutoSize = true;
  108. this->label1->Location = System::Drawing::Point(12, 51);
  109. this->label1->Name = L"label1";
  110. this->label1->Size = System::Drawing::Size(77, 17);
  111. this->label1->TabIndex = 2;
  112. this->label1->Text = L"Username:";
  113. //
  114. // label2
  115. //
  116. this->label2->AutoSize = true;
  117. this->label2->Location = System::Drawing::Point(12, 109);
  118. this->label2->Name = L"label2";
  119. this->label2->Size = System::Drawing::Size(73, 17);
  120. this->label2->TabIndex = 3;
  121. this->label2->Text = L"Password:";
  122. //
  123. // label3
  124. //
  125. this->label3->AutoSize = true;
  126. this->label3->Location = System::Drawing::Point(68, 9);
  127. this->label3->Name = L"label3";
  128. this->label3->Size = System::Drawing::Size(47, 17);
  129. this->label3->TabIndex = 4;
  130. this->label3->Text = L"Login:";
  131. //
  132. // button1
  133. //
  134. this->button1->Location = System::Drawing::Point(71, 168);
  135. this->button1->Name = L"button1";
  136. this->button1->Size = System::Drawing::Size(75, 23);
  137. this->button1->TabIndex = 5;
  138. this->button1->Text = L"Ok.";
  139. this->button1->UseVisualStyleBackColor = true;
  140. this->button1->Click += new System::EventHandler(this->button1_Click);
  141. //
  142. // Form1
  143. //
  144. this->setAutoScaleDimensions(System::Drawing::SizeF(8.0F, 16.0F));
  145. this->setAutoScaleMode(System::Windows::Forms::AutoScaleMode::Font);
  146. this->setClientSize(System::Drawing::Size(243, 203));
  147. this->getControls()->Add(this->button1);
  148. this->getControls()->Add(this->label3);
  149. this->getControls()->Add(this->label2);
  150. this->getControls()->Add(this->label1);
  151. this->getControls()->Add(this->textBox2);
  152. this->getControls()->Add(this->textBox1);
  153. this->setName(L"Form1");
  154. this->setText(L"Login Form");
  155. this->ResumeLayout(false);
  156. this->PerformLayout();
  157.  
  158. }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement