private void btnEdita_Click(object sender, EventArgs e) { if (lvEspecies.SelectedItems.Count > 0) { frmDatos frm = new frmDatos(); frm.bNuevo = false; frm.item = lvEspecies.SelectedItems[0]; frm.txtID.Text = frm.item.Text; frm.txtAlfa.Text = frm.item.SubItems[1].Text; frm.txtComercial.Text = frm.item.SubItems[2].Text; frm.txtCientífico.Text = frm.item.SubItems[3].Text; frm.txtPresentacion.Text = frm.item.SubItems[4].Text; frm.txtFAO.Text = frm.item.SubItems[5].Text; frm.txtOrigen.Text = frm.item.SubItems[6].Text; frm.txtPesca.Text = frm.item.SubItems[7].Text; frm.txtProd.Text = frm.item.SubItems[8].Text; frm.comboFecha1.Text = frm.item.SubItems[9].Text; frm.comboFormatoFecha1.Text = frm.item.SubItems[10].Text; frm.comboFecha2.Text = frm.item.SubItems[11].Text; frm.comboFormatoFecha2.Text = frm.item.SubItems[12].Text; frm.comboCaducidad.Text = frm.item.SubItems[13].Text; frm.comboFormatoCaducidad.Text = frm.item.SubItems[14].Text; frm.comboPeso.Text = frm.item.SubItems[15].Text; frm.txtPesoFijo.Text = frm.item.SubItems[16].Text; frm.comboDispensado.Text = frm.item.SubItems[17].Text; frm.txtCodigoBarras.Text = frm.item.SubItems[18].Text; frm.comboCodigoBarras.Text = frm.item.SubItems[19].Text; frm.comboPesoPrecio.Text = frm.item.SubItems[20].Text; frm.txtPrecio.Text = frm.item.SubItems[21].Text; frm.txtTara.Text = frm.item.SubItems[22].Text; frm.txtGlaseo.Text = frm.item.SubItems[23].Text; if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { lblDatosNoGuardados.Visible = true; lvEspecies.SelectedItems[0].Text = frm.item.Text; for (int i = 1; i < frm.item.SubItems.Count; i++) { lvEspecies.SelectedItems[0].SubItems[i].Text = frm.item.SubItems[i].Text; } } this.RenumeraGrid(); } }
private void btnNueva_Click(object sender, EventArgs e) { frmDatos frm = new frmDatos(); frm.bNuevo = true; frm.item = new ListViewItem((lvEspecies.Items.Count + 1).ToString("000")); frm.txtID.Text = frm.item.Text; for (int i = 1; i < 25; i++) { frm.item.SubItems.Add(string.Empty); } if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { lblDatosNoGuardados.Visible = true; lvEspecies.Items.Add(frm.item); } this.RenumeraGrid(); }