private void BtnFilter_Click(object sender, EventArgs e) { try { DlgFormIdiomas DlgFilter = new DlgFormIdiomas(); Point point = new Point(this.principal.Location.X + 100, this.principal.Location.Y + 100); DlgFilter.Location = point; DlgFilter.StartPosition = FormStartPosition.Manual; DlgFilter.ShowDialog(); if (DlgFilter.CodIdioma != "") { Idioma idioma = idiomaDAO.FindByLangu(DlgFilter.CodIdioma); if (idioma != null) { ValIdioma.Text = idioma.Langu; ValIdioma.Text = DlgFilter.CodIdioma; } } } catch (Exception ex) { MessageBoxEx.Show(this, ex.Message, "Erro Paises", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnSave_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; IList <Idioma> idiomas = new List <Idioma>(); for (int i = 0; i < DataIdioma.Rows.Count; i++) { if (DataIdioma.Rows[i].Cells[0].Value != null && DataIdioma.Rows[i].Cells[1].Value != null && DataIdioma.Rows[i].Cells[2].Value != null) { Idioma idioma = idiomaDAO.FindByLangu(DataIdioma.Rows[i].Cells[1].Value.ToString()); if (idioma == null) { idioma = new Idioma(); } idioma.Spras = DataIdioma.Rows[i].Cells[0].Value.ToString(); idioma.Langu = DataIdioma.Rows[i].Cells[1].Value.ToString(); idioma.Denominacao = DataIdioma.Rows[i].Cells[2].Value.ToString(); idiomas.Add(idioma); } } if (idiomas != null && idiomas.Count > 0) { for (int i = 0; i < idiomas.Count; i++) { if (idiomas[i].Id > 0) { idiomaDAO.Merge(idiomas[i]); } else { idiomaDAO.Persist(idiomas[i]); } } var message = "Idioma(s) salvo com sucesso..."; this.principal.exibirMessage(actionOK, message, "S"); FormUtil.GetMessage(actionOK, message); this.principal.HideExecucao(); } else { var message = "Dados nao salvo, campos obrigatórios..."; this.principal.exibirMessage(actionErr, message, "E"); FormUtil.GetMessage(actionErr, message); this.principal.HideExecucao(); } this.Cursor = Cursors.Default; DataIdioma.Focus(); } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBoxEx.Show(DataIdioma, ex.Message, "Erro Idiomas", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnSave_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (ValidaDados()) { Pais pais = paisDAO.FindByLand(ValPais.Text.ToString()); if (pais == null) { pais = new Pais(); } if (ValIdioma.Text != "") { Idioma idioma = idiomaDAO.FindByLangu(ValIdioma.Text.ToString()); if (idioma != null) { pais.Idioma = idioma; } } pais.Land = ValPais.Text.ToString(); pais.PaisIso = ValCodIso.Text.ToString(); pais.Nome = ValNome.Text.ToString(); if (pais.Id == 0) { paisDAO.Persist(pais); } else { paisDAO.Merge(pais); } this.Cursor = Cursors.Default; var message = "Pais " + pais.Nome + " salvo com sucesso..."; this.principal.exibirMessage(actionOK, message, "S"); FormUtil.GetMessage(actionOK, message); this.principal.HideExecucao(); if (pais.Id == 0) { ValPais.Focus(); } if (pais.Id > 0) { ValNome.Focus(); } this.PopulaData(); } else { this.Cursor = Cursors.Default; } } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBoxEx.Show(this, ex.Message, "Erro Paises", MessageBoxButtons.OK, MessageBoxIcon.Error); } }