private void Btn_Aceptar_Click(object sender, EventArgs e) { try { Datos.Medicacion_laboratorio ML = new Datos.Medicacion_laboratorio(); ML.Id_Medicacion_Laboratorio = (int)id_Medicacion_LaboratorioNumericUpDown.Value; ML.Descripcion_Laboratorio = descripcion_LaboratorioTextBox.Text; if (id_Medicacion_LaboratorioNumericUpDown.Value == 0) { Datos.Medicacion_laboratorio.Add(ML); MessageBox.Show("Se ha agregado un nuevo registro."); } else { Datos.Medicacion_laboratorio.Set(ML); MessageBox.Show("Se ha modificado correctamente el registro."); } Close(); } catch (Exception Error) { MessageBox.Show(Error.Message); } }
public FrmLaboratoriosABM(string IdLaboratorio) { InitializeComponent(); try { //Busco el una unica fila por su id Datos.Medicacion_laboratorio ML = Datos.Medicacion_laboratorio.GetMedicacion_laboratorio(IdLaboratorio, "").ListaMedicacion_laboratorio[0]; id_Medicacion_LaboratorioNumericUpDown.Value = ML.Id_Medicacion_Laboratorio; descripcion_LaboratorioTextBox.Text = ML.Descripcion_Laboratorio; } catch (Exception Error) { MessageBox.Show(Error.Message); } }
private void Buscar() { try { //Borro todo las filas y columnas anteriores DG_Datos.Columns.Clear(); DG_Datos.Rows.Clear(); //Busco la lista de datos Datos.Medicacion_laboratorio ML = Datos.Medicacion_laboratorio.GetMedicacion_laboratorio(Txt_Id.Text, Txt_Laboratorio.Text); //Agrego las columnas de la regilla de datos. DG_Datos.Columns.Add("Clm_Laboratorio", "Laboratorio"); DG_Datos.Font = new Font(Config.NombreFont, Config.TamañoFont); DG_Datos.Columns["Clm_Laboratorio"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; //Agrego las filas foreach (Datos.Medicacion_laboratorio ItemMedicacion_laboratorio in ML.ListaMedicacion_laboratorio) { DG_Datos.Rows.Add(); DG_Datos.Rows[DG_Datos.Rows.Count - 1].Tag = ItemMedicacion_laboratorio.Id_Medicacion_Laboratorio; DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Laboratorio"].Value = ItemMedicacion_laboratorio.Descripcion_Laboratorio; } Txt_CantidadRegistros.Text = ML.ListaMedicacion_laboratorio.Count.ToString(); if (NumeroFilaUltimaSeleccion != 0 && DG_Datos.Rows.Count > NumeroFilaUltimaSeleccion) { DG_Datos.Rows[NumeroFilaUltimaSeleccion].Selected = true; } } catch (Exception Error) { MessageBox.Show(Error.Message); } }