public void IncludeItemNota(ItemNota itemNota)
        {
            using (_dbConnection)
            {
                _dbConnection.Open();

                var command = new MySqlCommand("INSERT INTO ITEM_NOTA (ID_ITEM_NF, ID_NF, ID_ITEM_PEDIDO, COD_PRODUTO, QTDE_PESADA) VALUES" +
                                               "(@ID_ITEM_NF, @ID_NF, @ID_ITEM_PEDIDO, @COD_PRODUTO, @QTDE_PESADA)");


                command.CommandType = CommandType.Text;
                command.Connection  = _dbConnection;

                command.Parameters.Add("ID_ITEM_NF", DbType.Int32).Value     = itemNota.IdItemNF;
                command.Parameters.Add("ID_NF", DbType.Int32).Value          = itemNota.IdNF;
                command.Parameters.Add("ID_ITEM_PEDIDO", DbType.Int32).Value = itemNota.IdItemPedido;
                command.Parameters.Add("COD_PRODUTO", DbType.Int32).Value    = itemNota.CodProduto;
                command.Parameters.Add("QTDE_PESADA", DbType.Decimal).Value  = itemNota.QtdePesada;



                int result = command.ExecuteNonQuery();

                _dbConnection.Close();
            }
        }
        public ItemNota ItemNotaById(int idItemNota)
        {
            using (_dbConnection)
            {
                _dbConnection.Open();

                var cmd = new MySqlCommand("SELECT * FROM ITEM_NOTA WHERE ID_NOTA_NF = @ID_NOTA_NF");

                cmd.CommandType = CommandType.Text;
                cmd.Connection  = _dbConnection;

                cmd.Parameters.Add("ID_NOTA_NF", DbType.Int32).Value = idItemNota;

                int result = cmd.ExecuteNonQuery();

                MySqlDataReader dr;
                ItemNota        itemNotaById = new ItemNota();

                dr = cmd.ExecuteReader();


                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        ItemNota itemNota = new ItemNota();

                        itemNota.IdItemNF     = Convert.ToInt32(dr["ID_ITEM_NF"]);
                        itemNota.IdNF         = Convert.ToInt32(dr["ID_NF"]);
                        itemNota.IdItemPedido = Convert.ToInt32(dr["ID_ITEM_PEDIDO"]);
                        itemNota.CodProduto   = Convert.ToInt32(dr["COD_PRODUTO"]);
                        itemNota.QtdePesada   = Convert.ToDecimal(dr["QTDE_PESADA"]);

                        itemNotaById = itemNota;
                    }
                }

                _dbConnection.Close();

                return(itemNotaById);
            }
        }
        public List <ItemNota> ListItemNota()
        {
            using (_dbConnection)
            {
                _dbConnection.Open();

                var cmd = new MySqlCommand("SELECT * FROM ITEM_NOTA");

                cmd.CommandType = CommandType.Text;
                cmd.Connection  = _dbConnection;

                MySqlDataReader dr;
                List <ItemNota> listItemNota = new List <ItemNota>();

                dr = cmd.ExecuteReader();


                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        ItemNota itemNota = new ItemNota();

                        itemNota.IdItemNF     = Convert.ToInt32(dr["ID_ITEM_NF"]);
                        itemNota.IdNF         = Convert.ToInt32(dr["ID_NF"]);
                        itemNota.IdItemPedido = Convert.ToInt32(dr["ID_ITEM_PEDIDO"]);
                        itemNota.CodProduto   = Convert.ToInt32(dr["COD_PRODUTO"]);
                        itemNota.QtdePesada   = Convert.ToDecimal(dr["QTDE_PESADA"]);


                        listItemNota.Add(itemNota);
                    }
                }

                _dbConnection.Close();

                return(listItemNota);
            }
        }
        public void UpdateItemNota(ItemNota itemNota)
        {
            using (_dbConnection)
            {
                _dbConnection.Open();

                var command = new MySqlCommand("UPDATE ITEM_NOTA SET ID_ITEM_NF = @ID_ITEM_NF, ID_NF = @ID_NF, ID_ITEM_PEDIDO = @ID_ITEM_PEDIDO, COD_PRODUTO = @COD_PRODUTO, " +
                                               "QTDE_PESADA = @QTDE_PESADA");


                command.CommandType = CommandType.Text;
                command.Connection  = _dbConnection;

                command.Parameters.Add("ID_ITEM_NF", DbType.Int32).Value     = itemNota.IdItemNF;
                command.Parameters.Add("ID_NF", DbType.Int32).Value          = itemNota.IdNF;
                command.Parameters.Add("ID_ITEM_PEDIDO", DbType.Int32).Value = itemNota.IdItemPedido;
                command.Parameters.Add("COD_PRODUTO", DbType.Int32).Value    = itemNota.CodProduto;
                command.Parameters.Add("QTDE_PESADA", DbType.Decimal).Value  = itemNota.QtdePesada;

                int result = command.ExecuteNonQuery();

                _dbConnection.Close();
            }
        }