Exemplo n.º 1
0
        public DlgFormPaises()
        {
            InitializeComponent();
            this.Cursor = Cursors.WaitCursor;
            Image image = Image.FromFile(actionDown);

            BtnColapse.Image = image;
            image            = Image.FromFile(actionOK);
            BtnOK.Image      = image;
            image            = Image.FromFile(actionClose);
            BtnSair.Image    = image;
            image            = Image.FromFile(actionFilter);
            BtnFiltrar.Image = image;
            SplitDlgFilter.Panel1Collapsed = true;
            SplitDlgFilter.Panel2Collapsed = false;

            paisDAO = new PaisDAO();
            paises  = paisDAO.FindByCountAndFilter(50, "", "");
            if (paises != null)
            {
                DataPaises.Rows.Clear();
                for (int i = 0; i < paises.Count; i++)
                {
                    DataPaises.Rows.Add();
                    DataPaises.Rows[i].Cells[0].Value           = paises[i].Land;
                    DataPaises.Rows[i].Cells[0].ReadOnly        = true;
                    DataPaises.Rows[i].Cells[0].Style.BackColor = Color.LightSlateGray;
                    DataPaises.Rows[i].Cells[1].Value           = paises[i].Nome;
                    DataPaises.Rows[i].Cells[1].ReadOnly        = true;
                    DataPaises.Rows[i].Cells[1].Style.BackColor = Color.LightGray;
                }
            }
            this.CodPais = "";
            ValPais.Clear();
            ValNome.Clear();
            ValLinhas.Text = "50";
            this.Cursor    = Cursors.Default;
            DataPaises.AllowUserToAddRows = false;
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        private void DataPais_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                Pais pais = paisDAO.FindByLand(DataPais.Rows[e.RowIndex].Cells[0].Value.ToString());

                if (pais != null)
                {
                    ValPais.Text   = pais.Land;
                    ValCodIso.Text = pais.PaisIso;
                    ValIdioma.Text = pais.Langu;
                    ValNome.Text   = pais.Nome;
                    if (pais.Idioma != null)
                    {
                        Idioma idioma = idiomaDAO.FindByID(pais.Idioma.Id);
                        if (idioma != null)
                        {
                            ValIdioma.Text = idioma.Langu;
                        }
                    }

                    splitPais.Panel1Collapsed = true;
                    splitPais.Panel2Collapsed = false;

                    if (this.IsEdit || this.IsInsert)
                    {
                        ValPais.Enabled   = true;
                        ValCodIso.Enabled = true;
                        ValIdioma.Enabled = true;
                        ValNome.Enabled   = true;

                        if (IsEdit)
                        {
                            BtnSave.Enabled   = true;
                            ValPais.Enabled   = false;
                            ValCodIso.Enabled = false;
                            BtnSave.Enabled   = true;
                            ValNome.Focus();
                        }
                        if (IsInsert)
                        {
                            BtnSave.Enabled = true;
                            ValPais.Focus();
                        }
                    }
                    else
                    {
                        ValPais.Enabled   = false;
                        ValCodIso.Enabled = false;
                        ValIdioma.Enabled = false;
                        ValNome.Enabled   = false;
                    }

                    BtnEdit.Visible   = false;
                    BtnVoltar.Visible = true;
                    BtnDelete.Enabled = false;
                    BtnNew.Enabled    = false;
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(this, ex.Message, "Erro Paises",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }