private void BtnGuardar_Click(object sender, EventArgs e) { try { if (this.Comprobaciones(out List <string> variables)) { string rpta = NNotas.InsertarNota(variables, out int id_nota); if (rpta.Equals("OK")) { Mensajes.MensajeOkForm("Se insertó la nota correctamente " + id_nota); OnRefresh?.Invoke(sender, e); this.Close(); } else { throw new Exception(rpta); } } } catch (Exception ex) { Mensajes.MensajeErrorCompleto(this.Name, "BtnGuardar_Click", "Hubo un error al guardar una nota", ex.Message); } }
private void BuscarNotas(string tipo_busqueda, string texto_busqueda) { try { this.panelNotas.clearDataSource(); DataTable dtNotas = NNotas.BuscarNotas(tipo_busqueda, texto_busqueda, out string rpta); if (dtNotas != null) { this.panelNotas.Enabled = true; this.panelNotas.BackgroundImage = null; this.lblResultados.Click += LblResultados_Click; List <UserControl> controls = new List <UserControl>(); if (this.IsBusquedaCompleta) { this.lblResultados.Text = "Se encontraron " + dtNotas.Rows.Count + " notas. (Ver todas)"; foreach (DataRow row in dtNotas.Rows) { ENotas eNota = new ENotas(row); //NotaSmall notaSmall = new NotaSmall(); //notaSmall.AsignarDatos(eNota); //controls.Add(notaSmall); } } else { this.lblResultados.Text = "Última nota. (Ver todas)"; ENotas eNota = new ENotas(dtNotas, 0); //NotaSmall notaSmall = new NotaSmall(); //notaSmall.AsignarDatos(eNota); //controls.Add(notaSmall); } this.panelNotas.AddArrayControl(controls); } else { this.panelNotas.BackgroundImage = Resources.No_hay_notas; this.panelNotas.Enabled = false; this.lblResultados.Text = "No se encontraron notas recientes"; this.lblResultados.Click -= LblResultados_Click; if (!rpta.Equals("OK")) { throw new Exception(rpta); } } } catch (Exception ex) { Mensajes.MensajeErrorCompleto(this.Name, "BuscarNotas", "Hubo un error al buscar las notas", ex.Message); } }