Ejemplo n.º 1
0
        private void cmd_consultar_Click(object sender, EventArgs e)
        {
            CubiertaService cubiertaService = new CubiertaService();
            List <Cubierta> cubiertasList   = new List <Cubierta>();

            if (chk_todos.Checked)
            {
                cubiertasList = cubiertaService.GetAll();
                cargar_grilla(cubiertasList);
            }
            else
            {
                if (Convert.ToInt32(this.miCombito1.SelectedIndex.ToString()) != -1 && this.txt_nroCubierta.Text.ToString() != "")
                {
                    int codNavio    = Convert.ToInt32(this.miCombito1.SelectedValue.ToString());
                    int numCubierta = Convert.ToInt32(this.txt_nroCubierta.Text.ToString());

                    Cubierta cubierta = cubiertaService.GetByPrimaryKey(codNavio, numCubierta);

                    if (cubierta != null)
                    {
                        cubiertasList.Add(cubierta);
                        cargar_grilla(cubiertasList);
                    }
                    else
                    {
                        MessageBox.Show("No se encontró ninguna cubierta con esos datos", " Mensaje", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Faltan datos", " Mensaje", MessageBoxButtons.OK);
                }
            }
        }
Ejemplo n.º 2
0
        private void cmd_aceptar_Click(object sender, EventArgs e)
        {
            CubiertaService cubiertaService = new CubiertaService();

            if (this.miCombito1.SelectedIndex == -1 || this.txt_numCubierta.Text == "" || this.txt_descripcion.Text == "")
            {
                MessageBox.Show("Faltan datos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                int    idNavio         = Convert.ToInt32(this.miCombito1.SelectedValue);
                int    numCubierta     = Convert.ToInt32(this.txt_numCubierta.Text.ToString());
                string descripcion     = this.txt_descripcion.Text.ToString();
                int    legajoEncargado = this.txt_legEncargado.Text.ToString() == "" ? 0 : Convert.ToInt32(this.txt_legEncargado.Text.ToString());



                Cubierta cubiertaConsulta = cubiertaService.GetByPrimaryKey(idNavio, numCubierta);

                if (cubiertaConsulta == null)
                {
                    Cubierta cubierta = new Cubierta(idNavio, numCubierta, descripcion, legajoEncargado);
                    cubiertaService.CrearCubierta(cubierta);
                    MessageBox.Show("Se creó con éxito", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show("Ya existe una Cubierta con esos datos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Ejemplo n.º 3
0
        private void cmd_eliminar_Click(object sender, EventArgs e)
        {
            CubiertaService cubiertaService = new CubiertaService();
            int             id = -1;

            id = Convert.ToInt32(this.dvg1.CurrentRow.Cells["ID"].Value.ToString());

            if (id != -1)
            {
                cubiertaService.DeleteById(id);
                MessageBox.Show("Se eliminó con éxito");
            }
        }