Beispiel #1
0
        public DlgFormIdiomas()
        {
            try
            {
                InitializeComponent();

                this.Cursor = Cursors.WaitCursor;

                Image  image  = Image.FromFile(iconSystem);
                Bitmap bitmap = new Bitmap(image);
                this.Icon = Icon.FromHandle(bitmap.GetHicon());

                image            = Image.FromFile(actionDown);
                BtnColapse.Image = image;
                image            = Image.FromFile(actionOK);
                BtnOK.Image      = image;
                image            = Image.FromFile(actionFilter);
                BtnFiltrar.Image = image;
                image            = Image.FromFile(actionClose);
                BtnSair.Image    = image;

                SplitDlgFilter.Panel1Collapsed = true;
                SplitDlgFilter.Panel2Collapsed = false;
                idiomaDAO = new IdiomaDAO();

                idiomas = idiomaDAO.FindByCountAndFilter(50, "", "");
                if (idiomas != null)
                {
                    for (int i = 0; i < idiomas.Count; i++)
                    {
                        DataGridViewRow row = (DataGridViewRow)DataIdiomas.Rows[0].Clone();
                        row.Cells[0].Value           = idiomas[i].Langu;
                        row.Cells[0].ReadOnly        = true;
                        row.Cells[0].Style.BackColor = Color.LightSlateGray;
                        row.Cells[1].Value           = idiomas[i].Denominacao;
                        row.Cells[1].ReadOnly        = true;
                        row.Cells[1].Style.BackColor = Color.LightGray;
                        DataIdiomas.Rows.Add(row);
                    }
                }
                this.Cursor    = Cursors.Default;
                this.CodIdioma = "";
                ValIdioma.Clear();
                ValDescricao.Clear();
                ValLinhas.Text = "50";

                DataIdiomas.AllowUserToAddRows = false;
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(this, ex.Message, "Erro Pesquisa Idiomas",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void Salvar()
        {
            try
            {
                if (this.BtnSave.Enabled)
                {
                    if (ValMoeda.Text == "")
                    {
                        MessageBoxEx.Show(DataMoedas, "Código da moeda é obrigatório!", "Erro Moedas",
                                          MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ValMoeda.Focus();
                    }
                    else
                    {
                        this.Cursor = Cursors.WaitCursor;
                        Moeda moeda = moedaDAO.FindByWaers(ValMoeda.Text);
                        if (moeda == null)
                        {
                            moeda = new Moeda();
                        }

                        moeda.Waers     = ValMoeda.Text;
                        moeda.Tcurc     = ValIso.Text;
                        moeda.Descricao = ValDescricao.Text;
                        moeda.Cdecimal  = ValDecimal.Text;

                        if (ValPrimario.Checked)
                        {
                            moeda.Primario = "X";
                        }
                        else
                        {
                            moeda.Primario = "";
                        }

                        string waers = ValDesde.Text.Replace("/", "");
                        waers = waers.Trim();
                        if (waers != "")
                        {
                            moeda.ValDesde = DateTime.ParseExact(waers, "ddMMyyyy", CultureInfo.InvariantCulture);
                        }


                        if (moeda.Id == 0)
                        {
                            moedaDAO.Persist(moeda);

                            popula_dados = new Thread(Inicializa);
                            popula_dados.IsBackground = true;
                            popula_dados.Start();
                        }
                        else
                        {
                            moedaDAO.Merge(moeda);
                            int index = DataMoedas.CurrentCell.RowIndex;
                            DataMoedas.Rows[index].Cells[0].Value = moeda.Tcurc;
                            DataMoedas.Rows[index].Cells[1].Value = moeda.Descricao;
                            if (moeda.Primario == "X")
                            {
                                DataMoedas.Rows[index].Cells[2].Value = true;
                            }
                            else
                            {
                                DataMoedas.Rows[index].Cells[2].Value = false;
                            }
                        }

                        this.Cursor = Cursors.Default;
                        var message = "Moeda " + ValDescricao.Text + " salva com sucesso...";
                        this.principal.exibirMessage(actionOK, message, "S");

                        FormUtil.GetMessage(actionOK, message);
                        this.principal.HideExecucao();

                        if (this.IsInsert)
                        {
                            ValMoeda.Focus();
                        }
                        else
                        {
                            ValDescricao.Focus();
                        }
                    }
                }
            }catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBoxEx.Show(this, ex.Message, "Erro Moedas",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void DataMoedas_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                String waers = DataMoedas.Rows[e.RowIndex].Cells[0].Value.ToString();

                if (waers != "")
                {
                    Moeda moeda = moedaDAO.FindByWaers(waers);

                    if (moeda != null)
                    {
                        ValMoeda.Text     = moeda.Waers;
                        ValIso.Text       = moeda.Tcurc;
                        ValDescricao.Text = moeda.Descricao;
                        ValDecimal.Text   = moeda.Cdecimal;
                        if (moeda.Primario == "X")
                        {
                            ValPrimario.Checked = true;
                        }
                        else
                        {
                            ValPrimario.Checked = false;
                        }
                        if (!moeda.ValDesde.ToString().Equals("01/01/0001 00:00:00"))
                        {
                            ValDesde.Text = moeda.ValDesde.ToString();
                        }
                        else
                        {
                            ValDesde.Text = "";
                        }
                    }

                    SplitMoedas.Panel1Collapsed = true;
                    SplitMoedas.Panel2Collapsed = false;
                    BtnEdit.Visible             = false;
                    BtnVoltar.Visible           = true;

                    SplitMoedas.Refresh();

                    if (this.IsEdit || this.IsInsert)
                    {
                        BtnSave.Enabled           = true;
                        BtnDelete.Enabled         = false;
                        BtnNew.Enabled            = false;
                        ValDecimal.Enabled        = true;
                        ValDescricao.Enabled      = true;
                        ValDesde.Enabled          = true;
                        ValFCheckPrimario.Enabled = true;
                        ValFMoeda.Enabled         = true;
                        ValMoeda.Enabled          = true;
                        ValIso.Enabled            = true;
                    }
                    else
                    {
                        ValDecimal.Enabled        = false;
                        ValDescricao.Enabled      = false;
                        ValDesde.Enabled          = false;
                        ValFCheckPrimario.Enabled = false;
                        ValFMoeda.Enabled         = false;
                        ValMoeda.Enabled          = false;
                        ValIso.Enabled            = false;
                    }

                    if (IsEdit)
                    {
                        ValDescricao.Focus();
                    }

                    if (IsInsert)
                    {
                        ValMoeda.Focus();
                    }

                    BtnFiltrar.Visible  = false;
                    toolStrip06.Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(this, ex.Message, "Erro Moedas",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }