Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Online = TestarConexao();

            if (Online)
            {
                SorteioNegocio neg = new SorteioNegocio();

                if (neg.ModoOffline())
                {
                    Online = false;

                    if (!Aleatorio.TodosArquivosExiste())
                    {
                        Aleatorio.Serial();
                    }
                }
                else if (neg.Active())
                {
                    bancoSortearToolStripMenuItem.Visible = true;
                }
            }

            if (!Online)
            {
                sorteioToolStripMenuItem.Enabled = false;
                Aleatorio.desSerial();
                FormMessage.ShowMessegeWarning("O sistema funcionará no MODO OFFLINE!");
            }
        }
Пример #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (img != null)
            {
                if (string.IsNullOrEmpty(textBoxDescricaoProd.Text))
                {
                    FormMessage.ShowMessegeWarning("Informe uma descrição para este prêmio!");
                    textBoxDescricaoProd.Select();
                    return;
                }

                infoProd = new ProdutoInfo
                {
                    produtodescricao = textBoxDescricaoProd.Text,
                    produtofoto      = ConvertImagem(img),
                    produtovalor     = Convert.ToDecimal(textBoxValor.Text)
                };

                negSort = new SorteioNegocio();
                negSort.ExecutarProduto(enumCRUD.insert, infoProd);
                FormMessage.ShowMessegeInfo("Prêmio lançado com sucesso!");

                pictureBox1.Image = Properties.Resources.portateis;
                textBoxDescricaoProd.Clear();
                textBoxDescricaoProd.Select();
                textBoxValor.Text = "1,00";

                FormProduto formProduto = (FormProduto)Application.OpenForms["FormProduto"];
                formProduto.PreencherLista();
            }
            else
            {
                FormMessage.ShowMessegeWarning("Selecione uma imagem para este prêmio!");
            }
        }
Пример #3
0
        private void buttonRemover_Click(object sender, EventArgs e)
        {
            int n = 0;
            List <UserControlProd> l = new List <UserControlProd>();

            foreach (var item in flowLayoutPanelProd.Controls)
            {
                UserControlProd prod = (UserControlProd)item;

                if (prod.BackColor == Color.Gray)
                {
                    l.Add(prod);
                    ++n;
                }
            }

            if (n == 0)
            {
                FormMessage.ShowMessegeWarning("Selecione um produto para que seja removido!");
            }
            else
            {
                for (int i = 0; i < l.Count; i++)
                {
                    flowLayoutPanelProd.Controls.Remove(l[i]);
                    listProdRem.Add(l[i]);
                }
            }

            ContarItens();
        }
Пример #4
0
        private static void FormatTextBox_AoPerderFoco(object sender, EventArgs e)
        {
            TextBox box = sender as TextBox;

            if (!FormTextoFormat.ValidaEmail(box.Text))
            {
                FormMessage.ShowMessegeWarning("E-mail inválido, campo será definico como \" [email protected]\"");
                box.Text = "*****@*****.**";
            }
        }
Пример #5
0
        private void buttonSelecionar_Click(object sender, EventArgs e)
        {
            if (numericUpDown1.Value == 0)
            {
                return;
            }

            //lista de bilhetes livres para seleção
            List <UserControlBilhete> numBilhetes = new List <UserControlBilhete>();

            //preencher a lista de bilhestes livres
            foreach (Control item in flowLayoutPanel1.Controls)
            {
                UserControlBilhete b = (UserControlBilhete)item;
                if (b.Botao.Enabled && b.Botao.BackColor != Color.GreenYellow)
                {
                    numBilhetes.Add(b);
                }
            }

            if (numBilhetes.Count < (int)numericUpDown1.Value)
            {
                if (numBilhetes.Count == 0)
                {
                    FormMessage.ShowMessegeWarning("Todos os bilhetes já foram vendidos!");
                }
                else
                {
                    if (FormMessage.ShowMessegeQuestion("Há somente " + numBilhetes.Count + " bilhetes para serem vendidos, deseja selecionar todos?") == DialogResult.Yes)
                    {
                        foreach (var item in numBilhetes)
                        {
                            Button b = item.Botao;
                            BotaoSelcionado(b);
                        }
                    }
                }

                return;
            }

            //lista dos numeros aleatórios
            List <int> numA = Aleatorio.Gerar(numBilhetes.Count, (int)numericUpDown1.Value);

            //seleciona da lista com bilhetes sorteado
            foreach (var item in numA)
            {
                Button b = numBilhetes[item].Botao;
                BotaoSelcionado(b);
            }
            numericUpDown1.Value = 0;


            ContarVerde();
        }
 private void Selecionar()
 {
     if (dataGridViewConsultar.SelectedRows.Count > 0)
     {
         Selecionado  = (Form_Consultar)dataGridViewConsultar.SelectedRows[0].DataBoundItem;
         DialogResult = DialogResult.Yes;
     }
     else
     {
         FormMessage.ShowMessegeWarning("Selecione um item da lista!");
     }
 }
Пример #7
0
 private void buttonSalvar_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(textBoxDescricaoSort.Text) && flowLayoutPanelProd.Controls.Count > 0)
     {
         if (FormMessage.ShowMessegeQuestion("Deseja salvar?") == DialogResult.Yes)
         {
             Salvar();
         }
     }
     else
     {
         FormMessage.ShowMessegeWarning("Insira uma descrição para o sorteio e adicione no mínimo um produto para salvar!");
         textBoxDescricaoSort.Select();
     }
 }
