private Boolean CS_validarSenha(string senha) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); Boolean validar = false; string query = "SELECT NM_Senha FROM TB_Usuario WHERE NM_Senha=@SENHA"; SqlCommand cmd = new SqlCommand(query, conexao.conexao); cmd.Parameters.AddWithValue("@SENHA", senha); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { string senha1 = senha; return(true); } else { return(validar); } dr.Close(); conexao.desconectar(); }
public string inserirUsuario() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd; string mErro = null; try { cmd = new SqlCommand("INSERT INTO TB_USUARIO (ID_USUARIO, NM_USUARIO, NM_SENHA, ID_FUNCIONARIO) VALUES (@ID_USUARIO, @NM_USUARIO, @NM_SENHA, @ID_FUNCIONARIO)", conexao.conexao); cmd.Parameters.AddWithValue("@ID_USUARIO", mID_Usuario); cmd.Parameters.AddWithValue("@NM_USUARIO", mNM_Usuario); cmd.Parameters.AddWithValue("@NM_SENHA", mNM_Senha); cmd.Parameters.AddWithValue("@ID_FUNCIONARIO", mID_Funcionario); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); return(mErro); } catch (Exception ex) { mErro = ex.Message; return(mErro); } finally { conexao.desconectar(); } }
public string inserirFuncionario() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd; string mErro = null; try { cmd = new SqlCommand("INSERT INTO TB_FUNCIONARIO (ID_FUNCIONARIO, NM_FUNCIONARIO, NR_CPF, NR_RG, NM_CARGO, NM_SEXO, NM_EMAIL) VALUES (@ID_FUNCIONARIO, @NM_FUNCIONARIO, @NR_CPF, @NR_RG, @NM_CARGO, @NM_SEXO, @NM_EMAIL)", conexao.conexao); cmd.Parameters.AddWithValue("@ID_FUNCIONARIO", mID_Funcionario); cmd.Parameters.AddWithValue("@NM_FUNCIONARIO", mNM_Funcionario); cmd.Parameters.AddWithValue("@NR_CPF", mNR_Cpf); cmd.Parameters.AddWithValue("@NR_RG", mNR_Rg); cmd.Parameters.AddWithValue("@NM_CARGO", mNM_Cargo); cmd.Parameters.AddWithValue("@NM_SEXO", mNM_Sexo); cmd.Parameters.AddWithValue("@NM_EMAIL", mNM_Email); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); return(mErro); } catch (Exception ex) { mErro = ex.Message; return(mErro); } finally { conexao.desconectar(); } }
public float pegaPrecoInteira(int id) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("Select VL_Inteira FROM TB_SESSAO inner Join TB_Ingresso on TB_Sessao.ID_Sessao = TB_Ingresso.ID_Sessao WHERE tb_Sessao.ID_Sessao = @ID ", conexao.conexao); cmd.Parameters.AddWithValue("@ID", id); float preco = 0; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { preco = Convert.ToSingle(dr[("VL_INTEIRA")]); return(preco); } else { //foreach (Control ctl in this.Controls) // { // if (ctl is TextBox) // ctl.Text = ""; // } return(preco); } dr.Close(); conexao.desconectar(); }
public string inserirFilme() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd; string mErro = null; try { cmd = new SqlCommand("INSERT INTO TB_FILME (ID_FILME, NM_FILME, DS_DESCRICAO, HR_DURACAO, NM_GENERO, DT_ANOREALIZACAO, NM_FOLDER) VALUES (@ID_FILME, @NM_FILME, @DS_DESCRICAO, @HR_DURACAO, @NM_GENERO, @DT_ANOREALIZACAO, @NM_FOLDER)", conexao.conexao); //SqlParameter parametroCaminho = new SqlParameter("@NM_Folder", SqlDbType.Binary); cmd.Parameters.AddWithValue("@ID_FILME", mId_Filme); cmd.Parameters.AddWithValue("@NM_FILME", mTitulo_Filme); cmd.Parameters.AddWithValue("@DS_DESCRICAO", mNM_Descricao); cmd.Parameters.AddWithValue("@HR_DURACAO", mDuracao_Filme); cmd.Parameters.AddWithValue("@NM_GENERO", mGenero_Filme); cmd.Parameters.AddWithValue("@DT_ANOREALIZACAO", mAno_Realizacao); cmd.Parameters.AddWithValue("@NM_FOLDER", NM_Folder); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); return(mErro); } catch (Exception ex) { mErro = ex.Message; return(mErro); } finally { conexao.desconectar(); } }
public string atualizarFuncionario() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd; string mErro = null; try { cmd = new SqlCommand("UPDATE TB_FUNCIONARIO SET NM_FUNCIONARIO=@NM_FUNCIONARIO, NR_CPF=@NR_CPF, NR_RG=@NR_RG, NM_CARGO=@NM_CARGO, NM_SEXO=@NM_SEXO, NM_EMAIL=@NM_EMAIL WHERE ID_FUNCIONARIO=@ID_FUNCIONARIO", conexao.conexao); cmd.Parameters.AddWithValue("@ID_FUNCIONARIO", mID_Funcionario); cmd.Parameters.AddWithValue("@NM_FUNCIONARIO", mNM_Funcionario); cmd.Parameters.AddWithValue("@NR_CPF", mNR_Cpf); cmd.Parameters.AddWithValue("@NR_RG", mNR_Rg); cmd.Parameters.AddWithValue("@NM_CARGO", mNM_Cargo); cmd.Parameters.AddWithValue("@NM_SEXO", mNM_Sexo); cmd.Parameters.AddWithValue("@NM_EMAIL", mNM_Email); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); return(mErro); } catch (Exception ex) { mErro = ex.Message; return(mErro); } finally { conexao.desconectar(); } }
public CS_clsFuncionario getFuncionariosByCpf(string texto) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("SELECT ID_FUNCIONARIO FROM TB_FUNCIONARIO WHERE NR_CPF=@NR_CPF", conexao.conexao); cmd.Parameters.AddWithValue("@NR_CPF", texto); CS_clsFuncionario mObjFuncionario = new CS_clsFuncionario(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { mObjFuncionario.ID_Funcionario = Convert.ToInt32(dr[("ID_FUNCIONARIO")]); return(mObjFuncionario); } else { //foreach (Control ctl in this.Controls) // { // if (ctl is TextBox) // ctl.Text = ""; // } return(null); } dr.Close(); conexao.desconectar(); }
public int autoIncremento() { string query = "SELECT MAX(ID_FUNCIONARIO)+1 AS ID FROM TB_FUNCIONARIO"; int codigo = 0; CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand(query, conexao.conexao); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); try { if (dr.HasRows) { dr.Read(); codigo = Convert.ToInt32(dr["ID"].ToString()); return(codigo); } else { codigo = 1; return(codigo); } } catch (Exception) { return(1); } finally { dr.Close(); conexao.desconectar(); } }
public string inserirIngresso() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd; string mErro = null; try { cmd = new SqlCommand("INSERT INTO TB_INGRESSO (ID_INGRESSO, NM_TIPO, ID_POLTRONA, ID_SESSAO) VALUES (@ID_INGRESSO, @NM_TIPO, @ID_POLTRONA, @ID_SESSAO)", conexao.conexao); //SqlParameter parametroCaminho = new SqlParameter("@NM_Folder", SqlDbType.Binary); cmd.Parameters.AddWithValue("@ID_INGRESSO", mId_Ingresso); cmd.Parameters.AddWithValue("@NM_TIPO", mNM_Tipo); cmd.Parameters.AddWithValue("@ID_POLTRONA", mId_Poltrona); cmd.Parameters.AddWithValue("@ID_SESSAO", mId_Sessao); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); return(mErro); } catch (Exception ex) { mErro = ex.Message; return(mErro); } finally { conexao.desconectar(); } }
public CS_clsSessao verificarSala(string id) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("SELECT ID_SALA FROM TB_SESSAO WHERE ID_SESSAO=@ID", conexao.conexao); cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(id)); CS_clsSessao mObjSessao = new CS_clsSessao(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { mObjSessao.Id_Sala = Convert.ToInt32(dr[("ID_SALA")]); return(mObjSessao); } else { //foreach (Control ctl in this.Controls) // { // if (ctl is TextBox) // ctl.Text = ""; // } return(null); } dr.Close(); conexao.desconectar(); }
public string inativarSessao(int id) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd; string mErro = null; try { cmd = new SqlCommand("UPDATE TB_SESSAO SET ST_SITUACAO=@ST_SITUACAO WHERE ID_SESSAO = @ID_SESSAO", conexao.conexao); cmd.Parameters.AddWithValue("@ST_SITUACAO", "INATIVO"); cmd.Parameters.AddWithValue("@ID_SESSAO", id); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); return(mErro); } catch (Exception ex) { mErro = ex.Message; return(mErro); } finally { conexao.desconectar(); } }
public CS_clsIngresso exibirDados(int id) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("SELECT * FROM TB_INGRESSO WHERE ID_POLTRONA=@ID ", conexao.conexao); cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(id)); CS_clsIngresso mObjIngresso = new CS_clsIngresso(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { mObjIngresso.Id_Ingresso = Convert.ToInt32(dr[("ID_INGRESSO")]); mObjIngresso.NM_Tipo = dr[("NM_TIPO")].ToString(); mObjIngresso.Id_Poltrona = Convert.ToInt32(dr[("ID_POLTRONA")]); mObjIngresso.Id_Sessao = Convert.ToInt32(dr[("ID_SESSAO")]); return(mObjIngresso); } else { //foreach (Control ctl in this.Controls) // { // if (ctl is TextBox) // ctl.Text = ""; // } return(null); } dr.Close(); conexao.desconectar(); }
public SqlDataReader getIngresso() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("Select ID_INGRESSO, NM_TIPO, ID_POLTRONA, ID_SESSAO FROM TB_INGRESSO", conexao.conexao); cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(); //conexao.desconectar(); return(dr); }
public SqlDataReader getSessao() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("Select ID_SESSAO, HR_SESSAO, DT_SESSAO, VL_INTEIRA, VL_MEIA, ST_SITUACAO, tb_filme.nm_filme, ID_SALA, ID_FUNCIONARIO, VL_GRATUITA FROM TB_SESSAO inner Join tb_filme on tb_sessao.id_filme = tb_filme.id_filme WHERE ST_SITUACAO = 'ABERTA'", conexao.conexao); cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(); //conexao.desconectar(); return(dr); }
public SqlDataReader getFuncionarios() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("Select ID_FUNCIONARIO, NM_FUNCIONARIO, NR_CPF, NR_RG, NM_CARGO, NM_SEXO, NM_EMAIL FROM TB_FUNCIONARIO", conexao.conexao); cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(); //conexao.desconectar(); return(dr); }
public SqlDataReader getFilmes() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("Select ID_FILME, NM_FILME, DS_DESCRICAO, HR_DURACAO, NM_GENERO, DT_ANOREALIZACAO FROM TB_FILME", conexao.conexao); cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(); //conexao.desconectar(); return(dr); }
public void carregaFuncionario() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("SELECT ID_FUNCIONARIO, NM_FUNCIONARIO FROM TB_FUNCIONARIO ORDER BY NM_FUNCIONARIO", conexao.conexao); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); cmbFuncionario.DisplayMember = "NM_FUNCIONARIO"; cmbFuncionario.ValueMember = "ID_FUNCIONARIO"; cmbFuncionario.DataSource = dt; conexao.desconectar(); }
public void carregaFilme() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("SELECT ID_FILME, NM_FILME FROM TB_FILME ORDER BY NM_FILME", conexao.conexao); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); cmbFilme.DisplayMember = "NM_FILME"; cmbFilme.ValueMember = "ID_FILME"; cmbFilme.DataSource = dt; conexao.desconectar(); }
public CS_clsSessao exibirDados(int id) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("SELECT * FROM TB_SESSAO WHERE ID_SESSAO=@ID", conexao.conexao); cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(id)); CS_clsSessao mObjSessao = new CS_clsSessao(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { mObjSessao.Id_Sessao = Convert.ToInt32(dr[("ID_SESSAO")]); mObjSessao.HR_Sessao = dr[("HR_SESSAO")].ToString(); mObjSessao.DT_Sessao = Convert.ToDateTime(dr[("DT_SESSAO")]); mObjSessao.VL_Inteira = Convert.ToSingle(dr[("VL_INTEIRA")]); mObjSessao.VL_Meia = Convert.ToSingle(dr[("VL_MEIA")]); mObjSessao.ST_Situacao = dr[("ST_SITUACAO")].ToString(); mObjSessao.Id_Filme = Convert.ToInt32(dr[("ID_FILME")]); mObjSessao.Id_Sala = Convert.ToInt32(dr[("ID_SALA")]); mObjSessao.Id_Funcionario = Convert.ToInt32(dr[("ID_FUNCIONARIO")]); mObjSessao.VL_Gratuita = dr[("VL_GRATUITA")].ToString(); return(mObjSessao); } else { //foreach (Control ctl in this.Controls) // { // if (ctl is TextBox) // ctl.Text = ""; // } return(null); } dr.Close(); conexao.desconectar(); }
public string atualizarSessao() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); string mErro = null; try { SqlCommand cmd; cmd = new SqlCommand("UPDATE TB_SESSAO SET HR_SESSAO=@HR_SESSAO, DT_SESSAO=@DT_SESSAO, VL_INTEIRA=@VL_INTEIRA, VL_MEIA=@VL_MEIA, ST_SITUACAO=@ST_SITUACAO, ID_FILME=@ID_FILME, ID_SALA=@ID_SALA, ID_FUNCIONARIO=@ID_FUNCIONARIO, VL_GRATUITA=@VL_GRATUITA WHERE ID_SESSAO=@ID_SESSAO", conexao.conexao); cmd.Parameters.AddWithValue("@HR_SESSAO", mHR_Sessao); cmd.Parameters.AddWithValue("@DT_SESSAO", mDT_Sessao); cmd.Parameters.AddWithValue("@VL_INTEIRA", mVL_Inteira); cmd.Parameters.AddWithValue("@VL_MEIA", mVL_Meia); cmd.Parameters.AddWithValue("@ST_SITUACAO", mST_Situacao); cmd.Parameters.AddWithValue("@ID_FILME", mId_Filme); cmd.Parameters.AddWithValue("@ID_SALA", mId_Sala); cmd.Parameters.AddWithValue("@ID_FUNCIONARIO", mId_Funcionario); cmd.Parameters.AddWithValue("@VL_GRATUITA", "Gratuito"); cmd.Parameters.AddWithValue("@ID_SESSAO", mId_Sessao); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); return(mErro); } catch (Exception ex) { mErro = ex.Message; return(mErro); } finally { conexao.desconectar(); } }
public CS_clsFilme exibirDados(int id) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("SELECT * FROM TB_FILME WHERE ID_FILME=@ID ", conexao.conexao); cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(id)); CS_clsFilme mObjFilme = new CS_clsFilme(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { mObjFilme.Id_Filme = Convert.ToInt32(dr[("ID_FILME")]); mObjFilme.Titulo_Filme = dr[("NM_FILME")].ToString(); mObjFilme.NM_Descricao = dr[("DS_DESCRICAO")].ToString(); mObjFilme.Duracao_Filme = dr[("HR_DURACAO")].ToString(); mObjFilme.Genero_Filme = dr[("NM_GENERO")].ToString(); mObjFilme.Ano_Realizacao = dr[("DT_ANOREALIZACAO")].ToString(); mObjFilme.NM_Folder = dr[("NM_FOLDER")].ToString(); return(mObjFilme); } else { //foreach (Control ctl in this.Controls) // { // if (ctl is TextBox) // ctl.Text = ""; // } return(null); } dr.Close(); conexao.desconectar(); }
public Boolean CS_validarUsuario(CS_clsUsuario usuario) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); Boolean validar = false; string query = "SELECT NM_Usuario FROM TB_Usuario WHERE NM_Usuario=@USUARIO"; SqlCommand cmd = new SqlCommand(query, conexao.conexao); cmd.Parameters.AddWithValue("@USUARIO", usuario.NM_Usuario); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { string usuario1 = usuario.mNM_Usuario; validar = usuario.CS_validarSenha(usuario.mNM_Senha); if (!validar) { return(false);; } else { return(true); } } else { return(validar); } dr.Close(); conexao.desconectar(); }
public CS_clsFuncionario exibirDados(int id) { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("SELECT * FROM TB_FUNCIONARIO WHERE ID_FUNCIONARIO=@ID", conexao.conexao); cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(id)); CS_clsFuncionario mObjFuncionario = new CS_clsFuncionario(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { mObjFuncionario.ID_Funcionario = Convert.ToInt32(dr[("ID_FUNCIONARIO")]); mObjFuncionario.NM_Funcionario = dr[("NM_FUNCIONARIO")].ToString(); mObjFuncionario.NR_Cpf = dr[("NR_CPF")].ToString(); mObjFuncionario.NR_Rg = dr[("NR_RG")].ToString(); mObjFuncionario.NM_Cargo = dr[("NM_CARGO")].ToString(); mObjFuncionario.NM_Sexo = dr[("NM_SEXO")].ToString(); mObjFuncionario.NM_Email = dr[("NM_EMAIL")].ToString(); return(mObjFuncionario); } else { //foreach (Control ctl in this.Controls) // { // if (ctl is TextBox) // ctl.Text = ""; // } return(null); } dr.Close(); conexao.desconectar(); }
public string inserirSessao() { CS_clsConexao conexao = new CS_clsConexao(); conexao.conectar(); SqlCommand cmd; string mErro = null; try { cmd = new SqlCommand("INSERT INTO TB_SESSAO (ID_SESSAO, HR_SESSAO, DT_SESSAO, VL_INTEIRA, VL_MEIA, ST_SITUACAO, ID_FILME, ID_SALA, ID_FUNCIONARIO, VL_GRATUITA) VALUES (@ID_SESSAO, @HR_SESSAO, @DT_SESSAO, @VL_INTEIRA, @VL_MEIA, @ST_SITUACAO, @ID_FILME, @ID_SALA, @ID_FUNCIONARIO, @VL_GRATUITA)", conexao.conexao); cmd.Parameters.AddWithValue("@ID_SESSAO", mId_Sessao); cmd.Parameters.AddWithValue("@HR_SESSAO", mHR_Sessao); cmd.Parameters.AddWithValue("@DT_SESSAO", mDT_Sessao); cmd.Parameters.AddWithValue("@VL_INTEIRA", mVL_Inteira); cmd.Parameters.AddWithValue("@VL_MEIA", mVL_Meia); cmd.Parameters.AddWithValue("@ST_SITUACAO", mST_Situacao); cmd.Parameters.AddWithValue("@ID_FILME", mId_Filme); cmd.Parameters.AddWithValue("@ID_SALA", mId_Sala); cmd.Parameters.AddWithValue("@ID_FUNCIONARIO", mId_Funcionario); cmd.Parameters.AddWithValue("@VL_GRATUITA", "Gratuito"); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); return(mErro); } catch (Exception ex) { mErro = ex.Message; return(mErro); } finally { conexao.desconectar(); } }