protected void btPesq_Click(object sender, EventArgs e) { string _rh = txbRh.Text; using (OdbcConnection cnn = new OdbcConnection(ConfigurationManager.ConnectionStrings["HospubConn"].ToString())) { OdbcCommand cmm = cnn.CreateCommand(); cmm.CommandText = "Select ib6prontuar, ib6pnome, ib6compos, ib6municip, ib6telef, ib6dtnasc, ib6lograd, ib6numero, ib6complem, ib6bairro from intb6 where ib6regist = " + _rh; cnn.Open(); OdbcDataReader dr = cmm.ExecuteReader(); if (dr.Read()) { lbRF.Text = dr.GetString(0); lbNome.Text = dr.GetString(1) + dr.GetString(2); lbProcedencia.Text = Procedencia.getProcedencia(dr.GetString(3)); string tel = dr.GetString(4).TrimStart('0'); if (tel != "") { if (tel.Length.Equals(8)) { tel = tel.Substring(0, 4) + "-" + tel.Substring(4, 4); } else if (tel.Length.Equals(9)) { tel = tel.Substring(0, 5) + "-" + tel.Substring(5, 4); } } lbTel.Text = tel; lbIdade.Text = calcidade.getIdade(dr.GetString(5)).ToString() + " anos";; lblograd.Text = dr.GetString(6); lbnumero.Text = dr.GetString(7); lbcomplem.Text = dr.GetString(8); lbbairro.Text = dr.GetString(9); dr.Close(); } } //Pesquisa Histórico de Consultas GridView1.DataSource = AgendaPass1.gridCarregaAgendaPass(_rh); GridView1.DataBind(); // Consultas Marcadas GridView2.DataSource = AgendaMarcada.gridCarregaAgenda(_rh); GridView2.DataBind(); GridView3.DataSource = AgendaDemanda.gridCarregaAgendaDemanda(_rh); GridView3.DataBind(); }
protected void btPesq_Click(object sender, EventArgs e) { GridView6.SelectedIndex = -1; GridView6.DataBind(); string dtHoje = DateTime.Now.Date.Day.ToString().PadLeft(2, '0') + "/" + DateTime.Now.Date.Month.ToString().PadLeft(2, '0') + "/" + DateTime.Now.Date.Year.ToString().PadLeft(2, '0'); txbdtSol.Text = dtHoje; Button1.Enabled = true; Button2.Enabled = false; string _rh = txbRh.Text.TrimStart('0'); LimpaCampos(); txbdtSol.Text = dtHoje; txbSus.Text = Sus(_rh); txbTel2.Text = ""; txbTel3.Text = ""; txbTel4.Text = ""; //*************data e hora do início de uso do painel contando apartir da pesquisa do rh lbDateIni.Text = DateTime.Now.ToString(); //********************************************* chbRetorno.Checked = true; chbRegul.Checked = false; try { using (OdbcConnection cnn = new OdbcConnection(ConfigurationManager.ConnectionStrings["HospubConn"].ToString())) { OdbcCommand cmm = cnn.CreateCommand(); cmm.CommandText = "Select ib6prontuar, ib6pnome, ib6compos, ib6municip, ib6telef, ib6dtnasc, ib6lograd, ib6numero, ib6complem, ib6bairro from intb6 where ib6regist = " + _rh; cnn.Open(); OdbcDataReader dr = cmm.ExecuteReader(); if (dr.Read()) { lbRF.Text = dr.GetString(0); lbNome.Text = dr.GetString(1) + dr.GetString(2); lbProcedencia.Text = Procedencia.getProcedencia(dr.GetString(3)); string tel = dr.GetString(4).TrimStart('0'); if (tel != "") { if (tel.Length.Equals(8)) { tel = tel.Substring(0, 4) + "-" + tel.Substring(4, 4); txbTel1.Text = "(11) 0" + tel; } else if (tel.Length.Equals(9)) { tel = tel.Substring(0, 5) + "-" + tel.Substring(5, 4); txbTel1.Text = "(11) " + tel; } else if (tel.Length.Equals(10)) { tel = "(" + tel.Substring(0, 2) + ") 0" + tel.Substring(2, 4) + "-" + tel.Substring(6, 4); txbTel1.Text = tel; } else if (tel.Length.Equals(11)) { tel = "(" + tel.Substring(0, 2) + ") " + tel.Substring(2, 5) + "-" + tel.Substring(7, 4); txbTel1.Text = tel; } } lbTel.Text = tel; lbIdade.Text = calcidade.getIdade(dr.GetString(5)).ToString() + " anos";; lblograd.Text = dr.GetString(6); lbnumero.Text = dr.GetString(7); lbcomplem.Text = dr.GetString(8); lbbairro.Text = dr.GetString(9); dr.Close(); } else { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Número de RH inexistente.');", true); txbRh.Text = ""; LimpaCampos(); dtHoje = DateTime.Now.Date.Day.ToString().PadLeft(2, '0') + "/" + DateTime.Now.Date.Month.ToString().PadLeft(2, '0') + "/" + DateTime.Now.Date.Year.ToString().PadLeft(2, '0'); txbdtSol.Text = dtHoje; return; } //Colocar uma função para buscar os telefones no Banco de Dados Geral_Treina using (SqlConnection cnn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServices"].ToString())) { SqlCommand cmm1 = cnn1.CreateCommand(); cmm1.CommandText = "SELECT telefone2,telefone3,telefone4 FROM [Geral_Treina].[dbo].[Telefones_Adicionais] where rh = '" + _rh + "'"; cnn1.Open(); SqlDataReader drTel = cmm1.ExecuteReader(); if (drTel.Read()) { txbTel2.Text = drTel.GetString(0); txbTel3.Text = drTel.GetString(1); txbTel4.Text = drTel.GetString(2); } } } } catch (Exception ex) { string erro = ex.Message; } ddlEspec.Focus(); }