private void bntLogin_Click(object sender, EventArgs e) { try { if (txtLogin.Text == "") { throw new EmptyLoginException("Введіть логін!"); } if (txtPassword.Text == "") { throw new EmptyPasswordException("Введіть пароль!"); } AccountClient accountClient = new AccountClient(); User input = accountClient.Login(txtLogin.Text, txtPassword.Text); SqlConnection con = new SqlConnection(@"data source=WCFServise.mssql.somee.com;initial catalog=WCFServise;user id=OlegKret_SQLLogin_1;password=tqyupwho8j"); SqlDataAdapter sda = new SqlDataAdapter("Select Role FROM Users Where Login='******' and Password='******'", con); DataTable dt = new System.Data.DataTable(); sda.Fill(dt); if (dt.Rows.Count == 1) { this.Hide(); Parent ss = new Parent(dt.Rows[0][0].ToString()); ss.Show(); } if (input != null) { MessageBox.Show("Вхід успішний!"); } if (input == null) { MessageBox.Show("Ви НЕ ввійшли в особистий кабінет! \n Перевірте логін і пароль!"); } accountClient.Close(); } catch (EmptyLoginException emptyLoginException) { MessageBox.Show(emptyLoginException.Message); } catch (EmptyPasswordException emptyPasswordException) { MessageBox.Show(emptyPasswordException.Message); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void btnEnter_Click(object sender, EventArgs e) { try { if (txtLogin.Text == "") { throw new EmptyLoginException("Введіть логін!"); } if (txtPassword.Text == "") { throw new EmptyPasswordException("Введіть пароль!"); } BooksServise accountClient = new AccountClient(); User input = accountClient.Login(textBox6.Text, textBox7.Text); if (input != null) { MessageBox.Show("Вхід успішний!"); if (input.PhotoName != null) { Form2 form2 = new Form2(accountClient.GetImage(input.PhotoName)); form2.ShowDialog(); } else { Form2 form2 = new Form2(null); form2.ShowDialog(); } } if (input == null) { MessageBox.Show("Ви НЕ ввійшли в особистий кабінет! \n Перевірте логін і пароль!"); } accountClient.Close(); } catch (EmptyLoginException emptyLoginException) { MessageBox.Show(emptyLoginException.Message); } catch (EmptyPasswordException emptyPasswordException) { MessageBox.Show(emptyPasswordException.Message); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { using (var context = new BookLotEntities()) { try { int userId = Int32.Parse(txtId.Text); User userToUpdate = context.Users.Find(userId); if (userToUpdate != null) { AccountClient accountClient = new AccountClient(); string remoteUri = "ftp://olegkret.somee.com/www.OlegKret.somee.com/BOOOOK/App_Data/Users/Photo/" + txtPic.Text; WebClient webClient = new WebClient(); webClient.Credentials = new NetworkCredential("OlegKret", "26021982OlegKret"); MessageBox.Show("Downloading " + remoteUri); byte[] myDataBuffer = webClient.DownloadData(remoteUri); userToUpdate.Id = Int32.Parse(txtId.Text); userToUpdate.Login = txt_Login.Text; userToUpdate.Password = txt_Password.Text; userToUpdate.Email = txtEmail.Text; userToUpdate.PhoneNumber = txtPhoneNumber.Text; userToUpdate.role = txtRole.Text; userToUpdate.Pic = txtPic.Text; userToUpdate.Image = myDataBuffer; accountClient.Save(userToUpdate); //context.SaveChanges(); accountClient.Close(); } } catch (Exception ex) { MessageBox.Show("Empty format, try again"); } } }