Example #1
0
        private void cmd_Aceptar_Click(object sender, EventArgs e)
        {
            if (navioService.GetByName(this.txt_nombre.Text).Count == 0)
            {
                string nombre            = this.txt_nombre.Text;
                float  altura            = Convert.ToSingle(this.txt_altura.Text);
                float  autonomia         = Convert.ToSingle(this.txt_autonomia.Text);
                float  desplazamiento    = Convert.ToSingle(this.txt_desplazamiento.Text);
                float  eslora            = Convert.ToSingle(this.txt_eslora.Text);
                float  manga             = Convert.ToSingle(this.txt_manga.Text);
                int    cantMaxPasajeros  = Convert.ToInt32(this.txt_pasajeros.Text);
                int    cantTripulantes   = Convert.ToInt32(this.txt_tripulantes.Text);
                int    tipoClasificacion = Convert.ToInt32(this.txt_clasificacion.Text);
                int    cantMotores       = Convert.ToInt32(this.txt_motores.Text);
                Navio  navio             = new Navio(nombre, altura, autonomia, desplazamiento, eslora, manga, cantMaxPasajeros, cantTripulantes, tipoClasificacion, cantMotores);

                navioService.CreateNavio(navio);

                MessageBox.Show("Se grabó exitosamente los datos"
                                , ""
                                , MessageBoxButtons.OK
                                , MessageBoxIcon.Exclamation);
                this.Close();
            }
            else
            {
                MessageBox.Show("El Navío ya existe", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void cmd_Consultar_Click(object sender, EventArgs e)
        {
            NavioService navioService = new NavioService();
            List <Navio> navios       = new List <Navio>();

            if (txt_navio.Text == "" &&
                checkBox_todos.Checked == false)
            {
                MessageBox.Show("No se cargó ningún dato", "importante", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                txt_navio.Focus();
            }

            if (txt_navio.Text != "" &&
                checkBox_todos.Checked == false)
            {
                navios = navioService.GetByName(txt_navio.Text);
                if (navios.Count == 0)
                {
                    MessageBox.Show("No se encontró ningún navío con ese nombre.");
                }
            }

            if (checkBox_todos.Checked == true)
            {
                navios = navioService.GetAll();
            }
            cargar_grilla(navios);
        }