Пример #8
0
        public static bool ValidaEmail(string texto)
        {
            string padrao = @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                            @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$"; //@"(@\w+\.\w+)(\.\w+)*$";

            string novoTexto = FormatarEmail(texto).Trim();

            Regex er = new Regex(padrao, RegexOptions.IgnoreCase);

            if (er.IsMatch(novoTexto))
            {
                return(true);
            }
            else
            {
                FormMessage.ShowMessegeWarning(texto + " EMAIL INVÁLIDO!");
                return(false);
            }
        }
Пример #9
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox1.Text))
            {
                if (Txt != enumTexto.texto)
                {
                    if (Convert.ToInt32(textBox1.Text) == 0)
                    {
                        FormMessage.ShowMessegeWarning("Insira valores diferente de zero!");
                        textBox1.Clear();
                        textBox1.Select();
                        return;
                    }
                }

                Descricao         = textBox1.Text;
                this.DialogResult = DialogResult.Yes;
            }
            else
            {
                FormMessage.ShowMessegeWarning("Preencha o campo!");
            }
        }
Пример #10
0
        private void PreencherProd()
        {
            using (OpenFileDialog open = new OpenFileDialog())
            {
                open.Title            = "Selecionar uma foto...";
                open.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                open.Filter           = "Arquivos(*.jpg, *.jpeg, *.png)|*.jpg;*.jpeg;*.png";
                //open.RestoreDirectory = true;

                if (open.ShowDialog() == DialogResult.OK)
                {
                    FileInfo file = new FileInfo(open.FileName);

                    if (file.Length < 50000)
                    {
                        try
                        {
                            img = Image.FromStream(open.OpenFile());
                            pictureBox1.Image = img;
                        }
                        catch (Exception)
                        {
                            FormMessage.ShowMessegeWarning("A imagem apresentou algum tipo de incompatibilidade, selecione outra!");
                            PreencherProd();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Este arquivo possue mais de 50KB, a foto deve ser menor!");
                        PreencherProd();
                    }
                }
            }

            textBoxDescricaoProd.Select();
        }
Пример #11
0
        private void buttonSalvar_Click(object sender, EventArgs e)
        {
            //negCon = new ConcorrenteNegocio();
            //negSort = new SorteioNegocio();
            //ConcorrenteColecao col = negCon.CadTest();
            //ConcorrenteColecao col2 = (ConcorrenteColecao)negCon.ExecutarConcorrente(enumCRUD.select);
            //ConcorrenteColecao col3 = (ConcorrenteColecao)negCon.ExecutarConcorrente(enumCRUD.select, null, true);

            //foreach (var item in col)
            //{
            //    BilheteInfo b = new BilheteInfo
            //    {
            //        bilheteidconcorrente = col2.Where(w => w.concorrentenome == item.concorrentenome).FirstOrDefault(),
            //        bilheteidvendedor = col3.Where(w => w.concorrentenome == item.concorrenteemail.ToUpper()).FirstOrDefault(),
            //        bilheteidsorteio = new SorteioInfo { sorteioid = 1},
            //        bilhetenum = Convert.ToInt32(item.concorrentecpf)
            //    };

            //    negSort.ExecutarBilhete(enumCRUD.insert, b);
            //}

            //FormMessage.ShowMessageSave();
            //return;

            if (string.IsNullOrEmpty(textBoxNome.Text) || string.IsNullOrEmpty(textBoxIdSort.Text) || string.IsNullOrEmpty(textBoxVendCod.Text))
            {
                if (string.IsNullOrEmpty(textBoxNome.Text))
                {
                    FormMessage.ShowMessegeWarning("Selecione o concorrente!");
                    button1.Select();
                    return;
                }

                if (string.IsNullOrEmpty(textBoxIdSort.Text))
                {
                    FormMessage.ShowMessegeWarning("Selecione um sorteio!");
                    buttonSort.Select();
                    return;
                }

                if (string.IsNullOrEmpty(textBoxVendCod.Text))
                {
                    FormMessage.ShowMessegeWarning("Selecione o vendedor!");
                    buttonVendBuscar.Select();
                    return;
                }
            }

            if (FormMessage.ShowMessegeQuestion("Salvar?") == DialogResult.Yes)
            {
                this.Cursor = Cursors.WaitCursor;
                int         id = 0;
                BilheteInfo b1 = new BilheteInfo {
                    bilheteidconcorrente = infoConc, bilheteidsorteio = infoSort, bilheteidvendedor = infoVend
                };
                negSort.ExecutarBilhete(enumCRUD.delete, b1);
                foreach (var item in flowLayoutPanel1.Controls)
                {
                    UserControlBilhete bi = (UserControlBilhete)item;

                    if (bi.Botao.BackColor == Color.GreenYellow)
                    {
                        BilheteInfo b = new BilheteInfo
                        {
                            bilheteidconcorrente = infoConc,
                            bilheteidsorteio     = infoSort,
                            bilheteidvendedor    = infoVend,
                            bilhetenum           = Convert.ToInt32(bi.Botao.Text)
                        };
                        id = (int)negSort.ExecutarBilhete(enumCRUD.insert, b);
                    }
                }

                this.Cursor = Cursors.Default;

                if (id > 0)
                {
                    FormMessage.ShowMessageSave();
                    Limpar();
                }
                else
                {
                    FormMessage.ShowMessegeWarning("Nenhum bilhete selecionado!");
                }
            }
        }