Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async void jThinButton1_Click(object sender, EventArgs e)
- {
- SqlDataReader sqlReader = null;
- SqlCommand command = new SqlCommand("SELECT * FROM [accounts] WHERE login = '" + textBox1.Text + "' AND password = '" + textBox2.Text + "'", sqlconnection);
- try
- {
- sqlReader = await command.ExecuteReaderAsync();
- bool loginSuccess = false;
- while (await sqlReader.ReadAsync())
- {
- loginSuccess = true;
- Account.SetAccountData(Convert.ToInt32(sqlReader["documentid"]),
- Convert.ToString(sqlReader["name"]),
- Convert.ToString(sqlReader["secondname"]),
- Convert.ToString(sqlReader["fathername"]),
- Convert.ToString(sqlReader["login"]),
- Convert.ToString(sqlReader["password"]),
- Convert.ToString(sqlReader["phone"]),
- Convert.ToString(sqlReader["email"])
- );
- Account.SetAccepted(Convert.ToInt32(sqlReader["accepted"]));
- break;
- }
- if (loginSuccess)
- {
- // if account not accepted
- if ( Account.GetAccepted() == 0 )
- {
- label4.Visible = true;
- label4.Text = "Аккаунт не активований (зачекайте перевірки)";
- }
- else
- {
- Main MainForm = new Main();
- label4.Visible = false;
- //MessageBox.Show(Account.mail, Account.mail, MessageBoxButtons.OK, MessageBoxIcon.Error);
- // load main form
- MainForm.Show();
- MainForm.label_UpdateAccount();
- Hide();
- }
- }
- else
- {
- label4.Visible = true;
- label4.Text = "Пароль або логін невірний";
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- finally
- {
- if (sqlReader != null)
- sqlReader.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement