Esempio n. 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            int cont = dataGridView1.Rows.Count;

            if (cont == 0)
            {
                string       msg = "NÃO EXISTE DADOS PARA GERAR O EXCEL";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
            }
            else
            {
                int l = 3;
                salvarArquivo.FileName   = "Lista de Telefones - 2ª Opção" + " - " + comboBox2.Text.Remove(comboBox2.Text.Length - 10);
                salvarArquivo.DefaultExt = "*.xls";
                salvarArquivo.Filter     = "Todos os Aquivos do Excel (*.xls)|*.xls| Todos os arquivos (*.*)|*.*";

                try
                {
                    xlApp      = new Excel.Application();
                    xlWorkBook = xlApp.Workbooks.Add(misValue);

                    xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                    xlWorkSheet.PageSetup.Orientation    = Excel.XlPageOrientation.xlLandscape;
                    xlWorkSheet.PageSetup.TopMargin      = 2;
                    xlWorkSheet.PageSetup.BottomMargin   = 1;
                    xlWorkSheet.PageSetup.LeftMargin     = 0;
                    xlWorkSheet.PageSetup.RightMargin    = 0;
                    xlWorkSheet.PageSetup.PrintTitleRows = "$A$2:$H$2";
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 8]].Merge();
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 8]].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[1, 1]             = "Lista de Telefones - 2ª Opção" + " - " + comboBox2.Text.Remove(comboBox2.Text.Length - 10);
                    xlWorkSheet.Cells[1, 1].ColumnWidth = 7;
                    xlWorkSheet.Cells[1, 2].ColumnWidth = 20;
                    xlWorkSheet.Cells[1, 3].ColumnWidth = 30;
                    xlWorkSheet.Cells[1, 4].ColumnWidth = 35;
                    xlWorkSheet.Cells[1, 5].ColumnWidth = 14;
                    xlWorkSheet.Cells[1, 6].ColumnWidth = 14;
                    xlWorkSheet.Cells[1, 7].ColumnWidth = 7;
                    xlWorkSheet.Cells[1, 8].ColumnWidth = 8.43;
                    xlWorkSheet.Cells[1, 1].Font.Size   = 16;
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 8]].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 1] = "CLASS";
                    xlWorkSheet.Cells[2, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 1].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 2] = "CURSO";
                    xlWorkSheet.Cells[2, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 2].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 3] = "NOME";
                    xlWorkSheet.Cells[2, 3].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 3].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 4] = "ENDEREÇO";
                    xlWorkSheet.Cells[2, 4].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 4].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 5] = "TELEFONE";
                    xlWorkSheet.Cells[2, 5].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 5].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 6] = "CELULAR";
                    xlWorkSheet.Cells[2, 6].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 6].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 7] = "ESC.";
                    xlWorkSheet.Cells[2, 7].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 7].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 8] = "OBS.";
                    xlWorkSheet.Cells[2, 8].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 8].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;

                    xlWorkSheet.Range[xlWorkSheet.Cells[2, 1], xlWorkSheet.Cells[2, 7]].Font.Size = 12;
                    int quant = dataGridView1.Rows.Count;

                    progressBar1.Visible = true;
                    progressBar1.Maximum = quant;
                    for (int i = 0; i < quant; i++)
                    {
                        if (dataGridView1.Rows[i].DefaultCellStyle.BackColor == Color.Violet || dataGridView1.Rows[i].DefaultCellStyle.BackColor == Color.GreenYellow || dataGridView1.Rows[i].DefaultCellStyle.BackColor == Color.Salmon)
                        {
                            xlWorkSheet.Range[xlWorkSheet.Cells[l, 1], xlWorkSheet.Cells[l, 8]].Interior.Color = ColorTranslator.ToWin32(Color.Yellow);
                        }
                        else
                        {
                            xlWorkSheet.Range[xlWorkSheet.Cells[l, 1], xlWorkSheet.Cells[l, 8]].Interior.Color = ColorTranslator.ToWin32(Color.White);
                        }
                        xlWorkSheet.Cells[l, 1] = dataGridView1.Rows[i].Cells[3].Value.ToString();
                        xlWorkSheet.Cells[l, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 1].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 2] = dataGridView1.Rows[i].Cells[4].Value.ToString();
                        xlWorkSheet.Cells[l, 2].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 3] = dataGridView1.Rows[i].Cells[8].Value.ToString();
                        xlWorkSheet.Cells[l, 3].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 4] = dataGridView1.Rows[i].Cells[9].Value.ToString();
                        xlWorkSheet.Cells[l, 4].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 5] = dataGridView1.Rows[i].Cells[10].Value.ToString();
                        xlWorkSheet.Cells[l, 5].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 5].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 6] = dataGridView1.Rows[i].Cells[11].Value.ToString();
                        xlWorkSheet.Cells[l, 6].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 6].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 7] = dataGridView1.Rows[i].Cells[12].Value.ToString();
                        xlWorkSheet.Cells[l, 7].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 7].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 8].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        l = l + 1;
                        progressBar1.Value++;
                    }
                    xlWorkSheet.Application.Columns[2].ShrinkToFit = true;
                    xlWorkSheet.Application.Columns[3].ShrinkToFit = true;
                    xlWorkSheet.Application.Columns[4].ShrinkToFit = true;
                    progressBar1.Value   = 0;
                    progressBar1.Visible = false;

                    new System.Threading.Thread(delegate()
                    {
                        Export();
                    }).Start();
                }
                catch (Exception ex)
                {
                    string       msg = "Erro : " + ex.Message;
                    frm_Mensagem mg  = new frm_Mensagem(msg);
                    mg.ShowDialog();
                }
            }
        }
