示例#1
0
        private void pbxBack_Click(object sender, EventArgs e)
        {
            UserProfileAllForm UserprofForm = new UserProfileAllForm();

            UserprofForm.Show();
            this.Hide();
        }
示例#2
0
        private void pbxUserProfile_Click(object sender, EventArgs e)
        {
            UserProfileAllForm userProfileAllForm = new UserProfileAllForm();

            userProfileAllForm.Show();
        }
示例#3
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));

                    cmd.ExecuteNonQuery();

                    MessageBox.Show("Adicionado com sucesso!");
                    CleanData();

                    Log.SaveLog("Perfil Adicionado", "Adição", DateTime.Now);

                    UserProfileAllForm userProfileAll = new UserProfileAllForm();
                    userProfileAll.Show();
                    this.Hide();
                }
                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();
                    Log.SaveLog("Perfil Editado", "Edição", DateTime.Now);
                    MessageBox.Show("Altereções salvas com sucesso!");

                    UserProfileAllForm userProfileAll = new UserProfileAllForm();
                    userProfileAll.Show();
                    this.Hide();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show("Erro ao editar este Perfil de Usuario !" + "\n\n" + Ex.Message);
                    throw;
                }
                finally
                {
                    sqlConnect.Close();
                }
            }
        }