protected void btnAddPeopleRoleCatalog_Click(object sender, EventArgs e) { PersonBiz pBiz = new PersonBiz(); lwg_PersonInRole lg = new lwg_PersonInRole(); CatalogBiz cBiz = new CatalogBiz(); if (cBiz.GetByID(ProductId) != null) { if (ddlPeople.Items.Count > 0) { lg.CatalogId = ProductId; lg.PersonId = int.Parse(ddlPeople.SelectedValue); lg.RoleId = int.Parse(ddlRole.SelectedValue); if (pBiz.SavePersonInRole(lg)) { BindingCatalogRole(); } } ltrMessageNote.Visible = false; } else { ltrMessageNote.Visible = true; } }
public bool DeletePersonInRole(int id) { if (id > 0) { lwg_PersonInRole lg = dbContext.lwg_PersonInRole.SingleOrDefault(lw => lw.Id == id); if (lg != null) { dbContext.lwg_PersonInRole.Remove(lg); dbContext.SaveChanges(); return(true); } } return(false); }
public bool SavePersonInRole(lwg_PersonInRole p) { if (p != null && !dbContext.lwg_PersonInRole.Any(lw => lw.RoleId == p.RoleId && lw.PersonId == p.PersonId && lw.CatalogId == p.CatalogId)) { if (dbContext.lwg_PersonInRole.Count() > 0) { p.Id = dbContext.lwg_PersonInRole.OrderByDescending(lw => lw.Id).First().Id + 1; } else { p.Id = 1; } dbContext.lwg_PersonInRole.Add(p); dbContext.SaveChanges(); return(true); } return(false); }
protected void gvComposers_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.DataItem == null) { return; } lwg_PersonInRole lg = (lwg_PersonInRole)e.Row.DataItem; if (lg != null) { Literal ltrNamePeople = (Literal)e.Row.FindControl("ltrNamePeople"); ltrNamePeople.Text = lg.lwg_Person.NameDisplay; Literal ltrNameRole = (Literal)e.Row.FindControl("ltrNameRole"); ltrNameRole.Text = lg.lwg_Role.Name; LinkButton lnkbtnRemove = (LinkButton)e.Row.FindControl("lnkbtnRemove"); lnkbtnRemove.CommandArgument = lg.Id.ToString(); } }