public int InserirUsuarioSistema(AdministracaoPlayersVip administracaoPlayersVip) { try { using (var con = new SQLiteConnection(_conStringDB)) { using (var cmd = new SQLiteCommand(con)) { cmd.CommandText = "INSERT INTO TB_COESERVER_ADMIN(LEVEL_ADMIN_ID, ADMIN_NOME, ADMIN_LOGIN, ADMIN_PASSWORD, ADMIN_DATA_CADASTRO) " + "VALUES(@LEVEL_ADMIN_ID, @ADMIN_NOME, @ADMIN_LOGIN, @ADMIN_PASSWORD, @ADMIN_DATA_CADASTRO)"; cmd.Parameters.AddWithValue("LEVEL_ADMIN_ID", administracaoPlayersVip.LvlAdminID); cmd.Parameters.AddWithValue("ADMIN_NOME", administracaoPlayersVip.AdminNome); cmd.Parameters.AddWithValue("ADMIN_LOGIN", administracaoPlayersVip.AdminLogin); cmd.Parameters.AddWithValue("ADMIN_PASSWORD", administracaoPlayersVip.AdminPassword); cmd.Parameters.AddWithValue("ADMIN_DATA_CADASTRO", administracaoPlayersVip.AdminDataCadastro); cmd.CommandType = System.Data.CommandType.Text; if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } return(cmd.ExecuteNonQuery()); } } } catch (Exception ex) { throw new Exception("Erro ao inserir o Usuário de Sistema na base de dados: " + ex.Message); } }
private void btnLogin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtLogin.Text) || string.IsNullOrEmpty(txtSenha.Text)) { MessageBox.Show("Os campos de login e senha não deverão estar vazios", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string _msgErro = "Login e/ou senha inválido(s)"; BusinessOperations businessOperations = new BusinessOperations(); AdministracaoPlayersVip administracaoPlayersVip = businessOperations.BusinessAdministracaoPlayersVip(new AdministracaoPlayersVip { AdminLogin = txtLogin.Text, AdminPassword = txtSenha.Text }); if (administracaoPlayersVip == null) { MessageBox.Show(_msgErro, "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); lblMsgSistema.ForeColor = Color.Red; lblMsgSistema.Visible = true; lblMsgSistema.Text = _msgErro + ". Tente novamente!"; return; } else { FrmMain frmMain = new FrmMain(administracaoPlayersVip); Hide(); frmMain.Show(); } }
public bool BusinessInserirUsuarioSistema(AdministracaoPlayersVip administracaoPlayersVip) { _operationsDataBase = new OperationsDataBase(); administracaoPlayersVip.AdminPassword = MD5Hash(administracaoPlayersVip.AdminPassword); return(_operationsDataBase.InserirUsuarioSistema(administracaoPlayersVip) > 0 ? true : false); }
public AdministracaoPlayersVip BusinessAdministracaoPlayersVip(AdministracaoPlayersVip administracaoPlayersVip) { _operationsDataBase = new OperationsDataBase(); administracaoPlayersVip.AdminPassword = MD5Hash(administracaoPlayersVip.AdminPassword); return(_operationsDataBase.LoginAdministracao(administracaoPlayersVip)); }
// ACESSOS ADMINISTRAÇÃO SISTEMA public AdministracaoPlayersVip LoginAdministracao(AdministracaoPlayersVip administracaoPlayersVip) { try { using (var con = new SQLiteConnection(_conStringDB)) { using (var cmd = new SQLiteCommand(con)) { cmd.CommandText = "SELECT ADM.ADMIN_ID, ADM.LEVEL_ADMIN_ID, ADM.ADMIN_NOME, ADM.ADMIN_LOGIN, LVL_ADM.LEVEL_ADMIN_ID, LVL_ADM.LEVEL_ADMIN_DESCRICAO " + "FROM TB_COESERVER_ADMIN AS ADM " + "INNER JOIN TB_LEVEL_ADMIN AS LVL_ADM ON ADM.LEVEL_ADMIN_ID = LVL_ADM.LEVEL_ADMIN_ID " + "WHERE ADM.ADMIN_LOGIN = @ADMIN_LOGIN AND ADM.ADMIN_PASSWORD = @ADMIN_PASSWORD;"; cmd.Parameters.AddWithValue("ADMIN_LOGIN", administracaoPlayersVip.AdminLogin); cmd.Parameters.AddWithValue("ADMIN_PASSWORD", administracaoPlayersVip.AdminPassword); cmd.CommandType = System.Data.CommandType.Text; if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { return(AdministracaoPlayersVipTranslate.MapFromReader(reader)); } else { return(null); } } } } catch (Exception ex) { throw new Exception("Erro ao consultar usuário de administracão de Players VIP na base de dados: " + ex.Message); } }
public static AdministracaoPlayersVip MapFromReader(IDataReader reader) { AdministracaoPlayersVip administracaoPlayersVip = new AdministracaoPlayersVip(); while (reader.Read()) { administracaoPlayersVip = new AdministracaoPlayersVip { AdminID = Convert.ToInt32(reader["ADMIN_ID"]), LvlAdminID = Convert.ToInt32(reader["LEVEL_ADMIN_ID"]), AdminNome = reader["ADMIN_NOME"].ToString(), AdminLogin = reader["ADMIN_LOGIN"].ToString(), LevelAdministracaoPlayersVip = new LevelAdministracaoPlayersVip { LevelAdministracaoPlayersVipID = Convert.ToInt32(reader["LEVEL_ADMIN_ID"]), LevelAdministracaoPlayersVipDescricao = reader["LEVEL_ADMIN_DESCRICAO"].ToString() } }; } return(administracaoPlayersVip); }
// FORMULÁRIO public FrmMain(AdministracaoPlayersVip administracaoPlayersVip) { InitializeComponent(); // Seta neste tipo os dados do usuário logado _administracaoPlayersVip = administracaoPlayersVip; lblUsuarioLogado.Text = string.Format("({0}) {1}", administracaoPlayersVip.LevelAdministracaoPlayersVip.LevelAdministracaoPlayersVipDescricao, administracaoPlayersVip.AdminNome); // esconde os botões de cancelar e gravar novo Player vip btnCancelarGravarNovoPlayerVip.Visible = false; btnSalvarNovoPlayerVip.Visible = false; ResetarControlesDoFormulario(); // Desabilita as ações de usuários diferente de Administrador (ID 1) if (_administracaoPlayersVip.LevelAdministracaoPlayersVip.LevelAdministracaoPlayersVipID != 1) { foreach (TabPage item in tabMain.TabPages) { if (item.Name == "tabCadastroUsuarioSistema") { item.Controls.Clear(); item.Controls.Add(lblAvisoNaoAdministrador); lblAvisoNaoAdministrador.Visible = true; } } grpAdminAcoes.Controls.Clear(); grpAdminAcoes.Controls.Add(lblAvisoNaoAdministradorAcoesPlayersVip); lblAvisoNaoAdministradorAcoesPlayersVip.Visible = true; } // Habilita os radiobuttons da tab "Consulta de Players Vip" rdbBuscaPlayerVipAtivoSim.Checked = true; rdbBuscaPlayerVipEhAdminNao.Checked = true; }