protected void btnUpdate_Click(object sender, EventArgs e) { var user = (from us in dbUser.UserProfiles where us.UserId == Guid.Parse(lblUserId.Text) select us).FirstOrDefault(); user.FirstName = txtEditFirstName.Text; user.MiddleName = txtEditMiddleName.Text; user.LastName = txtEditLastName.Text; user.PositionId = Convert.ToInt32(ddlEditPosition.SelectedValue); //save to db dbUser.SubmitChanges(); //update roles Roles.RemoveUserFromRoles(lblUserName.Text, Roles.GetRolesForUser(lblUserName.Text)); Roles.AddUserToRole(lblUserName.Text, ddlRoles.SelectedItem.Text); //re-load gridview this.gvUsers.DataBind(); //audit trail DBLogger.Log("Update", "Updated User Details", user.User.UserName); //close modal Javascript.HideModal(this, this, "editRole"); }
protected void btnConfirmDelete_Click(object sender, EventArgs e) { Membership.DeleteUser(lblDeleteUsername.Text); this.gvUsers.DataBind(); //audit trail DBLogger.Log("Delete", "Delete User", lblDeleteUsername.Text); //hide modal Javascript.HideModal(this, this, "deleteUser"); }
protected void btnDelete_Click(object sender, EventArgs e) { var q = (from ir in dbIR.IRTransactions where ir.Id == Convert.ToInt32(hfDeleteId.Value) select ir).FirstOrDefault(); dbIR.IRTransactions.DeleteOnSubmit(q); dbIR.SubmitChanges(); this.gvIR.DataBind(); //audit trail DBLogger.Log("Delete", "Deleted IR", q.TicketNo); //hide modal Javascript.HideModal(this, this, "deleteModal"); }
protected void btnDelete_Click(object sender, EventArgs e) { int Id = Convert.ToInt32(hfDeleteId.Value); var pos = (from p in dbUser.Positions where p.Id == Id select p).FirstOrDefault(); dbUser.Positions.DeleteOnSubmit(pos); dbUser.SubmitChanges(); this.gvPositions.DataBind(); //audit trail DBLogger.Log("Delete", "Deleted Position ", pos.Name); //hide modal Javascript.HideModal(this, this, "deleteModal"); }
protected void btnSave_Click(object sender, EventArgs e) { Position pos = new Position(); pos.Name = txtAddPosition.Text; dbUser.Positions.InsertOnSubmit(pos); dbUser.SubmitChanges(); this.gvPositions.DataBind(); //audit trail DBLogger.Log("Create", "Created Position ", pos.Name); //hide modal Javascript.HideModal(this, this, "addModal"); }
protected void btnConfirmDelete_Click(object sender, EventArgs e) { int Id = Convert.ToInt32(hfDeleteGCId.Value); var gc = (from g in db.GCTransactions where g.Id == Id select g).FirstOrDefault(); db.GCTransactions.DeleteOnSubmit(gc); db.SubmitChanges(); this.gvGC.DataBind(); //audit trail DBLogger.Log("Delete", "Deleted for Approval GC", gc.GCNumber); Javascript.HideModal(this, this, "deleteModal"); }
protected void btnSave_Click(object sender, EventArgs e) { CrisisCode cc = new CrisisCode(); cc.Code = txtAddCrisisCode.Text; cc.Name = txtAddCrisisName.Text; db.CrisisCodes.InsertOnSubmit(cc); db.SubmitChanges(); this.gvCrisisCodes.DataBind(); //audit trail DBLogger.Log("Create", "Created Crisis Code", cc.Name); //hide modal Javascript.HideModal(this, this, "addModal"); }
protected void btnDelete_Click(object sender, EventArgs e) { int Id = Convert.ToInt32(hfDeleteId.Value); var q = (from cc in db.CrisisCodes where cc.Id == Id select cc).FirstOrDefault(); db.CrisisCodes.DeleteOnSubmit(q); db.SubmitChanges(); this.gvCrisisCodes.DataBind(); //audit trail DBLogger.Log("Delete", "Deleted Crisis Code", q.Name); //hide modal Javascript.HideModal(this, this, "deleteModal"); }
protected void btnUpdate_Click(object sender, EventArgs e) { int Id = Convert.ToInt32(hfEditId.Value); var q = (from cc in db.CrisisCodes where cc.Id == Id select cc).FirstOrDefault(); q.Code = txtEditCrisisCode.Text; q.Name = txtEditCrisisName.Text; db.SubmitChanges(); this.gvCrisisCodes.DataBind(); //audit trail DBLogger.Log("Update", "Updated Crisis Code", q.Name); //hide modal Javascript.HideModal(this, this, "updateModal"); }
protected void btnAddUser_Click(object sender, EventArgs e) { //chk if username already exist if (Membership.GetUser(txtCreateUsername.Text) != null) { lblErrorMsg.Text = "Username already exist."; } else { //register user Membership.CreateUser(txtCreateUsername.Text, txtCreateUsername.Text.Trim()); //add to user profile UserProfile user = new UserProfile(); user.UserId = Guid.Parse(Membership.GetUser(txtCreateUsername.Text).ProviderUserKey.ToString()); user.FirstName = txtCreateFirstName.Text; user.MiddleName = txtCreateMiddleName.Text; user.LastName = txtCreateLastName.Text; user.PositionId = Convert.ToInt32(ddlCreatePosition.SelectedValue); dbUser.UserProfiles.InsertOnSubmit(user); dbUser.SubmitChanges(); //assign role Roles.AddUserToRole(txtCreateUsername.Text, ddlCreateRoles.SelectedItem.Text); //re-load users this.gvUsers.DataBind(); //audit trail DBLogger.Log("Create", "Add User", user.User.UserName); //hide modal Javascript.HideModal(this, this, "createUser"); } }