/// <summary> /// Retorna a tabela contendo as informacoes de usuario /// </summary> /// <param name="_cns">Cartao do Sus Usuario.CNS</param> /// <returns>DataTable</returns> public DataTable ConsultaCNS(string _cns) { DataTable pessoa; try { USUARIOTableAdapter user = new USUARIOTableAdapter(); pessoa = user.PesquisaCartaoSus(_cns); return pessoa; } catch (Exception) { return pessoa = null; throw; } }
//Al cargar la ventana, relaciona el dataset con el reporte con el ultimo mes como parámetro private void frmInformeTopSellers_Load(object sender, EventArgs e) { string ahora = DateTime.Today.ToString("yyyy-MM-dd"); string hace1Mes = DateTime.Today.AddMonths(-1).ToString("yyyy-MM-dd"); txtDesde.Text = hace1Mes; txtHasta.Text = ahora; var myDataTable = new DS_TopSellers.USUARIODataTable(); var myTableAdapter = new USUARIOTableAdapter(); myTableAdapter.Fill(myDataTable, hace1Mes, ahora); var rds = new ReportDataSource("DataSet1", myDataTable as DataTable); reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(rds); reportViewer1.RefreshReport(); }
//Al apretar el boton, relaciona el dataset con el reporte con el período de tiempo elegido como parámetro private void button1_Click(object sender, EventArgs e) { DateTime fecha; if (DateTime.TryParse(txtDesde.Text, out fecha) & DateTime.TryParse(txtHasta.Text, out fecha)) { var myDataTable = new DS_TopSellers.USUARIODataTable(); var myTableAdapter = new USUARIOTableAdapter(); myTableAdapter.Fill(myDataTable, txtDesde.Text, txtHasta.Text); var rds = new ReportDataSource("DataSet1", myDataTable as DataTable); reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(rds); reportViewer1.RefreshReport(); } else { MessageBox.Show("Debe completar los datos", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private bool PesquisaProntuarioUsuarioSQLServer(string prontuario) { try { USUARIOTableAdapter user = new USUARIOTableAdapter(); var _prontuario = user.RetornaPronturarioporProntuario(prontuario); if (_prontuario == null) return false; else if (_prontuario.ToString().Equals(prontuario)) return true; else return false; } catch (Exception err) { MessageBox.Show(err.Message); } return false; }
private void btnConfirmar_Click(object sender, EventArgs e) { int tipousuario = 2; if (RadioAgudo.Checked) tipousuario = 1; USUARIOTableAdapter user = new USUARIOTableAdapter(); if (txProntuario.Text.Equals("") || txNome.Text.Equals("") || txCPF.Text.Equals("") || txCartaoSus.Text.Equals("") || DataNascimento.Value.Equals(DateTime.Now) || txNomeMae.Text.Equals("") || txCep.Text.Equals("") || txNumero.Text.Equals("") || txNome.Text.Equals("NONONONO") || txNomeMae.Text.Equals("DSMAE")) MessageBox.Show("Há campos sem preenchimento, verifique!"); else if (txTelFixo.Text.Equals("") && txTelCelular.Text.Equals("")) MessageBox.Show("Há campos sem preenchimento, verifique!"); else if (!RadioAgudo.Checked && !RadioCronico.Checked) MessageBox.Show("Há campos sem preenchimento, verifique!"); else if (!VerificaCaracteresEspeciais(txNome.Text) || !VerificaCaracteresEspeciais(txNomeMae.Text)) { MessageBox.Show("Não utilize caracteres especiais"); if (VerificaCaracteresEspeciais(txNome.Text)) { this.ActiveControl = txNome; txNome.BackColor = Color.Yellow; } else { this.ActiveControl = txNomeMae; txNomeMae.BackColor = Color.Yellow; } } else { if (btnConfirmar.Text.Equals("Incluir - F10")) { int retorno = user.InserirNovoUsuario(tipousuario, txProntuario.Text, txNome.Text.ToUpper(), DataNascimento.Value.ToShortDateString(), txCartaoSus.Text, int.Parse(txCep.Text), int.Parse(txNumero.Text), txComplemento.Text, txCPF.Text, txNomeMae.Text.ToUpper(), txTelFixo.Text, txTelCelular.Text); MessageBox.Show(retorno.ToString()); btnConfirmar.Enabled = false; btnEditar.Enabled = false; BloqueiaItens(); txIDUsuario.Text = user.RetornaIDUsuarioPorNome(txNome.Text).ToString(); } else if (btnConfirmar.Text.Equals("Confirmar - F10")) { MessageBox.Show("Confirmado"); btnConfirmar.Enabled = false; btnEditar.Enabled = false; BloqueiaItens(); user.AtualizaUsuario(tipousuario, txProntuario.Text, txNome.Text.ToUpper(), DataNascimento.Value.ToShortDateString(), txCartaoSus.Text, int.Parse(txCep.Text), int.Parse(txNumero.Text), txComplemento.Text, txCPF.Text, txNomeMae.Text.ToUpper(), txTelFixo.Text, txTelCelular.Text, int.Parse(txIDUsuario.Text)); } else { MessageBox.Show("Salvo"); btnConfirmar.Enabled = false; btnEditar.Enabled = false; user.AtualizaUsuario(tipousuario, txProntuario.Text, txNome.Text.ToUpper(), DataNascimento.Value.ToShortDateString(), txCartaoSus.Text, int.Parse(txCep.Text), int.Parse(txNumero.Text), txComplemento.Text, txCPF.Text, txNomeMae.Text.ToUpper(), txTelFixo.Text, txTelCelular.Text, int.Parse(txIDUsuario.Text)); BloqueiaItens(); } AbaDispensacao.Visible = true; CarregaDispensacao(); } }
private void txProntuario_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { if (txProntuario.Text.Equals("")) { txNome.ReadOnly = false; this.ActiveControl = txNome; } else { if (PesquisaProntuarioUsuarioFireBird(txProntuario.Text.PadLeft(7,'0'))) { string prontuario = txProntuario.Text.PadLeft(7, '0'); txProntuario.Clear(); txProntuario.Text = prontuario; PreencheCamposProntuarioFireBird(txProntuario.Text); PreencheCamposNomeSqlServer(txNome.Text); } else if (PesquisaProntuarioUsuarioSQLServer(txProntuario.Text)) { USUARIOTableAdapter user = new USUARIOTableAdapter(); DataTable tabela = user.RetornaDataTableUsuarioPorProntuario(txProntuario.Text); if (tabela.Rows.Count > 1) { MessageBox.Show("Mais de um usuario com o mesmo prontuario, procure pelo nome!"); this.ActiveControl = txNome; txNome.ReadOnly = false; } else if (tabela.Rows.Count == 1) { txNome.Text = tabela.Rows[0]["NOME"].ToString(); PreencheCamposNomeSqlServer(txNome.Text); } else { MessageBox.Show("Prontuario não localizado, procure pelo nome"); this.ActiveControl = txNome; } } else { txNome.ReadOnly = false; this.ActiveControl = txNome; MessageBox.Show("Prontuario não encontrado procure pelo nome ou cadastre novo!"); } } } } catch (Exception err) { MessageBox.Show(err.Message); } }
private void PreencheCamposNomeSqlServer(string nome) { USUARIOTableAdapter user = new USUARIOTableAdapter(); DataTable _tabela = new DataTable(); //string nome = "%" + txNome.Text.Substring(0, (int)(txNome.Text.Length / 2)) + "%"; if (txNome.Text.Equals("")) _tabela = user.RetornaDataTableUsuarioPorProntuario(txProntuario.Text); else _tabela = user.RetornaDataTableUsuarioPorNome(nome); if (_tabela.Rows.Count < 1) { MessageBox.Show("Nome não encontrado no sistema. Por favor confirme os dados."); LiberaCampos(); this.ActiveControl = DataNascimento; btnConfirmar.Text = "Incluir - F10"; btnConfirmar.Enabled = true; } else if (_tabela.Rows.Count == 1) { DataRow linha = _tabela.Rows[0]; if (!linha["NOME"].ToString().Equals("") && txNome.Text.Equals("")) txNome.Text = linha["NOME"].ToString(); if (!linha["CPF"].ToString().Equals("")) txCPF.Text = linha["CPF"].ToString(); if (!linha["CARTAOSUS"].ToString().Equals("")) txCartaoSus.Text = linha["CARTAOSUS"].ToString(); if (!linha["CEP"].ToString().Equals("")) txCep.Text = linha["CEP"].ToString(); if (!linha["ENDNUMERO"].ToString().Equals("")) txNumero.Text = linha["ENDNUMERO"].ToString(); if (!linha["ENDCOMPLEMENTO"].ToString().Equals("")) txComplemento.Text = linha["ENDCOMPLEMENTO"].ToString(); if (!linha["DTNASCIMENTO"].ToString().Equals("")) DataNascimento.Value = (DateTime)linha["DTNASCIMENTO"]; if (!txCep.Text.Equals("")) PreencheCamposPorCEP(int.Parse(txCep.Text)); if (!linha["NOMEMAE"].ToString().Equals("")) txNomeMae.Text = linha["NOMEMAE"].ToString(); if (!linha["TELFIXO"].ToString().Equals("")) txTelFixo.Text = linha["TELFIXO"].ToString(); if (!linha["TELCEL"].ToString().Equals("")) txTelCelular.Text = linha["TELCEL"].ToString(); if (linha["TIPOUSUARIO"].ToString().Equals("1")) RadioAgudo.Checked = true; else if (linha["TIPOUSUARIO"].ToString().Equals("2")) RadioCronico.Checked = true; txIDUsuario.Text = linha["IDUSUARIO"].ToString(); BloqueiaItens(); LiberaCamposAlteracao(); btnConfirmar.Text = "Confirmar - F10"; this.btnConfirmar.Image = global::SISHOMEROGIL.Properties.Resources.confirmar; btnConfirmar.Enabled = true; MessageBox.Show("Por favor confirme os dados!"); this.ActiveControl = btnConfirmar; } else { MessageBox.Show("Mais de um prontuário localizado, verifique pelo nome"); LimpaFormulario(); txNome.ReadOnly = false; this.ActiveControl = txNome; } }
public string RetornaQuantidadeUsuariosCadastrados() { USUARIOTableAdapter user = new USUARIOTableAdapter(); var quant = user.ContaUsuariosCadastrados() + 1; return quant.ToString(); }