private void ValPosicionar_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; DlgPaisPosiciona DlgFilter = new DlgPaisPosiciona(this.principal); Point point = new Point(this.principal.Location.X + 100, this.principal.Location.Y + 300); DlgFilter.Location = point; DlgFilter.StartPosition = FormStartPosition.Manual; DlgFilter.ShowDialog(); if (DlgFilter.CodPais != "") { for (int i = 0; i < DataPais.Rows.Count; i++) { if (DataPais.Rows[i].Cells[0].Value.ToString() == DlgFilter.CodPais) { DataPais.CurrentCell = DataPais.Rows[i].Cells[0]; DataPais.Rows[i].Selected = true; DataPais.FirstDisplayedScrollingRowIndex = i; DataPais.Update(); break; } } } this.Cursor = Cursors.Default; } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBoxEx.Show(this, ex.Message, "Erro Paises", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnDelete_Click(object sender, EventArgs e) { try { DialogResult result = MessageBoxEx.Show(DataPais, "Deseja excluir registros!", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { this.Cursor = Cursors.WaitCursor; for (int i = 0; i < DataPais.Rows.Count; i++) { if (DataPais.Rows[i].Selected) { Pais pais = paisDAO.FindByLand(DataPais.Rows[i].Cells[0].Value.ToString()); if (pais != null) { paisDAO.Delete(pais); } } } PopulaData(); this.Cursor = Cursors.Default; if (splitPais.Panel1Collapsed) { splitPais.Panel1Collapsed = false; splitPais.Panel2Collapsed = true; } MessageBoxEx.Show(DataPais, "Pais(s) excluido(s) com sucesso!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); DataPais.Focus(); } } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBoxEx.Show(this, ex.Message, "Erro Paises", MessageBoxButtons.OK, MessageBoxIcon.Error); } }