private void txtCodigo_KeyPressed(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { String codigo; codigo = txtCodigo.Text.Trim(); producto = PRODUCTOcn.GetPRODUCTO(codigo); if (producto == null) { MessageBox.Show("El código ingresado no existe"); txtCodigo.Text = ""; txtCodigo.Focus(); } else { this.DialogResult = DialogResult.OK; this.Close(); } } }
public LectorDoc(String id) { if (id == null) { estado = "NUEVO"; } else { llenarDesdeBD(id); if (cabecera == null) { estado = "NUEVO"; } } InitializeComponent(); responsables = ResponsableCn.GetResponsables(); var mapResponsables = new BindingList <KeyValuePair <string, string> >(); mapResponsables.Add(new KeyValuePair <string, string>(null, "[Seleccionar]")); foreach (RESPONSABLE r in responsables) { mapResponsables.Add(new KeyValuePair <string, string>(r.IDRESPONSABLE, r.NOMBRES)); } cboResponsable.DataSource = mapResponsables; cboResponsable.ValueMember = "Key"; cboResponsable.DisplayMember = "Value"; cboResponsable.SelectedIndex = 0; dt.Columns.Add(new DataColumn("Item")); dt.Columns.Add(new DataColumn("IdProducto")); dt.Columns.Add(new DataColumn("Descripcion")); dt.Columns.Add(new DataColumn("Idmedida")); dt.Columns.Add(new DataColumn("Cantidad")); grdDet.DataSource = dt; productos = PRODUCTOcn.GetPRODUCTOS(); tDocumentos = ASIG_TDOCUMENTOcn.GetAsig_TDocumento("LECTOR"); if (tDocumentos.Count == 0) { MessageBox.Show("No tiene definido documentos"); } else { if (estado.Equals("NUEVO")) { nuevo(); llenarVista(); edicion(true); } else { llenarVista(); edicion(false); } } }