예제 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try {
         this.Close();
         FrmMain mm = new FrmMain();
         mm.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "Erro Button1 Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        private void Excel()
        {
            DataSet ds = new DataSet();
            string cnnString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES;""", @"C:\IHMHR\BaseConhecimento.xlsx");//@"C:\Users\Martinelli\Desktop\N8\Projeto Base de conhecimento\Base de Conhecimento\Base de Conhecimento\bin\Debug\BaseConhecimento.xlsx");
            string isql = "SELECT TOP 50 Chamado AS [Numero do Chamado],Desc_Chamado AS [Descrição do Chamado],Desc_detalhada AS [Detalhes do Chamado],Causa,resolucao AS [Resolução],sintoma AS [Sintoma],Resposta_cliente AS [Resposta ao Cliente],[Solucionador por] AS [Analista responsável] FROM [{0}$] WHERE chamado IS NOT NULL AND resolucao IS NOT NULL AND Resposta_cliente IS NOT NULL AND " + FormatarLike(MyProperty, false) + " ORDER BY Chamado DESC";
            System.Data.OleDb.OleDbConnection cnn = new System.Data.OleDb.OleDbConnection(cnnString);
            System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(String.Format(isql, "Plan1"), cnn);
            comando = String.Format(isql, "Plan1");

            da.Fill(ds);

            dataGridView1.DataSource = ds.Tables[0];
            //lblQtdRegistros.Text = dataGridView1.RowCount.ToString();
            if (dataGridView1.RowCount <= 0)
            {
                MessageBox.Show("Nenhum dado encontrado");
                this.Close();
                FrmMain mm = new FrmMain();
                mm.Show();
            }
        }
예제 #3
0
        private void FrmSolucoes_Load(object sender, EventArgs e)
        {
            try
            {
                //Excel();
                using (SqlConnection con = new SqlConnection(@"Data Source=MARTINELLI-07\SQLEXPRESS;Initial Catalog=SS;Integrated Security=True"))
                {
                    string sql = "SELECT TOP 50 Chamado AS [Numero do Chamado],Desc_Chamado AS [Descrição do Chamado],Desc_detalhada AS [Detalhes do Chamado],Causa,resolucao AS Resolução,sintoma AS Sintoma,Resposta_cliente AS [Resposta ao Cliente],[Solucionador por] AS [Analista responsável] FROM Plan1$ WHERE Chamado IS NOT NULL AND resolucao IS NOT NULL AND Resposta_cliente IS NOT NULL AND ";
                    sql = sql + FormatarLike(MyProperty, false);
                    sql += " ORDER BY Chamado DESC";
                    comando = sql;

                    DataSet ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter(sql, con);

                    da.Fill(ds);
                    dataGridView1.DataSource = ds.Tables[0];
                    if (dataGridView1.RowCount <= 0)
                    {
                        MessageBox.Show("Nenhum dado encontrado");
                        this.Close();
                        FrmMain mm = new FrmMain();
                        mm.Show();
                    }
                }
            }
            catch (Exception)// ex)
            {
                //MessageBox.Show(ex.Message.ToString(), "Erro Load FrmSolucoes (popular dgv)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Excel();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
                tempo.Stop();
                elapsed = tempo.Elapsed;
                //MessageBox.Show(elapsed.ToString());
                tempo.Reset();
            }
        }