internal static eResultado EliminarOpcionModuloPerfil(int idPerfil, int idOpcionModulo) { try { using (DataClassEpiNetDataContext db = new DataClassEpiNetDataContext()) { TBL_EPI_OPCIONMODULOPERFIL oOpcionModuloPerfil = (from x in db.TBL_EPI_OPCIONMODULOPERFIL where x.EPI_BIT_ACTIVO == true && x.EPI_INT_IDPERFIL == idPerfil && x.EPI_INT_IDOPCIONMODULO == idOpcionModulo select x).Take(1).FirstOrDefault(); if (oOpcionModuloPerfil != null) { oOpcionModuloPerfil.EPI_BIT_ACTIVO = false; db.SubmitChanges(); } } return(eResultado.Correcto); } catch (Exception ex) { XtraMessageBox.Show(ex.ToString(), "Mensaje Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(eResultado.Error); throw ex; } }
public static void AgregarOpcionModuloPerfilPadre(int IdModuloHijo, int IdPerfil) { try { using (DataClassEpiNetDataContext db = new DataClassEpiNetDataContext()) { TBL_EPI_MODULO oModulo = (from m in db.TBL_EPI_MODULO where m.EPI_INT_IDMODULO == IdModuloHijo && m.EPI_BIT_ACTIVO == true select m).SingleOrDefault(); if (oModulo != null) { TBL_EPI_OPCIONMODULO oOpcionModulo = (from om in db.TBL_EPI_OPCIONMODULO where om.EPI_INT_IDMODULO == oModulo.EPI_INT_MODULOPADRE && om.EPI_INT_IDOPCION == null && om.EPI_BIT_ACTIVO == true select om).Take(1).SingleOrDefault(); if (oOpcionModulo != null) { TBL_EPI_OPCIONMODULOPERFIL oOpcionModuloPerfil = (from omp in db.TBL_EPI_OPCIONMODULOPERFIL where omp.EPI_INT_IDOPCIONMODULO == oOpcionModulo.EPI_INT_IDOPCIONMODULO && omp.EPI_INT_IDPERFIL == IdPerfil select omp).Take(1).SingleOrDefault(); if (oOpcionModuloPerfil == null) { oOpcionModuloPerfil = new TBL_EPI_OPCIONMODULOPERFIL(); oOpcionModuloPerfil.EPI_BIT_ACTIVO = true; oOpcionModuloPerfil.EPI_INT_IDOPCIONMODULO = oOpcionModulo.EPI_INT_IDOPCIONMODULO; oOpcionModuloPerfil.EPI_INT_IDPERFIL = IdPerfil; db.TBL_EPI_OPCIONMODULOPERFIL.InsertOnSubmit(oOpcionModuloPerfil); db.SubmitChanges(); } else { oOpcionModuloPerfil.EPI_BIT_ACTIVO = true; db.SubmitChanges(); } } if (oModulo.EPI_INT_MODULOPADRE != 0) { AgregarOpcionModuloPerfilPadre(Convert.ToInt32(oModulo.EPI_INT_MODULOPADRE), IdPerfil); } } } } catch (Exception ex) { //MessageBox.Show(ex.ToString(), "Mensaje Error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw ex; } }
internal static eResultado AgregarOpcionModuloPerfil(int idPerfil, int idOpcionModulo) { try { using (DataClassEpiNetDataContext db = new DataClassEpiNetDataContext()) { TBL_EPI_OPCIONMODULOPERFIL oOpcionModuloPerfil = (from x in db.TBL_EPI_OPCIONMODULOPERFIL where x.EPI_INT_IDPERFIL == idPerfil && x.EPI_INT_IDOPCIONMODULO == idOpcionModulo select x).Take(1).FirstOrDefault(); if (oOpcionModuloPerfil == null) { oOpcionModuloPerfil = new TBL_EPI_OPCIONMODULOPERFIL(); oOpcionModuloPerfil.EPI_BIT_ACTIVO = true; oOpcionModuloPerfil.EPI_INT_IDPERFIL = idPerfil; oOpcionModuloPerfil.EPI_INT_IDOPCIONMODULO = idOpcionModulo; db.TBL_EPI_OPCIONMODULOPERFIL.InsertOnSubmit(oOpcionModuloPerfil); db.SubmitChanges(); } else { oOpcionModuloPerfil.EPI_BIT_ACTIVO = true; db.SubmitChanges(); } List <TBL_EPI_MODULO> olModulo = (from m in db.TBL_EPI_OPCIONMODULOPERFIL where m.EPI_BIT_ACTIVO == true && m.EPI_INT_IDPERFIL == idPerfil && m.TBL_EPI_OPCIONMODULO.EPI_BIT_ACTIVO == true && m.TBL_EPI_OPCIONMODULO.TBL_EPI_MODULO.EPI_BIT_ACTIVO == true select m.TBL_EPI_OPCIONMODULO.TBL_EPI_MODULO).Distinct().ToList(); if (olModulo.Count > 0) { foreach (TBL_EPI_MODULO item in olModulo) { AgregarOpcionModuloPerfilPadre(item.EPI_INT_IDMODULO, idPerfil); } } } return(eResultado.Correcto); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Mensaje Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(eResultado.Error); throw ex; } }