Beispiel #1
0
        private void FrmFatorConversao_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == (char)Keys.Escape)
                {
                    if (this.IsEdit || this.IsInsert)
                    {
                        DataFator.AllowUserToAddRows = false;
                        BtnEdit.Enabled   = true;
                        BtnNew.Enabled    = false;
                        BtnSave.Enabled   = false;
                        BtnDelete.Enabled = false;

                        if (IsInsert)
                        {
                            int rows = row_current + (DataFator.Rows.Count - row_current);

                            for (int i = row_current; i < rows; i++)
                            {
                                DataFator.Rows[i].Selected = true;
                            }


                            UtilObject.DeleteSelected(DataFator);
                        }

                        for (int i = 0; i < DataFator.Rows.Count; i++)
                        {
                            DataFator.Rows[i].Cells[0].ReadOnly        = true;
                            DataFator.Rows[i].Cells[0].Style.BackColor = Color.LightSlateGray;
                            DataFator.Rows[i].Cells[1].ReadOnly        = true;
                            DataFator.Rows[i].Cells[1].Style.BackColor = Color.LightSlateGray;
                            DataFator.Rows[i].Cells[2].ReadOnly        = true;
                            DataFator.Rows[i].Cells[2].Style.BackColor = Color.LightSlateGray;
                            DataFator.Rows[i].Cells[3].ReadOnly        = true;
                            DataFator.Rows[i].Cells[3].Style.BackColor = Color.LightGray;
                            DataFator.Rows[i].Cells[4].ReadOnly        = true;
                            DataFator.Rows[i].Cells[4].Style.BackColor = Color.LightGray;
                            DataFator.Rows[i].Cells[6].ReadOnly        = true;
                            DataFator.Rows[i].Cells[6].Style.BackColor = Color.LightGray;
                        }
                        row_current = 0;
                        IsEdit      = false;
                        IsInsert    = false;
                    }
                    else
                    {
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(this, ex.Message, "Erro Fatores Conversão",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsInsert)
                {
                    for (int i = 0; i < DataIdioma.Rows.Count; i++)
                    {
                        if (DataIdioma.Rows[i].Selected)
                        {
                            UtilObject.DeleteSelected(DataIdioma);
                        }
                    }
                }
                else
                {
                    DialogResult result = MessageBoxEx.Show(DataIdioma, "Deseja excluir registros!", "Confirmação",
                                                            MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                    if (result == DialogResult.Yes)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        IList <Idioma> ids = new List <Idioma>();

                        for (int i = 0; i < DataIdioma.Rows.Count; i++)
                        {
                            if (DataIdioma.Rows[i].Selected)
                            {
                                Idioma idioma = idiomaDAO.FindByLangu(DataIdioma.Rows[i].Cells[1].Value.ToString());
                                if (idioma != null)
                                {
                                    idiomaDAO.Delete(idioma);
                                }
                            }
                        }

                        UtilObject.DeleteSelected(DataIdioma);

                        this.principal.exibirMessage(actionOK, "Idioma(s) excluido com sucesso...", "S");
                        this.Cursor = Cursors.Default;
                    }
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBoxEx.Show(DataIdioma, ex.Message, "Erro Idiomas",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DataIdioma.Focus();
        }
Beispiel #3
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsInsert)
                {
                    UtilObject.DeleteSelected(DataCatCambio);
                }
                else
                {
                    DialogResult result = MessageBoxEx.Show(DataCatCambio, "Deseja excluir registros!", "Confirmação",
                                                            MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                    if (result == DialogResult.Yes)
                    {
                        this.Cursor = Cursors.WaitCursor;

                        IList <int> indexes = new List <int>();

                        for (int i = 0; i < DataCatCambio.Rows.Count; i++)
                        {
                            if (DataCatCambio.Rows[i].Selected)
                            {
                                CategoriaCambio categoria = catCambioDAO.FindByCategoria(DataCatCambio.Rows[i].Cells[0].Value.ToString());
                                if (categoria != null)
                                {
                                    catCambioDAO.Delete(categoria);
                                }
                            }
                        }
                        UtilObject.DeleteSelected(DataCatCambio);
                        this.Cursor = Cursors.Default;
                    }
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBoxEx.Show(this, ex.Message, "Erro Categoria cambio",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }