private void txtPalletComercial_KeyPress(object sender, KeyPressEventArgs e) { if (panelErrorComercial.Visible == true) { panelErrorComercial.Visible = false; } if (ValidarCamposClienteProductor() == false) { e.Handled = true; return; } if (e.KeyChar == Convert.ToChar(Keys.Enter)) { if (txtPalletComercial.Text.Trim() == "") { lblMensajeComercial.Text = "Ingrese Pallet"; panelErrorComercial.Visible = true; return; } txtPalletComercial.Text = txtPalletComercial.Text.ToUpper(); if (Existe_Pallet_Lista(dgvListaComercial, txtPalletComercial.Text) == true) { lblMensajeComercial.Text = "Pallet ya esta en la Lista"; panelErrorComercial.Visible = true; txtPalletComercial.SelectAll(); return; } N_Comercial comercial1 = new N_Comercial(); E_Pallet_Comercial pallet1 = new E_Pallet_Comercial(); pallet1.Codigo = txtPalletComercial.Text; pallet1.ID_Cliente = cmbExportador.SelectedValue.ToString(); pallet1.ID_Productor = cmbProductor.SelectedValue.ToString(); if (comercial1.Existe_Pallet(pallet1) == true) { if (pallet1.Estado != "0") { lblMensajeComercial.Text = "Pallet fue asignado"; panelErrorComercial.Visible = true; return; } int rowNuevo; rowNuevo = 0; //dgvLista.Rows.Count; dgvListaComercial.Rows.Insert(0, 1); // .Add(1); dgvListaComercial.Rows[rowNuevo].Cells["item"].Value = (dgvListaComercial.Rows.Count); dgvListaComercial.Rows[rowNuevo].Cells["folio"].Value = pallet1.Codigo; dgvListaComercial.Rows[rowNuevo].Cells["tipo"].Value = pallet1.Tipo; dgvListaComercial.Rows[rowNuevo].Cells["kilos_netos"].Value = pallet1.Kilos_Netos; // dgvListaComercial.Rows[rowNuevo].Cells["descripcion"].Value = pallet1.Descripcion; dgvListaComercial.Rows[0].Selected = true; lblKilosSalidaComercial.Text = Total_Kilos_Lista(dgvListaComercial, "kilos_netos", "Comercial").ToString(); lblKilosSalidaMerma.Text = Total_Kilos_Lista(dgvListaComercial, "kilos_netos", "Merma").ToString(); } else { lblMensajeComercial.Text = "Pallet no Existe"; panelErrorComercial.Visible = true; } txtPalletComercial.Text = ""; } }