public void AgregarFacultad(Facultad paramfacultad) { FacultadDAL facultad = new FacultadDAL(); Facultad facu = new Facultad(); MateriaFacultadBLL matFacuBLL = new MateriaFacultadBLL(); facu = cargarCodigo(paramfacultad.codigo); if (facu != null) { throw new Exception("El codigo de facultad ya existe en la base de datos"); } else { int fecha = DateTime.Now.Year - paramfacultad.fechaCreacion.Year; if (fecha > 121) { throw new Exception("Fecha no permitida, introduce una fecha mayor a 1900"); } else if (fecha < 11) { throw new Exception("Fecha no permitida, introduce una fecha menor a 2010"); } else { using (TransactionScope ts = new TransactionScope()) { facultad.AgregarFacultad(paramfacultad); ts.Complete(); } } } }
public void AgregarFacultad(FACULTADD Facultad, List <MateriaFacultad> materiaFacultades) { FacultadDAL facultad = new FacultadDAL(); FACULTADD registro = new FACULTADD(); MateriaFacultadBLL materias = new MateriaFacultadBLL(); registro = facultad.buscarFacultad(Facultad.codigo); if (registro != null) { throw new Exception("Codigo de Facultad ya existe favor de ingresar uno diferente."); } else { int tiempo = Facultad.fechaCreacion.Year; if (tiempo <= 1900) { throw new Exception("Fecha no permitida, introduce una fecha mayor a 1900”."); } else { if (tiempo >= 2010) { throw new Exception("Fecha no permitida, introduce una fecha menor a 2010”."); } else { using (TransactionScope ts = new TransactionScope()) { facultad.AgregarFacultad(Facultad); foreach (MateriaFacultad materia in materiaFacultades) { materias.agregarMateriaFacultad(materia); } ts.Complete(); } } } } }
public void AgregarFacultad(Facultad oFacultad, List <MateriaFacultad> lst) { FacultadDAL facultad = new FacultadDAL(); Facultad facu = new Facultad(); MateriaFacultadBLL oMateria = new MateriaFacultadBLL(); if (facu == null) { throw new Exception("La Facultad ya existe en la base de datos"); } else { if (oFacultad.FechaCreacion.Year > 1900) { if (oFacultad.FechaCreacion.Year < 2010) { using (TransactionScope oScope = new TransactionScope()) { facultad.AgregarFacultad(oFacultad); foreach (MateriaFacultad materia in lst) { oMateria.AgregarMateriaFacultad(materia); } oScope.Complete(); } } else { throw new Exception("Fecha no permitida, introduce una fecha menor a 2010"); } } else { throw new Exception("Fecha no permitida, introduce una fecha mayor a 1900"); } } }