private void timer1_Tick(object sender, EventArgs e) { if (progressBar1.Value < 100) { progressBar1.Value = progressBar1.Value + 10; } if (progressBar1.Value == 100) { timer1.Stop(); this.Dispose(); MenuPrincipal menu = new MenuPrincipal(); menu.ShowDialog(); } }
private void BtnSalvar_Click(object sender, EventArgs e) { byte[] imagem = System.Convert.FromBase64String(ImageToBase64(txtAnexo.Text)); string tipoIncidente = rbtRemoto.Checked ? tipoIncidente = rbtRemoto.Text : tipoIncidente = rbtVisita.Text; try { DateTime localDate = DateTime.Now; MySqlConnection conexao = new MySqlConnection("Persist Security Info = False; server=localhost;database=MBR;uid=root;pwd=root"); conexao.Open(); string comando = @"insert into incidente (titulo,cliente,solicitante,descricao,tipo,imagem,status,data_abertura,usuario_atendente) VALUES (?titulo, ?cliente, ?solicitante, ?descricao, ?tipo, ?imagem, ?status, current_timestamp(), ?atendente )"; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conexao; cmd.CommandText = comando; cmd.Parameters.AddWithValue("titulo", txtTitulo.Text); cmd.Parameters.AddWithValue("cliente", cmbCliente.Text); cmd.Parameters.AddWithValue("solicitante", txtSolicitante.Text); cmd.Parameters.AddWithValue("descricao", txtDescricao.Text); cmd.Parameters.AddWithValue("tipo", tipoIncidente); cmd.Parameters.AddWithValue("imagem", imagem); cmd.Parameters.AddWithValue("status", "Pendente"); cmd.Parameters.AddWithValue("atendente", cmbAtendente.Text); cmd.ExecuteNonQuery(); conexao.Close(); MessageBox.Show("Incidente registrado com Sucesso!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(); MenuPrincipal menu = new MenuPrincipal(); menu.ShowDialog(); } catch (Exception ex) { MessageBox.Show("Erro ao registrar incidente! " + ex, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }