Primeira Funcionalidades
Apresentaremos agora nesse blog as primeiras funcionalidades do nosso sistema hospitalar.
Progress bar
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace projeto
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value < 100)
{
progressBar1.Value = progressBar1.Value + 2;
}
else
{
timer1.Enabled = false;
tela_login lgn = new tela_login();
lgn.Show();
this.Visible = false;
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
Com o código acima nossa form ficará dessa maneira:
![]() |
| progress bar |
Código de tela de login
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace projeto
{
public partial class tela_login : Form
{
public tela_login()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button2_Click(object sender, EventArgs e)
{
if((textBox1.Text == "admin") &&(textBox2.Text == "1234"))
{
tela_principal prin = new tela_principal();
prin.Show();
this.Visible = false;
}
else
{
MessageBox.Show("Usuário ou senha não conferem!", "Ocorreu um Erro na Autentificação!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
}
}
Com esse código o O windows form começa a funcionar dessa maneira:
![]() |
| tela de login |
![]() |
| quando o login ou senha estão incorretos |
![]() |
| quando login e senha estão corretos |
Depois de logar abre a tela inicial onde fica localizado tudo em nosso sistema:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace projeto
{
public partial class tela_principal : Form
{
public tela_principal()
{
InitializeComponent();
}
private void tela_principal_Load(object sender, EventArgs e)
{
}
private void toolStripStatusLabel2_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
toolStripStatusLabel2.Text = DateTime.Now.ToShortDateString();
toolStripStatusLabel3.Text = DateTime.Now.ToShortTimeString();
}
private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void tela_principal_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void calculadoraToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("calc");
}
private void wordToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("winword");
}
private void cadastroToolStripMenuItem_Click(object sender, EventArgs e)
{
frmCadPaciente cadpac = new frmCadPaciente();
cadpac.Show();
}
private void cadastroToolStripMenuItem1_Click(object sender, EventArgs e)
{
cadFuncionario cdf = new cadFuncionario();
cdf.Show();
}
private void consultaToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void marcarConsultaToolStripMenuItem_Click(object sender, EventArgs e)
{
Marcar_consulta mc = new Marcar_consulta();
mc.Show();
}
}
}
com esse código nossa tela principal fica dessa forma:
Para Fazermos o cadastro e a consulta do banco de dados usamos esse código.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace projeto
{
public partial class frmCadPaciente : Form
{
public bool AllowDBNull { get; set; }
public frmCadPaciente()
{
InitializeComponent();
}
private void frmCadPaciente_Load(object sender, EventArgs e)
{
// TODO: esta linha de código carrega dados na tabela 'sistemaDataSet1.funcionario'. Você pode movê-la ou removê-la conforme necessário.
this.funcionarioTableAdapter.Fill(this.sistemaDataSet1.funcionario);
// TODO: esta linha de código carrega dados na tabela 'sistemaDataSet1.paciente'. Você pode movê-la ou removê-la conforme necessário.
this.pacienteTableAdapter.Fill(this.sistemaDataSet1.paciente);
}
private void bairroLabel_Click(object sender, EventArgs e)
{
}
private void bairroTextBox_TextChanged(object sender, EventArgs e)
{
}
private void pacienteBindingNavigator_RefreshItems(object sender, EventArgs e)
{
}
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{
}
private void pacienteBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
{
try {
this.Validate();
this.pacienteBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.sistemaDataSet1);
MessageBox.Show("Registro salvo com sucesso", "Informa", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception Erro) {
MessageBox.Show("Falha em salvar o registro", "Informa", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Deseja excluir o registro?", "Pergunta!", MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
{
this.Validate();
this.pacienteBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.sistemaDataSet1);
}
else
{
this.pacienteTableAdapter.Fill(this.sistemaDataSet1.paciente);
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
this.pacienteTableAdapter.FillByPaciente(sistemaDataSet1.paciente, textBox1.Text);
}
}
}
![]() |
| Cadastro de paciente |
![]() |
| Consulta de paciente |
E essas são as primeiras funcionalidades do nosso programa.







Nenhum comentário:
Postar um comentário