private void NuevoMetroButton_Click(object sender, EventArgs e) { PrestamoAEForm frm = new PrestamoAEForm(); frm.Text = "Nuevo Prestamo"; DialogResult dr = frm.ShowDialog(this); if (dr == DialogResult.OK) { try { var prestamoDto = frm.GetPrestamo(); _servicio.Guardar(prestamoDto); var prestamoListDto = new PrestamoListDto { PrestamoId = prestamoDto.PrestamoId, NombreSocio = prestamoDto.NombreSocio.Nombre, ApellidoSocio = prestamoDto.ApellidoSocio.Apellido, FechaPrestamo = prestamoDto.FechaPrestamo, ItemsPrestamo = Helper.ConstruirListaItemsListDto(prestamoDto.DetallePrestamo) }; var r = ConstruirFila(); SetearFila(r, prestamoListDto); AgregarFila(r); MessageBox.Show("Prestamo ", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void SetearFila(DataGridViewRow r, PrestamoListDto prestamoListDto) { r.Cells[cmnPrestamoNro.Index].Value = prestamoListDto.PrestamoId; r.Cells[cmnNombre.Index].Value = prestamoListDto.NombreSocio; r.Cells[cmnApellido.Index].Value = prestamoListDto.ApellidoSocio; r.Cells[cmnFechaPrestamo.Index].Value = prestamoListDto.FechaPrestamo.ToShortDateString(); r.Tag = prestamoListDto; }
private PrestamoListDto ConstruirPrestamoListDto(SqlDataReader reader) { PrestamoListDto prestamoDto = new PrestamoListDto(); prestamoDto.PrestamoId = reader.GetInt32(0); prestamoDto.NombreSocio = reader.GetString(1); prestamoDto.ApellidoSocio = reader.GetString(2); prestamoDto.FechaPrestamo = reader.GetDateTime(3); prestamoDto.ItemsPrestamo = _repositorioDetalles.GetLista(reader.GetInt32(0)); //si anda mal puede ser esto de aca 1 renglon arriba return(prestamoDto); }