Beispiel #1
0
        public int insPlantas(ePlantas planta)
        {
            int idRetorno = 0;

            objSqlConect = new SqlConnection();
            objSqlCom    = new SqlCommand();
            con          = new duConexao();

            objSqlCom.CommandType = CommandType.StoredProcedure;
            objSqlCom.CommandText = "USP_INS_PLANTAS";

            if (planta.Id == 0)
            {
                objSqlCom.Parameters.AddWithValue("@Id", null);
            }
            else
            {
                objSqlCom.Parameters.AddWithValue("@Id", planta.Id);
            }

            objSqlCom.Parameters.AddWithValue("@Nome", planta.Nome);
            objSqlCom.Parameters.AddWithValue("@Preco", float.Parse(planta.Preco));
            objSqlCom.Parameters.AddWithValue("@Qtd", planta.Qtd);
            objSqlCom.Parameters.AddWithValue("@Especial", planta.Especial);
            objSqlCom.Parameters.AddWithValue("@Status", planta.Status);
            objSqlCom.Parameters.Add("@Id_Retorno", SqlDbType.Int).Direction = ParameterDirection.Output;

            objSqlConect         = con.abrirConexao();
            objSqlCom.Connection = objSqlConect;

            try
            {
                objSqlCom.ExecuteNonQuery();
                idRetorno = int.Parse(objSqlCom.Parameters["@Id_Retorno"].Value.ToString());
            }
            catch (Exception ex)
            {
                if (!idRetorno.Equals(0))
                {
                    MessageBox.Show("Erro de Conexão \n" + ex.Message);
                }
            }
            finally
            {
                objSqlConect.Dispose();
                objSqlConect.Close();
                objSqlConect = null;
            }

            return(idRetorno);
        }
Beispiel #2
0
        public bool insVendaProduto(eVendas venda)
        {
            bool gravou = false;

            objSqlCom    = new SqlCommand();
            objSqlConect = new SqlConnection();
            con          = new duConexao();

            objSqlCom.CommandType = CommandType.StoredProcedure;
            objSqlCom.CommandText = "USP_INS_VENDAS_PRODUTOS";

            if (venda.Id == 0)
            {
                objSqlCom.Parameters.AddWithValue("@Id", null);
            }
            else
            {
                objSqlCom.Parameters.AddWithValue("@Id", venda.Id);
            }

            objSqlCom.Parameters.AddWithValue("@Produto", venda.Produto);
            objSqlCom.Parameters.AddWithValue("@Preco", venda.Preco);
            objSqlCom.Parameters.AddWithValue("@QtdVendidas", venda.QtdVendidas);
            objSqlCom.Parameters.AddWithValue("@QtdEstocadas", venda.QtdEstocadas);

            objSqlConect         = con.abrirConexao();
            objSqlCom.Connection = objSqlConect;

            try
            {
                if (objSqlCom.ExecuteNonQuery() > 0)
                {
                    gravou = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro de Conexão \n" + ex.Message);
            }
            finally
            {
                objSqlConect.Dispose();
                objSqlConect.Close();
                objSqlConect = null;
            }

            return(gravou);
        }
Beispiel #3
0
        public List <eVendas> selRelatorioVendas(DateTime?dataAte, DateTime?dataDe, string nomeProd, int?qtdMaior, decimal?preco)
        {
            objSqlCom    = new SqlCommand();
            objSqlConect = new SqlConnection();
            con          = new duConexao();
            List <eVendas> lista = new List <eVendas>();

            objSqlCom.CommandText = "USP_SEL_RELATORIO_VENDAS";
            objSqlCom.CommandType = CommandType.StoredProcedure;

            objSqlCom.Parameters.AddWithValue("@Id", null);
            objSqlCom.Parameters.AddWithValue("@Produtos", nomeProd);
            objSqlCom.Parameters.AddWithValue("@PrecoTotal", preco);
            objSqlCom.Parameters.AddWithValue("@QtdProdutos", qtdMaior);
            objSqlCom.Parameters.AddWithValue("@DataDe", dataDe);
            objSqlCom.Parameters.AddWithValue("@DataAte", dataAte);


            objSqlConect         = con.abrirConexao();
            objSqlCom.Connection = objSqlConect;

            dr = objSqlCom.ExecuteReader();

            try
            {
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        lista.Add(SetarObjetoRelatorio(dr));
                    }
                }

                return(lista);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objSqlCom.Dispose();
                objSqlConect.Close();
                objSqlConect = null;
                objSqlCom    = null;
            }
        }