Esempio n. 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (maskedTextBox1.MaskCompleted && textBox3.Text != "")
            {
                int cont = dataGridView1.Rows.Count;
                if (cont == 0)
                {
                    string       msg = "NÃO EXISTE DADOS PARA GERAR O EXCEL";
                    frm_Mensagem mg  = new frm_Mensagem(msg);
                    mg.ShowDialog();
                }
                else
                {
                    int l = 3;
                    salvarArquivo.FileName   = "Lista de APM - 2ª Opção" + " - " + comboBox2.Text.Remove(comboBox2.Text.Length - 10);
                    salvarArquivo.DefaultExt = "*.xls";
                    salvarArquivo.Filter     = "Todos os Aquivos do Excel (*.xls)|*.xls| Todos os arquivos (*.*)|*.*";

                    try
                    {
                        xlApp      = new Excel.Application();
                        xlWorkBook = xlApp.Workbooks.Add(misValue);

                        xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                        xlWorkSheet.PageSetup.Orientation    = Excel.XlPageOrientation.xlPortrait;
                        xlWorkSheet.PageSetup.TopMargin      = 1;
                        xlWorkSheet.PageSetup.BottomMargin   = 1;
                        xlWorkSheet.PageSetup.LeftMargin     = 1;
                        xlWorkSheet.PageSetup.RightMargin    = 1;
                        xlWorkSheet.PageSetup.PrintTitleRows = "$A$2:$G$2";
                        xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 7]].Merge();
                        xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 7]].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 7]].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[1, 1]                     = "Lista de APM - 2ª Opção" + " - " + comboBox2.Text.Remove(comboBox2.Text.Length - 10);
                        xlWorkSheet.Cells[1, 1].ColumnWidth         = 4.86;
                        xlWorkSheet.Cells[1, 2].ColumnWidth         = 35;
                        xlWorkSheet.Cells[1, 3].ColumnWidth         = 4.71;
                        xlWorkSheet.Cells[1, 4].ColumnWidth         = 5.29;
                        xlWorkSheet.Cells[1, 5].ColumnWidth         = 18;
                        xlWorkSheet.Cells[1, 6].ColumnWidth         = 20;
                        xlWorkSheet.Cells[1, 7].ColumnWidth         = 6;
                        xlWorkSheet.Cells[1, 1].Font.Size           = 16;
                        xlWorkSheet.Cells[2, 1]                     = "MATR.";
                        xlWorkSheet.Cells[2, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[2, 1].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[2, 1].Font.Size           = 10;
                        xlWorkSheet.Cells[2, 2]                     = "NOME";
                        xlWorkSheet.Cells[2, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[2, 2].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[2, 2].Font.Size           = 10;
                        xlWorkSheet.Cells[2, 3]                     = "CLASS.";
                        xlWorkSheet.Cells[2, 3].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[2, 3].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[2, 3].Font.Size           = 10;
                        xlWorkSheet.Cells[2, 4]                     = "ESC.";
                        xlWorkSheet.Cells[2, 4].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[2, 4].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[2, 4].Font.Size           = 10;
                        xlWorkSheet.Range[xlWorkSheet.Cells[2, 5], xlWorkSheet.Cells[2, 7]].Merge();
                        xlWorkSheet.Range[xlWorkSheet.Cells[2, 5], xlWorkSheet.Cells[2, 7]] = "APM";
                        xlWorkSheet.Range[xlWorkSheet.Cells[2, 5], xlWorkSheet.Cells[2, 7]].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Range[xlWorkSheet.Cells[2, 5], xlWorkSheet.Cells[2, 7]].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Range[xlWorkSheet.Cells[2, 1], xlWorkSheet.Cells[2, 7]].Font.Size           = 10;
                        int quant = dataGridView1.Rows.Count;

                        progressBar1.Visible = true;
                        progressBar1.Maximum = quant;
                        for (int i = 0; i < quant; i++)
                        {
                            xlWorkSheet.Cells[l, 1] = "";
                            xlWorkSheet.Cells[l, 1].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 2] = dataGridView1.Rows[i].Cells[8].Value.ToString();
                            xlWorkSheet.Cells[l, 2].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 3] = dataGridView1.Rows[i].Cells[3].Value.ToString();
                            xlWorkSheet.Cells[l, 3].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 3].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 4] = dataGridView1.Rows[i].Cells[12].Value.ToString();
                            xlWorkSheet.Cells[l, 4].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 4].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 5] = "(  ) PG R$ " + textBox3.Text + label10.Text + "_______";
                            xlWorkSheet.Cells[l, 5].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 5].Font.Size           = 9;
                            xlWorkSheet.Cells[l, 5].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 6]                     = "(  ) Pagará até " + maskedTextBox1.Text;
                            xlWorkSheet.Cells[l, 6].Font.Size           = 9;
                            xlWorkSheet.Cells[l, 6].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 6].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 7]                     = "(  ) NÃO";
                            xlWorkSheet.Cells[l, 7].Font.Size           = 9;
                            xlWorkSheet.Cells[l, 7].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 7].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            l = l + 1;
                            progressBar1.Value++;
                        }
                        xlWorkSheet.Application.Columns[2].ShrinkToFit = true;
                        progressBar1.Value = 0;

                        int linhas = 0;
                        if (quant < 55)
                        {
                            linhas = 55;
                        }
                        else if (quant > 55 && quant < 110)
                        {
                            linhas = 110;
                        }
                        else if (quant > 110 && quant < 165)
                        {
                            linhas = 165;
                        }

                        progressBar1.Value   = 0;
                        progressBar1.Maximum = (linhas - l) + 1;
                        for (int i = l; i <= linhas; i++)
                        {
                            xlWorkSheet.Cells[l, 1] = "";
                            xlWorkSheet.Cells[l, 1].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 2] = "";
                            xlWorkSheet.Cells[l, 2].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 3] = "";
                            xlWorkSheet.Cells[l, 3].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 3].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 4] = "";
                            xlWorkSheet.Cells[l, 4].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 4].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 5] = "(  ) PG R$ " + textBox3.Text + label10.Text + "_______";
                            xlWorkSheet.Cells[l, 5].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 5].Font.Size           = 9;
                            xlWorkSheet.Cells[l, 5].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 6]                     = "(  ) Pagará até " + maskedTextBox1.Text;
                            xlWorkSheet.Cells[l, 6].Font.Size           = 9;
                            xlWorkSheet.Cells[l, 6].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 6].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            xlWorkSheet.Cells[l, 7]                     = "(  ) NÃO";
                            xlWorkSheet.Cells[l, 7].Font.Size           = 9;
                            xlWorkSheet.Cells[l, 7].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            xlWorkSheet.Cells[l, 7].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                            l = l + 1;
                            progressBar1.Value++;
                        }
                        progressBar1.Value   = 0;
                        progressBar1.Visible = false;
                        new System.Threading.Thread(delegate()
                        {
                            Export();
                        }).Start();
                    }
                    catch (Exception ex)
                    {
                        string       msg = "Erro : " + ex.Message;
                        frm_Mensagem mg  = new frm_Mensagem(msg);
                        mg.ShowDialog();
                    }
                }
            }
            else
            {
                string       msg = "INFORMAR O VALOR E ATÉ QUANDO PODERÁ PAGAR A APM";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            aux = "";
            foreach (DataRow item in cg.Verificar(gr).Rows)
            {
                unidade = item["escola"].ToString();
                vest    = item["vestibulinho"].ToString();
                if (unidade == dataGridView2.Rows[1].Cells[14].Value.ToString() && vest == comboBox1.Text + " " + textBox1.Text)
                {
                    aux = "Ok";
                }
            }

            if (aux == "Ok")
            {
                string       msg = "DADOS JÁ CADASTRADOS NO SISTEMA";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
            }
            else
            {
                if (dataGridView1.Rows.Count == 0)
                {
                    string       msg = "SELECIONAR UM ARQUIVO COM O BANCO DE DADOS";
                    frm_Mensagem mg  = new frm_Mensagem(msg);
                    mg.ShowDialog();
                }
                else if (comboBox1.Text == "" || textBox1.Text == "")
                {
                    string       msg = "INFORME O SEMESTRE E O ANO DO VESTIBULINHO";
                    frm_Mensagem mg  = new frm_Mensagem(msg);
                    mg.ShowDialog();
                }
                else
                {
                    int quant = dataGridView2.Rows.Count;
                    progressBar1.Visible = true;
                    progressBar1.Maximum = quant;

                    for (int i = 0; i < quant; i++)
                    {
                        gr.Classificacao   = dataGridView2.Rows[i].Cells[0].Value.ToString();
                        gr.Nota            = dataGridView2.Rows[i].Cells[1].Value.ToString();
                        gr.Habilitacao     = dataGridView2.Rows[i].Cells[2].Value.ToString();
                        gr.Nome            = dataGridView2.Rows[i].Cells[3].Value.ToString();
                        gr.Sexo            = dataGridView2.Rows[i].Cells[4].Value.ToString();
                        gr.Endereco        = dataGridView2.Rows[i].Cells[5].Value.ToString();
                        gr.Telefone        = dataGridView2.Rows[i].Cells[6].Value.ToString();
                        gr.Celular         = dataGridView2.Rows[i].Cells[7].Value.ToString();
                        gr.Cidade          = dataGridView2.Rows[i].Cells[8].Value.ToString();
                        gr.DtNascimento    = dataGridView2.Rows[i].Cells[9].Value.ToString();
                        gr.Email           = dataGridView2.Rows[i].Cells[10].Value.ToString();
                        gr.Afrodescendente = dataGridView2.Rows[i].Cells[11].Value.ToString();
                        gr.Escolaridade    = dataGridView2.Rows[i].Cells[12].Value.ToString();
                        gr.Periodo         = dataGridView2.Rows[i].Cells[13].Value.ToString();
                        gr.Situacao        = dataGridView2.Rows[i].Cells[14].Value.ToString();
                        gr.Vestibulinho    = comboBox1.Text + " " + textBox1.Text;
                        gr.Escola          = dataGridView2.Rows[i].Cells[15].Value.ToString();
                        gr.Habilitacao2    = dataGridView2.Rows[i].Cells[16].Value.ToString();
                        gr.Periodo2        = dataGridView2.Rows[i].Cells[17].Value.ToString();
                        gr.Classificacao2  = dataGridView2.Rows[i].Cells[18].Value.ToString();
                        cg.cadastro(gr);
                        progressBar1.Value++;
                    }
                    progressBar1.Visible = false;
                    progressBar1.Value   = 0;
                    string       msg = "DADOS CADASTRADOS COM SUCESSO";
                    frm_Mensagem mg  = new frm_Mensagem(msg);
                    mg.ShowDialog();

                    comboBox1.Text = "";
                    textBox1.Text  = "";
                }
                button2.Enabled = false;
            }
        }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "")
            {
                string       msg = "INFORME O SEMESTRE E O ANO DO VESTIBULINHO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox1.Focus();
            }
            else if (comboBox2.Text == "")
            {
                string       msg = "INFORME O CURSO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox2.Focus();
            }
            else if (comboBox4.Text == "")
            {
                string       msg = "INFORME O PERÍODO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox4.Focus();
            }
            else
            {
                string curso;
                vg.Vestibulinho = comboBox1.Text;
                curso           = comboBox2.Text;
                vg.Curso        = curso.Remove(curso.Length - 10);
                string vaga = cv.SelecionaVagas(vg).Rows[0]["VAGAS"].ToString();
                vg.Periodo           = comboBox4.Text;
                vg.Escola            = comboBox2.Text.Substring(comboBox2.Text.Length - 7);
                vg.Vaga              = vaga;
                progressBar1.Visible = true;

                dataGridView1.Rows.Clear();
                foreach (DataRow item in co.SegundaOpcao(vg).Rows)
                {
                    if (item["HABILITACAO2"].ToString() != "-")
                    {
                        if (item["CLAS2"].ToString() != "")
                        {
                            int n = dataGridView1.Rows.Add();
                            //dataGridView1.Rows[n].Cells[0].Value = item["COD"].GetHashCode();
                            dataGridView1.Rows[n].Cells[2].Value  = item["COD"].GetHashCode();
                            dataGridView1.Rows[n].Cells[3].Value  = item["CLAS"].ToString();
                            dataGridView1.Rows[n].Cells[4].Value  = item["HABILITACAO"].ToString() + " - " + item["PERIODO"].ToString();
                            dataGridView1.Rows[n].Cells[5].Value  = item["CLAS2"].ToString();
                            dataGridView1.Rows[n].Cells[6].Value  = item["HABILITACAO2"].ToString() + " - " + item["PERIODO2"].ToString();
                            dataGridView1.Rows[n].Cells[7].Value  = item["NOTA"].ToString();
                            dataGridView1.Rows[n].Cells[8].Value  = item["NOME"].ToString();
                            dataGridView1.Rows[n].Cells[9].Value  = item["ENDERECO"].ToString();
                            dataGridView1.Rows[n].Cells[10].Value = item["TELEFONE"].ToString();
                            dataGridView1.Rows[n].Cells[11].Value = item["CELULAR"].ToString();
                            dataGridView1.Rows[n].Cells[12].Value = item["ESCOL"].ToString();
                            //DateTime dta = Convert.ToDateTime(item["dtNasc"].ToString());
                            int idade = Idade(Convert.ToDateTime(item["dtNasc"].ToString()));
                            //MessageBox.Show(""+idade);
                            if ((item["HABILITACAO"].ToString() == "ENSINO MÉDIO" || item["HABILITACAO"].ToString() == "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" || item["HABILITACAO"].ToString().Contains("NOVOTEC") == true) && (idade <= 13))
                            {
                                dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                            }
                            else if ((item["HABILITACAO"].ToString() != "ENSINO MÉDIO" && item["HABILITACAO"].ToString() != "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" && item["HABILITACAO"].ToString().Contains("NOVOTEC") == false) && (idade <= 14))
                            {
                                dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                            }
                            if (item["matriculado"].ToString() == "Sim")
                            {
                                dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.GreenYellow;
                                dataGridView1.Rows[n].Cells[1].Value             = true;
                            }
                            if (item["CHAMADA"].ToString() == "2ª Opção")
                            {
                                dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Salmon;
                            }
                            dataGridView1.Columns[3].DefaultCellStyle.BackColor = Color.Aqua;
                            dataGridView1.Columns[4].DefaultCellStyle.BackColor = Color.Aqua;
                            dataGridView1.Columns[5].DefaultCellStyle.BackColor = Color.Orange;
                            dataGridView1.Columns[6].DefaultCellStyle.BackColor = Color.Orange;

                            if (dataGridView1.Rows[n].DefaultCellStyle.BackColor == Color.GreenYellow)
                            {
                                dataGridView1.Rows[n].Cells[1].ReadOnly = true;
                            }

                            if (item["ausSegOp"].ToString() == "Sim")
                            {
                                dataGridView1.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
                                dataGridView1.Rows[n].DefaultCellStyle.Font      = new Font(DataGridView.DefaultFont, FontStyle.Strikeout);
                                dataGridView1.Rows[n].Cells[0].Value             = true;
                            }
                        }
                    }
                }
                button3.Enabled        = true;
                button4.Enabled        = true;
                textBox3.Enabled       = true;
                maskedTextBox1.Enabled = true;
                progressBar1.Visible   = false;
            }
            textBox1.Text = co.TotalMatriculado(vg).Rows[0][0].ToString();
        }
 public void Pesquisa()
 {
     vg.Vestibulinho = comboBox1.Text;
     vg.Periodo      = comboBox4.Text;
     vg.Nome         = textBox1.Text;
     dataGridView1.Rows.Clear();
     if (comboBox3.Text == "")
     {
         string       msg = "INFORME O TIPO DE PESQUISA";
         frm_Mensagem mg  = new frm_Mensagem(msg);
         mg.ShowDialog();
         comboBox1.Focus();
     }
     else
     {
         if (comboBox3.Text == "Curso")
         {
             if (comboBox1.Text == "")
             {
                 string       msg = "INFORME O SEMESTRE E O ANO DO VESTIBULINHO";
                 frm_Mensagem mg  = new frm_Mensagem(msg);
                 mg.ShowDialog();
                 comboBox1.Focus();
             }
             else if (comboBox2.Text == "")
             {
                 string       msg = "INFORME O CURSO";
                 frm_Mensagem mg  = new frm_Mensagem(msg);
                 mg.ShowDialog();
                 comboBox2.Focus();
             }
             else if (comboBox4.Text == "")
             {
                 string       msg = "INFORME O PERÍODO";
                 frm_Mensagem mg  = new frm_Mensagem(msg);
                 mg.ShowDialog();
                 comboBox4.Focus();
             }
             else
             {
                 string curso;
                 curso     = comboBox2.Text;
                 vg.Curso  = curso.Remove(curso.Length - 10);
                 vg.Escola = comboBox2.Text.Substring(comboBox2.Text.Length - 7);
                 foreach (DataRow item in co.Pesquisa(vg).Rows)
                 {
                     if (item["CLAS"].ToString() != "")
                     {
                         int n = dataGridView1.Rows.Add();
                         dataGridView1.Rows[n].Cells[0].Value = item["CLAS"].ToString();
                         dataGridView1.Rows[n].Cells[1].Value = item["NOTA"].ToString();
                         dataGridView1.Rows[n].Cells[2].Value = item["NOME"].ToString();
                         dataGridView1.Rows[n].Cells[3].Value = item["ENDERECO"].ToString();
                         dataGridView1.Rows[n].Cells[4].Value = item["TELEFONE"].ToString();
                         dataGridView1.Rows[n].Cells[5].Value = item["CELULAR"].ToString();
                         dataGridView1.Rows[n].Cells[6].Value = item["HABILITACAO"].ToString();
                         int idade = Idade(Convert.ToDateTime(item["dtNasc"].ToString()));
                         if ((item["HABILITACAO"].ToString() == "ENSINO MÉDIO" || item["HABILITACAO"].ToString() == "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" || item["HABILITACAO"].ToString().Contains("NOVOTEC") == true) && (idade <= 13))
                         {
                             dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                         }
                         else if ((item["HABILITACAO"].ToString() != "ENSINO MÉDIO" && item["HABILITACAO"].ToString() != "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" && item["HABILITACAO"].ToString().Contains("NOVOTEC") == false) && (idade <= 14))
                         {
                             dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                         }
                         dataGridView1.Rows[n].Cells[7].Value = item["ESCOL"].ToString();
                         if (item["matriculado"].ToString() == "Sim")
                         {
                             dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.GreenYellow;
                         }
                         if (item["chamada"].ToString() == "2ª Opção" && item["matriculado"].ToString() == "Sim")
                         {
                             dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Orange;
                         }
                     }
                 }
             }
         }
         else if (comboBox3.Text == "Nome")
         {
             if (comboBox1.Text == "")
             {
                 string       msg = "INFORME O SEMESTRE E O ANO DO VESTIBULINHO";
                 frm_Mensagem mg  = new frm_Mensagem(msg);
                 mg.ShowDialog();
                 comboBox1.Focus();
             }
             else
             {
                 foreach (DataRow item in co.ListaoPorNome(vg).Rows)
                 {
                     int n = dataGridView1.Rows.Add();
                     dataGridView1.Rows[n].Cells[0].Value = item["CLAS"].ToString();
                     dataGridView1.Rows[n].Cells[1].Value = item["NOTA"].ToString();
                     dataGridView1.Rows[n].Cells[2].Value = item["NOME"].ToString();
                     dataGridView1.Rows[n].Cells[3].Value = item["ENDERECO"].ToString();
                     dataGridView1.Rows[n].Cells[4].Value = item["TELEFONE"].ToString();
                     dataGridView1.Rows[n].Cells[5].Value = item["CELULAR"].ToString();
                     dataGridView1.Rows[n].Cells[6].Value = item["HABILITACAO"].ToString();
                     int idade = Idade(Convert.ToDateTime(item["dtNasc"].ToString()));
                     if ((item["HABILITACAO"].ToString() == "ENSINO MÉDIO" || item["HABILITACAO"].ToString() == "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" || item["HABILITACAO"].ToString().Contains("NOVOTEC") == true) && (idade <= 13))
                     {
                         dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                     }
                     else if ((item["HABILITACAO"].ToString() != "ENSINO MÉDIO" && item["HABILITACAO"].ToString() != "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" && item["HABILITACAO"].ToString().Contains("NOVOTEC") == false) && (idade <= 14))
                     {
                         dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                     }
                     dataGridView1.Rows[n].Cells[7].Value = item["ESCOL"].ToString();
                     if (item["matriculado"].ToString() == "Sim")
                     {
                         dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.GreenYellow;
                     }
                     if (item["chamada"].ToString() == "2ª Opção" && item["matriculado"].ToString() == "Sim")
                     {
                         dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Orange;
                     }
                 }
             }
         }
     }
 }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "")
            {
                string       msg = "INFORME O SEMESTRE E O ANO DO VESTIBULINHO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox1.Focus();
            }
            else if (comboBox2.Text == "")
            {
                string       msg = "INFORME O CURSO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox2.Focus();
            }
            else if (comboBox4.Text == "")
            {
                string       msg = "INFORME O PERÍODO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox4.Focus();
            }
            else if (comboBox3.Text == "")
            {
                string       msg = "SELECIONAR A CHAMADA";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox3.Focus();
            }
            else
            {
                //MessageBox.Show(""+sob);
                dataGridView1.Rows.Clear();
                if (comboBox3.Text == "1ª chamada")
                {
                    string curso;
                    //chamada = Convert.ToInt32((comboBox3.Text).Remove((comboBox3.Text).Length - 9)) - 1;
                    vg.Banco        = comboBox3.Text;
                    vg.Escola       = comboBox2.Text.Substring(comboBox2.Text.Length - 7);
                    vg.Vestibulinho = comboBox1.Text;
                    curso           = comboBox2.Text;
                    vg.Curso        = curso.Remove(curso.Length - 10);
                    string vaga = cv.SelecionaVagas(vg).Rows[0]["VAGAS"].ToString();
                    vg.Periodo           = comboBox4.Text;
                    vg.Chamada           = comboBox3.Text;
                    vg.Banco             = comboBox3.Text;
                    vg.Vaga              = vaga;
                    sob                  = 0;
                    progressBar1.Visible = true;
                    progressBar1.Maximum = cv.SelecionaPorChamada(vg).Rows.Count;
                    foreach (DataRow item in cv.SelecionaPorChamada(vg).Rows)
                    {
                        int n = dataGridView1.Rows.Add();
                        dataGridView1.Rows[n].Cells[0].Value = item["CLAS"].ToString();
                        dataGridView1.Rows[n].Cells[1].Value = item["NOME"].ToString();
                        dataGridView1.Rows[n].Cells[2].Value = item["TELEFONE"].ToString();
                        dataGridView1.Rows[n].Cells[3].Value = item["CELULAR"].ToString();
                        dataGridView1.Rows[n].Cells[4].Value = item["EMAIL"].ToString();

                        int idade = Idade(Convert.ToDateTime(item["dtNasc"].ToString()));

                        if ((item["HABILITACAO"].ToString() == "ENSINO MÉDIO" || item["HABILITACAO"].ToString() == "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" || item["HABILITACAO"].ToString().Contains("NOVOTEC") == true) && (idade <= 13))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        else if ((item["HABILITACAO"].ToString() != "ENSINO MÉDIO" && item["HABILITACAO"].ToString() != "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" && item["HABILITACAO"].ToString().Contains("NOVOTEC") == false) && (idade <= 14))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }

                        if (item["matriculado"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.GreenYellow;
                        }
                        else
                        {
                            sob = sob + 1;
                        }
                        if (item["ausente"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
                            dataGridView1.Rows[n].DefaultCellStyle.Font      = new Font(DataGridView.DefaultFont, FontStyle.Strikeout);
                        }
                        progressBar1.Value++;
                    }
                    vg.Sobra = sob;
                    co.GravarSobras(vg);

                    if (dataGridView1.Rows.Count < 40)
                    {
                        co.SalvarObs(gr);
                        string       msg = "COMPLETE A TURMA COM A LISTA DA 2º OPÇÃO E/OU COM O LISTÃO";
                        frm_Mensagem mg  = new frm_Mensagem(msg);
                        mg.ShowDialog();
                    }
                }
                else if (comboBox3.Text == "2ª chamada")
                {
                    sob = 0;
                    int vag = Convert.ToInt32(cv.SelecionaVagas(vg).Rows[0]["VAGAS"].ToString()) + 1;
                    vg.Periodo = comboBox4.Text;
                    vg.Vaga    = Convert.ToString(vag);
                    int cont = co.SomaMatricula(vg).Rows[0][0].GetHashCode();
                    vg.Banco = Convert.ToString(Convert.ToInt32((comboBox3.Text).Remove((comboBox3.Text).Length - 9)) - 1) + "ª Chamada";
                    int sobra = co.VerificaSobra(vg).Rows[0][0].GetHashCode() - 1;
                    vg.Sobra             = vag + sobra;
                    vg.Escola            = comboBox2.Text.Substring(comboBox2.Text.Length - 7);
                    progressBar1.Visible = true;
                    progressBar1.Maximum = co.SegundaChamada(vg).Rows.Count;
                    foreach (DataRow item in co.SegundaChamada(vg).Rows)
                    {
                        int n = dataGridView1.Rows.Add();
                        dataGridView1.Rows[n].Cells[0].Value = item["CLAS"].ToString();
                        dataGridView1.Rows[n].Cells[1].Value = item["NOME"].ToString();
                        dataGridView1.Rows[n].Cells[2].Value = item["TELEFONE"].ToString();
                        dataGridView1.Rows[n].Cells[3].Value = item["CELULAR"].ToString();
                        dataGridView1.Rows[n].Cells[4].Value = item["EMAIL"].ToString();

                        int idade = Idade(Convert.ToDateTime(item["dtNasc"].ToString()));

                        if ((item["HABILITACAO"].ToString() == "ENSINO MÉDIO" || item["HABILITACAO"].ToString() == "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" || item["HABILITACAO"].ToString().Contains("NOVOTEC") == true) && (idade <= 13))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        else if ((item["HABILITACAO"].ToString() != "ENSINO MÉDIO" && item["HABILITACAO"].ToString() != "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" && item["HABILITACAO"].ToString().Contains("NOVOTEC") == false) && (idade <= 14))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        if (item["matriculado"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.GreenYellow;
                        }
                        else
                        {
                            sob = sob + 1;
                        }
                        if (item["ausente"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
                            dataGridView1.Rows[n].DefaultCellStyle.Font      = new Font(DataGridView.DefaultFont, FontStyle.Strikeout);
                        }
                        vg.Ultimo = dataGridView1.Rows[n].Cells[0].Value.ToString();
                        progressBar1.Value++;
                    }
                    vg.Banco = comboBox3.Text;
                    vg.Sobra = sob;
                    co.GravarSobras(vg);

                    vg.Banco = comboBox3.Text;
                    co.GravarChamadas(vg);

                    if (dataGridView1.Rows.Count < sob)
                    {
                        co.SalvarObs(gr);
                        string       msg = "COMPLETE A TURMA COM A LISTA DA 2º OPÇÃO E/OU COM O LISTÃO";
                        frm_Mensagem mg  = new frm_Mensagem(msg);
                        mg.ShowDialog();
                    }
                }
                else if (comboBox3.Text == "Pós Chamadas")
                {
                    int cont = co.UltimaChamada().Rows.Count;
                    for (int i = 0; i < cont; i++)
                    {
                        chamada = co.UltimaChamada().Rows[i][0].ToString();
                    }
                    vg.Banco   = chamada;
                    vg.Periodo = comboBox4.Text;
                    string ult = co.VerificaChamada(vg).Rows[0][0].ToString();
                    vg.Ultimo            = ult;
                    vg.Escola            = comboBox2.Text.Substring(comboBox2.Text.Length - 7);
                    progressBar1.Visible = true;
                    progressBar1.Maximum = co.PosChamadas(vg).Rows.Count;
                    foreach (DataRow item in co.PosChamadas(vg).Rows)
                    {
                        vg.Banco = comboBox3.Text;
                        int n = dataGridView1.Rows.Add();
                        dataGridView1.Rows[n].Cells[0].Value = item["CLAS"].ToString();
                        dataGridView1.Rows[n].Cells[1].Value = item["NOME"].ToString();
                        dataGridView1.Rows[n].Cells[2].Value = item["TELEFONE"].ToString();
                        dataGridView1.Rows[n].Cells[3].Value = item["CELULAR"].ToString();
                        dataGridView1.Rows[n].Cells[4].Value = item["EMAIL"].ToString();

                        int idade = Idade(Convert.ToDateTime(item["dtNasc"].ToString()));

                        if ((item["HABILITACAO"].ToString() == "ENSINO MÉDIO" || item["HABILITACAO"].ToString() == "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" || item["HABILITACAO"].ToString().Contains("NOVOTEC") == true) && (idade <= 13))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        else if ((item["HABILITACAO"].ToString() != "ENSINO MÉDIO" && item["HABILITACAO"].ToString() != "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" && item["HABILITACAO"].ToString().Contains("NOVOTEC") == false) && (idade <= 14))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        if (item["matriculado"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.GreenYellow;
                        }
                        if (item["ausente"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
                            dataGridView1.Rows[n].DefaultCellStyle.Font      = new Font(DataGridView.DefaultFont, FontStyle.Strikeout);
                        }
                        progressBar1.Value++;
                    }
                }
                else
                {
                    sob        = 0;
                    vg.Banco   = Convert.ToInt32((comboBox3.Text).Remove((comboBox3.Text).Length - 9)) - 1 + "ª chamada";
                    vg.Periodo = comboBox4.Text;
                    int sobra = co.VerificaSobra(vg).Rows[0][0].GetHashCode();
                    vg.Banco = Convert.ToInt32((comboBox3.Text).Remove((comboBox3.Text).Length - 9)) - 1 + "ª chamada";
                    string ult = co.VerificaChamada(vg).Rows[0][0].ToString();
                    vg.Ultimo            = Convert.ToString(Convert.ToInt32(ult) + 1);
                    vg.Sobra             = Convert.ToInt32(ult) + sobra;
                    vg.Escola            = comboBox2.Text.Substring(comboBox2.Text.Length - 7);
                    progressBar1.Visible = true;
                    progressBar1.Maximum = co.DemaisOpcao(vg).Rows.Count;
                    foreach (DataRow item in co.DemaisOpcao(vg).Rows)
                    {
                        vg.Banco = comboBox3.Text;
                        int n = dataGridView1.Rows.Add();
                        dataGridView1.Rows[n].Cells[0].Value = item["CLAS"].ToString();
                        dataGridView1.Rows[n].Cells[1].Value = item["NOME"].ToString();
                        dataGridView1.Rows[n].Cells[2].Value = item["TELEFONE"].ToString();
                        dataGridView1.Rows[n].Cells[3].Value = item["CELULAR"].ToString();
                        dataGridView1.Rows[n].Cells[4].Value = item["EMAIL"].ToString();
                        int idade = Idade(Convert.ToDateTime(item["dtNasc"].ToString()));

                        if ((item["HABILITACAO"].ToString() == "ENSINO MÉDIO" || item["HABILITACAO"].ToString() == "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" || item["HABILITACAO"].ToString().Contains("NOVOTEC") == true) && (idade <= 13))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        else if ((item["HABILITACAO"].ToString() != "ENSINO MÉDIO" && item["HABILITACAO"].ToString() != "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" && item["HABILITACAO"].ToString().Contains("NOVOTEC") == false) && (idade <= 14))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        if (item["matriculado"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.GreenYellow;
                        }
                        else
                        {
                            sob = sob + 1;
                        }
                        if (item["ausente"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
                            dataGridView1.Rows[n].DefaultCellStyle.Font      = new Font(DataGridView.DefaultFont, FontStyle.Strikeout);
                        }
                        vg.Ultimo = item["CLAS"].ToString();

                        progressBar1.Value++;
                    }
                    vg.Banco = comboBox3.Text;
                    vg.Sobra = sob;
                    co.GravarSobras(vg);
                    vg.Banco = comboBox3.Text;
                    co.GravarChamadas(vg);
                    if (dataGridView1.Rows.Count < sob)
                    {
                        co.SalvarObs(gr);
                        string       msg = "COMPLETE A TURMA COM A LISTA DA 2º OPÇÃO E/OU COM O LISTÃO";
                        frm_Mensagem mg  = new frm_Mensagem(msg);
                        mg.ShowDialog();
                    }
                }
                button4.Enabled = true;
            }
            progressBar1.Value   = 0;
            progressBar1.Visible = false;
            if (Convert.ToInt32(cv.SelecionaVagas(vg).Rows[0]["VAGAS"].ToString()) <= Convert.ToInt32(co.TotalMatriculado(vg).Rows[0][0].ToString()))
            {
                string       msg = "TURMA COMPLETA";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            int cont = dataGridView1.Rows.Count;

            if (cont == 0)
            {
                string       msg = "NÃO EXISTE DADOS PARA GERAR O EXCEL";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
            }
            else
            {
                int l = 3;
                salvarArquivo.FileName   = "Lista de Telefones dos que não foram convocados";
                salvarArquivo.DefaultExt = "*.xls";
                salvarArquivo.Filter     = "Todos os Aquivos do Excel (*.xls)|*.xls| Todos os arquivos (*.*)|*.*";

                try
                {
                    xlApp      = new Excel.Application();
                    xlWorkBook = xlApp.Workbooks.Add(misValue);

                    xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                    xlWorkSheet.PageSetup.Orientation    = Excel.XlPageOrientation.xlLandscape;
                    xlWorkSheet.PageSetup.TopMargin      = 2;
                    xlWorkSheet.PageSetup.BottomMargin   = 1;
                    xlWorkSheet.PageSetup.LeftMargin     = 0;
                    xlWorkSheet.PageSetup.RightMargin    = 0;
                    xlWorkSheet.PageSetup.PrintTitleRows = "$A$2:$G$2";
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 7]].Merge();
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 7]].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[1, 1]             = "Lista de Telefones";
                    xlWorkSheet.Cells[1, 1].ColumnWidth = 7;
                    xlWorkSheet.Cells[1, 2].ColumnWidth = 7;
                    xlWorkSheet.Cells[1, 3].ColumnWidth = 39;
                    xlWorkSheet.Cells[1, 4].ColumnWidth = 39;
                    xlWorkSheet.Cells[1, 5].ColumnWidth = 13;
                    xlWorkSheet.Cells[1, 6].ColumnWidth = 14;
                    xlWorkSheet.Cells[1, 7].ColumnWidth = 20;
                    xlWorkSheet.Cells[1, 1].Font.Size   = 16;
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 7]].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 1] = "CLASS";
                    xlWorkSheet.Cells[2, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 1].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 2] = "NOTA";
                    xlWorkSheet.Cells[2, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 2].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 3] = "NOME";
                    xlWorkSheet.Cells[2, 3].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 3].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 4] = "ENDEREÇO";
                    xlWorkSheet.Cells[2, 4].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 4].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 5] = "TELEFONE";
                    xlWorkSheet.Cells[2, 5].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 5].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 6] = "CELULAR";
                    xlWorkSheet.Cells[2, 6].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 6].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 7] = "CURSO.";
                    xlWorkSheet.Cells[2, 7].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

                    xlWorkSheet.Range[xlWorkSheet.Cells[2, 1], xlWorkSheet.Cells[2, 7]].Font.Size = 12;
                    int quant = dataGridView1.Rows.Count;

                    progressBar1.Minimum = 0;
                    progressBar1.Maximum = quant;
                    for (int i = 0; i < quant; i++)
                    {
                        xlWorkSheet.Cells[l, 1] = dataGridView1.Rows[i].Cells[0].Value.ToString();
                        xlWorkSheet.Cells[l, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 1].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 2] = dataGridView1.Rows[i].Cells[1].Value.ToString();
                        xlWorkSheet.Cells[l, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 2].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 3] = dataGridView1.Rows[i].Cells[2].Value.ToString();
                        xlWorkSheet.Cells[l, 3].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 4] = dataGridView1.Rows[i].Cells[3].Value.ToString();
                        xlWorkSheet.Cells[l, 4].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 5] = dataGridView1.Rows[i].Cells[4].Value.ToString();
                        xlWorkSheet.Cells[l, 5].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 5].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 6] = dataGridView1.Rows[i].Cells[5].Value.ToString();
                        xlWorkSheet.Cells[l, 6].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 6].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 7] = dataGridView1.Rows[i].Cells[6].Value.ToString() + " - " + comboBox1.Text;
                        xlWorkSheet.Cells[l, 7].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 7].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        l = l + 1;
                        progressBar1.Value++;
                    }
                    xlWorkSheet.Application.Columns[3].ShrinkToFit = true;
                    xlWorkSheet.Application.Columns[4].ShrinkToFit = true;

                    new System.Threading.Thread(delegate()
                    {
                        Export();
                    }).Start();
                }
                catch (Exception ex)
                {
                    string       msg = "Erro : " + ex.Message;
                    frm_Mensagem mg  = new frm_Mensagem(msg);
                    mg.ShowDialog();
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "")
            {
                string       msg = "INFORME O SEMESTRE E O ANO DO VESTIBULINHO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox1.Focus();
            }
            else if (comboBox2.Text == "")
            {
                string       msg = "INFORME O CURSO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox2.Focus();
            }
            else if (comboBox4.Text == "")
            {
                string       msg = "INFORME O PERÍODO";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
                comboBox4.Focus();
            }
            else
            {
                if (textBox4.Text == "" || textBox5.Text == "")
                {
                    string       msg = "INFORME UM INTERVALO VÁLIDO PARA PESQUISA";
                    frm_Mensagem mg  = new frm_Mensagem(msg);
                    mg.ShowDialog();
                    textBox4.Focus();
                }
                else
                {
                    string curso;
                    int    cs = cv.SelecionaCurso(vg).Rows.Count;
                    vg.Vestibulinho = comboBox1.Text;
                    curso           = comboBox2.Text;
                    vg.Curso        = curso.Remove(curso.Length - 10);
                    string vaga = cv.SelecionaVagas(vg).Rows[0]["VAGAS"].ToString();
                    vg.Periodo  = comboBox4.Text;
                    vg.Vaga     = vaga;
                    vg.Primeiro = textBox4.Text;
                    vg.Ultimo   = textBox5.Text;
                    vg.Escola   = comboBox2.Text.Substring(comboBox2.Text.Length - 7);
                    //dataGridView1.Rows.Clear();
                    foreach (DataRow item in co.Listao(vg).Rows)
                    {
                        int n = dataGridView1.Rows.Add();
                        //dataGridView1.Rows[n].Cells[0].Value = item["COD"].GetHashCode();
                        dataGridView1.Rows[n].Cells[1].Value = item["COD"].GetHashCode();
                        dataGridView1.Rows[n].Cells[2].Value = item["CLAS"].ToString();
                        dataGridView1.Rows[n].Cells[3].Value = item["NOTA"].ToString();
                        dataGridView1.Rows[n].Cells[4].Value = item["NOME"].ToString();
                        dataGridView1.Rows[n].Cells[5].Value = item["ENDERECO"].ToString();
                        dataGridView1.Rows[n].Cells[6].Value = item["TELEFONE"].ToString();
                        dataGridView1.Rows[n].Cells[7].Value = item["CELULAR"].ToString();
                        dataGridView1.Rows[n].Cells[8].Value = item["HABILITACAO"].ToString();
                        //DateTime dta = Convert.ToDateTime(item["dtNasc"].ToString());
                        int idade = Idade(Convert.ToDateTime(item["dtNasc"].ToString()));
                        //MessageBox.Show(""+idade);
                        if ((item["HABILITACAO"].ToString() == "ENSINO MÉDIO" || item["HABILITACAO"].ToString() == "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" || item["HABILITACAO"].ToString().Contains("NOVOTEC") == true) && (idade <= 13))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        else if ((item["HABILITACAO"].ToString() != "ENSINO MÉDIO" && item["HABILITACAO"].ToString() != "ADMINISTRAÇÃO - INTEGRADO AO ENSINO MÉDIO" && item["HABILITACAO"].ToString().Contains("NOVOTEC") == false) && (idade <= 14))
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.Violet;
                        }
                        dataGridView1.Rows[n].Cells[9].Value = item["ESCOL"].ToString();
                        if (item["matriculado"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.BackColor = Color.GreenYellow;
                            //dataGridView1.Rows[n].Cells[0].Value = true;
                        }

                        if (item["ausente"].ToString() == "Sim")
                        {
                            dataGridView1.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
                            dataGridView1.Rows[n].DefaultCellStyle.Font      = new Font(DataGridView.DefaultFont, FontStyle.Strikeout);
                            dataGridView1.Rows[n].Cells[0].Value             = true;
                        }

                        DataGridViewComboBoxCell aux  = (DataGridViewComboBoxCell)dataGridView1.Rows[n].Cells[10];
                        DataGridViewComboBoxCell aux1 = (DataGridViewComboBoxCell)dataGridView1.Rows[n].Cells[11];
                        aux.Items.Add("");
                        for (int i = 0; i < cs; i++)
                        {
                            aux.Items.Add(cv.SelecionaCurso(vg).Rows[i]["curso"].ToString() + " - " + cv.SelecionaCurso(vg).Rows[i]["escola"].ToString());
                        }

                        aux1.Items.Add("");
                        aux1.Items.Add("INTEGRAL");
                        aux1.Items.Add("MANHÃ");
                        aux1.Items.Add("NOITE");
                        aux1.Items.Add("TARDE");

                        vg.Codigo = item["COD"].GetHashCode();
                        foreach (DataRow combo in cg.comboListao(vg).Rows)
                        {
                            if (combo["chamada"].ToString() == "2ª Opção")
                            {
                                aux.Value  = combo["habilitacao2"].ToString() + " - " + combo["escola"].ToString();
                                aux1.Value = combo["periodo2"].ToString();
                            }
                            else if (combo["chamada"].ToString() == "Listão")
                            {
                                aux.Value  = combo["listao"].ToString() + " - " + combo["escola"].ToString();
                                aux1.Value = combo["perListao"].ToString();
                            }
                            else
                            {
                                aux.Value  = combo["habilitacao"].ToString() + " - " + combo["escola"].ToString();
                                aux1.Value = combo["periodo"].ToString();
                            }
                        }
                    }
                    button3.Enabled        = true;
                    button4.Enabled        = true;
                    textBox3.Enabled       = true;
                    maskedTextBox1.Enabled = true;
                }
            }
        }
