コード例 #1
0
        public bool ExcluirDados(int Codigo)
        {
            {
                try
                {
                    string          sSQL = "";
                    MySqlCommand    cmd  = new MySqlCommand();
                    MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                    cn.Open();

                    sSQL = "delete from tb_cor  where codigocor=@codigocor";
                    cmd.Parameters.AddWithValue("@codigocor", Codigo);

                    cmd.CommandText = sSQL;
                    cmd.Connection  = cn;
                    cmd.ExecuteNonQuery();

                    return(true);
                }
                catch (Exception e)
                {
                    string msg = e.Message;
                    return(false);
                }
            }
        }
コード例 #2
0
        public bool UpDateDadosAdmin(tb_login obj)
        {
            {
                try
                {
                    string          sSQL = "";
                    MySqlCommand    cmd  = new MySqlCommand();
                    MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                    cn.Open();

                    sSQL = "update tb_login set tipo=@tipo, ativo=@ativo";

                    cmd.Parameters.AddWithValue("@tipo", obj.Tipo);
                    cmd.Parameters.AddWithValue("@ativo", obj.Ativo);

                    cmd.CommandText = sSQL;
                    cmd.Connection  = cn;
                    cmd.ExecuteNonQuery();

                    return(true);
                }
                catch (Exception e)
                {
                    string msg = e.Message;
                    return(false);
                }
            }
        }
コード例 #3
0
        public bool UpDateDados(tb_tamanho obj)
        {
            {
                try
                {
                    string          sSQL = "";
                    MySqlCommand    cmd  = new MySqlCommand();
                    MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                    cn.Open();

                    sSQL = "update tb_cor set descricao=@descricao where codigocor=@codigocor";
                    cmd.Parameters.AddWithValue("@descricao", obj.Descricao);
                    cmd.Parameters.AddWithValue("@codigocor", obj.CodigoTamanho);

                    cmd.CommandText = sSQL;
                    cmd.Connection  = cn;
                    cmd.ExecuteNonQuery();

                    return(true);
                }
                catch (Exception e)
                {
                    string msg = e.Message;
                    return(false);
                }
            }
        }
コード例 #4
0
        public List <tb_tamanho> GetAllTamanho()
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL = "select * from tb_tamanho order by descricao";

                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                var Dr = cmd.ExecuteReader();

                var Lista = new List <tb_tamanho>();

                while (Dr.Read())
                {
                    var item = new tb_tamanho
                    {
                        CodigoTamanho = Convert.ToInt32(Dr["CodigoTamanho"]),
                        Descricao     = Dr["Descricao"].ToString()
                    };
                    Lista.Add(item);
                }

                return(Lista);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(null);
            }
        }
コード例 #5
0
        public List <SelectListItem> GetTamanho()
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL            = "select * from tb_tamanho";
                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                var Dr = cmd.ExecuteReader();

                List <SelectListItem> LT = new List <SelectListItem>();

                while (Dr.Read())
                {
                    var item = new SelectListItem
                    {
                        Value = Dr["CodigoTamanho"].ToString(),
                        Text  = Dr["Descricao"].ToString(),
                    };

                    LT.Add(item);
                }

                return(LT);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(null);
            }
        }
コード例 #6
0
        public bool UpDateDadosUsuario(tb_login obj)
        {
            {
                try
                {
                    string          sSQL = "";
                    MySqlCommand    cmd  = new MySqlCommand();
                    MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                    cn.Open();

                    sSQL = "update tb_login set nome=@nome, email=@email, telefone=@telefone, cpf_cnpj@cpf_cnpj, senha@senha";
                    cmd.Parameters.AddWithValue("@nome", obj.Nome);
                    cmd.Parameters.AddWithValue("@email", obj.Email);
                    cmd.Parameters.AddWithValue("@telefone", obj.Telefone);
                    cmd.Parameters.AddWithValue("@cpf_cnpj", obj.CPF_CNPJ);
                    cmd.Parameters.AddWithValue("@senha", obj.Senha);


                    cmd.CommandText = sSQL;
                    cmd.Connection  = cn;
                    cmd.ExecuteNonQuery();

                    return(true);
                }
                catch (Exception e)
                {
                    string msg = e.Message;
                    return(false);
                }
            }
        }
コード例 #7
0
        public bool InserirDados(tb_login obj)
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL = "insert into tb_login(nome, email, telefone, cpf_cnpj, senha, tipo, datacadastro, ativo) values " +
                       "(@nome, @email, @telefone, @cpf_cnpj, @senha, 'C', Now(), 1)";
                cmd.Parameters.AddWithValue("@nome", obj.Nome);
                cmd.Parameters.AddWithValue("@email", obj.Email);
                cmd.Parameters.AddWithValue("@telefone", obj.Telefone);
                cmd.Parameters.AddWithValue("@cpf_cnpj", obj.CPF_CNPJ);
                cmd.Parameters.AddWithValue("@senha", obj.Senha);

                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                cmd.ExecuteNonQuery();

                return(true);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(false);
            }
        }
