コード例 #1
0
ファイル: oshiDAO.cs プロジェクト: NatalNW/Mainline-Web
        public List <Ativo> selectAtivo(int idUser)
        {
            List <Ativo> lista = new List <Ativo>();
            Ativo        ativo = new Ativo();
            //String connection = "Server=tcp:lol-2018.database.windows.net,1433;Initial Catalog=ADS 2018;Persist Security Info=False;User ID=jessicasantos;Password=Corinthians11;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            CnxSql cnxSql = new CnxSql();

            using (cnxSql.cnx)
            {
                cnxSql.cnx.Open();
                String select = "select p.IDPOSSUI,p.IDATIVO,a.NOMEATIVO from possui as p , ativo as a Where p.IDUSER = @id and a.idAtivo = p.idAtivo order by p.IDATIVO desc";
                using (SqlCommand cmd = new SqlCommand(select, cnxSql.cnx))
                {
                    cmd.Parameters.AddWithValue("@id", idUser);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            lista.Add(new Ativo()
                            {
                                idPossui = reader.GetInt32(0),
                                id       = reader.GetString(1),
                                nome     = reader.GetString(2)
                            });

                            //ativo.nome = reader.GetString(1);

                            //lista.Add(ativo);
                        }
                    }
                }
                return(lista);
            }
        }
コード例 #2
0
ファイル: oshiDAO.cs プロジェクト: NatalNW/Mainline-Web
        public List <Ativo> selectAtivo2()
        {
            List <Ativo> lista = new List <Ativo>();
            Ativo        ativo = new Ativo();
            //String connection = "Server=tcp:lol-2018.database.windows.net,1433;Initial Catalog=ADS 2018;Persist Security Info=False;User ID=jessicasantos;Password=Corinthians11;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            CnxSql cnxSql = new CnxSql();

            using (cnxSql.cnx)
            {
                cnxSql.cnx.Open();
                String select = "select * from ativo;";
                using (SqlCommand cmd = new SqlCommand(select, cnxSql.cnx))
                {
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            lista.Add(new Ativo()
                            {
                                id = reader.GetString(0),
                                //nome = reader.GetString(1)
                            });

                            //ativo.nome = reader.GetString(1);

                            //lista.Add(ativo);
                        }
                    }
                }
                return(lista);
            }
        }
コード例 #3
0
ファイル: oshiDAO.cs プロジェクト: NatalNW/Mainline-Web
        public Ativo selectAtivoById(String idAtivo)
        {
            Ativo ativo = new Ativo();
            //String connection = "Server=tcp:lol-2018.database.windows.net,1433;Initial Catalog=ADS 2018;Persist Security Info=False;User ID=jessicasantos;Password=Corinthians11;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            CnxSql cnxSql = new CnxSql();

            using (cnxSql.cnx)
            {
                cnxSql.cnx.Open();
                String select = "select * from ativo where idAtivo = @idAtivo;";
                using (SqlCommand cmd = new SqlCommand(select, cnxSql.cnx))
                {
                    cmd.Parameters.AddWithValue("@idAtivo", idAtivo);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            ativo.id   = reader.GetString(0);
                            ativo.nome = reader.GetString(1);
                            ativo.SO   = reader.GetString(2);


                            //ativo.nome = reader.GetString(1);

                            //lista.Add(ativo);
                        }
                    }
                }
                return(ativo);
            }
        }
コード例 #4
0
        public Usuario selectId(String usuario, String senha)
        {
            CnxSql cnxSql     = new CnxSql();
            string sqlCommand = "SELECT * FROM Usuario WHERE email = @email and senha = @senha";

            using (cnxSql.cnx)
            {
                cnxSql.cnx.Open();

                SqlCommand cmd = new SqlCommand(sqlCommand, cnxSql.cnx);

                cmd.Parameters.AddWithValue("@email", usuario);
                cmd.Parameters.AddWithValue("@senha", senha);

                SqlDataReader reader = cmd.ExecuteReader();

                Usuario user = new Usuario();
                if (reader.Read())
                {
                    user.idUser   = int.Parse(reader["IDUSER"].ToString());
                    user.nome     = reader["nome"].ToString();
                    user.telefone = reader["telefone"].ToString();
                    user.isAdm    = bool.Parse(reader["isADM"].ToString());
                    //Session["Usuario"] = user.idUser;

                    //Response.Redirect("dashboard.aspx");
                }
                return(user);
            }
        }
コード例 #5
0
        protected void btn_cadastrar_Click(object sender, EventArgs e)
        {
            CnxSql cnxSql     = new CnxSql();
            string sqlCommand = "INSERT INTO Usuario (nome, telefone, email, senha, isADM) VALUES (@nome, @telefone, @email, @senha, @isADM)";

            if (txtSenha.Text == txtconfSenha.Text)
            {
                if (isADM.Text != "null")
                {
                    using (cnxSql.cnx)
                    {
                        cnxSql.cnx.Open();

                        SqlCommand cmd = new SqlCommand(sqlCommand, cnxSql.cnx);
                        cmd.Parameters.AddWithValue("@nome", txtnome.Text);
                        cmd.Parameters.AddWithValue("@telefone", txttelefone.Text);
                        cmd.Parameters.AddWithValue("@email", txtemail.Text);
                        cmd.Parameters.AddWithValue("@senha", txtSenha.Text);
                        cmd.Parameters.AddWithValue("@isADM", isADM.Text);

                        cmd.ExecuteNonQuery();

                        Response.Redirect("Login2.aspx");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Por favor selecione seu nível de usuário');</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('As senhas devem ser iguais');</script>");
            }
        }
コード例 #6
0
        public int cadastroNome(String idAtivo, String NomeMaquina)
        {
            int cadastro = 0;
            //String connection = "Server=tcp:lol-2018.database.windows.net,1433;Initial Catalog=ADS 2018;Persist Security Info=False;User ID=jessicasantos;Password=Corinthians11;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            CnxSql cnxSql = new CnxSql();

            using (cnxSql.cnx)
            {
                cnxSql.cnx.Open();
                String select = "update ativo set nomeAtivo = @NomeMaquina where idAtivo = @idAtivo";
                using (SqlCommand cmd = new SqlCommand(select, cnxSql.cnx))
                {
                    cmd.Parameters.AddWithValue("@idAtivo", idAtivo);
                    cmd.Parameters.AddWithValue("@NomeMaquina", NomeMaquina);
                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        cadastro = 1;
                    }
                    else
                    {
                        cadastro = 0;
                    }
                }
                return(cadastro);
            }
        }
コード例 #7
0
        public int excluirAtivo(String idAtivo, String idUser)
        {
            int excluir = 0;
            //String connection = "Server=tcp:lol-2018.database.windows.net,1433;Initial Catalog=ADS 2018;Persist Security Info=False;User ID=jessicasantos;Password=Corinthians11;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            CnxSql cnxSql = new CnxSql();

            using (cnxSql.cnx)
            {
                cnxSql.cnx.Open();
                String select = "delete from possui where idAtivo = @idAtivo AND idUser = @idUser";
                using (SqlCommand cmd = new SqlCommand(select, cnxSql.cnx))
                {
                    cmd.Parameters.AddWithValue("@idAtivo", idAtivo);
                    cmd.Parameters.AddWithValue("@idUser", idUser);
                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        excluir = 1;
                    }
                    else
                    {
                        excluir = 0;
                    }
                }
                return(excluir);
            }
        }
コード例 #8
0
        protected void btnLogar_Click(object sender, EventArgs e)
        {
            Usuario user = new Usuario();

            user.email = txtEmail.Text;
            user.senha = txtSenha.Text;

            CnxSql cnxSql     = new CnxSql();
            string sqlCommand = "SELECT * FROM Usuario WHERE email = @email and senha = @senha";

            using (cnxSql.cnx)
            {
                cnxSql.cnx.Open();

                SqlCommand cmd = new SqlCommand(sqlCommand, cnxSql.cnx);

                cmd.Parameters.AddWithValue("@email", user.email);
                cmd.Parameters.AddWithValue("@senha", user.senha);

                SqlDataReader reader = cmd.ExecuteReader();


                if (reader.Read())
                {
                    user.idUser         = int.Parse(reader["IdUser"].ToString());
                    user.nome           = reader["nome"].ToString();
                    user.telefone       = reader["telefone"].ToString();
                    user.isAdm          = bool.Parse(reader["isADM"].ToString());
                    Session["Usuario"]  = user.idUser;
                    Session["nomeUser"] = user.nome;

                    Response.Redirect("dashboard2.aspx");
                }
                else
                {
                    Response.Write("<script>alert('Login Inválido')</script>");
                }
            }
        }