Esempio n. 9
0
        private void button2_Click(object sender, EventArgs e)
        {
            int cont = dataGridView1.Rows.Count;

            if (cont == 0)
            {
                string       msg = "NÃO EXISTE DADOS PARA GERAR O EXCEL";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
            }
            else
            {
                int l = 3;
                salvarArquivo.FileName   = "Lista de Matriculados" + " - " + comboBox2.Text.Remove(comboBox2.Text.Length - 10);
                salvarArquivo.DefaultExt = "*.xls";
                salvarArquivo.Filter     = "Todos os Aquivos do Excel (*.xls)|*.xls| Todos os arquivos (*.*)|*.*";

                try
                {
                    xlApp      = new Excel.Application();
                    xlWorkBook = xlApp.Workbooks.Add(misValue);

                    xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                    xlWorkSheet.PageSetup.Orientation    = Excel.XlPageOrientation.xlLandscape;
                    xlWorkSheet.PageSetup.PrintTitleRows = "$A$2:$c$2";
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 3]].Merge();
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 3]].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[1, 1]             = "Lista de Matriculados" + " - " + comboBox2.Text.Remove(comboBox2.Text.Length - 10);
                    xlWorkSheet.Cells[1, 1].ColumnWidth = 8;
                    xlWorkSheet.Cells[1, 2].ColumnWidth = 40;
                    xlWorkSheet.Cells[1, 3].ColumnWidth = 20;
                    xlWorkSheet.Cells[1, 1].Font.Size   = 16;
                    xlWorkSheet.Range[xlWorkSheet.Cells[1, 1], xlWorkSheet.Cells[1, 3]].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 1] = "CLASS";
                    xlWorkSheet.Cells[2, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 1].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 2] = "NOME";
                    xlWorkSheet.Cells[2, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 2].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                    xlWorkSheet.Cells[2, 3] = "SEXO";
                    xlWorkSheet.Cells[2, 3].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                    xlWorkSheet.Cells[2, 3].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;

                    xlWorkSheet.Range[xlWorkSheet.Cells[2, 1], xlWorkSheet.Cells[2, 3]].Font.Size = 12;
                    int quant = dataGridView1.Rows.Count;

                    progressBar1.Visible = true;
                    progressBar1.Maximum = quant;
                    for (int i = 0; i < quant; i++)
                    {
                        xlWorkSheet.Cells[l, 1] = dataGridView1.Rows[i].Cells[0].Value.ToString();
                        xlWorkSheet.Cells[l, 1].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 1].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 2] = dataGridView1.Rows[i].Cells[1].Value.ToString();
                        xlWorkSheet.Cells[l, 2].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                        xlWorkSheet.Cells[l, 3] = dataGridView1.Rows[i].Cells[2].Value.ToString();
                        xlWorkSheet.Cells[l, 3].HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                        xlWorkSheet.Cells[l, 3].Borders.LineStyle   = Excel.XlLineStyle.xlContinuous;
                        l = l + 1;
                        progressBar1.Value++;
                    }
                    xlWorkSheet.Application.Columns[2].ShrinkToFit = true;
                    progressBar1.Value   = 0;
                    progressBar1.Visible = false;

                    new System.Threading.Thread(delegate()
                    {
                        Export();
                    }).Start();
                }
                catch (Exception ex)
                {
                    string       msg = "Erro : " + ex.Message;
                    frm_Mensagem mg  = new frm_Mensagem(msg);
                    mg.ShowDialog();
                }
            }
        }