コード例 #8
0
        public bool InserirDados(ProdutoModel obj)
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL = "insert into tb_produto (Nome, Descricao, valor, dataregistro, peso)values(@nome, @descricao, @valor, @dataregistro, @peso)";
                cmd.Parameters.AddWithValue("@nome", obj.tb_produto.Nome);
                cmd.Parameters.AddWithValue("@descricao", obj.tb_produto.Descricao);
                cmd.Parameters.AddWithValue("@valor", obj.tb_produto.Valor);
                cmd.Parameters.AddWithValue("@dataregistro", obj.tb_produto.DataRegistro);
                cmd.Parameters.AddWithValue("@peso", obj.tb_produto.Peso);

                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                cmd.ExecuteNonQuery();
                AddCategoria(obj);
                AddCor(obj);

                return(true);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(false);
            }
        }
コード例 #9
0
        public bool AddFoto(ProdutoModel obj)
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();
                cmd.Connection = cn;

                var CodigoProduto = obj.tb_produto.CodigoProduto;
                if (obj.tb_produto.CodigoProduto == 0)
                {
                    sSQL = "select CodigoProduto from tb_produto order by CodigoProduto desc limit 1 ";
                    cmd.Parameters.AddWithValue("@nome", obj.tb_produto.Nome);
                    cmd.CommandText = sSQL;
                    var Dr = cmd.ExecuteReader();
                    Dr.Read();
                    CodigoProduto = Convert.ToInt32(Dr["CodigoProduto"].ToString());
                    Dr.Dispose();
                }
                int CodigoFoto = 0;

                //Deletando Registros antes do insert caso for update
                cmd.Parameters.Clear();
                sSQL            = "delete from tb_produto_foto where CodigoProduto=" + CodigoProduto;
                cmd.CommandText = sSQL;
                cmd.ExecuteNonQuery();


                foreach (var item in obj.tb_produto_foto)
                {
                    CodigoFoto++;
                    cmd.Parameters.Clear();
                    sSQL  = "insert into tb_produto_foto (CodigoFoto,CodigoProduto, Descricao, Caminho)";
                    sSQL += "values(@CodigoCor,@CodigoProduto, @Descricao,@Caminho)";
                    cmd.Parameters.AddWithValue("@CodigoFoto", CodigoFoto);
                    cmd.Parameters.AddWithValue("@CodigoProduto", CodigoProduto);
                    cmd.Parameters.AddWithValue("@Descricao", item.Descricao);
                    cmd.Parameters.AddWithValue("@Caminho", item.Caminho);

                    cmd.CommandText = sSQL;
                    cmd.ExecuteNonQuery();
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #10
0
        public List <tb_produto> GetAllProduto()
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL = "select * from tb_produto order by nome";

                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                var Dr = cmd.ExecuteReader();

                var Lista = new List <tb_produto>();

                while (Dr.Read())
                {
                    var item = new tb_produto
                    {
                        CodigoProduto = Convert.ToInt32(Dr["CodigoProduto"]),
                        Nome          = Dr["Nome"].ToString(),
                        Descricao     = Dr["Descricao"].ToString(),
                        Valor         = Convert.ToDouble(Dr["Valor"]),
                        DataRegistro  = Convert.ToDateTime(Dr["DataRegistro"]),
                        Peso          = Convert.ToDouble(Dr["Peso"]),
                    };
                    Lista.Add(item);
                }

                return(Lista);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(null);
            }
        }
コード例 #11
0
        public bool ValidarNome(tb_categoria obj)
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL = "select * from tb_categoria where descricao=@descricao";
                cmd.Parameters.AddWithValue("@descricao", obj.Descricao);

                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                var Dr = cmd.ExecuteReader();
                return(Dr.HasRows);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(false);
            }
        }
コード例 #12
0
        public List <tb_login> GetAllCliente()
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL = "select * from tb_login where tipo='C' order by nome";

                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                var Dr = cmd.ExecuteReader();

                var Lista = new List <tb_login>();

                while (Dr.Read())
                {
                    var item = new tb_login
                    {
                        CodigoLogin = Convert.ToInt32(Dr["CodigoLogin"]),
                        Nome        = Dr["Nome"].ToString(),
                        Email       = Dr["Email"].ToString(),
                        Telefone    = Dr["Telefone"].ToString()
                    };
                    Lista.Add(item);
                }

                return(Lista);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(null);
            }
        }
コード例 #13
0
        public bool InserirDados(tb_tamanho obj)
        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL = "insert into tb_tamanho(Descricao) values (@descricao)";
                cmd.Parameters.AddWithValue("@descricao", obj.Descricao);

                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                cmd.ExecuteNonQuery();

                return(true);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(false);
            }
        }
コード例 #14
0
        public bool Validalogin(tb_login obj)

        {
            try
            {
                string          sSQL = "";
                MySqlCommand    cmd  = new MySqlCommand();
                MySqlConnection cn   = new MySqlConnection(CConexao.Get_StringConexao());
                cn.Open();

                sSQL = "select * from tb_login where nome=@nome";
                cmd.Parameters.AddWithValue("@nome", obj.Nome);

                cmd.CommandText = sSQL;
                cmd.Connection  = cn;
                var Dr = cmd.ExecuteReader();
                return(Dr.HasRows);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(false);
            }
        }