private void Form_Login_Shown(object sender, EventArgs e) { try { txtUsername.Text = PrivateProfileStringHandler.ReadPrivateProfileString("USERNAME"); } catch { } //if (txtUsername.Text.Length == 0) txtUsername.Text = Environment.UserName; txtPassword.Focus(); lookUpConnections.Properties.DataSource = StaticData.ConnectionConfigurations; lookUpConnections.Properties.DisplayMember = "Name"; lookUpConnections.ItemIndex = 0; //TO DO Test only //txtUsername.Text = "Admin"; //txtPassword.Text = "000"; }
void Login() { try { if (txtUsername.Text == string.Empty) { XtraMessageBox.Show("İstifadəçi adı daxil edin"); return; } if (txtPassword.Text == string.Empty) { XtraMessageBox.Show("Şifrə daxil edin"); return; } object lookUpConnectionsCurrentRow = lookUpConnections.GetSelectedDataRow(); if (lookUpConnectionsCurrentRow == null) { return; } ConnectionConfiguration SelectedConfig = (lookUpConnectionsCurrentRow as ConnectionConfiguration); StaticData.CurrentConnectionConfiguration = SelectedConfig; Operation <UserView> operation = OperationHandler.LoginUser(new LoginData { Login = txtUsername.Text, PassHash = StaticData.Cryptor.Encrypt(txtPassword.Text) }); if (operation.Successful) { StaticData.CurrentUser = operation.Value; PrivateProfileStringHandler.SetPrivateProfileString("USERNAME", txtUsername.Text); Close(); } else { XtraMessageBox.Show(operation.Fail); } } catch (Exception ex) { XtraMessageBox.Show("Bağlantı alınmadı /n" + ex.Message); } }