public void BtnLogin_Click(object sender, EventArgs e) { try { //string strConexao = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C: \Users\JR TECH\source\repos\CinemaV1\CinemaV1\bdGeral.mdf;Integrated Security=True"; //cria a conexao OleDbConnection conn = new OleDbConnection(CinemaV1.Properties.Settings.Default.strConexao); //SqlConnection conn = new SqlConnection(strConexao); OleDbCommand comm = new OleDbCommand("select * from Cadastros where Nome = @user and Senha = @senha", conn); // SqlCommand comm = new SqlCommand("select * from Cadastros where Nome = @user and Senha = @senha", conn); comm.Parameters.Add("@user", OleDbType.VarChar).Value = TxtBoxUser.Text; //comm.Parameters.Add("@user", SqlDbType.VarChar).Value = TxtBoxUser.Text; //comm.Parameters.Add("@senha", SqlDbType.VarChar).Value = TxtBoxPass.Text; comm.Parameters.Add("@senha", OleDbType.VarChar).Value = TxtBoxPass.Text; conn.Open(); if (TxtBoxUser.Text == "genji" && TxtBoxPass.Text == "genji") { adminlogin frmadmin = new adminlogin(TxtBoxUser.Text); frmadmin.Show(); this.Hide(); } int i = int.Parse(comm.ExecuteScalar().ToString()); if (i > 0) { //Abre o form Home e esconde o form1 Home frmHome = new Home(TxtBoxUser.Text); frmHome.Show(); this.Hide(); } else { MessageBox.Show("Error Usuario não foi encontrado, verifique a senha e o Login"); } conn.Close(); } catch (Exception) { MessageBox.Show("Error, Usuario ou Senha invalidos, ou bd danificado"); } }
private void BtnUploadAll_Click(object sender, EventArgs e) { try { //defini uma arrey de binarios, onde sera a feita a conversão pra byte byte[] imgByte = null; FileStream fstream = new FileStream(this.imgload.Text, FileMode.Open, FileAccess.Read); BinaryReader BinReader = new BinaryReader(fstream); imgByte = BinReader.ReadBytes((int)fstream.Length); //string de conexao ; //String strConexao = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C: \Users\JR TECH\source\repos\CinemaV1\CinemaV1\bdGeral.mdf;Integrated Security=True"; String strConexao = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\JR TECH\source\repos\CinemaV1\CinemaV1\bdCadastro.mdb"; //cria a conexao OleDbConnection conn = new OleDbConnection(strConexao); //SqlConnection conn = new SqlConnection(strConexao); //abrir conexao (conn) conn.Open(); //comando slq //comando slq String SQL; SQL = "Insert Into Filmes (Imagens , Sinopse , Genero, TagIdade ,VideoDoYT , Box , Nome ) Values"; SQL += "('" + imgByte + "','" + textsinopse.Text + "','" + checkedListGen.CheckedItems + "','" + comboTagidade.Text + "','" + textNavegacao.Text + "','" + Box.ToString() + "','" + txtNomeDoFilme.Text + "')"; OleDbCommand cmd = new OleDbCommand(SQL, conn); //SqlCommand cmd = new SqlCommand(SQL, conn); cmd.Parameters.Add("Nome", OleDbType.VarChar).Value = txtNomeDoFilme.Text; //cmd.Parameters.Add("Nome", SqlDbType.VarChar).Value = txtNomeDoFilme.Text; //cmd.Parameters.Add("Box", SqlDbType.VarChar).Value = Box.ToString(); cmd.Parameters.Add("Box", OleDbType.VarChar).Value = Box.ToString(); cmd.ExecuteNonQuery(); MessageBox.Show("Otimo, o Filme foi cadastrado no Banco "); conn.Close(); this.Hide(); Home frmain = new Home(TxtUser.Text); frmain.Show(); if (Box == "Box1") { Home frmHomeBox1 = new Home(txtNomeDoFilme.Text); } if (Box == "Box2") { Home frmHomeBox2 = new Home(txtNomeDoFilme.Text); } else { Home frmHomeBox3 = new Home(txtNomeDoFilme.Text); } } catch (Exception error) { MessageBox.Show(error.Message); } }