Example #1
0
        private void ValPosicionar_Click(object sender, EventArgs e)
        {
            try
            {
                DlgIdiomaPosiciona DlgFilter = new DlgIdiomaPosiciona(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.CodIdioma != "")
                {
                    for (int i = 0; i < DataIdioma.Rows.Count; i++)
                    {
                        if (DataIdioma.Rows[i].Cells[0].Value.ToString() == DlgFilter.CodIdioma)
                        {
                            DataIdioma.CurrentCell      = DataIdioma.Rows[i].Cells[0];
                            DataIdioma.Rows[i].Selected = true;
                            DataIdioma.FirstDisplayedScrollingRowIndex = i;
                            DataIdioma.Update();
                            break;
                        }
                    }
                }
            } catch (Exception ex)
            {
                MessageBoxEx.Show(DataIdioma, ex.Message, "Erro Idiomas",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #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();
        }
Example #3
0
        private void DataIdioma_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            for (int i = 0; i < DataIdioma.Rows.Count; i++)
            {
                if (DataIdioma.Rows[i].Cells[0].Value == null && DataIdioma.Rows[i].Cells[1].Value != null)
                {
                    e.Cancel = true;
                }

                if (DataIdioma.Rows[i].Cells[0].Value != null && DataIdioma.Rows[i].Cells[1].Value == null)
                {
                    e.Cancel = true;
                }
            }

            DataIdioma.Focus();
        }
Example #4
0
        private void PopulaDados()
        {
            this.Cursor = Cursors.WaitCursor;
            DataIdioma.Rows.Clear();

            idiomas = idiomaDAO.FindAllIdioma();
            for (int i = 0; i < idiomas.Count; i++)
            {
                DataIdioma.Rows.Add();
                DataIdioma.Rows[i].Cells[0].Value           = idiomas[i].Spras;
                DataIdioma.Rows[i].Cells[0].ReadOnly        = true;
                DataIdioma.Rows[i].Cells[0].Style.BackColor = Color.LightSlateGray;
                DataIdioma.Rows[i].Cells[1].Value           = idiomas[i].Langu;
                DataIdioma.Rows[i].Cells[1].ReadOnly        = true;
                DataIdioma.Rows[i].Cells[1].Style.BackColor = Color.LightSlateGray;
                DataIdioma.Rows[i].Cells[2].Value           = idiomas[i].Denominacao;
                DataIdioma.Rows[i].Cells[2].ReadOnly        = true;
                DataIdioma.Rows[i].Cells[2].Style.BackColor = Color.LightGray;
            }
            DataIdioma.AllowUserToAddRows = false;
            this.Cursor = Cursors.Default;
            DataIdioma.Focus();
        }
Example #5
0
        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);
            }
        }