Estou tentando fazer o seguinte:
- Compilo o programa clicando em iniciar;
- A tela splash é exibida, a barra de progresso roda e chega a 100% (fecha a tela de splash);
Abre a tela de login, coloca-se a identificação e tudo ocorre corretamente (a tela de identificação é fechada);
Abre a tela home (principal), sendo que ao fechar a tela home pelo X (ainda não coloquei os outros botões) o Visual Studio continua rodando, a compilação não para até que eu aperte o botão parar do Visual Studio.
O que gostaria que acontecesse, quando inserisse usuário e senha, a tela de login fosse fechada e aparecesse apenas a tela home.
O que estou fazendo de errado??
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;
using MySql.Data.MySqlClient;
namespace App.Sis_Igreja
{
public partial class frm_inicial : Form
{
public frm_inicial()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
String usuario = tb_usuario.Text;
String senha = tb_senha.Text;
if (String.IsNullOrEmpty(usuario) || (String.IsNullOrEmpty(senha)))
{
MessageBox.Show("Por favor preencha todos os campos!!");
}else
{
String config = "server=localhost; userid=root; pwd=root; database=sis_igreja";
MySqlConnection conexao = new MySqlConnection(config);
MySqlCommand Query = new MySqlCommand();
Query.Connection = conexao;
conexao.Open();
Query.CommandText = "select usuario, senha from login where usuario = '" + usuario + "' and senha = '" + senha + "'";
bool verifica = Query.ExecuteReader().HasRows;
if (verifica == true)
{
String titulo = "Bem Vindo";
String mensagem = "Usuário Logado com Sucesso";
MessageBox.Show(titulo, mensagem);
MessageBoxButtons botao = MessageBoxButtons.OK;
//DialogResult resultado = ;
if( botao == MessageBoxButtons.OK)
{
this.Close();
}
frm_gerenciamento frm = new frm_gerenciamento();
frm.Show();
}
else
{
MessageBox.Show("Nome do usuário ou senha incorreto!");
}
conexao.Close();
}
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace App.Sis_Igreja
{
static class Program
{
/// <summary>
/// Ponto de entrada principal para o aplicativo.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SplashScreen());
}
}
}
Segue o form da Splash
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 App.Sis_Igreja
{
public partial class SplashScreen : Form
{
public SplashScreen()
{
InitializeComponent();
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
lb_porcentagem.Text = pb_splash.Value + "%";
if (pb_splash.Value < 100)
{
pb_splash.Value = pb_splash.Value + 2;
}
else
{
timer1.Enabled = false;
frm_inicial frm = new frm_inicial();
frm.Show();
this.Visible = false;
//comentario
}
}
}
}