示例#1
0
 private void btnEntregar_Click(object sender, EventArgs e)
 {
     if (Comprobar())
     {
         Empresa   E = new Empresa();
         Residente R = new Residente();
         Proyecto  P = new Proyecto();
         E = empresa();
         R = Residente();
         P = Proyecto();
         if (E != null && R != null && P != null)
         {
             try
             {
                 int EE = new EmpresaDAO().Agregar(E);
                 int PP = new ProyectoDAO().Agregar(P);
                 int RR = new ResidenteDAO().Agregar(R);
                 if (EE + RR + PP == 3)
                 {
                     MessageBox.Show("Datos guardados satisfactoriamente\n" +
                                     "entra como residente para que bajes tu carta para que se la entregues a tu cordinador", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     x.Visible = true;
                     this.Dispose();
                 }
                 else
                 {
                     MessageBox.Show("Error al guardar los datos del residente,empresa y proyeto");
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
 }
示例#2
0
        // Lógica de negocio
        #region "Residente"
        public Residente RegistrarResidente(Residente residente)
        {
            // Validación de DNI obligatorio
            if (null == residente.DNI || String.Empty.Equals(residente.DNI))
            {
                throw new Exception("No se puede registrar un Residente sin DNI");
            }

            // Validación de longitud de DNI = 8
            if (residente.DNI.Length != 8)
            {
                throw new Exception("El DNI debe tener 8 posiciones");
            }

            // Validación de existencia de un residente con el mismo DNI
            if (ResidenteDAO.Obtener(residente.DNI) != null)
            {
                throw new Exception("Ya existe un Residente con el DNI indicado");
            }

            // Validación de existencia de un residente con el mismo Correo
            if (ResidenteDAO.BuscarCorreo(residente.Correo).Count > 0)
            {
                throw new Exception("Ya existe un Residente con el Correo indicado");
            }

            if (null == residente.Tipo || String.Empty.Equals(residente.Tipo))
            {
                throw new Exception("No se puede registrar un residente sin el Tipo");
            }

            // Validación de edad aceptable
            if (residente.Edad < 18)
            {
                throw new Exception("Para poder registrarse debe ser mayor de edad");
            }

            Residente residenteACrear = new Residente();

            residenteACrear.DNI             = residente.DNI;
            residenteACrear.Nombres         = residente.Nombres;
            residenteACrear.ApellidoPaterno = residente.ApellidoPaterno;
            residenteACrear.ApellidoMaterno = residente.ApellidoMaterno;
            residenteACrear.Edad            = residente.Edad;
            residenteACrear.Correo          = residente.Correo;
            residenteACrear.Clave           = residente.Clave;
            residenteACrear.Tipo            = residente.Tipo;

            return(ResidenteDAO.Crear(residenteACrear));
        }
示例#3
0
        public void InicializarPruebas()
        {
            //"assembly://assembly/namespace/capaPersistencia.xml",
            Spring = new XmlApplicationContext(
                "assembly://Condominios/Condominios/capaPersistencia.xml",
                "assembly://Condominios/Condominios/capaNegocio.xml"
                );

            //Preparar datos para las pruebas de Residente
            Residente residente = new Residente();

            ResidenteDAO residenteDAO = (ResidenteDAO)Spring.GetObject("residenteDAO");

            residente.DNI = "40717629";
            residenteDAO.Eliminar(residente);
        }
        public void TestCrear()
        {
            ResidenteDAO objresidentedao = new ResidenteDAO();

             Residente objresidente = new Residente();
            objresidente.C_Nombre ="MARITZA ESPERANZA";
            objresidente.C_Apellidos = "GUERRA RIVERA";
            objresidente.N_TipoDoc = 1;
            objresidente.C_NumDocume = "12343213";
            objresidente.D_FecNacimi = Convert.ToDateTime("1986-10-21");
            objresidente.C_Correo = "*****@*****.**";
            objresidente.C_Clave = "SUPERMAN";
            objresidente.B_Estado = true;
            Int32 id = objresidentedao.CreaResidente(objresidente);

            Assert.AreNotEqual(id, 0);
        }
        public void Test01Crear()
        {
            DResidente   residente    = new DResidente();
            ResidenteDAO residenteDAO = new ResidenteDAO();

            residente = residenteDAO.Obtener("40717626");

            DVivienda r = viviendaDAO.Crear(new DVivienda()
            {
                NumVivienda = 1,
                Ubicacion   = "San Borja",
                Numero      = 459,
                Metraje     = 200,
                Tipo        = "C",
                Residente   = residente
            });

            Assert.AreEqual(r.NumVivienda, 1);
        }
示例#6
0
        public void cargar()
        {
            TutorDAO         TD = new TutorDAO();
            Tutor            T  = new Tutor();
            ResidenteDAO     RD = new ResidenteDAO();
            Residente        R  = new Residente();
            List <Tutor>     LT = new List <Tutor>();
            List <Residente> LR = new List <Residente>();

            LT = TD.traerTodos();
            LR = RD.lista();
            for (int i = 0; i < LT.Count; i++)
            {
                CbxAsesores.Items.Add(LT[i].NombreCompleto);
            }
            for (int i = 0; i < LR.Count; i++)
            {
                CbxAlumno.Items.Add(LR[i].NombreCompleto);
            }
        }
示例#7
0
        public FrmResidente(Form c, String id)
        {
            InitializeComponent();
            x = c;
            String d = new ResidenteDAO().Estatus(id);

            if (d.Equals(""))
            {
                LblEstatus.Text = "Estatus: pendiente";
                BtnEntregaDocumentos.Visible = false;
            }
            else if (d.Equals("Estatus: aceptado"))
            {
                LblEstatus.Text = "Aceptado";
                BtnHoja.Visible = false;
            }
            else if (d.Equals("Rechazado"))
            {
                LblEstatus.Text = "Estatus: rechazado";
                BtnEntregaDocumentos.Visible = false;
                BtnHoja.Visible = false;
            }
        }
示例#8
0
        public Vivienda RegistrarVivienda(Vivienda vivienda)
        {
            // Validación de existencia de una vivienda
            if (ViviendaDAO.Obtener(vivienda.NumVivienda) != null)
            {
                throw new Exception("Ya existe la Vivienda");
            }

            // Validación de existencia del residente
            Residente residente = ResidenteDAO.Obtener(vivienda.Residente.DNI);

            if (residente == null)
            {
                throw new Exception("Residente inexistente");
            }

            if (null == vivienda.Tipo || String.Empty.Equals(vivienda.Tipo))
            {
                throw new Exception("No se puede registrar un residente sin el Tipo");
            }

            if (ViviendaDAO.obtenerViviendaPorResidente(residente.DNI).Count > 0)
            {
                throw new Exception("El residente ingresado ya tiene vivienda registrada");
            }

            Vivienda viviendaACrear = new Vivienda();

            viviendaACrear.NumVivienda = vivienda.NumVivienda;
            viviendaACrear.Ubicacion   = vivienda.Ubicacion;
            viviendaACrear.Numero      = vivienda.Numero;
            viviendaACrear.Metraje     = vivienda.Metraje;
            viviendaACrear.Tipo        = vivienda.Tipo;
            viviendaACrear.Residente   = vivienda.Residente;

            return(ViviendaDAO.Crear(viviendaACrear));
        }
示例#9
0
 public ICollection <Residente> ListarTodosLosAlumnos()
 {
     // Aquí deben ir las validaciones, reglas de negocio, algoritmos, etc.
     return(ResidenteDAO.ListarTodosLosResidentes());
 }
示例#10
0
 public void EliminarResidente(Residente residente)
 {
     // Aquí deben ir las validaciones, reglas de negocio, algoritmos, etc.
     ResidenteDAO.Eliminar(residente);
 }
示例#11
0
 public Residente ModificarResidente(Residente residente)
 {
     // Aquí deben ir las validaciones, reglas de negocio, algoritmos, etc.
     return(ResidenteDAO.Modificar(residente));
 }
示例#12
0
 public Residente ObtenerResidente(String codigo)
 {
     // Aquí deben ir las validaciones, reglas de negocio, algoritmos, etc.
     return(ResidenteDAO.Obtener(codigo));
 }
示例#13
0
 private void BtnAceptar_Click(object sender, EventArgs e)
 {
     if (Comprobar())
     {
         if (CbxTipo.Text.Equals("Residente"))
         {
             Residente    ObjR  = new Residente();
             ResidenteDAO objRD = new ResidenteDAO();
             ObjR = objRD.Buscar(TxtUsuario.Text);
             if (ObjR == null)
             {
                 MessageBox.Show("El usuario no existe", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 if (TxtContrasenia.Text.Equals(ObjR.contrasenia))
                 {
                     String id = TxtUsuario.Text;
                     limpiar();
                     this.Visible = false;
                     new FrmResidente(this, id).Show();
                 }
                 else
                 {
                     MessageBox.Show("El usuario o contraseñia incorrectos", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         else if (CbxTipo.Text.Equals("Coordinador"))
         {
             CoordinadorDAO objCD = new CoordinadorDAO();
             Coordinador    ObjCo = new Coordinador();
             ObjCo = objCD.Buscar(TxtUsuario.Text);
             if (ObjCo == null)
             {
                 MessageBox.Show("El usuario no existe", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 if (TxtContrasenia.Text.Equals(ObjCo.contrasenia))
                 {
                     String id = TxtUsuario.Text;
                     limpiar();
                     this.Visible = false;
                     new FrmCordinador(this, id).Show();
                 }
                 else
                 {
                     MessageBox.Show("El usuario o contraseñia incorrectos", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         else if (CbxTipo.Text.Equals("Asesor"))
         {
             TutorDAO ObjTD = new TutorDAO();
             Tutor    ObjT  = new Tutor();
             ObjT = ObjTD.Buscar(TxtUsuario.Text);
             if (ObjT == null)
             {
                 MessageBox.Show("El usuario no existe", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 if (TxtContrasenia.Text.Equals(ObjT.contrasenia))
                 {
                     String id = TxtUsuario.Text;
                     limpiar();
                     this.Visible = false;
                     new FrmAsesor(this).Show();
                 }
                 else
                 {
                     MessageBox.Show("El usuario o contraseñia incorrectos", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
     }
 }