private void Bind() { DataAccess.Security.DAccountProfile daProfile = new DataAccess.Security.DAccountProfile(); DataAccess.Security.DAccounts daAccount = new DataAccess.Security.DAccounts(); var acct = daAccount.Get(Id); DataAccess.AccountProfile profileEntity = daProfile.GetAccoutProfileById(acct.ProfileId); txtTitle.Text = profileEntity.Title; txtFname.Text = profileEntity.FirstName; txtLname.Text = profileEntity.LastName; txtJobTitle.Text = profileEntity.JobTitle; ddlSex.SelectedValue = profileEntity.IsMale.ToString().ToLower(); lblUserName.Text = acct.UserName; lblEmail.Text = acct.Email; var roles = daAccount.GetRoles(Id); foreach (ListItem item in chkRoles.Items) { item.Selected = roles.Select(x => x.Code).ToList().Contains(item.Value); } }
void wzdAccount_FinishButtonClick(object sender, WizardNavigationEventArgs e) { DataAccess.Security.DAccountProfile daProfile = new DataAccess.Security.DAccountProfile(); DataAccess.Security.DAccounts daAccount = new DataAccess.Security.DAccounts(); DataAccess.AccountProfile profileEntity = new DataAccess.AccountProfile(); //Profile profileEntity.Id = Guid.NewGuid(); profileEntity.FirstName = txtFname.Text; profileEntity.LastName = txtLname.Text; profileEntity.FirstName = string.Format("{0} {1}", txtFname.Text, txtLname.Text); profileEntity.Title = txtTitle.Text; profileEntity.JobTitle = txtJobTitle.Text; profileEntity.IsMale = bool.Parse(ddlSex.SelectedValue); profileEntity.IsDeleted = false; //Account if (txtPassword.Text != txtConfirmPassword.Text) { return; } DataAccess.Account acctEntity = new DataAccess.Account(); acctEntity.Id = Guid.NewGuid(); acctEntity.UserName = txtUserName.Text; acctEntity.Email = txtEmail.Text; acctEntity.Password = txtConfirmPassword.Text; acctEntity.IsDeleted = false; acctEntity.ChangePasswordOnFirstLogon = true; acctEntity.CreatedDate = DateTime.Now; //Roles List<string> roleCode = new List<string>(); roleCode = chkRoles.Items.Cast<ListItem>().Where(x => x.Selected).Select(x => x.Value).ToList(); try { daProfile.CreateAccountProfile(profileEntity); acctEntity.ProfileId = profileEntity.Id; daAccount.CreateAccount(acctEntity); daAccount.AddRoles(acctEntity.Id, roleCode); SetMessage(MessageType.Succes, "Saving Successfull",true); } catch (System.Transactions.TransactionAbortedException ex) { SetMessage(MessageType.Error, ex.Message,true); } catch (Exception ex) { SetMessage(MessageType.Error, ex.Message, true); } RedirectToReferrerUrl(); //daProfile.DeleteAccountProfile(profId.Value, false); //throw (ex); }
void Bind() { DataAccess.Security.DAccounts daAccount = new DataAccess.Security.DAccounts(); chkOperation.ClearSelection(); var userOpertion = daAccount.GetPrivileges(ddlRole.SelectedValue); foreach (ListItem item in chkOperation.Items) { item.Selected = userOpertion.Select(x => x.Code).ToList().Contains(item.Value); } }
void btn_Logon_Click(object sender, EventArgs e) { var security = new DataAccess.Security.DAccounts(); if(security.ValidateAccount(UserName.Text,Password.Text)) { FormsAuthentication.RedirectFromLoginPage (UserName.Text, RememberMe.Checked); } else { FailureText.Text = "Invalid credentials. Please try again."; } }
void btnSave_Click(object sender, EventArgs e) { DataAccess.Security.DAccountProfile daProfile = new DataAccess.Security.DAccountProfile(); DataAccess.Security.DAccounts daAccount = new DataAccess.Security.DAccounts(); var acct = daAccount.Get(Id); DataAccess.AccountProfile profileEntity = daProfile.GetAccoutProfileById(acct.ProfileId); //Profile profileEntity.Id = Guid.NewGuid(); profileEntity.FirstName = txtFname.Text; profileEntity.LastName = txtLname.Text; profileEntity.FullName = string.Format("{0} {1}", txtFname.Text, txtLname.Text); profileEntity.Title = txtTitle.Text; profileEntity.JobTitle = txtJobTitle.Text; profileEntity.IsMale = bool.Parse(ddlSex.SelectedValue); profileEntity.IsDeleted = false; //Roles List<string> roleCodes = new List<string>(); roleCodes = chkRoles.Items.Cast<ListItem>().Where(x => x.Selected).Select(x => x.Value).ToList(); try { daProfile.UpdateAccountProfile(profileEntity); daAccount.AddRoles(Id, roleCodes); SetMessage(MessageType.Succes, "Saving Successfull", true); } catch (System.Transactions.TransactionAbortedException ex) { SetMessage(MessageType.Error, ex.Message); } catch (Exception ex) { SetMessage(MessageType.Error, ex.Message); } RedirectToReferrerUrl(); //daProfile.DeleteAccountProfile(profId.Value, false); //throw (ex); }
void btnSave_Click(object sender, EventArgs e) { try { DataAccess.Security.DAccounts daAccount = new DataAccess.Security.DAccounts(); daAccount.DeletePrivileges(ddlRole.SelectedValue); foreach (ListItem item in chkOperation.Items) { if (item.Selected) daAccount.AddPrivilege(item.Value, ddlRole.SelectedValue); } SetMessage(MessageType.Succes, "Saving Success"); } catch(Exception ex) { SetMessage(MessageType.Error, string.Format("Saving Faile: {0}",ex.Message)); } }
void grdAccounts_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Edit") { int rowindex = Convert.ToInt32(e.CommandArgument); string id = grdAccounts.DataKeys[rowindex].Value.ToString(); Response.Redirect("~/Pages/Administration/AccountManagement/update.aspx?id=" + id); } else if (e.CommandName == "Delete") { int rowindex = Convert.ToInt32(e.CommandArgument); Guid id = new Guid( grdAccounts.DataKeys[rowindex].Value.ToString()); DataAccess.Security.DAccounts daAccount = new DataAccess.Security.DAccounts(); daAccount.DeleteAccount(id); var acct = daAccount.Get(id); SetMessage(MessageType.Succes, string.Format("<b>{0}</b> was deleted successfully", acct.UserName)); BindGrid(); } }
void BindGrid() { DataAccess.Security.DAccounts daAccount = new DataAccess.Security.DAccounts(); grdAccounts.DataSource = daAccount.List(); grdAccounts.DataBind(); }