private void dgvMacota_CellClick(object sender, DataGridViewCellEventArgs e) { posicion = dgvMacota.CurrentRow.Index; _idMascota = Convert.ToInt32(dgvMacota[6, posicion].Value.ToString()); txtId.Text = dgvMacota[6, posicion].Value.ToString(); txtMascota.Text = dgvMacota[1, posicion].Value.ToString(); txtCodigo.Text = dgvMacota[0, posicion].Value.ToString(); var tabla = NMascota.BuscarMascotaId(_idMascota); if (tabla.Rows.Count != 0) { byte[] img = (byte[])tabla.Rows[0]["imagen"]; var ms = new MemoryStream(img); pbFoto.Image = Image.FromStream(ms); } }
private void dgvMascota_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex != -1) { if (dgvMascota.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar")) { int idmascota = Convert.ToInt32(dgvMascota.Rows[e.RowIndex].Cells[1].Value.ToString()); frmMascota fMascota = new frmMascota(); fMascota.Show(); var tabla = NMascota.BuscarMascotaId(idmascota); frmMascota.MiFormMascota.txtCodigo.Text = tabla.Rows[0]["codigo"].ToString(); frmMascota.MiFormMascota.txtCliente.Text = tabla.Rows[0]["nombres"].ToString() + " " + tabla.Rows[0]["apellidos"].ToString(); frmMascota.MiFormMascota.txtNombre.Text = tabla.Rows[0]["nombre"].ToString(); frmMascota.MiFormMascota.txtEdad.Text = tabla.Rows[0]["edad"].ToString(); frmMascota.MiFormMascota.txtPeso.Text = tabla.Rows[0]["peso"].ToString(); frmMascota.MiFormMascota.cboSexo.SelectedItem = tabla.Rows[0]["sexo"].ToString(); frmMascota.MiFormMascota.cboEspecie.SelectedValue = tabla.Rows[0]["idespecie"].ToString(); frmMascota.MiFormMascota.cboRaza.SelectedValue = tabla.Rows[0]["idraza"].ToString(); frmMascota.MiFormMascota.txtDescripcion.Text = tabla.Rows[0]["descripcion"].ToString(); byte[] img = (byte[])tabla.Rows[0]["imagen"]; var ms = new MemoryStream(img); frmMascota.MiFormMascota.pbFoto.Image = Image.FromStream(ms); frmMascota.MiFormMascota._idMascota = idmascota; frmMascota.MiFormMascota._idCliente = Convert.ToInt32(tabla.Rows[0]["idcliente"].ToString()); /* frmMascota.MiFormMascota._idRaza = Convert.ToInt32(tabla.Rows[0]["idraza"].ToString());*/ frmMascota.MiFormMascota.txtCodigo.Visible = true; frmMascota.MiFormMascota.label1.Visible = true; frmMascota.MiFormMascota._IsNew = false; frmMascota.MiFormMascota.txtBuscar.Enabled = false; frmMascota.MiFormMascota.cboEspecie.Enabled = false; frmMascota.MiFormMascota.cboRaza.Enabled = false; frmMascota.MiFormMascota.cboSexo.Enabled = false; } if (dgvMascota.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar")) { int idmascota = Convert.ToInt32(dgvMascota.Rows[e.RowIndex].Cells[1].Value.ToString()); DialogResult rspta = MessageBox.Show("Desea Eliminar", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (DialogResult.Yes == rspta) { var rpta = NMascota.EliminarMascota(idmascota); if (rpta == "Ok") { MessageBox.Show(rpta + "---Elimado"); dgvMascota.Rows.RemoveAt(e.RowIndex); NMascota objMascota = new NMascota(); objMascota.ListadoDgv(dgvMascota); dgvMascota.Refresh(); } else { MessageBox.Show("error"); } } } if (dgvMascota.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Ver")) { int idmascota = Convert.ToInt32(dgvMascota.Rows[e.RowIndex].Cells[1].Value.ToString()); frmPerfil perfil = new frmPerfil(); perfil.Show(); var tabla = NMascota.BuscarMascotaId(idmascota); frmPerfil.MiFormPerfil.listDatos.Items.Add("Nombre: " + tabla.Rows[0]["nombres"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Apellidos: " + tabla.Rows[0]["apellidos"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Telefono: " + tabla.Rows[0]["telefono"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Codigo: " + tabla.Rows[0]["codigo"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Nombre: " + tabla.Rows[0]["nombre"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Edad: " + tabla.Rows[0]["edad"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Peso: " + tabla.Rows[0]["peso"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Especie: " + tabla.Rows[0]["especie"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Raza: " + tabla.Rows[0]["raza"].ToString()); byte[] img = (byte[])tabla.Rows[0]["imagen"]; var ms = new MemoryStream(img); frmPerfil.MiFormPerfil.pbFoto.Image = Image.FromStream(ms); frmPerfil.MiFormPerfil.lblTitulo.Text = "Datos Dueño - Mascota"; } } }