Esempio n. 1
0
        private void PopulaDados()
        {
            try
            {
                IList <FatorConversao> fatores = fatorDAO.FindAll();

                if (fatores != null && fatores.Count > 0)
                {
                    DataFator.Rows.Clear();

                    for (int i = 0; i < fatores.Count; i++)
                    {
                        DataFator.Rows.Add();
                        if (fatores[i].Categoria != null && fatores[i].Categoria.Id > 0)
                        {
                            CategoriaCambio categoria = categoriaDAO.FindByID(fatores[i].Categoria.Id);
                            DataFator.Rows[i].Cells[0].Value = categoria.Kurst;
                        }

                        DataFator.Rows[i].Cells[0].ReadOnly        = true;
                        DataFator.Rows[i].Cells[0].Style.BackColor = Color.LightSlateGray;
                        DataFator.Rows[i].Cells[1].Value           = fatores[i].Fcurr;
                        DataFator.Rows[i].Cells[1].ReadOnly        = true;
                        DataFator.Rows[i].Cells[1].Style.BackColor = Color.LightSlateGray;
                        DataFator.Rows[i].Cells[2].Value           = fatores[i].Waers;
                        DataFator.Rows[i].Cells[2].ReadOnly        = true;
                        DataFator.Rows[i].Cells[2].Style.BackColor = Color.LightSlateGray;
                        DataFator.Rows[i].Cells[3].Value           = fatores[i].ValDesde;
                        DataFator.Rows[i].Cells[3].ReadOnly        = true;
                        DataFator.Rows[i].Cells[3].Style.BackColor = Color.LightGray;
                        DataFator.Rows[i].Cells[4].Value           = fatores[i].Fator_Ori;
                        DataFator.Rows[i].Cells[4].ReadOnly        = true;
                        DataFator.Rows[i].Cells[4].Style.BackColor = Color.LightGray;
                        DataFator.Rows[i].Cells[6].Value           = fatores[i].Fator_Dst;
                        DataFator.Rows[i].Cells[6].ReadOnly        = true;
                        DataFator.Rows[i].Cells[6].Style.BackColor = Color.LightGray;
                    }
                }
                DataFator.Visible = true;
            }
            catch (Exception ex)
            {
                DataFator.Cursor = Cursors.Default;
                this.Cursor      = Cursors.Default;
                MessageBoxEx.Show(this, ex.Message, "Erro Fatores Conversão",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                IList <CategoriaCambio> categorias = new List <CategoriaCambio>();

                for (int i = 0; i < DataCatCambio.Rows.Count; i++)
                {
                    if (DataCatCambio.Rows[i].Cells[0].Value != null && DataCatCambio.Rows[i].Cells[1].Value != null)
                    {
                        CategoriaCambio categoria = catCambioDAO.FindByCategoria(DataCatCambio.Rows[i].Cells[0].Value.ToString());
                        if (categoria == null)
                        {
                            categoria = new CategoriaCambio();
                        }

                        categoria.Kurst     = DataCatCambio.Rows[i].Cells[0].Value.ToString();
                        categoria.Descricao = DataCatCambio.Rows[i].Cells[1].Value.ToString();

                        categorias.Add(categoria);
                    }
                }

                if (categorias.Count > 0)
                {
                    for (int i = 0; i < categorias.Count; i++)
                    {
                        CategoriaCambio categoria = catCambioDAO.FindByCategoria(categorias[i].Kurst);
                        if (categoria == null)
                        {
                            categoria = new CategoriaCambio();
                        }

                        categoria.Kurst     = categorias[i].Kurst;
                        categoria.Descricao = categorias[i].Descricao;

                        if (categoria.Id > 0)
                        {
                            catCambioDAO.Merge(categoria);
                        }
                        else
                        {
                            catCambioDAO.Persist(categoria);
                        }
                    }

                    this.Cursor = Cursors.Default;
                    var message = "Idioma(s) salvo com sucesso...";
                    this.principal.exibirMessage(actionOK, "Idioma(s) salvo com sucesso...", "S");
                    FormUtil.GetMessage(actionOK, message);
                    this.principal.HideExecucao();
                }
                else
                {
                    this.Cursor = Cursors.Default;
                    var message = "Dados nao salvo, campos obrigatórios...";
                    this.principal.exibirMessage(actionErr, message, "S");

                    FormUtil.GetMessage(actionErr, message);
                    this.principal.HideExecucao();
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBoxEx.Show(this, ex.Message, "Erro Categoria cambio",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }