Beispiel #1
0
        private void pbxBack_Click(object sender, EventArgs e)
        {
            UserProfileAllForm upfa = new UserProfileAllForm();

            upfa.Show();
            this.Close();
        }
Beispiel #2
0
        private void pbxSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(lblId.Text))
            {
                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));
                    if (name != "")
                    {
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Adicionado com sucesso!");
                        Log.SaveLog(sqlConnect, "Perfil adicionado", DateTime.Now, "Adição");
                    }
                    else
                    {
                        MessageBox.Show("Erro ao adicionar perfil, nome em branco!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro ao adicionar perfil!" + ex.Message);
                    ClearData();
                }
                finally
                {
                    ClearData();
                    sqlConnect.Close();
                }
            }
            else
            {
                SqlConnection sqlConnect = new SqlConnection(connectionString);

                try
                {
                    GetData();

                    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("@name", name));
                    cmd.Parameters.Add(new SqlParameter("@active", active));
                    cmd.Parameters.Add(new SqlParameter("@id", lblId.Text));

                    cmd.ExecuteNonQuery();

                    MessageBox.Show("Alterações salvas com sucesso!");
                    Log.SaveLog(sqlConnect, "Perfil Editado", DateTime.Now, "Edição");
                }
                catch (Exception Ex)
                {
                    MessageBox.Show("Erro ao editar este perfil" + "\n\n" + Ex.Message);
                    throw;
                }
                finally
                {
                    sqlConnect.Close();
                    UserProfileAllForm upf = new UserProfileAllForm();
                    upf.Show();
                    this.Close();
                }
            }
        }
Beispiel #3
0
        private void pbxUserProfile_Click(object sender, EventArgs e)
        {
            UserProfileAllForm upaf = new UserProfileAllForm();

            upaf.Show();
        }