private void pbxBack_Click(object sender, EventArgs e) { HomeForm hm = new HomeForm(aux); hm.Show(); this.Close(); }
private void lblSignIn_Click(object sender, EventArgs e) { GetData(); if (CheckLogin(password, name)) { HomeForm hf = new HomeForm(userAux); hf.Show(); this.Hide(); } else { CleanData(); MessageBox.Show("Usuário ou senha incorretos!"); } }
private void btnLogin_Click(object sender, EventArgs e) { GetData(); if (CheckLogin(password, name)) { HomeForm mainForm = new HomeForm(aux); mainForm.Show(); this.Hide(); } else { CleanData(); MessageBox.Show("Usuário ou senha incorretos!"); } }
private void pbxSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(lblID.Text)) { //Salvar SqlConnection sqlConnect = new SqlConnection(connectionString); try { GetData(); sqlConnect.Open(); string sql = "INSERT INTO USER_PROFILE(NAME, ACTIVE) VALUES (@name, @active)"; SqlCommand cmd = new SqlCommand(sql, sqlConnect); cmd.Parameters.Add(new SqlParameter("@name", name)); cmd.Parameters.Add(new SqlParameter("@active", active)); cmd.ExecuteNonQuery(); MessageBox.Show("Adicionado com sucesso!"); Log.SalvarLog("perfil de usuário ativado", "inclusão", DateTime.Now); CleanData(); } catch (Exception ex) { MessageBox.Show("Erro ao adicionar perfil de usuário!" + ex.Message); CleanData(); } finally { sqlConnect.Close(); } } else { SqlConnection sqlConnect = new SqlConnection(connectionString); try { sqlConnect.Open(); string sql = "UPDATE USER_PROFILE SET NAME = @name, ACTIVE = @active Where ID = @id"; SqlCommand cmd = new SqlCommand(sql, sqlConnect); cmd.Parameters.Add(new SqlParameter("@id", this.lblID.Text)); cmd.Parameters.Add(new SqlParameter("@name", this.tbxName.Text)); cmd.Parameters.Add(new SqlParameter("@active", this.cbxActive.Checked)); cmd.ExecuteNonQuery(); MessageBox.Show("Alterações salvas com sucesso!"); Log.SalvarLog("perfil de usuário editado", "edição", DateTime.Now); CleanData(); } catch (Exception Ex) { MessageBox.Show("Erro ao editar este perfil!" + "\n\n" + Ex.Message); throw; } finally { sqlConnect.Close(); HomeForm homeForm = new HomeForm(); homeForm.Show(); this.Hide(); } } }