/// <summary> /// Decripta o registo que veio do banco de acordo com o nome do campo /// </summary> /// <param name="Ds">Data set com os registros</param> /// <param name="FieldName"></param> private void DecryptDataSetField(ref DataSet Ds, string FieldName) { foreach (DataRow Dr in Ds.Tables[0].Rows) { Dr[FieldName] = Crypt.Decripta(Dr[FieldName].ToString()); } }
/// <summary> /// Enche a lista de usuarios de acordo com o grupo escolhido /// </summary> private void FillUserListBox() { ListBox6.Items.Clear(); DataTable dt = vgMembership.GetAllUsersByGroup(ListBox5.SelectedItem.Value); foreach (DataRow dr in dt.Rows) { ListItem li = new ListItem(Crypt.Decripta(dr[GMembershipProvider.Default.UserLoginField].ToString()), dr[GMembershipProvider.Default.UserLoginField].ToString()); li.Value = dr["LOGIN_USER_LOGIN"].ToString(); ListBox6.Items.Add(li); } }
/// <summary> /// ao mudar de grupo selecionado ele coloca as permissões e arruma a toolbar de acordo com o grupo escolhido /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ChangedGroup() { try { if (CurrentGroup != null && (bool)CurrentGroup.Fields["IsAdmin"].Value) { LoginGroupItem item = vgMembership.GetGroupByID(ListBox3.SelectedItem.Value); if ((bool)item.Fields["IsAdmin"].Value) { ListBox4.Enabled = false; CheckBox5.Enabled = false; CheckBox3.Enabled = false; CheckBox4.Enabled = false; CheckBox2.Enabled = false; CheckBox5.Checked = false; CheckBox3.Checked = false; CheckBox4.Checked = false; CheckBox2.Checked = false; EnableGroupButtons(false, false, false, true); CheckBox1.Checked = true; TextBox6.Text = Crypt.Decripta(item.Fields["Name"].GetFormattedValue()); TextBox6.Focus(); } else { ListBox4.Enabled = true; CheckBox5.Enabled = false; CheckBox3.Enabled = false; CheckBox4.Enabled = false; CheckBox2.Enabled = false; EnableGroupButtons(true, true, true, true); TextBox6.Text = Crypt.Decripta(item.Fields["Name"].GetFormattedValue()); CheckBox1.Checked = (bool)item.Fields["IsAdmin"].Value; TextBox6.Focus(); ChangedPagesPermission(); } } } catch { } }
/// <summary> /// Metodo que mostra o registro do usuario selecionado /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ChangedUser() { if (ListBox6.SelectedItem != null) { LoginUserItem vgUser = vgMembership.GetUser(Crypt.Encripta(ListBox6.SelectedItem.Text)); TextBox7.Text = Crypt.Decripta(vgUser.Fields["Login"].GetFormattedValue()); TextBox11.Text = Crypt.Decripta(vgUser.Fields["Name"].GetFormattedValue()); TextBox10.Text = Crypt.Decripta(vgUser.Fields["Obs"].GetFormattedValue()); TextBox9.Enabled = true; TextBox9.Text = ""; TextBox10.Enabled = true; TextBox8.Text = ""; TextBox7.Enabled = true; TextBox8.Enabled = true; ViewState["IncluiUsuario"] = false; EnableUserButtons(true, true, true, true); } }
/// <summary> /// Enche a list de grupos com os grupos que estao no banco /// </summary> private void FillGroupsListBox(bool JustUser) { if (!JustUser) { ListBox3.Items.Clear(); } ListBox5.Items.Clear(); DataTable dt = vgMembership.GetAllGroups(); foreach (DataRow dr in dt.Rows) { ListItem li = new ListItem(Crypt.Decripta(dr[GMembershipProvider.Default.GroupNameField].ToString()), dr[GMembershipProvider.Default.GroupIdField].ToString()); if (!JustUser) { ListBox3.Items.Add(li); } ListBox5.Items.Add(li); } }
/// <summary> /// Troca a senha do usuário que está logado /// </summary> public void ChangeUserPassword() { if (vgMembership.ValidateUser(Crypt.Decripta(HttpContext.Current.Session["vgUserLogin"].ToString()), txtActualPassword.Text.ToUpper()) == true) { if (txtNewPassword.Text != "") { if (txtNewPasswordConfirm.Text != "") { if (txtNewPassword.Text.ToUpper() == txtNewPasswordConfirm.Text.ToUpper()) { vgMembership.ChangePassword(Crypt.Decripta(HttpContext.Current.Session["vgUserLogin"].ToString()), "", txtNewPassword.Text.ToUpper()); OpenAlert("Salvo com sucesso!"); } else { ErrorList.Add("ConfirmTrcaSenhaErrada", "Confirmação de senha invalida!"); } } else { ErrorList.Add("SenhaAtualErrada", "Confirmação de senha tem que ser preenchida!"); } } else { ErrorList.Add("SenhaAtualErrada", "Senha nova tem que ser preenchida!"); } } else { if (txtActualPassword.Text != "") { ErrorList.Add("SenhaAtualErrada", "Senha atual errada!"); } else { ErrorList.Add("SenhaAtualErrada", "Senha atual tem que ser preenchida!"); } } ShowError(); }
private void CancelUserChanges() { try { if (CurrentGroup != null && (bool)CurrentGroup.Fields["IsAdmin"].Value) { if (ViewState["IncluiUsuario"] != null && (bool)ViewState["IncluiUsuario"] == true) { TextBox7.Text = ""; TextBox11.Text = ""; TextBox9.Text = ""; TextBox8.Text = ""; TextBox10.Text = ""; ViewState["IncluiUsuario"] = false; } else if (ListBox6.SelectedIndex != -1 && ListBox6.SelectedValue != null) { LoginUserItem vgUser = vgMembership.GetUser(Crypt.Encripta(ListBox6.SelectedItem.Text)); TextBox7.Text = Crypt.Decripta(vgUser.Fields["Login"].GetFormattedValue()); TextBox11.Text = Crypt.Decripta(vgUser.Fields["Name"].GetFormattedValue()); TextBox10.Text = Crypt.Decripta(vgUser.Fields["Obs"].GetFormattedValue()); } EnableUserButtons(true, true, true, true); ListBox6.Enabled = true; ListBox5.Enabled = true; TextBox9.Enabled = true; TextBox7.Enabled = true; TextBox8.Enabled = true; TextBox10.Enabled = true; } } catch { } }