Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "EasyLogin.Form1.h"
- namespace EasyLogin
- {
- Form1::Form1()
- {
- InitializeComponent();
- }
- void Form1::button1_Click(void *sender, EventArgs *e)
- {
- bool dologin = Login(textBox1->Text, textBox2->Text);
- if (dologin == true)
- {
- MessageBox::Show(L"Logged in!");
- }
- else if (dologin == false)
- {
- MessageBox::Show(L"Username and/or password is incorrect.");
- }
- else
- {
- MessageBox::Show(L"Error5 please check ur mom.");
- }
- }
- bool Form1::Login(const std::wstring &username, const std::wstring &password)
- {
- if (username == L"" || username == L"" || username == L" ")
- {
- return false;
- }
- else if (password == L"" || password == L"" || password == L" ")
- {
- return false;
- }
- WebClient *client = new WebClient();
- std::wstring userdb = client->DownloadString(LR"()");
- std::wstring passdb = client->DownloadString(LR"()");
- if (userdb.find(username) != std::wstring::npos)
- {
- if (passdb.find(password) != std::wstring::npos)
- {
- userdb = L"";
- passdb = L"";
- return true;
- }
- else
- {
- userdb = L"";
- passdb = L"";
- return false;
- }
- }
- else
- {
- userdb = L"";
- passdb = L"";
- return false;
- }
- return false;
- }
- void Form1::Dispose(bool disposing)
- {
- if (disposing && (components != nullptr))
- {
- delete components;
- }
- //C# TO C++ CONVERTER NOTE: There is no explicit call to the base class destructor in C++:
- // base.Dispose(disposing);
- }
- void Form1::InitializeComponent()
- {
- this->textBox1 = new System::Windows::Forms::TextBox();
- this->textBox2 = new System::Windows::Forms::TextBox();
- this->label1 = new System::Windows::Forms::Label();
- this->label2 = new System::Windows::Forms::Label();
- this->label3 = new System::Windows::Forms::Label();
- this->button1 = new System::Windows::Forms::Button();
- this->SuspendLayout();
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(95, 48);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(100, 22);
- this->textBox1->TabIndex = 0;
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(95, 106);
- this->textBox2->Name = L"textBox2";
- this->textBox2->PasswordChar = L'*';
- this->textBox2->Size = System::Drawing::Size(100, 22);
- this->textBox2->TabIndex = 1;
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(12, 51);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(77, 17);
- this->label1->TabIndex = 2;
- this->label1->Text = L"Username:";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(12, 109);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(73, 17);
- this->label2->TabIndex = 3;
- this->label2->Text = L"Password:";
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(68, 9);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(47, 17);
- this->label3->TabIndex = 4;
- this->label3->Text = L"Login:";
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(71, 168);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(75, 23);
- this->button1->TabIndex = 5;
- this->button1->Text = L"Ok.";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += new System::EventHandler(this->button1_Click);
- //
- // Form1
- //
- this->setAutoScaleDimensions(System::Drawing::SizeF(8.0F, 16.0F));
- this->setAutoScaleMode(System::Windows::Forms::AutoScaleMode::Font);
- this->setClientSize(System::Drawing::Size(243, 203));
- this->getControls()->Add(this->button1);
- this->getControls()->Add(this->label3);
- this->getControls()->Add(this->label2);
- this->getControls()->Add(this->label1);
- this->getControls()->Add(this->textBox2);
- this->getControls()->Add(this->textBox1);
- this->setName(L"Form1");
- this->setText(L"Login Form");
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement