示例#1
0
        private void btnCadastro_Click(object sender, EventArgs e)
        {
            CodigosGerais c    = new CodigosGerais();
            SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=false;Initial Catalog=BaseDados;Data Source=.\\SQLEXPRESS01");

            SqlCommand cmd = new SqlCommand("INSERT INTO dbo.Login_user(Usuario, Senha) VALUES(@Usuario, @Senha)", conn);

            cmd.Parameters.Add("@Usuario", SqlDbType.VarChar).Value = txtUser.Text;
            cmd.Parameters.Add("@Senha", SqlDbType.VarChar).Value   = txtSenha.Text;

            if (txtUser.Text != "" & txtSenha.Text != "")
            {
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    c.MostrarMSG("3", "Cadastro Concluído !");
                    txtSenha.Text = "";
                    txtUser.Text  = "";
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
        }
示例#2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            CodigosGerais c = new CodigosGerais();

            SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BaseDados;Data Source=.\\SQLEXPRESS01");

            conn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "Select Usuario,Senha FROM dbo.Login_user WHERE Usuario =@Usuario And Senha=@Senha";
            cmd.Parameters.Add("@Usuario", SqlDbType.VarChar).Value = txtUser.Text;
            cmd.Parameters.Add("@Senha", SqlDbType.VarChar).Value   = txtSenha.Text;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn;

            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                c.MostrarMSG("3", " Seja Bem Vindo " + txtUser.Text);
                this.Visible = false;
                LocadoraSistem locad = new LocadoraSistem();
                locad.ShowDialog();
            }
            else
            {
                c.MostrarMSG("1", "Usuário ou Senha Incorretos.");
            }
            conn.Close();
        }
        private void btnConfirma_Click(object sender, EventArgs e)
        {
            CodigosGerais c = new CodigosGerais();

            SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=true;Initial Catalog=BaseDados;Data Source=.\\SQLEXPRESS01");

            SqlCommand cmd = new SqlCommand("INSERT INTO dbo.Tabela_Usuario(Nome, Telefone, CPF, Usuario, Senha) VALUES (@Nome, @Telefone, @CPF, @Usuario, @Senha)", conn);

            cmd.Parameters.Add("@Nome", SqlDbType.VarChar).Value    = txtNomeUser.Text;
            cmd.Parameters.Add("@Telefone", SqlDbType.BigInt).Value = txtTelUser.Text;
            cmd.Parameters.Add("@CPF", SqlDbType.BigInt).Value      = txtCPF.Text;
            cmd.Parameters.Add("@Usuario", SqlDbType.VarChar).Value = txtUsuario.Text;
            cmd.Parameters.Add("@Senha", SqlDbType.VarChar).Value   = txtSenha.Text;

            if (txtNomeUser.Text != "" & txtTelUser.Text != "" & txtCPF.Text != "" & txtUsuario.Text != "" & txtSenha.Text != "")
            {
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    c.MostrarMSG("3", "Cadastrado !");
                    txtNomeUser.Text = "";
                    txtTelUser.Text  = "";
                    txtCPF.Text      = "";
                    txtUsuario.Text  = "";
                    txtSenha.Text    = "";
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                }
                finally
                {
                    conn.Close();
                    gBoxCadastro.Enabled = false;
                }
            }
            else
            {
                c.MostrarMSG("1", "Preencha todos os Campos..");
            }
        }
        private void btnConfirmaLoc_Click(object sender, EventArgs e)
        {
            CodigosGerais c = new CodigosGerais();

            SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=true;Initial Catalog=BaseDados;Data source=.\\SQLEXPRESS01");

            SqlCommand cmd = new SqlCommand("INSERT INTO dbo.Tabela_Locacao(Nome_Usuario, Nome_Livro, Autor_Livro, Quantidade, Classificacao) VALUES (@Nome_Usuario, @Nome_Livro, @Autor_Livro, @Quantidade, @Classificacao)", conn);

            cmd.Parameters.Add("@Nome_Usuario", SqlDbType.VarChar).Value  = txtUserLoc.Text;
            cmd.Parameters.Add("@Nome_Livro", SqlDbType.VarChar).Value    = txtTituloLoc.Text;
            cmd.Parameters.Add("@Autor_Livro", SqlDbType.VarChar).Value   = txtAutorLoc.Text;
            cmd.Parameters.Add("@Quantidade", SqlDbType.Int).Value        = txtQtde.Text;
            cmd.Parameters.Add("@Classificacao", SqlDbType.VarChar).Value = cbxClass1.Text;

            if (txtUserLoc.Text != "" & txtTituloLoc.Text != "" & txtAutorLoc.Text != "" & txtQtde.Text != "" & cbxClass1.Text != "")
            {
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    c.MostrarMSG("3", "Cadastrado !");
                    txtUserLoc.Text   = "";
                    txtTituloLoc.Text = "";
                    txtAutorLoc.Text  = "";
                    txtQtde.Text      = "";
                    cbxClass1.Text    = "";
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                }
                finally
                {
                    conn.Close();
                    gBoxLivros.Enabled = false;
                }
            }
            else
            {
                c.MostrarMSG("1", "Prrencha todos os Campos..");
            }
        }
        private void btnConfirmaLivro_Click(object sender, EventArgs e)
        {
            CodigosGerais c = new CodigosGerais();

            SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=true;Initial Catalog=BaseDados;Data Source=.\\SQLEXPRESS01");

            SqlCommand cmd = new SqlCommand("INSERT INTO dbo.Cad_Livro(Titulo, Autor, Editora, Classe) VALUES(@Titulo, @Autor, @Editora, @Classe)", conn);

            cmd.Parameters.Add("@Titulo", SqlDbType.VarChar).Value  = txtTitulo.Text;
            cmd.Parameters.Add("@Autor", SqlDbType.VarChar).Value   = txtAutor.Text;
            cmd.Parameters.Add("@Editora", SqlDbType.VarChar).Value = txtEditora.Text;
            cmd.Parameters.Add("@Classe", SqlDbType.VarChar).Value  = cbxClass.Text;

            if (txtTitulo.Text != "" & txtAutor.Text != "" & txtEditora.Text != "" & cbxClass.Text != "")
            {
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    c.MostrarMSG("3", "Cadastrado !");
                    txtTitulo.Text  = "";
                    txtAutor.Text   = "";
                    txtEditora.Text = "";
                    cbxClass.Text   = "";
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                }
                finally
                {
                    conn.Close();
                    gBoxLivros.Enabled = false;
                }
            }
        }
示例#6
0
        public bool Logar(TextBox user, TextBox senha)
        {
            CodigosGerais c = new CodigosGerais();

            if (c.TestLogin(user, " Usuário "))
            {
                return(false);
            }
            if (c.TestLogin(senha, " Senha "))
            {
                return(false);
            }

            if ((user.Text == "Junior") && (senha.Text == "123"))
            {
                c.MostrarMSG("3", user.Text + " Seja Bem vindo ! ");
                return(true);
            }
            else
            {
                c.MostrarMSG("1", " Usuario nao encontrado.. ");
                return(false);
            }
        }