Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog arquivoExcel = new OpenFileDialog();

            if (arquivoExcel.ShowDialog() == DialogResult.OK)
            {
                string          caminho = arquivoExcel.FileName;
                OleDbConnection con     = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + arquivoExcel.FileName + ";Extended Properties=Excel 12.0;");
                con.Open();
                //DataSet excelDataSet = new DataSet();
                OleDbDataAdapter query     = new OleDbDataAdapter(" SELECT * FROM [Banco de Dados$]order by nome", con);
                DataTable        dataTable = new DataTable();
                query.Fill(dataTable);
                int mat = dataTable.Rows.Count;

                dataGridView1.Rows.Clear();
                foreach (DataRow dtRow in dataTable.Rows)
                {
                    int n = dataGridView1.Rows.Add();
                    dataGridView1.Rows[n].Cells[0].Value = dtRow[1].ToString().ToUpper();
                    dataGridView1.Rows[n].Cells[1].Value = Convert.ToDateTime(dtRow[3].ToString()).ToString("dd/MM/yyyy");
                    dataGridView1.Rows[n].Cells[2].Value = Convert.ToString(dtRow[4].ToString()).TrimEnd().ToUpper() + ", " + dtRow[5].ToString();
                    dataGridView1.Rows[n].Cells[3].Value = dtRow[7].ToString().ToUpper();
                    dataGridView1.Rows[n].Cells[4].Value = dtRow[8].ToString().ToUpper();
                    dataGridView1.Rows[n].Cells[5].Value = dtRow[9].ToString();
                    dataGridView1.Rows[n].Cells[6].Value = dtRow[10].ToString().ToUpper();
                    dataGridView1.Rows[n].Cells[7].Value = dtRow[2].ToString().ToUpper();
                }
                string      ms  = "ANTES DE PROSSEGUIR VERIFIQUE SE HÁ CADASTROS DUPLICADOS, CASO ENCONTRE, CLIQUE DUAS VEZES SOBRE A LINHA PARA EXCLUÍ-LO, APÓS VERIFICAR, CLIQUE NO BOTÃO 3º GRAVAR DADOS";
                frmLembrete frm = new frmLembrete(ms);
                frm.ShowDialog();
            }
        }
Example #2
0
        private void frmSorteados_Load(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            foreach (DataRow dtRow in ci.sorteioMeninas().Rows)
            {
                int n = dataGridView1.Rows.Add();
                dataGridView1.Rows[n].Cells[1].Value = dtRow["cod"].GetHashCode();
                dataGridView1.Rows[n].Cells[2].Value = dtRow["nome"].ToString().ToUpper();
                dataGridView1.Rows[n].Cells[3].Value = dtRow["dtNasc"].ToString();
                dataGridView1.Rows[n].Cells[4].Value = dtRow["endereco"].ToString().ToUpper();
                dataGridView1.Rows[n].Cells[5].Value = dtRow["telefone"].ToString();
                dataGridView1.Rows[n].Cells[6].Value = dtRow["cidade"].ToString().ToUpper();
                dataGridView1.Rows[n].Cells[7].Value = dtRow["cep"].ToString();
                dataGridView1.Rows[n].Cells[8].Value = dtRow["sexo"].ToString().ToUpper();
                dataGridView1.Rows[n].Cells[9].Value = dtRow["escalada"].ToString();
                ins.Nome     = dtRow["nome"].ToString().ToUpper();
                ins.Endereco = dtRow["endereco"].ToString().ToUpper();
                ins.Escalada = dtRow["escalada"].ToString();
                //MessageBox.Show("" + ci.verificaSorteados(ins).Rows[1][1].ToString());
                if (ci.verificaSorteados(ins).Rows.Count > 0)
                {
                    if (ci.verificaSorteados(ins).Rows[0][1].ToString() == dtRow["nome"].ToString().ToUpper() && ci.verificaSorteados(ins).Rows[0][2].ToString() == dtRow["endereco"].ToString().ToUpper())
                    {
                        dataGridView1.Rows[n].Cells[0].Value = true;
                        if (dtRow["sexo"].ToString().ToUpper() == "FEMININO")
                        {
                            fem           = fem + 1;
                            textBox1.Text = Convert.ToString(fem);
                        }
                        else if (dtRow["sexo"].ToString().ToUpper() == "MASCULINO")
                        {
                            masc          = masc + 1;
                            textBox2.Text = Convert.ToString(masc);
                        }
                    }
                }
            }
            string      ms  = "CONFIRA TODOS OS DADOS E FAÇA AS CORREÇÕES, CASO HOUVER, ANTES DE CLICAR NA COLUNA SORTEADO(A)";
            frmLembrete frm = new frmLembrete(ms);

            frm.ShowDialog();
        }
Example #3
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            if (aviso == "")
            {
                string msg = "Sempre antes de apagar uma data, a não ser que tenha cadastrado errado, atualize as porcentagens para eleição.";
                frmLembrete mg = new frmLembrete(msg);
                mg.ShowDialog();
                button2.Focus();
                aviso = "Ok";
            }
            else
            {
                int pos;
                pos = dataGridView1.CurrentRow.Index.GetHashCode();
                va.Data = Convert.ToDateTime(dataGridView1.Rows[pos].Cells[0].Value.ToString());
                string dt = (Convert.ToDateTime(va.Data).ToString("ddMMyyyy"));
                string aux = ("data" + Convert.ToString(dt));

                string message = "Deseja realmente excluir a data " + Convert.ToDateTime(va.Data).ToString("dd/MM/yyyy") + "?";
                string caption = "Confirmar exclusão";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult result;

                result = MessageBox.Show(message, caption, buttons);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    dataGridView1.Rows.RemoveAt(pos);

                    try
                    {
                        co.DeletarData(va);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Erro de comandos: " + ex.Message);
                    }
                }
            }
        }