示例#1
0
        public bool DesmaterializaDado(cDados dado)
        {
            string sql;

            try
            {
                sql = "INSERT INTO dados(id_avaliacao, data_hora, freq_cardiaca) values (?, ?, ?)";

                sqlConn = new System.Data.Odbc.OdbcConnection(connString);
                sqlConn.Open();


                sqlCmd = new System.Data.Odbc.OdbcCommand(sql, sqlConn);

                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value      = dado.id_avaliacao;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.DateTime).Value = dado.data;
                sqlCmd.Parameters.Add("", System.Data.Odbc.OdbcType.Int).Value      = dado.fc;


                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    sqlConn.Close();
                    return(true);
                }
                else
                {
                    sqlConn.Close();
                    return(false);
                }
            }
            catch (Exception Ex)
            {
                return(false);
            }
        }
示例#2
0
        private void dbGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                cAvaliacao ava = new cAvaliacao();
                ava.id = int.Parse(dbGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
                ava.CarregaAvaliacao();

                cDados   data  = new cDados();
                cDados[] dados = new cDados[0];

                data.id_avaliacao = ava.id;
                int size = data.ListarDados(ref dados);

                repAvaliacao[] rep = new repAvaliacao[0];
                for (int i = 0; i < size; i++)
                {
                    Array.Resize(ref rep, i + 1);
                    rep[i] = new repAvaliacao();

                    rep[i].id             = ava.id;
                    rep[i].nome           = ava.x_nome;
                    rep[i].data_avaliacao = ava.data_hora.ToShortDateString() + " " + ava.data_hora.ToShortTimeString();
                    rep[i].dthr_medida    = dados[i].data;
                    rep[i].fc             = dados[i].fc;
                }
                repViewAvaliacao frm = new repViewAvaliacao(rep);
                frm.Show();
            }
        }
示例#3
0
        public int ListarDados(cDados obj, ref cDados[] array)
        {
            string sql;

            try
            {
                sql = "SELECT ID, id_avaliacao, data_hora, freq_cardiaca FROM dados WHERE id_avaliacao = " + obj.id_avaliacao.ToString();

                sqlConn = new System.Data.Odbc.OdbcConnection(connString);
                sqlConn.Open();

                sqlCmd     = new System.Data.Odbc.OdbcCommand(sql, sqlConn);
                sqlAdapter = new System.Data.Odbc.OdbcDataAdapter();

                sqlAdapter.SelectCommand = sqlCmd;


                sqlDataSet = new System.Data.DataSet();
                sqlAdapter.Fill(sqlDataSet);

                System.Data.DataTable dt = sqlDataSet.Tables[0];

                foreach (System.Data.DataRow row in dt.Rows)
                {
                    Array.Resize(ref array, array.Length + 1);
                    System.Data.DataRow linha = row;
                    array[array.Length - 1]      = new cDados();
                    array[array.Length - 1].id   = int.Parse(linha["id"].ToString());
                    array[array.Length - 1].fc   = int.Parse(linha["freq_cardiaca"].ToString());
                    array[array.Length - 1].data = DateTime.Parse(linha["data_hora"].ToString());
                }

                sqlConn.Close();

                return(dt.Rows.Count);
            }
            catch (Exception Ex)
            {
                return(-1);
            }
        }
示例#4
0
        public int ListarDados(cDados obj, ref cDados[] array)
        {
            string sql;

            try
            {
                sql = "SELECT id, id_pessoa, data_hora, freq_cardiaca FROM dados WHERE id_pessoa = " + obj.id_avaliacao.ToString() + " ORDER BY data_hora";


                sqlConn = new System.Data.Odbc.OdbcConnection(connString);
                sqlConn.Open();

                sqlCmd = new System.Data.Odbc.OdbcCommand(sql, sqlConn);
                System.Data.Odbc.OdbcDataReader data;

                data = sqlCmd.ExecuteReader();
                int cont = 0;
                while (data.Read())
                {
                    Array.Resize(ref array, array.Length + 1);
                    array[cont]              = new cDados();
                    array[cont].id           = data.GetInt32(0);
                    array[cont].id_avaliacao = data.GetInt32(1);
                    array[cont].data         = data.GetDateTime(2);
                    array[cont].fc           = data.GetInt32(3);
                    cont++;
                }

                sqlConn.Close();

                return(cont);
            }
            catch (Exception Ex)
            {
                return(-1);
            }
        }