private void timer1_Tick(object sender, EventArgs e) { int j = 0; int cont = cs.Usuario().Rows.Count; OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + caminho + ";Extended Properties=Excel 12.0;"); con.Open(); OleDbDataAdapter query = new OleDbDataAdapter(" SELECT * FROM [Planilha1$]", con); DataTable dataTable = new DataTable(); query.Fill(dataTable); timer1.Enabled = true; timer1.Start(); progressBar1.Maximum = mat1; Conecta cl = new Conecta(); Variavel va = new Variavel(); foreach (DataRow dtRow in dataTable.Rows) { us.Nome = dtRow[0].ToString(); int aux = co.pesquisaFalta(us).Rows.Count; if (mat1 > progressBar1.Value) { if (j == 0) { } else { if (cont == 0) { if (aux == 0) { va.Nome = dtRow[0].ToString(); va.DtCadastro = Convert.ToDateTime(data).ToString("dd/MM/yyyy"); cl.cadastro(va); } } else { if (aux == 0) { va.Nome = dtRow[0].ToString(); va.DtCadastro = Convert.ToDateTime(data).ToString("dd/MM/yyyy"); cl.cadastro(va); cont = cs.Usuario().Rows.Count; } } } j = j + 1; if (j + 1 <= mat1) { progressBar1.Value++; } } } con.Close(); timer1.Stop(); timer2.Enabled = true; seg = 10; }