Beispiel #4
0
        public bool insFotos(eFotos foto)
        {
            bool gravou = false;

            objSqlConect = new SqlConnection();
            objSqlCom    = new SqlCommand();
            con          = new duConexao();

            objSqlCom.CommandType = CommandType.StoredProcedure;
            objSqlCom.CommandText = "USP_INS_FOTO_PLANTA";
            if (foto.Id == 0)
            {
                objSqlCom.Parameters.AddWithValue("@Id", null);
            }
            else
            {
                objSqlCom.Parameters.AddWithValue("@Id", foto.Id);
            }
            objSqlCom.Parameters.AddWithValue("@Caminho", foto.Caminho);
            objSqlCom.Parameters.AddWithValue("@Status", foto.Status);
            objSqlCom.Parameters.AddWithValue("@IdPlanta", foto.IdPlanta);

            objSqlConect         = con.abrirConexao();
            objSqlCom.Connection = objSqlConect;

            try
            {
                if (objSqlCom.ExecuteNonQuery() > 0)
                {
                    gravou = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro de Conexão \n" + ex.Message);
            }
            finally
            {
                objSqlConect.Dispose();
                objSqlConect.Close();
                objSqlConect = null;
            }

            return(gravou);
        }
Beispiel #5
0
        public List <eVendas> selProdutosVendidos(int?id, string produto)
        {
            objSqlCom    = new SqlCommand();
            objSqlConect = new SqlConnection();
            con          = new duConexao();
            List <eVendas> lista = new List <eVendas>();

            objSqlCom.Parameters.AddWithValue("@Id", id);
            objSqlCom.Parameters.AddWithValue("@Produto", produto);

            objSqlCom.CommandText = "USP_SEL_PRODUTOS_VENDIDOS";
            objSqlCom.CommandType = CommandType.StoredProcedure;
            objSqlConect          = con.abrirConexao();
            objSqlCom.Connection  = objSqlConect;

            dr = objSqlCom.ExecuteReader();

            try
            {
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        lista.Add(SetarObjetoProdutosVendidos(dr));
                    }
                }

                return(lista);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objSqlCom.Dispose();
                objSqlConect.Close();
                objSqlConect = null;
                objSqlCom    = null;
            }
        }
Beispiel #6
0
        public List <ePlantas> selPlantas(string nome)
        {
            List <ePlantas> lista = new List <ePlantas>();

            objSqlConect = new SqlConnection();
            objSqlCom    = new SqlCommand();
            con          = new duConexao();

            objSqlCom.CommandType = CommandType.StoredProcedure;
            objSqlCom.CommandText = "USP_SEL_PLANTAS";

            objSqlCom.Parameters.AddWithValue("@Nome", nome);
            objSqlCom.Parameters.AddWithValue("@Id", null);

            objSqlConect         = con.abrirConexao();
            objSqlCom.Connection = objSqlConect;

            dr = objSqlCom.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    lista.Add(SetarObjeto(dr));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro de Conexão \n" + ex.Message);
            }
            finally
            {
                dr.Close();
                objSqlConect.Dispose();
                objSqlConect.Close();
                objSqlConect = null;
            }

            return(lista);
        }
Beispiel #7
0
        public bool delPlanta(int?idPlanta, int?idFoto)
        {
            bool deletou = false;

            objSqlConect = new SqlConnection();
            objSqlCom    = new SqlCommand();
            con          = new duConexao();

            objSqlCom.CommandType = CommandType.StoredProcedure;
            objSqlCom.CommandText = "USP_DEL_PLANTA_FOTO";

            objSqlCom.Parameters.AddWithValue("@idPlanta", idPlanta);
            objSqlCom.Parameters.AddWithValue("@idFoto", idFoto);

            objSqlConect         = con.abrirConexao();
            objSqlCom.Connection = objSqlConect;

            try
            {
                if (objSqlCom.ExecuteNonQuery() > 0)
                {
                    deletou = true;
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                objSqlConect.Dispose();
                objSqlConect.Close();
                objSqlConect = null;
            }

            return(deletou);
        }
Beispiel #8
0
        public List <eVendas> selVendas(eVendas venda)
        {
            objSqlCom    = new SqlCommand();
            objSqlConect = new SqlConnection();
            con          = new duConexao();
            List <eVendas> lista = new List <eVendas>();

            objSqlCom.CommandText = "USP_SEL_VENDAS";
            objSqlCom.CommandType = CommandType.StoredProcedure;

            if (venda.Id == 0)
            {
                objSqlCom.Parameters.AddWithValue("@Id", null);
            }
            else
            {
                objSqlCom.Parameters.AddWithValue("@Id", venda.Id);
            }

            objSqlCom.Parameters.AddWithValue("@Produto", venda.Produto);

            if (venda.Preco == 0)
            {
                objSqlCom.Parameters.AddWithValue("@Preco", null);
            }
            else
            {
                objSqlCom.Parameters.AddWithValue("@Preco", venda.Preco);
            }

            if (venda.QtdVendidas == 0)
            {
                objSqlCom.Parameters.AddWithValue("@QtdVendidas", null);
            }
            else
            {
                objSqlCom.Parameters.AddWithValue("@QtdVendidas", venda.QtdVendidas);
            }

            if (venda.QtdEstocadas == 0)
            {
                objSqlCom.Parameters.AddWithValue("@QtdEstocada", null);
            }
            else
            {
                objSqlCom.Parameters.AddWithValue("@QtdEstocada", venda.QtdEstocadas);
            }

            objSqlConect         = con.abrirConexao();
            objSqlCom.Connection = objSqlConect;

            dr = objSqlCom.ExecuteReader();

            try
            {
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        lista.Add(SetarObjetoVendas(venda, dr));
                    }
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objSqlCom.Dispose();
                objSqlConect.Close();
                objSqlConect = null;
                objSqlCom    = null;
            }
        }