1
Here’s what I’m trying to do:
- I compile the program by clicking start;
- The screen splash is displayed, the progress bar rotates and reaches 100% (closes the screen splash);
Opens the screen of login, the identification is placed and everything happens correctly (the identification screen is closed);
Open the screen home (main), and when closing the screen home for X (not yet put the other buttons) Visual Studio keeps running, the compilation does not stop until I press the stop button of Visual Studio.
What would you like to happen, when entering user and password, the screen login was closed and only the screen appeared home.
What am I doing wrong??
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());
}
}
}
Follow the Splash form
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
}
}
}
}
Start the project with CTRL+F5. Or go to Debug -> Start Without Debug
– Marcos Marques
It worked, but there is some problem in you with debug in my case ?
– Fabio Aragão
No, that’s standard Visual Studio. When you run debugging, there are other "tied" processes to your program that monitor it, so it keeps running even when you close your screen.
– Marcos Marques
puts the code of Program.Cs and frm_management
– Rovann Linhalis
I’m not able to make other blocks to post what you asked for. have to help in this too ?
– Fabio Aragão
like other blocks ? editing the question ?
– Rovann Linhalis
I think the best thing to do is to clone your project and get out taking away everything that does not influence the problem. Then you put all the code here.
– Miguel Angelo
@Rovannlinhalis yes, I’m not getting it
– Fabio Aragão
@Fabioaragdon’t click here: https://answall.com/posts/226047/edit. and to format the text, give 4 spaces before the code block, or put it between two high accents ``` to separate the blocks, just skip the line and write something without obeying this formatting
– Rovann Linhalis
I tried and it didn’t work
– Fabio Aragão
@Fabioaragão the problem is that you start the application by Splashscreen, and if it continues like this, when users close the application, it will continue running on the machine, without being accessible.
– Rovann Linhalis
see the answer, if you want more details, enter the code of the
SplashScreen
also... rs– Rovann Linhalis