Example #1
0
 internal static TipoSangre ConvertirTipoSangreListDtoEnTipoSangre(TipoSangreListDto selectedItem)
 {
     return(new TipoSangre
     {
         Factor = selectedItem.Factor,
         Grupo = selectedItem.Grupo,
         GrupoSanguineoID = selectedItem.GrupoSanguineoID
     });
 }
Example #2
0
        public static void CargarDatosComboTipoSangre(ref ComboBox combo)
        {
            IServicioTipoSangre servicioTipoSangre = new ServicioTipoSangre();
            var lista    = servicioTipoSangre.GetTipoSangres();
            var defaultt = new TipoSangreListDto {
                GrupoSanguineoID = 0, Grupo = "Seleccione Grupo"
            };

            lista.Insert(0, defaultt);
            combo.DataSource    = lista;
            combo.ValueMember   = "GrupoSanguineoID";
            combo.DisplayMember = "Grupo";

            combo.SelectedIndex = 0;
        }
Example #3
0
 private void btnEditar_Click(object sender, EventArgs e)
 {
     if (dgbDatos.SelectedRows.Count > 0)
     {
         DataGridViewRow   r                 = dgbDatos.SelectedRows[0];
         TipoSangreListDto tipoSangre        = (TipoSangreListDto)r.Tag;
         TipoSangreListDto SanAux            = (TipoSangreListDto)tipoSangre.Clone();
         TipoSangreEditDto tipoSangreEditDto = new TipoSangreEditDto
         {
             GrupoSanguineoID = tipoSangre.GrupoSanguineoID,
             Grupo            = tipoSangre.Grupo,
             Factor           = tipoSangre.Factor
         };
         FrmTipoSangreAE frm = new FrmTipoSangreAE();
         frm.Text = "editar Grupo Sanguineo";
         frm.SetTipoSangre(tipoSangreEditDto);
         DialogResult dr = frm.ShowDialog(this);
         if (dr == DialogResult.OK)
         {
             try
             {
                 tipoSangreEditDto = frm.GetTipoSangre();
                 if (!_Servicio.existe(tipoSangreEditDto))
                 {
                     _Servicio.guardar(tipoSangreEditDto);
                     tipoSangre.Grupo  = tipoSangreEditDto.Grupo;
                     tipoSangre.Factor = tipoSangreEditDto.Factor;
                     setearfila(r, tipoSangre);
                     MessageBox.Show("registro Modifica3", "mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     setearfila(r, SanAux);
                     MessageBox.Show("registro ya existente", "mensajee", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             catch (Exception ex)
             {
                 setearfila(r, SanAux);
                 MessageBox.Show(ex.Message, "error llamar al programador", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
        public List <TipoSangreListDto> GetTipoSangres()
        {
            List <TipoSangreListDto> lista = new List <TipoSangreListDto>();

            try
            {
                string        cadenaComando = "select GrupoSanguineoID, Grupo, Factor from GruposSanguineos";
                SqlCommand    comando       = new SqlCommand(cadenaComando, _conexion);
                SqlDataReader reader        = comando.ExecuteReader();
                while (reader.Read())
                {
                    TipoSangreListDto tipoSangre = ConstruirTipoSangreListDto(reader);
                    lista.Add(tipoSangre);
                }
                reader.Close();
                return(lista);
            }
            catch (Exception)
            {
                throw new Exception("Error al intentar we");
            }
        }
Example #5
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            FrmTipoSangreAE frm = new FrmTipoSangreAE();

            frm.Text = "Agregar un nuevo tipo de SAngre";
            DialogResult dr = frm.ShowDialog(this);

            if (dr == DialogResult.OK)
            {
                try
                {
                    TipoSangreEditDto tipoSangreEditDto = frm.GetTipoSangre();
                    if (!_Servicio.existe(tipoSangreEditDto))
                    {
                        _Servicio.guardar(tipoSangreEditDto);
                        TipoSangreListDto tipoSangreListDto = new TipoSangreListDto
                        {
                            GrupoSanguineoID = tipoSangreEditDto.GrupoSanguineoID,
                            Grupo            = tipoSangreEditDto.Grupo,
                            Factor           = tipoSangreEditDto.Factor
                        };
                        DataGridViewRow r = construirFila();
                        setearfila(r, tipoSangreListDto);
                        agregarfila(r);
                        MessageBox.Show("Registro Agregado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Registro ya existente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #6
0
 private void setearfila(DataGridViewRow r, TipoSangreListDto tipoSangre)
 {
     r.Cells[cmnGrupo.Index].Value  = tipoSangre.Grupo;
     r.Cells[cmnFactor.Index].Value = tipoSangre.Factor;
     r.Tag = tipoSangre;
 }