Esempio n. 1
0
 private void txtAltura_TextChanged(object sender, EventArgs e)
 {
     if (!mJaCarregouInterface)
     {
         return;
     }
     txtAltura.Text = CustomStrings.DeixaSomenteDecimais(txtAltura.Text);
     CalculaPesoEmQuilos_MateriaPrima();
 }
Esempio n. 2
0
        /// <summary>
        ///     Método que busca as cotações ativas no banco de dados intermediário
        /// e as adiciona na interface para o usuário.
        /// </summary>
        /// <param name="Moeda">Nome da moeda a ser pesquisada.</param>
        private void GetCoinCotation(String Moeda)
        {
            try
            {
                System.Net.WebClient client;

                //  Primeiro verifica se já foi pesquisada a cotação do dia que está armazenada
                //no banco de dados, caso ela exista, retorna ela.
                if (!CoinAlreadyQueried(Moeda))
                {
                }

                if (!String.IsNullOrEmpty(cotacaoSalvaBanco))
                {
                    return(cotacaoSalvaBanco);
                }
                else
                {
                    //O sistema só consulta/obtém a cotação atual se tiver internet.
                    if (mPossuiConexaoInternet)
                    {
                        client = new System.Net.WebClient();
                        System.IO.Stream data = client.OpenRead(String.Format("https://www.google.com.br/search?client=opera&q={0}+hoje&sourceid=opera&ie=UTF-8&oe=UTF-8", Moeda));
                        //System.IO.Stream data = client.OpenRead(String.Format("https://dolarhoje.com/{0}", Moeda.ToUpper().Contains("DÓLAR") ? "" : Moeda.Replace(" ", "") + "-hoje"));
                        System.IO.StreamReader reader = new System.IO.StreamReader(data);
                        string s = reader.ReadToEnd();

                        data.Close();
                        reader.Close();

                        //Contém o valor da cotação do dia de hoje de acordo com o google.
                        //String valorCotacaoAtual = CustomStrings.GetTextBetween(s, "<div class=\"J7UKTe\">", "</div>");
                        String valorCotacaoAtual = CustomStrings.GetTextBetween(s, "<div class=\"BNeawe iBp4i AP7Wnd\">", "</div></div></div></div></div><div class=").Replace(".", ",");
                        //String valorCotacaoAtual = CustomStrings.GetTextBetween(s, "<input type=\"text\" id=\"nacional\" value=\"", "\"/></span><span class=\"optional\">").Replace(".", ",");

                        //Criei essa condição, pois em determinadas situações, o sistema
                        //não consegue obter o valor da moeda do dia (por alguma razão
                        //desconhecida).
                        if (String.IsNullOrEmpty(valorCotacaoAtual))
                        {
                            valorCotacaoAtual  = String.Format("1 {0} = ", Moeda);
                            valorCotacaoAtual += CustomStrings.GetTextBetween(s, "<div><div><span><div class=", "</div></span></div><div><span><div").Split(new char[] { '>' })[1].Replace(".", ",");
                        }

                        valorCotacaoAtual = String.Format("1 {0} = {1} Real Brasileiro", Moeda, valorCotacaoAtual.ToUpper().Replace("REAL BRASILEIRO", "").Trim());

                        SalvaCotacaoDiaria(Moeda, valorCotacaoAtual);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void txtMargem_TextChanged(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtMargem.Text))
            {
                txtMargem.Text = CustomStrings.DeixaSomenteDecimais(this.txtMargem.Text);

                //Coloca um nome automático para facilitar a vida do usuário.
                txtNome.Text = $"Margem {txtMargem.Text.ToString().Replace(",", ".")}%";
                RecalculaMarkup();
            }
            else
            {
                return;
            }
        }
Esempio n. 4
0
 private void txtAdditive_Diam_TextChanged(object sender, EventArgs e)
 {
     txtAdditive_Diam.Text = CustomStrings.DeixaSomenteDecimais(txtAdditive_Diam.Text);
 }
 /// <summary>
 ///     Evento para permitir apenas inteiros na caixa de texto
 /// </summary>
 private void txtQtde_TextChanged(object sender, EventArgs e)
 {
     txtQtde.Text = CustomStrings.DeixaSomenteNumeros(txtQtde.Text);
 }
 private void txtEstoqueMinimo_TextChanged(object sender, EventArgs e)
 {
     txtEstoqueMinimo.Text = CustomStrings.DeixaSomenteNumeros(txtEstoqueMinimo.Text);
 }
 private void txtTempoEntrega_TextChanged(object sender, EventArgs e)
 {
     txtTempoEntrega.Text = CustomStrings.DeixaSomenteNumeros(txtTempoEntrega.Text);
 }
Esempio n. 8
0
 private void txtLucro_TextChanged(object sender, EventArgs e)
 {
     txtLucro.Text = CustomStrings.DeixaSomenteDecimais(txtLucro.Text);
 }
Esempio n. 9
0
 private void txtValorInicial_TextChanged(object sender, EventArgs e)
 {
     txtValorInicial.Text = CustomStrings.DeixaSomenteNumeros(txtValorInicial.Text);
 }
Esempio n. 10
0
 private void txtValorFinal_TextChanged(object sender, EventArgs e)
 {
     txtValorFinal.Text = CustomStrings.DeixaSomenteDecimais(txtValorFinal.Text);
 }
Esempio n. 11
0
 private void txtCotacaoMoeda_TextChanged(object sender, EventArgs e)
 {
     txtCotacaoMoeda.Text = CustomStrings.DeixaSomenteDecimais(txtCotacaoMoeda.Text);
 }